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