source: sasmodels/sasmodels/models/stacked_disks.py @ 7c57861

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

normalize nearest neighbor spaccing dnn, vs bragg spacing d_spacing and
polydispersity in spacing sigma_d

  • Property mode set to 100644
File size: 7.8 KB
Line 
1r"""
2This model provides the form factor, $P(q)$, for stacked discs (tactoids)
3with a core/layer structure where the form factor is normalized by the volume
4of the cylinder. Assuming the next neighbor distance (d-spacing) in a stack
5of parallel discs obeys a Gaussian distribution, a structure factor $S(q)$
6proposed by Kratky and Porod in 1949 is used in this function.
7
8Note that the resolution smearing calculation uses 76 Gauss quadrature points
9to properly smear the model since the function is HIGHLY oscillatory,
10especially around the q-values that correspond to the repeat distance of
11the layers.
12
13The 2D scattering intensity is the same as 1D, regardless of the orientation
14of the q vector which is defined as
15
16.. math:: q = \sqrt{q_x^2 + q_y^2}
17
18Definition
19----------
20
21.. figure:: img/stacked_disks_geometry.png
22
23The scattered intensity $I(q)$ is calculated as
24
25.. math::
26
27    I(q) = N\int_{0}^{\pi /2}\left[ \Delta \rho_t
28    \left( V_t f_t(q) - V_c f_c(q)\right) + \Delta \rho_c V_c f_c(q)
29    \right]^2 S(q)\sin{\alpha}\ d\alpha + \text{background}
30
31where the contrast
32
33.. math::
34
35    \Delta \rho_i = \rho_i - \rho_\text{solvent}
36
37and $N$ is the number of discs per unit volume,
38$\alpha$ is the angle between the axis of the disc and $q$,
39and $V_t$ and $V_c$ are the total volume and the core volume of
40a single disc, respectively.
41
42.. math::
43
44    \left\langle f_{t}^2(q)\right\rangle_{\alpha} =
45    \int_{0}^{\pi/2}\left[
46    \left(\frac{\sin(q(d+h)\cos{\alpha})}{q(d+h)\cos{\alpha}}\right)
47    \left(\frac{2J_1(qR\sin{\alpha})}{qR\sin{\alpha}} \right)
48    \right]^2 \sin{\alpha}\ d\alpha
49
50    \left\langle f_{c}^2(q)\right\rangle_{\alpha} =
51    \int_{0}^{\pi/2}\left[
52    \left(\frac{\sin(qh)\cos{\alpha})}{qh\cos{\alpha}}\right)
53    \left(\frac{2J_1(qR\sin{\alpha})}{qR\sin{\alpha}}\right)
54    \right]^2 \sin{\alpha}\ d\alpha
55
56where $d$ = thickness of the layer (*thick_layer*),
57$2h$ = core thickness (*thick_core*), and $R$ = radius of the disc (*radius*).
58
59.. math::
60
61    S(q) = 1 + \frac{1}{2}\sum_{k=1}^n(n-k)\cos{(kDq\cos{\alpha})}
62    \exp\left[ -k(q\cos{\alpha})^2\sigma_d/2\right]
63
64where $n$ is the total number of the disc stacked (*n_stacking*),
65$D = 2(d+h)$ is the next neighbor center-to-center distance (d-spacing),
66and $\sigma_d$ = the Gaussian standard deviation of the d-spacing (*sigma_d*).
67
68.. note::
69    Each assembly in the stack is layer/core/layer, so the spacing of the
70    cores is core plus two layers. The 2nd virial coefficient of the cylinder
71    is calculated based on the *radius* and *length*
72    = *n_stacking* * (*thick_core* + 2 * *thick_layer*)
73    values, and used as the effective radius for $S(Q)$ when $P(Q) * S(Q)$
74    is applied.
75
76To provide easy access to the orientation of the stacked disks, we define
77the axis of the cylinder using two angles $\theta$ and $\varphi$.
78
79.. figure:: img/stacked_disks_angle_definition.jpg
80
81    Examples of the angles for oriented stacked disks against
82    the detector plane.
83
84.. figure:: img/stacked_disks_angle_projection.jpg
85
86    Examples of the angles for oriented pp against the detector plane.
87
88Our model uses the form factor calculations implemented in a c-library provided
89by the NIST Center for Neutron Research (Kline, 2006)
90
91References
92----------
93
94A Guinier and G Fournet, *Small-Angle Scattering of X-Rays*,
95John Wiley and Sons, New York, 1955
96
97O Kratky and G Porod, *J. Colloid Science*, 4, (1949) 35
98
99J S Higgins and H C Benoit, *Polymers and Neutron Scattering*,
100Clarendon, Oxford, 1994
101
102**Author:** NIST IGOR/DANSE **on:** pre 2010
103
104**Last Modified by:** Piotr Rozyczko **on:** February 18, 2016
105
106**Last Reviewed by:** Richard Heenan **on:** March 22, 2016
107"""
108
109from numpy import inf
110
111name = "stacked_disks"
112title = ""
113description = """\
114    One layer of disk consists of a core, a top layer, and a bottom layer.
115    radius =  the radius of the disk
116    thick_core = thickness of the core
117    thick_layer = thickness of a layer
118    sld_core = the SLD of the core
119    sld_layer = the SLD of the layers
120    n_stacking = the number of the disks
121    sigma_d =  Gaussian STD of d-spacing
122    sld_solvent = the SLD of the solvent
123    """
124category = "shape:cylinder"
125
126# pylint: disable=bad-whitespace, line-too-long
127#   ["name", "units", default, [lower, upper], "type","description"],
128parameters = [
129    ["thick_core",  "Ang",        10.0, [0, inf],    "volume",      "Thickness of the core disk"],
130    ["thick_layer", "Ang",        10.0, [0, inf],    "volume",      "Thickness of layer each side of core"],
131    ["radius",      "Ang",        15.0, [0, inf],    "volume",      "Radius of the stacked disk"],
132    ["n_stacking",  "",            1.0, [0, inf],    "volume",      "Number of stacked layer/core/layer disks"],
133    ["sigma_d",     "Ang",         0,   [0, inf],    "",            "Sigma of nearest neighbor spacing"],
134    ["sld_core",    "1e-6/Ang^2",  4,   [-inf, inf], "sld",         "Core scattering length density"],
135    ["sld_layer",   "1e-6/Ang^2",  0.0, [-inf, inf], "sld",         "Layer scattering length density"],
136    ["sld_solvent", "1e-6/Ang^2",  5.0, [-inf, inf], "sld",         "Solvent scattering length density"],
137    ["theta",       "degrees",     0,   [-inf, inf], "orientation", "Orientation of the stacked disk axis w/respect incoming beam"],
138    ["phi",         "degrees",     0,   [-inf, inf], "orientation", "Orientation of the stacked disk in the plane of the detector"],
139    ]
140# pylint: enable=bad-whitespace, line-too-long
141
142source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "stacked_disks.c"]
143
144demo = dict(background=0.001,
145            scale=0.01,
146            thick_core=10.0,
147            thick_layer=10.0,
148            radius=15.0,
149            n_stacking=1,
150            sigma_d=0,
151            sld_core=4,
152            sld_layer=0.0,
153            sld_solvent=5.0,
154            theta=0,
155            phi=0)
156
157tests = [
158    # Accuracy tests based on content in test/utest_extra_models.py.
159    # Added 2 tests with n_stacked = 5 using SasView 3.1.2 - PDB
160    [{'thick_core': 10.0,
161      'thick_layer': 15.0,
162      'radius': 3000.0,
163      'n_stacking': 1.0,
164      'sigma_d': 0.0,
165      'sld_core': 4.0,
166      'sld_layer': -0.4,
167      'solvent_sd': 5.0,
168      'theta': 0.0,
169      'phi': 0.0,
170      'scale': 0.01,
171      'background': 0.001,
172     }, 0.001, 5075.12],
173
174    [{'thick_core': 10.0,
175      'thick_layer': 15.0,
176      'radius': 3000.0,
177      'n_stacking': 5.0,
178      'sigma_d': 0.0,
179      'sld_core': 4.0,
180      'sld_layer': -0.4,
181      'solvent_sd': 5.0,
182      'theta': 0.0,
183      'phi': 0.0,
184      'scale': 0.01,
185      'background': 0.001,
186     }, 0.001, 5065.12793824],
187
188    [{'thick_core': 10.0,
189      'thick_layer': 15.0,
190      'radius': 3000.0,
191      'n_stacking': 5.0,
192      'sigma_d': 0.0,
193      'sld_core': 4.0,
194      'sld_layer': -0.4,
195      'solvent_sd': 5.0,
196      'theta': 0.0,
197      'phi': 0.0,
198      'scale': 0.01,
199      'background': 0.001,
200     }, 0.164, 0.0127673597265],
201
202    [{'thick_core': 10.0,
203      'thick_layer': 15.0,
204      'radius': 3000.0,
205      'n_stacking': 1.0,
206      'sigma_d': 0.0,
207      'sld_core': 4.0,
208      'sld_layer': -0.4,
209      'solvent_sd': 5.0,
210      'theta': 0.0,
211      'phi': 0.0,
212      'scale': 0.01,
213      'background': 0.001,
214     }, [0.001, 90.0], [5075.12, 0.001]],
215
216    [{'thick_core': 10.0,
217      'thick_layer': 15.0,
218      'radius': 3000.0,
219      'n_stacking': 1.0,
220      'sigma_d': 0.0,
221      'sld_core': 4.0,
222      'sld_layer': -0.4,
223      'solvent_sd': 5.0,
224      'theta': 0.0,
225      'phi': 0.0,
226      'scale': 0.01,
227      'background': 0.001,
228     }, ([0.4, 0.5]), [0.00105074, 0.00121761]],
229
230    [{'thick_core': 10.0,
231      'thick_layer': 15.0,
232      'radius': 3000.0,
233      'n_stacking': 1.0,
234      'sigma_d': 0.0,
235      'sld_core': 4.0,
236      'sld_layer': -0.4,
237      'solvent_sd': 5.0,
238      'theta': 0.0,
239      'phi': 0.0,
240      'scale': 0.01,
241      'background': 0.001,
242     }, ([1.3, 1.57]), [0.0010039, 0.0010038]],
243    ]
244# 21Mar2016   RKH notes that unit tests all have n_stacking=1, ought to test other values
245
Note: See TracBrowser for help on using the repository browser.