source: sasmodels/sasmodels/models/gauss_lorentz_gel.py @ 46ed760

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 46ed760 was ec45c4f, checked in by Paul Kienzle <pkienzle@…>, 8 years ago

remove oldname/oldpars from new models

  • Property mode set to 100644
File size: 5.0 KB
Line 
1r"""
2This model calculates the scattering from a gel structure,
3but typically a physical rather than chemical network.
4It is modeled as a sum of a low-q exponential decay (which happens to
5give a functional form similar to Guinier scattering, so interpret with
6care) plus a Lorentzian at higher-q values. See also the gel_fit model.
7
8Definition
9----------
10
11The scattering intensity I(q) is calculated as (Eqn. 5 from the reference)
12
13.. math::
14
15    I(q) = I_G(0)exp(-q^2\Xi ^2/2) + I_L(0)/(1+q^2\xi^2)
16
17$\Xi$ is the length scale of the static correlations in the gel,
18which can be attributed to the "frozen-in" crosslinks.
19\ |xi|\  is the dynamic correlation length, which can be attributed to the
20fluctuating polymer chains between crosslinks.
21$I_G(0)$ and $I_L(0)$ are the scaling factors for each of these structures.
22Think carefully about how these map to your particular system!
23
24.. note::
25    The peaked structure at higher $q$ values (Figure 2 from the reference)
26    is not reproduced by the model. Peaks can be introduced into the model
27    by summing this model with the PeakGaussModel function.
28
29For 2D data the scattering intensity is calculated in the same way as 1D,
30where the $q$ vector is defined as
31
32.. math::
33
34    q = \sqrt{q_x^2 + q_y^2}
35
36
37References
38----------
39
40G Evmenenko, E Theunissen, K Mortensen, H Reynaers, *Polymer*,
4142 (2001) 2907-2913
42
43"""
44
45from numpy import inf, sqrt, exp
46
47name = "gauss_lorentz_gel"
48title = "Gauss Lorentz Gel model of scattering from a gel structure"
49description = """
50            Class that evaluates a GaussLorentzGel model.
51
52            I(q) = scale_g*exp(- q^2*Z^2 / 2)+scale_l/(1+q^2*z^2)
53                    + background
54            List of default parameters:
55                scale_g = Gauss scale factor
56                Z = Static correlation length
57                scale_l = Lorentzian scale factor
58                z = Dynamic correlation length
59                background = Incoherent background
60            """
61category = "shape-independent"
62# pylint: disable=bad-whitespace, line-too-long
63#            ["name", "units", default, [lower, upper], "type", "description"],
64parameters = [["gauss_scale_factor",   "",    100.0,  [-inf, inf], "", "Gauss scale factor"],
65              ["static_cor_length",    "Ang", 100.0,  [0, inf],    "", "Static correlation length"],
66              ["lorentz_scale_factor", "",     50.0,  [-inf, inf], "", "Lorentzian scale factor"],
67              ["dynamic_cor_length",   "Ang",  20.0,  [0, inf],    "", "Dynamic correlation length"],
68             ]
69# pylint: enable=bad-whitespace, line-too-long
70
71def Iq(q,
72       gauss_scale_factor=100.0,
73       static_cor_length=100.0,
74       lorentz_scale_factor=50.0,
75       dynamic_cor_length=20.0):
76    """
77
78    :param q:                    Input q-value
79    :param gauss_scale_factor:   Gauss scale factor
80    :param static_cor_length:    Static correlation length
81    :param lorentz_scale_factor: Lorentzian scale factor
82    :param dynamic_cor_length:   Dynamic correlation length
83    :return:                     1-D intensity
84    """
85
86    term1 = gauss_scale_factor *\
87            exp(-1.0*q*q*static_cor_length*static_cor_length/2.0)
88    term2 = lorentz_scale_factor /\
89            (1.0+(q*dynamic_cor_length)*(q*dynamic_cor_length))
90
91    return term1 + term2
92
93Iq.vectorized = True  # Iq accepts an array of q values
94
95
96def Iqxy(qx, qy, *args):
97    """
98    :param qx:   Input q_x-value
99    :param qy:   Input q_y-value
100    :param args: Remaining aruments
101    :return:     2-D intensity
102    """
103
104    return Iq(sqrt(qx**2 + qy**2), *args)
105
106Iqxy.vectorized = True  # Iqxy accepts an array of qx, qy values
107
108
109demo = dict(scale=1, background=0.1,
110            gauss_scale_factor=100.0,
111            static_cor_length=100.0,
112            lorentz_scale_factor=50.0,
113            dynamic_cor_length=20.0)
114
115tests = [
116
117    # Accuracy tests based on content in test/utest_extra_models.py
118    [{'gauss_scale_factor':  100.0,
119      'static_cor_length':   100.0,
120      'lorentz_scale_factor': 50.0,
121      'dynamic_cor_length':   20.0,
122     }, 0.001, 149.482],
123
124    [{'gauss_scale_factor':  100.0,
125      'static_cor_length':   100.0,
126      'lorentz_scale_factor': 50.0,
127      'dynamic_cor_length':   20.0,
128     }, 0.105363, 9.1913],
129
130    [{'gauss_scale_factor':  100.0,
131      'static_cor_length':   100.0,
132      'lorentz_scale_factor': 50.0,
133      'dynamic_cor_length':   20.0,
134     }, 0.441623, 0.633811],
135
136    # Additional tests with larger range of parameters
137    [{'gauss_scale_factor':  10.0,
138      'static_cor_length':  100.0,
139      'lorentz_scale_factor': 3.0,
140      'dynamic_cor_length':   1.0,
141     }, 0.1, 2.9712970297],
142
143    [{'gauss_scale_factor':  10.0,
144      'static_cor_length':  100.0,
145      'lorentz_scale_factor': 3.0,
146      'dynamic_cor_length':   1.0,
147      'background':         100.0
148     }, 5.0, 100.116384615],
149
150    [{'gauss_scale_factor':  10.0,
151      'static_cor_length':  100.0,
152      'lorentz_scale_factor': 3.0,
153      'dynamic_cor_length':   1.0,
154      'background':           0.0,
155     }, 200., 7.49981250469e-05],
156    ]
Note: See TracBrowser for help on using the repository browser.