source: sasmodels/sasmodels/models/stacked_disks.py @ edf1e8b

core_shell_microgelscostrafo411magnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since edf1e8b was edf1e8b, checked in by Paul Kienzle <pkienzle@…>, 7 years ago

round to nearest number of disks; require at least one disk; code tidying

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