source: sasmodels/sasmodels/models/core_shell_ellipsoid_xt.py @ ec45c4f

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

remove oldname/oldpars from new models

  • Property mode set to 100644
File size: 6.1 KB
Line 
1r"""
2An alternative version of $P(q)$ for the core_shell_ellipsoid
3having as parameters the core axial ratio X and a shell thickness,
4which are more often what we would like to determine.
5
6This model is also better behaved when polydispersity is applied than the four
7independent radii in core_shell_ellipsoid model.
8
9Definition
10----------
11
12.. figure:: img/core_shell_ellipsoid_geometry.png
13
14The geometric parameters of this model are
15
16*equat_core =* equatorial core radius *= R_minor_core*
17
18*X_core = polar_core / equat_core = Rmajor_core / Rminor_core*
19
20*T_shell = equat_outer - equat_core = Rminor_outer - Rminor_core*
21
22*XpolarShell = Tpolar_shell / T_shell = (Rmajor_outer - Rmajor_core)/
23(Rminor_outer - Rminor_core)*
24
25In terms of the original radii
26
27*polar_core = equat_core * X_core*
28
29*equat_shell = equat_core + T_shell*
30
31*polar_shell = equat_core * X_core + T_shell * XpolarShell*
32
33(where we note that "shell" perhaps confusingly, relates to the outer radius)
34When *X_core < 1* the core is oblate; when *X_core > 1* it is prolate.
35*X_core = 1* is a spherical core.
36
37For a fixed shell thickness *XpolarShell = 1*, to scale the shell thickness
38pro-rata with the radius *XpolarShell = X_core*.
39
40When including an $S(q)$, the radius in $S(q)$ is calculated to be that of
41a sphere with the same 2nd virial coefficient of the outer surface of the
42ellipsoid. This may have some undesirable effects if the aspect ratio of the
43ellipsoid is large (ie, if $X << 1$ or $X >> 1$ ), when the $S(q)$
44- which assumes spheres - will not in any case be valid.
45
46If SAS data are in absolute units, and the SLDs are correct, then scale should
47be the total volume fraction of the "outer particle". When $S(q)$ is introduced
48this moves to the $S(q)$ volume fraction, and scale should then be 1.0,
49or contain some other units conversion factor (for example, if you have SAXS data).
50
51References
52----------
53
54R K Heenan, 2015, reparametrised the core_shell_ellipsoid model
55
56"""
57
58from numpy import inf, sin, cos, pi
59
60name = "core_shell_ellipsoid_xt"
61title = "Form factor for an spheroid ellipsoid particle with a core shell structure."
62description = """
63        [core_shell_ellipsoid_xt] Calculates the form factor for an spheroid
64        ellipsoid particle with a core_shell structure.
65        The form factor is averaged over all possible
66        orientations of the ellipsoid such that P(q)
67        = scale*<f^2>/Vol + bkg, where f is the
68        single particle scattering amplitude.
69        [Parameters]:
70        equat_core = equatorial radius of core,
71        x_core = ratio of core polar/equatorial radii,
72        t_shell = equatorial radius of outer surface,
73        x_polar_shell = ratio of polar shell thickness to equatorial shell thickness,
74        sld_core = SLD_core
75        sld_shell = SLD_shell
76        sld_solvent = SLD_solvent
77        background = Incoherent bkg
78        scale =scale
79        Note:It is the users' responsibility to ensure
80        that shell radii are larger than core radii.
81        oblate: polar radius < equatorial radius
82        prolate :  polar radius > equatorial radius - this new model will make this easier
83        and polydispersity integrals more logical (as previously the shell could disappear).
84    """
85category = "shape:ellipsoid"
86
87# pylint: disable=bad-whitespace, line-too-long
88#             ["name", "units", default, [lower, upper], "type", "description"],
89parameters = [
90    ["equat_core",    "Ang",       20,   [0, inf],    "volume",      "Equatorial radius of core"],
91    ["x_core",        "None",       3,   [0, inf],    "volume",      "axial ratio of core, X = r_polar/r_equatorial"],
92    ["t_shell",       "Ang",       30,   [0, inf],    "volume",      "thickness of shell at equator"],
93    ["x_polar_shell", "",           1,   [0, inf],    "volume",      "ratio of thickness of shell at pole to that at equator"],
94    ["sld_core",      "1e-6/Ang^2", 2,   [-inf, inf], "",            "Core scattering length density"],
95    ["sld_shell",     "1e-6/Ang^2", 1,   [-inf, inf], "",            "Shell scattering length density"],
96    ["sld_solvent",   "1e-6/Ang^2", 6.3, [-inf, inf], "",            "Solvent scattering length density"],
97    ["theta",         "degrees",    0,   [-inf, inf], "orientation", "Oblate orientation wrt incoming beam"],
98    ["phi",           "degrees",    0,   [-inf, inf], "orientation", "Oblate orientation in the plane of the detector"],
99    ]
100# pylint: enable=bad-whitespace, line-too-long
101
102source = ["lib/sph_j1c.c", "lib/gfn.c", "lib/gauss76.c",
103          "core_shell_ellipsoid_xt.c"]
104
105def ER(equat_core, x_core, t_shell, x_polar_shell):
106    """
107        Returns the effective radius used in the S*P calculation
108    """
109    from .ellipsoid import ER as ellipsoid_ER
110    polar_outer = equat_core*x_core + t_shell*x_polar_shell
111    equat_outer = equat_core + t_shell
112    return ellipsoid_ER(polar_outer, equat_outer)
113
114
115demo = dict(scale=0.05, background=0.001,
116            equat_core=20.0,
117            x_core=3.0,
118            t_shell=30.0,
119            x_polar_shell=1.0,
120            sld_core=2.0,
121            sld_shell=1.0,
122            sld_solvent=6.3,
123            theta=0,
124            phi=0)
125
126q = 0.1
127phi = pi/6
128qx = q*cos(phi)
129qy = q*sin(phi)
130
131tests = [
132    # Accuracy tests based on content in test/utest_coreshellellipsoidXTmodel.py
133    [{'equat_core': 200.0,
134      'x_core': 0.1,
135      't_shell': 50.0,
136      'x_polar_shell': 0.2,
137      'sld_core': 2.0,
138      'sld_shell': 1.0,
139      'sld_solvent': 6.3,
140      'background': 0.001,
141      'scale': 1.0,
142     }, 1.0, 0.00189402],
143
144    # Additional tests with larger range of parameters
145    [{'background': 0.01}, 0.1, 11.6915],
146
147    [{'equat_core': 20.0,
148      'x_core': 200.0,
149      't_shell': 54.0,
150      'x_polar_shell': 3.0,
151      'sld_core': 20.0,
152      'sld_shell': 10.0,
153      'sld_solvent': 6.0,
154      'background': 0.0,
155      'scale': 1.0,
156     }, 0.01, 8688.53],
157
158    [{'background': 0.001}, (0.4, 0.5), 0.00690673],
159
160    [{'equat_core': 20.0,
161      'x_core': 200.0,
162      't_shell': 54.0,
163      'x_polar_shell': 3.0,
164      'sld_core': 20.0,
165      'sld_shell': 10.0,
166      'sld_solvent': 6.0,
167      'background': 0.01,
168      'scale': 0.01,
169     }, (qx, qy), 0.0100002],
170    ]
Note: See TracBrowser for help on using the repository browser.