source: sasmodels/sasmodels/models/core_shell_ellipsoid.py @ 7f1ee79

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

check models labelled as single=False

  • Property mode set to 100644
File size: 6.2 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) = scale * \left<f^2\right>/V + background
8
9where the volume $V = (4/3)\pi(R_{major\_outer}R_{minor\_outer}^2)$ and the averaging $< >$ is
10applied 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{scale}{V}\int_0^1
24        \left|F(q,r_{minor\_core},r_{major\_core},\alpha) + F(q,r_{major\_outer},r_{major\_outer},\alpha)\right|^2d\alpha + background
25
26    \left|F(q,r_{minor},r_{major},\alpha)\right|=(4\pi/3)r_{major}r_{minor}^2 \Delta \rho \cdot (3j_1(u)/u)
27
28    u = q\left[ r_{major}^2\alpha ^2 + r_{minor}^2(1-\alpha ^2)\right]^{1/2}
29
30where
31
32.. math::
33
34    j_1(u)=(\sin x - x \cos x)/x^2
35
36To provide easy access to the orientation of the core-shell ellipsoid,
37we define the axis of the solid ellipsoid using two angles $\theta$ and $\phi$.
38These angles are defined as for
39:ref:`cylinder orientation <cylinder-angle-definition>`.
40The contrast is defined as SLD(core) - SLD(shell) and SLD(shell) - SLD(solvent).
41
42In the parameters, *equat_core* = equatorial core radius, *polar_core* =
43polar core radius, *equat_shell* = $r_{min}$ (or equatorial outer radius),
44and *polar_shell* = $r_{maj}$ (or polar outer radius).
45
46Note:It is the users' responsibility to ensure that shell radii are larger than
47the core radii, especially if both are polydisperse, in which case the
48core_shell_ellipsoid_xt model may be much better.
49
50
51.. note::
52    The 2nd virial coefficient of the solid ellipsoid is calculated based on
53    the *radius_a* (= *polar_shell)* and *radius_b (= equat_shell)* values,
54    and used as the effective radius for *S(Q)* when $P(Q) * S(Q)$ is applied.
55
56.. figure:: img/core_shell_ellipsoid_angle_projection.jpg
57
58    The angles for oriented core_shell_ellipsoid.
59
60Our model uses the form factor calculations implemented in a c-library provided
61by the NIST Center for Neutron Research (Kline, 2006).
62
63References
64----------
65
66M Kotlarchyk, S H Chen, *J. Chem. Phys.*, 79 (1983) 2461
67
68S J Berr, *Phys. Chem.*, 91 (1987) 4760
69
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, Rminor_core "],
105    ["polar_core",  "Ang",       10,   [0, inf],    "volume",      "Polar radius of core, Rmajor_core"],
106    ["equat_shell", "Ang",      250,   [0, inf],    "volume",      "Equatorial radius of shell, Rminor_outer "],
107    ["polar_shell", "Ang",       30,   [0, inf],    "volume",      "Polar radius of shell, Rmajor_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    import numpy as np
123    from .ellipsoid import ER as ellipsoid_ER
124    return ellipsoid_ER(polar_shell, equat_shell)
125
126
127demo = dict(scale=1, background=0.001,
128            equat_core=200.0,
129            polar_core=10.0,
130            equat_shell=250.0,
131            polar_shell=30.0,
132            sld_core=2.0,
133            sld_shell=1.0,
134            sld_solvent=6.3,
135            theta=0,
136            phi=0)
137
138q = 0.1
139phi = pi/6
140qx = q*cos(phi)
141qy = q*sin(phi)
142
143tests = [
144    # Accuracy tests based on content in test/utest_other_models.py
145    [{'equat_core': 200.0,
146      'polar_core': 20.0,
147      'equat_shell': 250.0,
148      'polar_shell': 30.0,
149      'sld_core': 2.0,
150      'sld_shell': 1.0,
151      'sld_solvent': 6.3,
152      'background': 0.001,
153      'scale': 1.0,
154     }, 1.0, 0.00189402],
155
156    # Additional tests with larger range of parameters
157    [{'background': 0.01}, 0.1, 8.86741],
158
159    [{'equat_core': 20.0,
160      'polar_core': 200.0,
161      'equat_shell': 54.0,
162      'polar_shell': 3.0,
163      'sld_core': 20.0,
164      'sld_shell': 10.0,
165      'sld_solvent': 6.0,
166      'background': 0.0,
167      'scale': 1.0,
168     }, 0.01, 26150.4],
169
170    [{'background': 0.001}, (0.4, 0.5), 0.00170471],
171
172    [{'equat_core': 20.0,
173      'polar_core': 200.0,
174      'equat_shell': 54.0,
175      'polar_shell': 3.0,
176      'sld_core': 20.0,
177      'sld_shell': 10.0,
178      'sld_solvent': 6.0,
179      'background': 0.01,
180      'scale': 0.01,
181     }, (qx, qy), 0.105764],
182    ]
Note: See TracBrowser for help on using the repository browser.