source: sasmodels/sasmodels/models/gauss_lorentz_gel.py @ 2c74c11

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

implicit Iqxy; fix divide by 0 for q=0

  • Property mode set to 100644
File size: 4.7 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, 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
96demo = dict(scale=1, background=0.1,
97            gauss_scale_factor=100.0,
98            static_cor_length=100.0,
99            lorentz_scale_factor=50.0,
100            dynamic_cor_length=20.0)
101
102tests = [
103
104    # Accuracy tests based on content in test/utest_extra_models.py
105    [{'gauss_scale_factor':  100.0,
106      'static_cor_length':   100.0,
107      'lorentz_scale_factor': 50.0,
108      'dynamic_cor_length':   20.0,
109     }, 0.001, 149.482],
110
111    [{'gauss_scale_factor':  100.0,
112      'static_cor_length':   100.0,
113      'lorentz_scale_factor': 50.0,
114      'dynamic_cor_length':   20.0,
115     }, 0.105363, 9.1913],
116
117    [{'gauss_scale_factor':  100.0,
118      'static_cor_length':   100.0,
119      'lorentz_scale_factor': 50.0,
120      'dynamic_cor_length':   20.0,
121     }, 0.441623, 0.633811],
122
123    # Additional tests with larger range of parameters
124    [{'gauss_scale_factor':  10.0,
125      'static_cor_length':  100.0,
126      'lorentz_scale_factor': 3.0,
127      'dynamic_cor_length':   1.0,
128     }, 0.1, 2.9712970297],
129
130    [{'gauss_scale_factor':  10.0,
131      'static_cor_length':  100.0,
132      'lorentz_scale_factor': 3.0,
133      'dynamic_cor_length':   1.0,
134      'background':         100.0
135     }, 5.0, 100.116384615],
136
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      'background':           0.0,
142     }, 200., 7.49981250469e-05],
143    ]
Note: See TracBrowser for help on using the repository browser.