1 | #poly_gauss_coil model |
---|
2 | #conversion of Poly_GaussCoil.py |
---|
3 | #converted by Steve King, Mar 2016 |
---|
4 | r""" |
---|
5 | This empirical model describes the scattering from *polydisperse* polymer |
---|
6 | chains in theta solvents or polymer melts, assuming a Schulz-Zimm type |
---|
7 | molecular weight distribution. |
---|
8 | |
---|
9 | To describe the scattering from *monodisperse* polymer chains, see the |
---|
10 | :ref:`mono-gauss-coil` model. |
---|
11 | |
---|
12 | Definition |
---|
13 | ---------- |
---|
14 | |
---|
15 | .. math:: |
---|
16 | |
---|
17 | I(q) = \text{scale} \cdot I_0 \cdot P(q) + \text{background} |
---|
18 | |
---|
19 | where |
---|
20 | |
---|
21 | .. math:: |
---|
22 | |
---|
23 | I_0 &= \phi_\text{poly} \cdot V \cdot (\rho_\text{poly}-\rho_\text{solv})^2 \\ |
---|
24 | P(q) &= 2 [(1 + UZ)^{-1/U} + Z - 1] / [(1 + U) Z^2] \\ |
---|
25 | Z &= [(q R_g)^2] / (1 + 2U) \\ |
---|
26 | U &= (Mw / Mn) - 1 = \text{polydispersity ratio} - 1 \\ |
---|
27 | V &= M / (N_A \delta) |
---|
28 | |
---|
29 | Here, $\phi_\text{poly}$, is the volume fraction of polymer, $V$ is the |
---|
30 | volume of a polymer coil, $M$ is the molecular weight of the polymer, |
---|
31 | $N_A$ is Avogadro's Number, $\delta$ is the bulk density of the polymer, |
---|
32 | $\rho_\text{poly}$ is the sld of the polymer, $\rho_\text{solv}$ is the |
---|
33 | sld of the solvent, and $R_g$ is the radius of gyration of the polymer coil. |
---|
34 | |
---|
35 | The 2D scattering intensity is calculated in the same way as the 1D, |
---|
36 | but where the $q$ vector is redefined as |
---|
37 | |
---|
38 | .. math:: |
---|
39 | |
---|
40 | q = \sqrt{q_x^2 + q_y^2} |
---|
41 | |
---|
42 | References |
---|
43 | ---------- |
---|
44 | |
---|
45 | .. [#] O Glatter and O Kratky (editors), *Small Angle X-ray Scattering*, Academic Press, (1982) Page 404 |
---|
46 | .. [#] J S Higgins, H C Benoit, *Polymers and Neutron Scattering*, Oxford Science Publications, (1996) |
---|
47 | .. [#] S M King, *Small Angle Neutron Scattering* in *Modern Techniques for Polymer Characterisation*, Wiley, (1999) |
---|
48 | .. [#] http://www.ncnr.nist.gov/staff/hammouda/distance_learning/chapter_28.pdf |
---|
49 | |
---|
50 | Source |
---|
51 | ------ |
---|
52 | |
---|
53 | `poly_gauss_coil.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/poly_gauss_coil.py>`_ |
---|
54 | |
---|
55 | `poly_gauss_coil.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/poly_gauss_coil.c>`_ |
---|
56 | |
---|
57 | Authorship and Verification |
---|
58 | ---------------------------- |
---|
59 | |
---|
60 | * **Author:** |
---|
61 | * **Last Modified by:** |
---|
62 | * **Last Reviewed by:** |
---|
63 | * **Source added by :** Steve King **Date:** March 25, 2019 |
---|
64 | """ |
---|
65 | |
---|
66 | import numpy as np |
---|
67 | from numpy import inf, expm1, power |
---|
68 | |
---|
69 | name = "poly_gauss_coil" |
---|
70 | title = "Scattering from polydisperse polymer coils" |
---|
71 | |
---|
72 | description = """ |
---|
73 | Evaluates the scattering from |
---|
74 | polydisperse polymer chains. |
---|
75 | """ |
---|
76 | category = "shape-independent" |
---|
77 | |
---|
78 | # pylint: disable=bad-whitespace, line-too-long |
---|
79 | # ["name", "units", default, [lower, upper], "type", "description"], |
---|
80 | parameters = [ |
---|
81 | ["i_zero", "1/cm", 70.0, [0.0, inf], "", "Intensity at q=0"], |
---|
82 | ["rg", "Ang", 75.0, [0.0, inf], "", "Radius of gyration"], |
---|
83 | ["polydispersity", "None", 2.0, [1.0, inf], "", "Polymer Mw/Mn"], |
---|
84 | ] |
---|
85 | # pylint: enable=bad-whitespace, line-too-long |
---|
86 | |
---|
87 | # NB: Scale and Background are implicit parameters on every model |
---|
88 | def Iq(q, i_zero, rg, polydispersity): |
---|
89 | # pylint: disable = missing-docstring |
---|
90 | u = polydispersity - 1.0 |
---|
91 | z = q**2 * (rg**2 / (1.0 + 2.0*u)) |
---|
92 | |
---|
93 | # need to trap the case of the polydispersity being 1 (ie, monodisperse!) |
---|
94 | if polydispersity == 1.0: |
---|
95 | result = 2.0 * (expm1(-z) + z) |
---|
96 | index = q != 0. |
---|
97 | result[index] /= z[index]**2 |
---|
98 | result[~index] = 1.0 |
---|
99 | else: |
---|
100 | # Taylor series around z=0 of (2*(1+uz)^(-1/u) + z - 1) / (z^2(u+1)) |
---|
101 | p = [ |
---|
102 | #(-1 - 20*u - 155*u**2 - 580*u**3 - 1044*u**4 - 720*u**5) / 2520., |
---|
103 | #(+1 + 14*u + 71*u**2 + 154*u**3 + 120*u**4) / 360., |
---|
104 | #(-1 - 9*u - 26*u**2 - 24*u**3) / 60., |
---|
105 | (+1 + 5*u + 6*u**2) / 12., |
---|
106 | (-1 - 2*u) / 3., |
---|
107 | (+1), |
---|
108 | ] |
---|
109 | result = 2.0 * (power(1.0 + u*z, -1.0/u) + z - 1.0) / (1.0 + u) |
---|
110 | index = z > 1e-4 |
---|
111 | result[index] /= z[index]**2 |
---|
112 | result[~index] = np.polyval(p, z[~index]) |
---|
113 | return i_zero * result |
---|
114 | Iq.vectorized = True # Iq accepts an array of q values |
---|
115 | |
---|
116 | def random(): |
---|
117 | """Return a random parameter set for the model.""" |
---|
118 | rg = 10**np.random.uniform(0, 4) |
---|
119 | #rg = 1e3 |
---|
120 | polydispersity = 10**np.random.uniform(0, 3) |
---|
121 | pars = dict( |
---|
122 | #scale=1, background=0, |
---|
123 | i_zero=1e7, # i_zero is a simple scale |
---|
124 | rg=rg, |
---|
125 | polydispersity=polydispersity, |
---|
126 | ) |
---|
127 | return pars |
---|
128 | |
---|
129 | demo = dict(scale=1.0, |
---|
130 | i_zero=70.0, |
---|
131 | rg=75.0, |
---|
132 | polydispersity=2.0, |
---|
133 | background=0.0) |
---|
134 | |
---|
135 | # these unit test values taken from SasView 3.1.2 |
---|
136 | tests = [ |
---|
137 | [{'scale': 1.0, 'i_zero': 70.0, 'rg': 75.0, |
---|
138 | 'polydispersity': 2.0, 'background': 0.0}, |
---|
139 | [0.0106939, 0.469418], [57.6405, 0.169016]], |
---|
140 | ] |
---|