Changes in / [e0de72f:5031ca3] in sasmodels


Ignore:
Location:
sasmodels
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/teubner_strey.py

    rcaddb14 r40a87fa  
    55This model calculates the scattered intensity of a two-component system 
    66using the Teubner-Strey model. Unlike :ref:`dab` this function generates 
    7 a peak. A two-phase material can be characterised by two length scales - 
    8 a correlation length and a domain size (periodicity). 
    9  
    10 The original paper by Teubner and Strey defined the function as: 
     7a peak. 
    118 
    129.. math:: 
    1310 
    14     I(q) \propto \frac{1}{a_2 + c_1 q^2 + c_2 q^4} + \text{background} 
     11    I(q) = \frac{1}{a_2 + c_1 q^2 + c_2 q^4} + \text{background} 
    1512 
    16 where the parameters $a_2$, $c_1$ and $c_2$ are defined in terms of the 
    17 periodicity, $d$, and correlation length $\xi$ as: 
    18  
    19 .. math:: 
    20  
    21     a_2 &= \biggl[1+\bigl(\frac{2\pi\xi}{d}\bigr)^2\biggr]\\ 
    22     c_1 &= -2\xi^2\bigl(\frac{2\pi\xi}{d}\bigr)^2+2\xi^2\\ 
    23     c_2 &= \xi^4 
    24  
    25 and thus, the periodicity, $d$ is given by 
     13The parameters $a_2$, $c_1$ and $c_2$ can be used to determine the 
     14characteristic domain size $d$, 
    2615 
    2716.. math:: 
    2817 
    2918    d = 2\pi\left[\frac12\left(\frac{a_2}{c_2}\right)^{1/2} 
    30                   - \frac14\frac{c_1}{c_2}\right]^{-1/2} 
     19                  + \frac14\frac{c_1}{c_2}\right]^{-1/2} 
    3120 
    32 and the correlation length, $\xi$, is given by 
     21 
     22and the correlation length $\xi$, 
    3323 
    3424.. math:: 
    3525 
    3626    \xi = \left[\frac12\left(\frac{a_2}{c_2}\right)^{1/2} 
    37                   + \frac14\frac{c_1}{c_2}\right]^{-1/2} 
     27                  - \frac14\frac{c_1}{c_2}\right]^{-1/2} 
    3828 
    39 Here the model is parameterised in terms of  $d$ and $\xi$ and with an explicit 
    40 volume fraction for one phase, $\phi_a$, and contrast, 
    41 $\delta\rho^2 = (\rho_a - \rho_b)^2$ : 
    42  
    43 .. math:: 
    44  
    45     I(q) = \frac{8\pi\phi_a(1-\phi_a)(\Delta\rho)^2c_2/\xi} 
    46         {a_2 + c_1q^2 + c_2q^4} 
    47  
    48 where :math:`8\pi\phi_a(1-\phi_a)(\Delta\rho)^2c_2/\xi` is the constant of 
    49 proportionality from the first equation above. 
    50  
    51 In the case of a microemulsion, $a_2 > 0$, $c_1 < 0$, and $c_2 >0$. 
    5229 
    5330For 2D data, scattering intensity is calculated in the same way as 1D, 
     
    5734 
    5835    q = \sqrt{q_x^2 + q_y^2} 
     36 
    5937 
    6038References 
     
    6644*J. Chem. Phys.*, 101 (1994) 5343 
    6745 
    68 H Endo, M Mihailescu, M. Monkenbusch, J Allgaier, G Gompper, D Richter, 
    69 B Jakobs, T Sottmann, R Strey, and I Grillo, *J. Chem. Phys.*, 115 (2001), 580 
    7046""" 
    7147 
    7248import numpy as np 
    73 from numpy import inf,power,pi 
     49from numpy import inf 
    7450 
    7551name = "teubner_strey" 
    7652title = "Teubner-Strey model of microemulsions" 
    7753description = """\ 
    78     Calculates scattering according to the Teubner-Strey model 
     54   Scattering model class for the Teubner-Strey model given by 
     55    Provide F(x) = 1/( a2 + c1 q^2+  c2 q^4 ) + background 
     56    a2>0, c1<0, c2>0, 4 a2 c2 - c1^2 > 0 
    7957""" 
    8058category = "shape-independent" 
     
    8260#   ["name", "units", default, [lower, upper], "type","description"], 
    8361parameters = [ 
    84     ["volfraction_a", "", 0.5, [0, 1.0], "", "Volume fraction of phase a"], 
    85     ["sld_a", "1e-6/Ang^2", 0.3, [-inf, inf], "", "SLD of phase a"], 
    86     ["sld_b", "1e-6/Ang^2", 6.3, [-inf, inf], "", "SLD of phase b"], 
    87     ["d", "Ang", 100.0, [0, inf], "", "Domain size (periodicity)"], 
    88     ["xi", "Ang", 30.0, [0, inf], "", "Correlation length"], 
     62    ["a2", "", 0.1, [0, inf], "", "a2"], 
     63    ["c1", "1e-6/Ang^2", -30., [-inf, 0], "", "c1"], 
     64    ["c2", "Ang", 5000., [0, inf], "volume", "c2"], 
    8965    ] 
    9066 
    91 def Iq(q, volfraction, sld, sld_solvent,d,xi): 
     67def Iq(q, a2, c1, c2): 
    9268    """SAS form""" 
    93     drho2 = (sld-sld_solvent)*(sld-sld_solvent) 
    94     a2 = power(1.0+power(2.0*pi*xi/d,2.0),2.0) 
    95     c1 = -2.0*xi*xi*power(2.0*pi*xi/d,2.0)+2*xi*xi 
    96     c2 = power(xi,4.0) 
    97     prefactor = 8.0*pi*volfraction*(1.0-volfraction)*drho2*c2/xi 
    98     #k2 = (2.0*pi/d)*(2.0*pi/d) 
    99     #xi2 = 1/(xi*xi) 
    100     #q2 = q*q 
    101     #result = prefactor/((xi2+k2)*(xi2+k2)+2.0*(xi2-k2)*q2+q2*q2) 
    102     return 1.0e-4*prefactor / np.polyval([c2, c1, a2], q**2) 
    103  
     69    return 1. / np.polyval([c2, c1, a2], q**2) 
    10470Iq.vectorized = True  # Iq accepts an array of q values 
    10571 
    106 demo = dict(scale=1, background=0, volfraction_a=0.5, 
    107                      sld_a=0.3, sld_b=6.3, 
    108                      d=100.0, xi=30.0) 
    109 tests = [[{}, 0.06, 41.5918888453]] 
     72demo = dict(scale=1, background=0, a2=0.1, c1=-30.0, c2=5000.0) 
     73tests = [[{}, 0.2, 0.145927536232]] 
  • sasmodels/resolution.py

    r69ef533 r2472141  
    804804        pars = { 
    805805            'scale':0.05, 
    806             'radius_polar':500, 'radius_equatorial':15000, 
     806            'r_polar':500, 'r_equatorial':15000, 
    807807            'sld':6, 'sld_solvent': 1, 
    808808            } 
Note: See TracChangeset for help on using the changeset viewer.