source: sasmodels/sasmodels/models/core_shell_ellipsoid.py @ 5111921

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

replace gifs so that we can build pdf

  • Property mode set to 100644
File size: 5.7 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 cylinder.
4
5.. math::
6
7    P(q) = scale * \left<f^2\right>/V + background
8
9where the volume $V = (4/3)\pi(r_{maj}r_{min}^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_{min},r_{max},\alpha)\right|^2d\alpha + background
25
26    \left|F(q,r_{min},r_{max},\alpha)\right|=V\Delta \rho \cdot (3j_1(u)/u)
27
28    u = q\left[ r_{maj}^2\alpha ^2 + r_{min}^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
46.. note::
47    The 2nd virial coefficient of the solid ellipsoid is calculated based on
48    the *radius_a* (= *polar_shell)* and *radius_b (= equat_shell)* values,
49    and used as the effective radius for *S(Q)* when $P(Q) * S(Q)$ is applied.
50
51.. figure:: img/core_shell_ellipsoid_angle_projection.jpg
52
53    The angles for oriented core_shell_ellipsoid.
54
55Our model uses the form factor calculations implemented in a c-library provided
56by the NIST Center for Neutron Research (Kline, 2006).
57
58References
59----------
60
61M Kotlarchyk, S H Chen, *J. Chem. Phys.*, 79 (1983) 2461
62
63S J Berr, *Phys. Chem.*, 91 (1987) 4760
64
65"""
66
67from numpy import inf, sin, cos, pi
68
69name = "core_shell_ellipsoid"
70title = "Form factor for an spheroid ellipsoid particle with a core shell structure."
71description = """
72    [SpheroidCoreShellModel] Calculates the form factor for an spheroid
73    ellipsoid particle with a core_shell structure.
74    The form factor is averaged over all possible
75    orientations of the ellipsoid such that P(q)
76    = scale*<f^2>/Vol + bkg, where f is the
77    single particle scattering amplitude.
78    [Parameters]:
79    equat_core = equatorial radius of core,
80    polar_core = polar radius of core,
81    equat_shell = equatorial radius of shell,
82    polar_shell = polar radius (revolution axis) of shell,
83    core_sld = SLD_core
84    shell_sld = SLD_shell
85    solvent_sld = SLD_solvent
86    background = Incoherent bkg
87    scale =scale
88    Note:It is the users' responsibility to ensure
89    that shell radii are larger than core radii.
90    oblate: polar radius < equatorial radius
91    prolate :  polar radius > equatorial radius
92    """
93category = "shape:ellipsoid"
94
95single = False  # TODO: maybe using sph_j1c inside gfn would help?
96# pylint: disable=bad-whitespace, line-too-long
97#             ["name", "units", default, [lower, upper], "type", "description"],
98parameters = [
99    ["equat_core",  "Ang",      200,   [0, inf],    "volume",      "Equatorial radius of core"],
100    ["polar_core",  "Ang",       10,   [0, inf],    "volume",      "Polar radius of core"],
101    ["equat_shell", "Ang",      250,   [0, inf],    "volume",      "Equatorial radius of shell"],
102    ["polar_shell", "Ang",       30,   [0, inf],    "volume",      "Polar radius of shell"],
103    ["core_sld",    "1e-6/Ang^2", 2,   [-inf, inf], "",            "Core scattering length density"],
104    ["shell_sld",   "1e-6/Ang^2", 1,   [-inf, inf], "",            "Shell scattering length density"],
105    ["solvent_sld", "1e-6/Ang^2", 6.3, [-inf, inf], "",            "Solvent scattering length density"],
106    ["theta",       "degrees",    0,   [-inf, inf], "orientation", "Oblate orientation wrt incoming beam"],
107    ["phi",         "degrees",    0,   [-inf, inf], "orientation", "Oblate orientation in the plane of the detector"],
108    ]
109# pylint: enable=bad-whitespace, line-too-long
110
111source = ["lib/sph_j1c.c", "lib/gfn.c", "lib/gauss76.c", "core_shell_ellipsoid.c"]
112
113demo = dict(scale=1, background=0.001,
114            equat_core=200.0,
115            polar_core=10.0,
116            equat_shell=250.0,
117            polar_shell=30.0,
118            core_sld=2.0,
119            shell_sld=1.0,
120            solvent_sld=6.3,
121            theta=0,
122            phi=0)
123
124oldname = 'CoreShellEllipsoidModel'
125
126oldpars = dict(core_sld='sld_core',
127               shell_sld='sld_shell',
128               solvent_sld='sld_solvent',
129               theta='axis_theta',
130               phi='axis_phi')
131
132q = 0.1
133phi = pi/6
134qx = q*cos(phi)
135qy = q*sin(phi)
136
137tests = [
138    # Accuracy tests based on content in test/utest_other_models.py
139    [{'equat_core': 200.0,
140      'polar_core': 20.0,
141      'equat_shell': 250.0,
142      'polar_shell': 30.0,
143      'core_sld': 2.0,
144      'shell_sld': 1.0,
145      'solvent_sld': 6.3,
146      'background': 0.001,
147      'scale': 1.0,
148     }, 1.0, 0.00189402],
149
150    # Additional tests with larger range of parameters
151    [{'background': 0.01}, 0.1, 8.86741],
152
153    [{'equat_core': 20.0,
154      'polar_core': 200.0,
155      'equat_shell': 54.0,
156      'polar_shell': 3.0,
157      'core_sld': 20.0,
158      'shell_sld': 10.0,
159      'solvent_sld': 6.0,
160      'background': 0.0,
161      'scale': 1.0,
162     }, 0.01, 26150.4],
163
164    [{'background': 0.001}, (0.4, 0.5), 0.00170471],
165
166    [{'equat_core': 20.0,
167      'polar_core': 200.0,
168      'equat_shell': 54.0,
169      'polar_shell': 3.0,
170      'core_sld': 20.0,
171      'shell_sld': 10.0,
172      'solvent_sld': 6.0,
173      'background': 0.01,
174      'scale': 0.01,
175     }, (qx, qy), 0.105764],
176    ]
Note: See TracBrowser for help on using the repository browser.