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

core_shell_microgelscostrafo411magnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since ef5a314 was ef5a314, checked in by dirk, 7 years ago

After rewriting angles to spherical coordinates unit test fails

  • Property mode set to 100644
File size: 7.6 KB
Line 
1r"""
2Definition
3----------
4
5Parameters for this model are the core axial ratio X and a shell thickness,
6which are more often what we would like to determine and makes the model
7better behaved, particularly when polydispersity is applied than the four
8independent radii used in the original parameterization of this model.
9
10
11.. figure:: img/core_shell_ellipsoid_geometry.png
12
13The geometric parameters of this model are shown in the diagram above, which
14shows (a) a cut through at the circular equator and (b) a cross section through
15the poles, of a prolate ellipsoid.
16
17When *X_core < 1* the core is oblate; when *X_core > 1* it is prolate.
18*X_core = 1* is a spherical core.
19
20For a fixed shell thickness *XpolarShell = 1*, to scale the shell thickness
21pro-rata with the radius set or constrain *XpolarShell = X_core*.
22
23When including an $S(q)$, the radius in $S(q)$ is calculated to be that of
24a sphere with the same 2nd virial coefficient of the outer surface of the
25ellipsoid. This may have some undesirable effects if the aspect ratio of the
26ellipsoid is large (ie, if $X << 1$ or $X >> 1$ ), when the $S(q)$
27- which assumes spheres - will not in any case be valid.  Generating a
28custom product model will enable separate effective volume fraction and effective
29radius in the $S(q)$.
30
31If SAS data are in absolute units, and the SLDs are correct, then scale should
32be the total volume fraction of the "outer particle". When $S(q)$ is introduced
33this moves to the $S(q)$ volume fraction, and scale should then be 1.0,
34or contain some other units conversion factor (for example, if you have SAXS data).
35
36The calculation of intensity follows that for the solid ellipsoid, but with separate
37terms for the core-shell and shell-solvent boundaries.
38
39.. math::
40
41    P(q,\alpha) = \frac{\text{scale}}{V} F^2(q,\alpha) + \text{background}
42
43where
44
45.. math::
46    \begin{align}   
47    F(q,\alpha) = &f(q,radius\_equat\_core,radius\_equat\_core.x\_core,\alpha) \\
48    &+ f(q,radius\_equat\_core + thick\_shell,radius\_equat\_core.x\_core + thick\_shell.x\_polar\_shell,\alpha)
49    \end{align}
50
51where
52 
53.. math::
54
55    f(q,R_e,R_p,\alpha) = \frac{3 \Delta \rho V (\sin[qr(R_p,R_e,\alpha)]
56                - \cos[qr(R_p,R_e,\alpha)])}
57                {[qr(R_p,R_e,\alpha)]^3}
58
59and
60
61.. math::
62
63    r(R_e,R_p,\alpha) = \left[ R_e^2 \sin^2 \alpha
64        + R_p^2 \cos^2 \alpha \right]^{1/2}
65
66
67$\alpha$ is the angle between the axis of the ellipsoid and $\vec q$,
68$V = (4/3)\pi R_pR_e^2$ is the volume of the ellipsoid , $R_p$ is the polar radius along the
69rotational axis of the ellipsoid, $R_e$ is the equatorial radius perpendicular
70to the rotational axis of the ellipsoid and $\Delta \rho$ (contrast) is the
71scattering length density difference, either $(sld\_core - sld\_shell)$ or $(sld\_shell - sld\_solvent)$.
72
73For randomly oriented particles:
74
75.. math::
76
77   F^2(q)=\int_{0}^{\pi/2}{F^2(q,\alpha)\sin(\alpha)d\alpha}
78
79
80References
81----------
82see for example:
83Kotlarchyk, M.; Chen, S.-H. J. Chem. Phys., 1983, 79, 2461.
84Berr, S.  J. Phys. Chem., 1987, 91, 4760.
85
86Authorship and Verification
87----------------------------
88
89* **Author:** NIST IGOR/DANSE **Date:** pre 2010
90* **Last Modified by:** Richard Heenan (reparametrised model) **Date:** 2015
91* **Last Reviewed by:** Richard Heenan **Date:** October 6, 2016
92
93"""
94
95from numpy import inf, sin, cos, pi
96
97name = "core_shell_ellipsoid"
98title = "Form factor for an spheroid ellipsoid particle with a core shell structure."
99description = """
100        [core_shell_ellipsoid] Calculates the form factor for an spheroid
101        ellipsoid particle with a core_shell structure.
102        The form factor is averaged over all possible
103        orientations of the ellipsoid such that P(q)
104        = scale*<f^2>/Vol + bkg, where f is the
105        single particle scattering amplitude.
106        [Parameters]:
107        radius_equat_core = equatorial radius of core,
108        x_core = ratio of core polar/equatorial radii,
109        thick_shell = equatorial radius of outer surface,
110        x_polar_shell = ratio of polar shell thickness to equatorial shell thickness,
111        sld_core = SLD_core
112        sld_shell = SLD_shell
113        sld_solvent = SLD_solvent
114        background = Incoherent bkg
115        scale =scale
116        Note:It is the users' responsibility to ensure
117        that shell radii are larger than core radii.
118        oblate: polar radius < equatorial radius
119        prolate :  polar radius > equatorial radius - this new model will make this easier
120        and polydispersity integrals more logical (as previously the shell could disappear).
121    """
122category = "shape:ellipsoid"
123
124# pylint: disable=bad-whitespace, line-too-long
125#             ["name", "units", default, [lower, upper], "type", "description"],
126parameters = [
127    ["radius_equat_core","Ang",     20,   [0, inf],    "volume",      "Equatorial radius of core"],
128    ["x_core",        "None",       3,   [0, inf],    "volume",      "axial ratio of core, X = r_polar/r_equatorial"],
129    ["thick_shell",   "Ang",       30,   [0, inf],    "volume",      "thickness of shell at equator"],
130    ["x_polar_shell", "",           1,   [0, inf],    "volume",      "ratio of thickness of shell at pole to that at equator"],
131    ["sld_core",      "1e-6/Ang^2", 2,   [-inf, inf], "sld",         "Core scattering length density"],
132    ["sld_shell",     "1e-6/Ang^2", 1,   [-inf, inf], "sld",         "Shell scattering length density"],
133    ["sld_solvent",   "1e-6/Ang^2", 6.3, [-inf, inf], "sld",         "Solvent scattering length density"],
134    ["theta",         "degrees",    0,   [-inf, inf], "orientation", "Oblate orientation wrt incoming beam"],
135    ["phi",           "degrees",    0,   [-inf, inf], "orientation", "Oblate orientation in the plane of the detector"],
136    ]
137# pylint: enable=bad-whitespace, line-too-long
138
139source = ["lib/sph_j1c.c", "lib/gfn.c", "lib/gauss76.c",
140          "core_shell_ellipsoid.c"]
141
142def ER(radius_equat_core, x_core, thick_shell, x_polar_shell):
143    """
144        Returns the effective radius used in the S*P calculation
145    """
146    from .ellipsoid import ER as ellipsoid_ER
147    polar_outer = radius_equat_core*x_core + thick_shell*x_polar_shell
148    equat_outer = radius_equat_core + thick_shell
149    return ellipsoid_ER(polar_outer, equat_outer)
150
151
152demo = dict(scale=0.05, background=0.001,
153            radius_equat_core=20.0,
154            x_core=3.0,
155            thick_shell=30.0,
156            x_polar_shell=1.0,
157            sld_core=2.0,
158            sld_shell=1.0,
159            sld_solvent=6.3,
160            theta=0,
161            phi=0)
162
163q = 0.1
164phi = pi/6
165qx = q*cos(phi)
166qy = q*sin(phi)
167# After redefinition of angles find new reasonable values for unit test
168#tests = [
169#    # Accuracy tests based on content in test/utest_coreshellellipsoidXTmodel.py
170#    [{'radius_equat_core': 200.0,
171#      'x_core': 0.1,
172#      'thick_shell': 50.0,
173#      'x_polar_shell': 0.2,
174#      'sld_core': 2.0,
175#      'sld_shell': 1.0,
176#      'sld_solvent': 6.3,
177#      'background': 0.001,
178#      'scale': 1.0,
179#     }, 1.0, 0.00189402],
180
181    # Additional tests with larger range of parameters
182#    [{'background': 0.01}, 0.1, 11.6915],
183
184#    [{'radius_equat_core': 20.0,
185#      'x_core': 200.0,
186#      'thick_shell': 54.0,
187#      'x_polar_shell': 3.0,
188#      'sld_core': 20.0,
189#      'sld_shell': 10.0,
190#      'sld_solvent': 6.0,
191#      'background': 0.0,
192#      'scale': 1.0,
193#     }, 0.01, 8688.53],
194
195#   [{'background': 0.001}, (0.4, 0.5), 0.00690673],
196
197#   [{'radius_equat_core': 20.0,
198#      'x_core': 200.0,
199#      'thick_shell': 54.0,
200#      'x_polar_shell': 3.0,
201#      'sld_core': 20.0,
202#      'sld_shell': 10.0,
203#      'sld_solvent': 6.0,
204#      'background': 0.01,
205#      'scale': 0.01,
206#     }, (qx, qy), 0.0100002],
207#    ]
Note: See TracBrowser for help on using the repository browser.