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

Last change on this file since d57b06c was d57b06c, checked in by Paul Kienzle <pkienzle@…>, 5 years ago

Merge remote-tracking branch 'origin/master' into ticket-1263-source-link

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