source: sasmodels/sasmodels/models/core_shell_ellipsoid.py @ 40a87fa

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 40a87fa was 40a87fa, checked in by Paul Kienzle <pkienzle@…>, 8 years ago

lint and latex cleanup

  • Property mode set to 100644
File size: 6.1 KB
Line 
1r"""
2This model provides the form factor, $P(q)$, for a core shell ellipsoid (below)
3where the form factor is normalized by the volume of the outer [CHECK].
4
5.. math::
6
7    P(q) = \text{scale} * \left<f^2\right>/V + \text{background}
8
9where the volume $V = (4/3)\pi(r_\text{major outer} r_\text{minor outer}^2)$
10and the averaging $< >$ is applied over all orientations for 1D.
11
12.. figure:: img/core_shell_ellipsoid_geometry.png
13
14    The returned value is in units of |cm^-1|, on absolute scale.
15
16Definition
17----------
18
19The form factor calculated is
20
21.. math::
22
23    P(q) &= \frac{\text{scale}}{V}\int_0^1
24        \left|F(q,r_\text{minor core},r_\text{major core},\alpha)
25        + F(q,r_\text{minor outer},r_\text{major outer},\alpha)\right|^2
26        d\alpha
27        + \text{background}
28
29    \left|F(q,r_\text{minor},r_\text{major},\alpha)\right|
30        &=(4\pi/3)r_\text{major}r_\text{minor}^2 \Delta \rho \cdot (3j_1(u)/u)
31
32    u &= q\left[ r_\text{major}^2\alpha ^2
33                  + r_\text{minor}^2(1-\alpha ^2)\right]^{1/2}
34
35where
36
37.. math::
38
39    j_1(u)=(\sin x - x \cos x)/x^2
40
41To provide easy access to the orientation of the core-shell ellipsoid,
42we define the axis of the solid ellipsoid using two angles $\theta$ and $\phi$.
43These angles are defined as for
44:ref:`cylinder orientation <cylinder-angle-definition>`.
45The contrast is defined as SLD(core) - SLD(shell) and SLD(shell) - SLD(solvent).
46
47Note: It is the users' responsibility to ensure that shell radii are larger than
48the core radii, especially if both are polydisperse, in which case the
49core_shell_ellipsoid_xt model may be much better.
50
51
52.. note::
53    The 2nd virial coefficient of the solid ellipsoid is calculated based on
54    the *radius_a* (= *polar_shell)* and *radius_b (= equat_shell)* values,
55    and used as the effective radius for *S(Q)* when $P(Q) * S(Q)$ is applied.
56
57.. figure:: img/core_shell_ellipsoid_angle_projection.jpg
58
59    The angles for oriented core_shell_ellipsoid.
60
61Our model uses the form factor calculations implemented in a c-library provided
62by the NIST Center for Neutron Research (Kline, 2006).
63
64References
65----------
66
67M Kotlarchyk, S H Chen, *J. Chem. Phys.*, 79 (1983) 2461
68
69S J Berr, *Phys. Chem.*, 91 (1987) 4760
70"""
71
72from numpy import inf, sin, cos, pi
73
74name = "core_shell_ellipsoid"
75title = "Form factor for an spheroid ellipsoid particle with a core shell structure."
76description = """
77    [SpheroidCoreShellModel] Calculates the form factor for an spheroid
78    ellipsoid particle with a core_shell structure.
79    The form factor is averaged over all possible
80    orientations of the ellipsoid such that P(q)
81    = scale*<f^2>/Vol + bkg, where f is the
82    single particle scattering amplitude.
83    [Parameters]:
84    equat_core = equatorial radius of core, Rminor_core,
85    polar_core = polar radius of core, Rmajor_core,
86    equat_shell = equatorial radius of shell, Rminor_outer,
87    polar_shell = polar radius of shell, Rmajor_outer,
88    sld_core = scattering length density of core,
89    sld_shell = scattering length density of shell,
90    sld_solvent = scattering length density of solvent,
91    background = Incoherent bkg
92    scale =scale
93    Note:It is the users' responsibility to ensure
94    that shell radii are larger than core radii,
95    especially if both are polydisperse.
96    oblate: polar radius < equatorial radius
97    prolate :  polar radius > equatorial radius
98    """
99category = "shape:ellipsoid"
100
101# pylint: disable=bad-whitespace, line-too-long
102#   ["name", "units", default, [lower, upper], "type", "description"],
103parameters = [
104    ["equat_core",  "Ang",      200,   [0, inf],    "volume",      "Equatorial radius of core, r minor core"],
105    ["polar_core",  "Ang",       10,   [0, inf],    "volume",      "Polar radius of core, r major core"],
106    ["equat_shell", "Ang",      250,   [0, inf],    "volume",      "Equatorial radius of shell, r minor outer"],
107    ["polar_shell", "Ang",       30,   [0, inf],    "volume",      "Polar radius of shell, r major outer"],
108    ["sld_core",    "1e-6/Ang^2", 2,   [-inf, inf], "sld",         "Core scattering length density"],
109    ["sld_shell",   "1e-6/Ang^2", 1,   [-inf, inf], "sld",         "Shell scattering length density"],
110    ["sld_solvent", "1e-6/Ang^2", 6.3, [-inf, inf], "sld",         "Solvent scattering length density"],
111    ["theta",       "degrees",    0,   [-inf, inf], "orientation", "Oblate orientation wrt incoming beam"],
112    ["phi",         "degrees",    0,   [-inf, inf], "orientation", "Oblate orientation in the plane of the detector"],
113    ]
114# pylint: enable=bad-whitespace, line-too-long
115
116source = ["lib/sph_j1c.c", "lib/gfn.c", "lib/gauss76.c", "core_shell_ellipsoid.c"]
117
118def ER(equat_core, polar_core, equat_shell, polar_shell):
119    """
120        Returns the effective radius used in the S*P calculation
121    """
122    from .ellipsoid import ER as ellipsoid_ER
123    return ellipsoid_ER(polar_shell, equat_shell)
124
125
126demo = dict(scale=1, background=0.001,
127            equat_core=200.0,
128            polar_core=10.0,
129            equat_shell=250.0,
130            polar_shell=30.0,
131            sld_core=2.0,
132            sld_shell=1.0,
133            sld_solvent=6.3,
134            theta=0,
135            phi=0)
136
137q = 0.1
138phi = pi/6
139qx = q*cos(phi)
140qy = q*sin(phi)
141
142tests = [
143    # Accuracy tests based on content in test/utest_other_models.py
144    [{'equat_core': 200.0,
145      'polar_core': 20.0,
146      'equat_shell': 250.0,
147      'polar_shell': 30.0,
148      'sld_core': 2.0,
149      'sld_shell': 1.0,
150      'sld_solvent': 6.3,
151      'background': 0.001,
152      'scale': 1.0,
153     }, 1.0, 0.00189402],
154
155    # Additional tests with larger range of parameters
156    [{'background': 0.01}, 0.1, 8.86741],
157
158    [{'equat_core': 20.0,
159      'polar_core': 200.0,
160      'equat_shell': 54.0,
161      'polar_shell': 3.0,
162      'sld_core': 20.0,
163      'sld_shell': 10.0,
164      'sld_solvent': 6.0,
165      'background': 0.0,
166      'scale': 1.0,
167     }, 0.01, 26150.4],
168
169    [{'background': 0.001}, (0.4, 0.5), 0.00170471],
170
171    [{'equat_core': 20.0,
172      'polar_core': 200.0,
173      'equat_shell': 54.0,
174      'polar_shell': 3.0,
175      'sld_core': 20.0,
176      'sld_shell': 10.0,
177      'sld_solvent': 6.0,
178      'background': 0.01,
179      'scale': 0.01,
180     }, (qx, qy), 0.105764],
181    ]
Note: See TracBrowser for help on using the repository browser.