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

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

stacked_disks fails compare, even before rkh edited it, will investigate

  • Property mode set to 100644
File size: 7.1 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::
17
18    q = \sqrt{q_x^2 + q_y^2}
19
20Definition
21----------
22
23.. figure:: img/stacked_disks_geometry.png
24
25The scattered intensity $I(q)$ is calculated as
26
27.. math::
28
29    I(q) = N\int_{0}^{\pi /2}\left[ \Delta \rho_t
30    \left( V_tf_t(q) - V_cf_c(q)\right) + \Delta \rho_cV_cf_c(q)
31    \right]^2S(q)\sin{\alpha d\alpha} + background
32
33where the contrast
34
35.. math::
36
37    \Delta \rho_i = \rho_i - \rho_{solvent}
38
39and *N* is the number of discs per unit volume,
40$\alpha$ is the angle between the axis of the disc and *q*,
41and $V_t$ and $V_c$ are the total volume and the core volume of
42a single disc, respectively.
43
44.. math::
45
46    \left\langle f_{t}^2(q)\right\rangle_{\alpha} =
47    \int_{0}^{\pi/2}\left[
48    \left(\frac{sin(q(d+h)\cos{\alpha})}{q(d+h)\cos{\alpha}}\right)
49    \left(\frac{2J_1(qR\sin{\alpha})}{qR\sin{\alpha}} \right)
50    \right]^2 \sin{\alpha d\alpha}
51
52    \left\langle f_{c}^2(q)\right\rangle_{\alpha} =
53    \int_{0}^{\pi/2}\left[
54    \left(\frac{sin(qh)\cos{\alpha})}{qh\cos{\alpha}}\right)
55    \left(\frac{2J_1(qR\sin{\alpha})}{qR\sin{\alpha}} \right)
56    \right]^2 \sin{\alpha d\alpha}
57
58where *d* = thickness of the layer (layer_thick),
59*2h* = core thickness (core_thick), and *R* = radius of the disc (radius).
60
61.. math::
62
63    S(q) = 1 + \frac{1}{2}\sum_{k=1}^n(n-k)\cos{(kDq\cos{\alpha})}
64    exp\left[ -k(q\cos{\alpha})^2\sigma_D/2\right]
65
66where *n* = the total number of the disc stacked (n_stacking),
67*D* = 2*(*d*+*h*)the next neighbor center-to-center distance (d-spacing),
68and $\sigma_D$ = the Gaussian standard deviation of the d-spacing (sigma_d).
69
70.. note::
71    Each assmebly in the stack is layer/core/layer, so the spacing of the cores
72    is core plus two layers. The 2nd virial coefficient of the cylinder is
73    calculated based on the
74    *radius* and *length* = *n_stacking* * (*core_thick* + 2 * *layer_thick*)
75    values, and used as the effective radius for $S(Q)$ when $P(Q) * S(Q)$
76    is applied.
77
78To provide easy access to the orientation of the stacked disks, we define
79the axis of the cylinder using two angles $\theta$ and $\varphi$.
80
81.. figure:: img/stacked_disks_angle_definition.jpg
82
83    Examples of the angles for oriented stacked disks against
84    the detector plane.
85
86.. figure:: img/stacked_disks_angle_projection.jpg
87
88    Examples of the angles for oriented pp against the detector plane.
89
90Our model uses the form factor calculations implemented in a c-library provided
91by the NIST Center for Neutron Research (Kline, 2006)
92
93References
94----------
95
96A Guinier and G Fournet, *Small-Angle Scattering of X-Rays*, John Wiley and Sons, New York, 1955
97
98O Kratky and G Porod, *J. Colloid Science*, 4, (1949) 35
99
100J S Higgins and H C Benoit, *Polymers and Neutron Scattering*, Clarendon, Oxford, 1994
101
102"""
103
104from numpy import inf
105
106name = "stacked_disks"
107title = ""
108description = """\
109    One layer of disk consists of a core, a top layer, and a bottom layer.
110    radius =  the radius of the disk
111    core_thick = thickness of the core
112    layer_thick = thickness of a layer
113    sld_core = the SLD of the core
114    sld_layer = the SLD of the layers
115    n_stacking = the number of the disks
116    sigma_d =  Gaussian STD of d-spacing
117    sld_solvent = the SLD of the solvent
118    """
119category = "shape:cylinder"
120
121# pylint: disable=bad-whitespace, line-too-long
122#   ["name", "units", default, [lower, upper], "type","description"],
123parameters = [
124    ["core_thick",  "Ang",        10.0, [0, inf],    "volume",      "Thickness of the core disk"],
125    ["layer_thick", "Ang",        10.0, [0, inf],    "volume",      "Thickness of layer each side of core"],
126    ["radius",      "Ang",        15.0, [0, inf],    "volume",      "Radius of the stacked disk"],
127    ["n_stacking",  "",            1.0, [0, inf],    "volume",      "Number of stacked layer/core/layer disks"],
128    ["sigma_d",     "Ang",         0,   [0, inf],    "",            "GSD of disks sigma_d"],
129    ["sld_core",    "1e-6/Ang^2",  4,   [-inf, inf], "",            "Core scattering length density"],
130    ["sld_layer",   "1e-6/Ang^2",  0.0, [-inf, inf], "",            "Layer scattering length density"],
131    ["sld_solvent", "1e-6/Ang^2",  5.0, [-inf, inf], "",            "Solvent scattering length density"],
132    ["theta",       "degrees",     0,   [-inf, inf], "orientation", "Orientation of the stacked disk axis w/respect incoming beam"],
133    ["phi",         "degrees",     0,   [-inf, inf], "orientation", "Orientation of the stacked disk in the plane of the detector"],
134    ]
135# pylint: enable=bad-whitespace, line-too-long
136
137source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "stacked_disks.c"]
138
139demo = dict(background=0.001,
140            scale=0.01,
141            core_thick=10.0,
142            layer_thick=10.0,
143            radius=15.0,
144            n_stacking=1,
145            sigma_d=0,
146            sld_core=4,
147            sld_layer=0.0,
148            sld_solvent=5.0,
149            theta=0,
150            phi=0)
151
152
153oldname = 'StackedDisksModel'
154
155oldpars = dict(sld_core='core_sld',sld_layer='layer_sld',sld_solvent='solvent_sld',n_stacking='n_stacking',theta='axis_theta',
156               phi='axis_phi')
157
158tests = [
159    # Accuracy tests based on content in test/utest_extra_models.py
160    [{'core_thick': 10.0,
161      'layer_thick': 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    [{'core_thick': 10.0,
175      'layer_thick': 15.0,
176      'radius': 3000.0,
177      'n_stacking': 1.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, 90.0], [5075.12, 0.001]],
187
188    [{'core_thick': 10.0,
189      'layer_thick': 15.0,
190      'radius': 3000.0,
191      'n_stacking': 1.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.4, 0.5]), [0.00105074, 0.00121761]],
201
202    [{'core_thick': 10.0,
203      'layer_thick': 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     }, ([1.3, 1.57]), [0.0010039, 0.0010038]],
215    ]
216# 21Mar2016   RKH notes that unit tests all have n_stacking=1, ought to test other values
217
Note: See TracBrowser for help on using the repository browser.