source: sasmodels/sasmodels/models/core_shell_ellipsoid.py @ 81dd619

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 81dd619 was 81dd619, checked in by piotr, 8 years ago

Converted CoreShellEllipsoid?

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