source: sasmodels/sasmodels/models/ellipsoid.py @ 4b0a294

core_shell_microgelscostrafo411magnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 4b0a294 was 4b0a294, checked in by richardh, 7 years ago

docu improvements re #890

  • Property mode set to 100644
File size: 6.5 KB
Line 
1# ellipsoid model
2# Note: model title and parameter table are inserted automatically
3r"""
4The form factor is normalized by the particle volume
5
6Definition
7----------
8
9The output of the 2D scattering intensity function for oriented ellipsoids
10is given by (Feigin, 1987)
11
12.. math::
13
14    P(q,\alpha) = \frac{\text{scale}}{V} F^2(q,\alpha) + \text{background}
15
16where
17
18.. math::
19
20    F(q,\alpha) = \Delta \rho V \frac{3(\sin qr  - qr \cos qr)}{(qr)^3}
21
22for
23
24.. math::
25
26    r = \left[ R_e^2 \sin^2 \alpha + R_p^2 \cos^2 \alpha \right]^{1/2}
27
28
29$\alpha$ is the angle between the axis of the ellipsoid and $\vec q$,
30$V = (4/3)\pi R_pR_e^2$ is the volume of the ellipsoid, $R_p$ is the polar
31radius along the rotational axis of the ellipsoid, $R_e$ is the equatorial
32radius perpendicular to the rotational axis of the ellipsoid and
33$\Delta \rho$ (contrast) is the scattering length density difference between
34the scatterer and the solvent.
35
36For randomly oriented particles use the orientational average,
37
38.. math::
39
40   \langle F^2(q) \rangle = \int_{0}^{\pi/2}{F^2(q,\alpha)\sin(\alpha)\,d\alpha}
41
42
43computed via substitution of $u=\sin(\alpha)$, $du=\cos(\alpha)\,d\alpha$ as
44
45.. math::
46
47    \langle F^2(q) \rangle = \int_0^1{F^2(q, u)\,du}
48
49with
50
51.. math::
52
53    r = R_e \left[ 1 + u^2\left(R_p^2/R_e^2 - 1\right)\right]^{1/2}
54
55To provide easy access to the orientation of the ellipsoid, we define
56the rotation axis of the ellipsoid using two angles $\theta$ and $\phi$.
57These angles are defined in the
58:ref:`cylinder orientation figure <cylinder-angle-definition>`.
59For the ellipsoid, $\theta$ is the angle between the rotational axis
60and the $z$ -axis in the $xz$ plane followed by a rotation by $\phi$
61in the $xy$ plane.
62
63NB: The 2nd virial coefficient of the solid ellipsoid is calculated based
64on the $R_p$ and $R_e$ values, and used as the effective radius for
65$S(q)$ when $P(q) \cdot S(q)$ is applied.
66
67
68The $\theta$ and $\phi$ parameters are not used for the 1D output.
69
70
71
72Validation
73----------
74
75Validation of the code was done by comparing the output of the 1D model
76to the output of the software provided by the NIST (Kline, 2006).
77
78The implementation of the intensity for fully oriented ellipsoids was
79validated by averaging the 2D output using a uniform distribution
80$p(\theta,\phi) = 1.0$ and comparing with the output of the 1D calculation.
81
82
83.. _ellipsoid-comparison-2d:
84
85.. figure:: img/ellipsoid_comparison_2d.jpg
86
87    Comparison of the intensity for uniformly distributed ellipsoids
88    calculated from our 2D model and the intensity from the NIST SANS
89    analysis software. The parameters used were: *scale* = 1.0,
90    *radius_polar* = 20 |Ang|, *radius_equatorial* = 400 |Ang|,
91    *contrast* = 3e-6 |Ang^-2|, and *background* = 0.0 |cm^-1|.
92
93The discrepancy above $q$ = 0.3 |cm^-1| is due to the way the form factors
94are calculated in the c-library provided by NIST. A numerical integration
95has to be performed to obtain $P(q)$ for randomly oriented particles.
96The NIST software performs that integration with a 76-point Gaussian
97quadrature rule, which will become imprecise at high $q$ where the amplitude
98varies quickly as a function of $q$. The SasView result shown has been
99obtained by summing over 501 equidistant points. Our result was found
100to be stable over the range of $q$ shown for a number of points higher
101than 500.
102
103Model was also tested against the triaxial ellipsoid model with equal major
104and minor equatorial radii.  It is also consistent with the cyclinder model
105with polar radius equal to length and equatorial radius equal to radius.
106
107References
108----------
109
110L A Feigin and D I Svergun.
111*Structure Analysis by Small-Angle X-Ray and Neutron Scattering*,
112Plenum Press, New York, 1987.
113
114Authorship and Verification
115----------------------------
116
117* **Author:** NIST IGOR/DANSE **Date:** pre 2010
118* **Converted to sasmodels by:** Helen Park **Date:** July 9, 2014
119* **Last Modified by:** Paul Kienzle **Date:** March 22, 2017
120"""
121
122from numpy import inf
123
124name = "ellipsoid"
125title = "Ellipsoid of revolution with uniform scattering length density."
126
127description = """\
128P(q.alpha)= scale*f(q)^2 + background, where f(q)= 3*(sld
129        - sld_solvent)*V*[sin(q*r(Rp,Re,alpha))
130        -q*r*cos(qr(Rp,Re,alpha))]
131        /[qr(Rp,Re,alpha)]^3"
132
133     r(Rp,Re,alpha)= [Re^(2)*(sin(alpha))^2
134        + Rp^(2)*(cos(alpha))^2]^(1/2)
135
136        sld: SLD of the ellipsoid
137        sld_solvent: SLD of the solvent
138        V: volume of the ellipsoid
139        Rp: polar radius of the ellipsoid
140        Re: equatorial radius of the ellipsoid
141"""
142category = "shape:ellipsoid"
143
144#             ["name", "units", default, [lower, upper], "type","description"],
145parameters = [["sld", "1e-6/Ang^2", 4, [-inf, inf], "sld",
146               "Ellipsoid scattering length density"],
147              ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld",
148               "Solvent scattering length density"],
149              ["radius_polar", "Ang", 20, [0, inf], "volume",
150               "Polar radius"],
151              ["radius_equatorial", "Ang", 400, [0, inf], "volume",
152               "Equatorial radius"],
153              ["theta", "degrees", 60, [-inf, inf], "orientation",
154               "In plane angle"],
155              ["phi", "degrees", 60, [-inf, inf], "orientation",
156               "Out of plane angle"],
157             ]
158
159source = ["lib/sas_3j1x_x.c", "lib/gauss76.c", "ellipsoid.c"]
160
161def ER(radius_polar, radius_equatorial):
162    import numpy as np
163# see equation (26) in A.Isihara, J.Chem.Phys. 18(1950)1446-1449
164    ee = np.empty_like(radius_polar)
165    idx = radius_polar > radius_equatorial
166    ee[idx] = (radius_polar[idx] ** 2 - radius_equatorial[idx] ** 2) / radius_polar[idx] ** 2
167    idx = radius_polar < radius_equatorial
168    ee[idx] = (radius_equatorial[idx] ** 2 - radius_polar[idx] ** 2) / radius_equatorial[idx] ** 2
169    idx = radius_polar == radius_equatorial
170    ee[idx] = 2 * radius_polar[idx]
171    valid = (radius_polar * radius_equatorial != 0)
172    bd = 1.0 - ee[valid]
173    e1 = np.sqrt(ee[valid])
174    b1 = 1.0 + np.arcsin(e1) / (e1 * np.sqrt(bd))
175    bL = (1.0 + e1) / (1.0 - e1)
176    b2 = 1.0 + bd / 2 / e1 * np.log(bL)
177    delta = 0.75 * b1 * b2
178
179    ddd = np.zeros_like(radius_polar)
180    ddd[valid] = 2.0 * (delta + 1.0) * radius_polar * radius_equatorial ** 2
181    return 0.5 * ddd ** (1.0 / 3.0)
182
183
184demo = dict(scale=1, background=0,
185            sld=6, sld_solvent=1,
186            radius_polar=50, radius_equatorial=30,
187            theta=30, phi=15,
188            radius_polar_pd=.2, radius_polar_pd_n=15,
189            radius_equatorial_pd=.2, radius_equatorial_pd_n=15,
190            theta_pd=15, theta_pd_n=45,
191            phi_pd=15, phi_pd_n=1)
Note: See TracBrowser for help on using the repository browser.