source: sasmodels/sasmodels/models/gauss_lorentz_gel.py @ c1e44e5

Last change on this file since c1e44e5 was c1e44e5, checked in by Paul Kienzle <pkienzle@…>, 5 years ago

Add local link to source files. Refs #1263.

  • Property mode set to 100644
File size: 5.1 KB
RevLine 
[29da213]1r"""
2This model calculates the scattering from a gel structure,
3but typically a physical rather than chemical network.
[b8954d7]4It is modeled as a sum of a low-q exponential decay (which happens to
[48462b0]5give a functional form similar to Guinier scattering, so interpret with
[b8954d7]6care) plus a Lorentzian at higher-q values. See also the gel_fit model.
[29da213]7
8Definition
9----------
10
[40a87fa]11The scattering intensity $I(q)$ is calculated as (Eqn. 5 from the reference)
[29da213]12
[40a87fa]13.. math:: I(q) = I_G(0) \exp(-q^2\Xi ^2/2) + I_L(0)/(1+q^2\xi^2)
[29da213]14
[40a87fa]15$\Xi$ is the length scale of the static correlations in the gel, which can
16be attributed to the "frozen-in" crosslinks. $\xi$ is the dynamic correlation
17length, which can be attributed to the fluctuating polymer chains between
18crosslinks. $I_G(0)$ and $I_L(0)$ are the scaling factors for each of these
19structures. Think carefully about how these map to your particular system!
[29da213]20
21.. note::
22    The peaked structure at higher $q$ values (Figure 2 from the reference)
23    is not reproduced by the model. Peaks can be introduced into the model
[40a87fa]24    by summing this model with the :ref:`gaussian-peak` model.
[29da213]25
26For 2D data the scattering intensity is calculated in the same way as 1D,
27where the $q$ vector is defined as
28
[40a87fa]29.. math:: q = \sqrt{q_x^2 + q_y^2}
[29da213]30
31References
32----------
33
[0507e09]34.. [#] G Evmenenko, E Theunissen, K Mortensen, H Reynaers, *Polymer*, 42 (2001) 2907-2913
35
36Authorship and Verification
37----------------------------
38
[c1e44e5]39* **Author:**
40* **Last Modified by:**
41* **Last Reviewed by:**
[29da213]42"""
43
[2d81cfe]44import numpy as np
[2c74c11]45from numpy import inf, exp
[29da213]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"
[168052c]62# pylint: disable=bad-whitespace, line-too-long
[29da213]63#            ["name", "units", default, [lower, upper], "type", "description"],
[a807206]64parameters = [["gauss_scale",   "",    100.0,  [-inf, inf], "", "Gauss scale factor"],
65              ["cor_length_static",    "Ang", 100.0,  [0, inf],    "", "Static correlation length"],
66              ["lorentz_scale", "",     50.0,  [-inf, inf], "", "Lorentzian scale factor"],
67              ["cor_length_dynamic",   "Ang",  20.0,  [0, inf],    "", "Dynamic correlation length"],
[168052c]68             ]
69# pylint: enable=bad-whitespace, line-too-long
[29da213]70
71def Iq(q,
[a807206]72       gauss_scale=100.0,
73       cor_length_static=100.0,
74       lorentz_scale=50.0,
75       cor_length_dynamic=20.0):
[168052c]76    """
77
78    :param q:                    Input q-value
[a807206]79    :param gauss_scale:   Gauss scale factor
80    :param cor_length_static:    Static correlation length
81    :param lorentz_scale: Lorentzian scale factor
82    :param cor_length_dynamic:   Dynamic correlation length
[168052c]83    :return:                     1-D intensity
84    """
85
[a807206]86    term1 = gauss_scale *\
87            exp(-1.0*q*q*cor_length_static*cor_length_static/2.0)
88    term2 = lorentz_scale /\
89            (1.0+(q*cor_length_dynamic)*(q*cor_length_dynamic))
[168052c]90
91    return term1 + term2
[29da213]92
93Iq.vectorized = True  # Iq accepts an array of q values
94
95
[48462b0]96def random():
[b297ba9]97    """Return a random parameter set for the model."""
[48462b0]98    gauss_scale = 10**np.random.uniform(1, 3)
99    lorentz_scale = 10**np.random.uniform(1, 3)
100    cor_length_static = 10**np.random.uniform(0, 3)
101    cor_length_dynamic = 10**np.random.uniform(0, 3)
102    pars = dict(
103        #background=0,
104        scale=1,
105        gauss_scale=gauss_scale,
106        lorentz_scale=lorentz_scale,
107        cor_length_static=cor_length_static,
108        cor_length_dynamic=cor_length_dynamic,
109    )
110    return pars
111
112
[29da213]113demo = dict(scale=1, background=0.1,
[a807206]114            gauss_scale=100.0,
115            cor_length_static=100.0,
116            lorentz_scale=50.0,
117            cor_length_dynamic=20.0)
[29da213]118
[07a6700]119tests = [
[168052c]120
121    # Accuracy tests based on content in test/utest_extra_models.py
[a807206]122    [{'gauss_scale':  100.0,
123      'cor_length_static':   100.0,
124      'lorentz_scale': 50.0,
125      'cor_length_dynamic':   20.0,
[6dd90c1]126     }, 0.001, 149.482],
[168052c]127
[a807206]128    [{'gauss_scale':  100.0,
129      'cor_length_static':   100.0,
130      'lorentz_scale': 50.0,
131      'cor_length_dynamic':   20.0,
[6dd90c1]132     }, 0.105363, 9.1913],
[168052c]133
[a807206]134    [{'gauss_scale':  100.0,
135      'cor_length_static':   100.0,
136      'lorentz_scale': 50.0,
137      'cor_length_dynamic':   20.0,
[6dd90c1]138     }, 0.441623, 0.633811],
[168052c]139
140    # Additional tests with larger range of parameters
[a807206]141    [{'gauss_scale':  10.0,
142      'cor_length_static':  100.0,
143      'lorentz_scale': 3.0,
144      'cor_length_dynamic':   1.0,
[6dd90c1]145     }, 0.1, 2.9712970297],
[168052c]146
[a807206]147    [{'gauss_scale':  10.0,
148      'cor_length_static':  100.0,
149      'lorentz_scale': 3.0,
150      'cor_length_dynamic':   1.0,
[168052c]151      'background':         100.0
[6dd90c1]152     }, 5.0, 100.116384615],
[168052c]153
[a807206]154    [{'gauss_scale':  10.0,
155      'cor_length_static':  100.0,
156      'lorentz_scale': 3.0,
157      'cor_length_dynamic':   1.0,
[6dd90c1]158      'background':           0.0,
[168052c]159     }, 200., 7.49981250469e-05],
160    ]
Note: See TracBrowser for help on using the repository browser.