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

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since b99734a was b99734a, checked in by butler, 7 years ago

fix name of c file called by new core_shell_ellipsoid and edited the
documentation to remove comparison to old core_shell_ellipsoid.

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