[29da213] | 1 | r""" |
---|
| 2 | This model calculates the scattering from a gel structure, |
---|
| 3 | but typically a physical rather than chemical network. |
---|
[b8954d7] | 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. |
---|
[29da213] | 7 | |
---|
| 8 | Definition |
---|
| 9 | ---------- |
---|
| 10 | |
---|
| 11 | The 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, |
---|
| 18 | which can be attributed to the "frozen-in" crosslinks. |
---|
[b8954d7] | 19 | \ |xi|\ is the dynamic correlation length, which can be attributed to the |
---|
[29da213] | 20 | fluctuating polymer chains between crosslinks. |
---|
[b8954d7] | 21 | $I_G(0)$ and $I_L(0)$ are the scaling factors for each of these structures. |
---|
[29da213] | 22 | Think 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 | |
---|
| 29 | For 2D data the scattering intensity is calculated in the same way as 1D, |
---|
| 30 | where the $q$ vector is defined as |
---|
| 31 | |
---|
| 32 | .. math:: |
---|
| 33 | |
---|
| 34 | q = \sqrt{q_x^2 + q_y^2} |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | References |
---|
| 38 | ---------- |
---|
| 39 | |
---|
[168052c] | 40 | G Evmenenko, E Theunissen, K Mortensen, H Reynaers, *Polymer*, |
---|
| 41 | 42 (2001) 2907-2913 |
---|
[29da213] | 42 | |
---|
| 43 | """ |
---|
| 44 | |
---|
[168052c] | 45 | from numpy import inf, sqrt, exp |
---|
[29da213] | 46 | |
---|
| 47 | name = "gauss_lorentz_gel" |
---|
| 48 | title = "Gauss Lorentz Gel model of scattering from a gel structure" |
---|
| 49 | description = """ |
---|
| 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 | """ |
---|
| 61 | category = "shape-independent" |
---|
[168052c] | 62 | # pylint: disable=bad-whitespace, line-too-long |
---|
[29da213] | 63 | # ["name", "units", default, [lower, upper], "type", "description"], |
---|
| 64 | parameters = [["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"], |
---|
[168052c] | 68 | ] |
---|
| 69 | # pylint: enable=bad-whitespace, line-too-long |
---|
[29da213] | 70 | |
---|
| 71 | def Iq(q, |
---|
[168052c] | 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 |
---|
[29da213] | 92 | |
---|
| 93 | Iq.vectorized = True # Iq accepts an array of q values |
---|
| 94 | |
---|
| 95 | |
---|
| 96 | def Iqxy(qx, qy, *args): |
---|
[168052c] | 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 | """ |
---|
[29da213] | 103 | |
---|
[168052c] | 104 | return Iq(sqrt(qx**2 + qy**2), *args) |
---|
[29da213] | 105 | |
---|
| 106 | Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values |
---|
| 107 | |
---|
| 108 | |
---|
| 109 | demo = 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 | |
---|
[07a6700] | 115 | tests = [ |
---|
[168052c] | 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, |
---|
[6dd90c1] | 122 | }, 0.001, 149.482], |
---|
[168052c] | 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, |
---|
[6dd90c1] | 128 | }, 0.105363, 9.1913], |
---|
[168052c] | 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, |
---|
[6dd90c1] | 134 | }, 0.441623, 0.633811], |
---|
[168052c] | 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, |
---|
[6dd90c1] | 141 | }, 0.1, 2.9712970297], |
---|
[168052c] | 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 |
---|
[6dd90c1] | 148 | }, 5.0, 100.116384615], |
---|
[168052c] | 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, |
---|
[6dd90c1] | 154 | 'background': 0.0, |
---|
[168052c] | 155 | }, 200., 7.49981250469e-05], |
---|
| 156 | ] |
---|