# source:sasmodels/sasmodels/models/polymer_excl_volume.py@a2ca6e5

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since a2ca6e5 was a2ca6e5, checked in by smk78, 6 years ago

Updated help doc for polymer_excl_volume model in wake of Ticket 1073

• Property mode set to 100644
File size: 5.4 KB
Line
1r"""
2This model describes the scattering from polymer chains subject to excluded
3volume effects and has been used as a template for describing mass fractals.
4
5Definition
6----------
7
8The form factor was originally presented in the following integral form
9(Benoit, 1957)
10
11.. math::
12
13    P(Q)=2\int_0^{1}dx(1-x)exp\left[-\frac{Q^2a^2}{6}n^{2v}x^{2v}\right]
14
15where $\nu$ is the excluded volume parameter
16(which is related to the Porod exponent $m$ as $\nu=1/m$ ),
17$a$ is the statistical segment length of the polymer chain,
18and $n$ is the degree of polymerization.
19
20This integral was later put into an almost analytical form as follows
21(Hammouda, 1993)
22
23.. math::
24
25    P(Q)=\frac{1}{\nu U^{1/2\nu}}\gamma\left(\frac{1}{2\nu},U\right) -
26    \frac{1}{U^{1/2\nu}}\gamma\left(\frac{1}{\nu},U\right)
27
28later recast as (for example, Hore, 2013; Hammouda & Kim, 2017)
29
30.. math::
31
32    P(Q)=\frac{1}{\nu U^{1/2\nu}}\gamma\left(\frac{1}{2\nu},U\right) -
33    \frac{1}{\nu U^{1/\nu}}\gamma\left(\frac{1}{\nu},U\right)
34
35where $\gamma(x,U)$ is the incomplete gamma function
36
37.. math::
38
39    \gamma(x,U)=\int_0^{U}dt\ exp(-t)t^{x-1}
40
41and the variable $U$ is given in terms of the scattering vector $Q$ as
42
43.. math::
44
45    U=\frac{Q^2a^2n^{2\nu}}{6} = \frac{Q^2R_{g}^2(2\nu+1)(2\nu+2)}{6}
46
47The two analytic forms are equivalent. In the 1993 paper
48
49.. math::
50
51    \frac{1}{\nu U^{1/2\nu}}
52
53has been factored out.
54
55**SasView implements the 1993 expression**.
56
57The square of the radius-of-gyration is defined as
58
59.. math::
60
61    R_{g}^2 = \frac{a^2n^{2\nu}}{(2\nu+1)(2\nu+2)}
62
63.. note::
64    This model applies only in the mass fractal range (ie, $5/3<=m<=3$ )
65    and **does not apply** to surface fractals ( $3<m<=4$ ).
66    It also does not reproduce the rigid rod limit (m=1) because it assumes chain
67    flexibility from the outset. It may cover a portion of the semi-flexible chain
68    range ( $1<m<5/3$ ).
69
70A low-Q expansion yields the Guinier form and a high-Q expansion yields the
71Porod form which is given by
72
73.. math::
74
75    P(Q\rightarrow \infty) = \frac{1}{\nu U^{1/2\nu}}\Gamma\left(
76    \frac{1}{2\nu}\right) - \frac{1}{\nu U^{1/\nu}}\Gamma\left(
77    \frac{1}{\nu}\right)
78
79Here $\Gamma(x) = \gamma(x,\infty)$ is the gamma function.
80
81The asymptotic limit is dominated by the first term
82
83.. math::
84
85    P(Q\rightarrow \infty) \sim \frac{1}{\nu U^{1/2\nu}}\Gamma\left(\frac{1}{2\nu}\right) =
86    \frac{m}{\left(QR_{g}\right)^m}\left[\frac{6}{(2\nu +1)(2\nu +2)} \right]^{m/2}
87    \Gamma (m/2)
88
89The special case when $\nu=0.5$ (or $m=1/\nu=2$ ) corresponds to Gaussian chains for
90which the form factor is given by the familiar Debye function.
91
92.. math::
93
94    P(Q) = \frac{2}{Q^4R_{g}^4} \left[exp(-Q^2R_{g}^2) - 1 + Q^2R_{g}^2 \right]
95
96For 2D data: The 2D scattering intensity is calculated in the same way as 1D,
97where the $q$ vector is defined as
98
99.. math::
100
101    q = \sqrt{q_x^2 + q_y^2}
102
103
104References
105----------
106
107H Benoit, *Comptes Rendus*, 245 (1957) 2244-2247
108
109B Hammouda, *SANS from Homogeneous Polymer Mixtures - A Unified Overview,
110Advances in Polym. Sci.* 106 (1993) 87-133
111
112M Hore et al, *Co-Nonsolvency of Poly(n-isopropylacrylamide) in Deuterated
113Water/Ethanol Mixtures* 46 (2013) 7894-7901
114
115B Hammouda & M-H Kim, *The empirical core-chain model* 247 (2017) 434-440
116"""
117
118import numpy as np
119from numpy import inf, power, errstate
120from scipy.special import gammainc, gamma
121
122name = "polymer_excl_volume"
123title = "Polymer Excluded Volume model"
124description = """Compute the scattering intensity from polymers with excluded
125                volume effects.
127                porod_exp:  Porod exponent
128              """
129category = "shape-independent"
130
132#   ["name", "units", default, [lower, upper], "type", "description"],
133parameters = [
134    ["rg",        "Ang", 60.0, [0, inf], "", "Radius of Gyration"],
135    ["porod_exp", "",     3.0, [0, inf], "", "Porod exponent"],
136]
138
139
140def Iq(q, rg=60.0, porod_exp=3.0):
141    """
142    :param q:         Input q-value (float or [float, float])
143    :param rg:        Radius of gyration
144    :param porod_exp: Porod exponent
145    :return:          Calculated intensity
146    """
147    usub = (q*rg)**2 * (2.0/porod_exp + 1.0) * (2.0/porod_exp + 2.0)/6.0
148    with errstate(divide='ignore', invalid='ignore'):
149        upow = power(usub, -0.5*porod_exp)
150        result = (porod_exp*upow *
151                  (gamma(0.5*porod_exp)*gammainc(0.5*porod_exp, usub) -
152                   upow*gamma(porod_exp)*gammainc(porod_exp, usub)))
153    result[q <= 0] = 1.0
154
155    return result
156
157Iq.vectorized = True  # Iq accepts an array of q values
158
159def random():
160    rg = 10**np.random.uniform(0, 4)
161    porod_exp = np.random.uniform(1e-3, 6)
162    scale = 10**np.random.uniform(1, 5)
163    pars = dict(
164        #background=0,
165        scale=scale,
166        rg=rg,
167        porod_exp=porod_exp,
168    )
169    return pars
170
171tests = [
172    # Accuracy tests based on content in test/polyexclvol_default_igor.txt
173    [{'rg': 60, 'porod_exp': 3.0}, 0.001, 0.999801],
174    [{'rg': 60, 'porod_exp': 3.0}, 0.105363, 0.0172751],
175    [{'rg': 60, 'porod_exp': 3.0, 'background': 0.0}, 0.665075, 6.56261e-05],
176
177    # Additional tests with larger range of parameters
178    [{'rg': 10, 'porod_exp': 4.0}, 0.1, 0.724436675809],
179    [{'rg': 2.2, 'porod_exp': 22.0, 'background': 100.0}, 5.0, 100.0],
180    [{'rg': 1.1, 'porod_exp': 1, 'background': 10.0, 'scale': 1.25},
181     20000., 10.0000712097]
182    ]
Note: See TracBrowser for help on using the repository browser.