source: sasmodels/sasmodels/models/polymer_excl_volume.py @ 23d3b41

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 23d3b41 was 23d3b41, checked in by piotr, 8 years ago

Converted PolymerExclVol? ume model

  • Property mode set to 100644
File size: 4.7 KB
Line 
1r"""
2This model describes the scattering from polymer chains subject to excluded volume effects
3and 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 (Benoit, 1957)
9
10.. math::
11
12    P(Q)=2\int_0^{1}dx(1-x)exp\left[-\frac{Q^2a^2}{6}n^{2v}x^{2v}\right]
13
14where $\nu$ is the excluded volume parameter
15(which is related to the Porod exponent $m$ as $\nu=1/m$ ),
16$a$ is the statistical segment length of the polymer chain,
17and $n$ is the degree of polymerization.
18This integral was later put into an almost analytical form as follows (Hammouda, 1993)
19
20.. math::
21
22    P(Q)=\frac{1}{\nu U^{1/2\nu}}\gamma\left(\frac{1}{2\nu},U\right) -
23    \frac{1}{\nu U^{1/\nu}}\gamma\left(\frac{1}{\nu},U\right)
24
25where $\gamma(x,U)$ is the incomplete gamma function
26
27.. math::
28
29    \gamma(x,U)=\int_0^{U}dt\ exp(-t)t^{x-1}
30
31and the variable $U$ is given in terms of the scattering vector $Q$ as
32
33.. math::
34
35    U=\frac{Q^2a^2n^{2\nu}}{6} = \frac{Q^2R_{g}^2(2\nu+1)(2\nu+2)}{6}
36
37The square of the radius-of-gyration is defined as
38
39.. math::
40
41    R_{g}^2 = \frac{a^2n^{2\nu}}{(2\nu+1)(2\nu+2)}
42
43Note that this model applies only in the mass fractal range (ie, $5/3<=m<=3$ )
44and **does not apply** to surface fractals ( $3<m<=4$ ).
45It also does not reproduce the rigid rod limit (m=1) because it assumes chain flexibility
46from the outset. It may cover a portion of the semi-flexible chain range ( $1<m<5/3$ ).
47
48A low-Q expansion yields the Guinier form and a high-Q expansion yields the Porod form
49which is given by
50
51.. math::
52
53    P(Q\rightarrow \infty) = \frac{1}{\nu U^{1/2\nu}}\Gamma\left(\frac{1}{2\nu}\right) -
54    \frac{1}{\nu U^{1/\nu}}\Gamma\left(\frac{1}{\nu}\right)
55
56Here $\Gamma(x) = \gamma(x,\infty)$ is the gamma function.
57
58The asymptotic limit is dominated by the first term
59
60.. math::
61
62    P(Q\rightarrow \infty) \sim \frac{1}{\nu U^{1/2\nu}}\Gamma\left(\frac{1}{2\nu}\right) =
63    \frac{m}{\left(QR_{g}\right)^m}\left[\frac{6}{(2\nu +1)(2\nu +2)} \right]^{m/2}
64    \Gamma (m/2)
65
66The special case when $\nu=0.5$ (or $m=2/\nu=2$ ) corresponds to Gaussian chains for
67which the form factor is given by the familiar Debye function.
68
69.. math::
70
71    P(Q) = \frac{2}{Q^4R_{g}^4} \left[exp(-Q^2R_{g}^2) - 1 + Q^2R_{g}^2 \right]
72
73For 2D data: The 2D scattering intensity is calculated in the same way as 1D,
74where the $q$ vector is defined as
75
76.. math::
77
78    q = \sqrt{q_x^2 + q_y^2}
79
80This example dataset is produced using 200 data points, $qmin=0.001Ang^{-1}$,
81$qmax=0.2Ang^{-1}$ and the default values
82
83.. figure:: img/polymer_excl_volume_1d.jpg
84
85    1D plot using the default values (w/500 data point).
86
87
88References
89----------
90
91H Benoit, *Comptes Rendus*, 245 (1957) 2244-2247
92
93B Hammouda, *SANS from Homogeneous Polymer Mixtures - A Unified Overview,
94Advances in Polym. Sci.* 106(1993) 87-133
95
96"""
97
98from math import sqrt
99from numpy import inf, power
100from scipy.special import gammainc, gamma
101
102name = "polymer_excl_volume"
103title = "Polymer Excluded Volume model"
104description = """Compute the scattering intensity from polymers with excluded volume effects.
105                rg:         radius of gyration
106                porod_exp:  Porod exponent
107              """
108category = "shape-independent"
109
110#             ["name", "units", default, [lower, upper], "type", "description"],
111parameters = [["rg",        "Ang", 60.0, [0, inf],    "", "Radius of Gyration"],
112              ["porod_exp", "",     3.0, [-inf, inf], "", "Porod exponent"],
113              ]
114
115
116def Iq(q, rg, porod_exp):
117
118    """
119    :param q:         Input q-value (float or [float, float])
120    :param rg:        Radius of gyration
121    :param porod_exp: Porod exponent
122    :return:          Calculated intensity
123    """
124    nu = 1.0/porod_exp
125    u = q*q*rg*rg*(2.0*nu+1.0) * (2.0*nu+2.0)/6.0
126    o2nu = 1.0/(2.0*nu)
127
128    intensity = ((1.0/(nu*power(u, o2nu))) * (gamma(o2nu)*gammainc(o2nu, u) -
129                 1.0/power(u, o2nu) * gamma(porod_exp)*gammainc(porod_exp, u)))*(q > 0) + \
130                 1.0*(q <= 0)
131
132    return intensity
133
134Iq.vectorized = True  # Iq accepts an array of q values
135
136
137def Iqxy(qx, qy, *args):
138        iq = Iq(sqrt(qx**2 + qy**2), *args)
139
140        return iq
141
142Iqxy.vectorized = True  # Iqxy accepts an array of qx, qy values
143
144
145demo = dict(scale=1, background=0.0,
146            rg=60.0,
147            porod_exp=3.0)
148
149oldname = "PolymerExclVolume"
150oldpars = dict(background='background', scale='scale',
151               rg='rg',
152               porod_exp='m')
153
154tests = [[{'rg': 10, 'porod_exp': 4.0}, 0.1, 0.723436675809],
155
156         [{'rg': 2.2, 'porod_exp': 22.0, 'background': 100.0}, 5.0, 100.0],
157
158         [{'rg': 1.1, 'porod_exp': 1, 'background': 10.0, 'scale': 1.25}, 20000., 10.0000712097]
159         ]
Note: See TracBrowser for help on using the repository browser.