source: sasmodels/sasmodels/models/triaxial_ellipsoid.py @ 67595af

core_shell_microgelscostrafo411magnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 67595af was 67595af, checked in by Paul Kienzle <pkienzle@…>, 7 years ago

triaxial ellipsoid: update equations in the docs.

  • Property mode set to 100644
File size: 5.5 KB
Line 
1# triaxial ellipsoid model
2# Note: model title and parameter table are inserted automatically
3r"""
4Definition
5----------
6
7.. figure:: img/triaxial_ellipsoid_geometry.jpg
8
9    Ellipsoid with $R_a$ as *radius_equat_minor*, $R_b$ as *radius_equat_major*
10    and $R_c$ as *radius_polar*.  For highest accuracy in the orientational
11    average, prefer $R_c > R_b > R_a$.
12
13Given an ellipsoid
14
15.. math::
16
17    \frac{X^2}{R_a^2} + \frac{Y^2}{R_b^2} + \frac{Z^2}{R_c^2} = 1
18
19the scattering is defined by the average over all orientations $\Omega$,
20
21.. math::
22
23    P(q) = \text{scale}\frac{V}{4 \pi}\int_\Omega \Phi^2(qr) d\Omega + \text{background}
24
25where
26
27.. math::
28
29    \Phi(qr) &= 3 j_1(qr)/qr = 3 (\sin qr - qr \cos qr)/(qr)^3 \\
30    r^2 &= R_a^2e^2 + R_b^2f^2 + R_c^2g^2 \\
31    V &= \tfrac{4}{3} \pi R_a R_b R_c
32
33The $e$, $f$ and $g$ terms are the projections of the orientation vector on $X$,
34$Y$ and $Z$ respectively.  Keeping the orientation fixed at the canonical
35axes, we can integrate over the incident direction using polar angle
36$-\pi/2 \le \gamma \le \pi/2$ and equatorial angle $0 \le \phi \le 2\pi$
37(as defined in ref [1]),
38
39 .. math::
40
41     \langle\Phi^2\rangle = \int_0^{2\pi} \int_{-\pi/2}^{\pi/2} \Phi^2(qr) \cos \gamma\,d\gamma d\phi
42
43with $e = \cos\gamma \sin\phi$, $f = \cos\gamma \cos\phi$ and $g = \sin\gamma$.
44A little algebra yields
45
46.. math::
47
48    r^2 = b^2(p_a \sin^2 \phi \cos^2 \gamma + 1 + p_c \sin^2 \gamma)
49
50for
51
52.. math::
53
54    p_a = \frac{a^2}{b^2} - 1 \text{ and } p_c = \frac{c^2}{b^2} - 1
55
56Due to symmetry, the ranges can be restricted to a single quadrant
57$0 \le \gamma \le \pi/2$ and $0 \le \phi \le \pi/2$, scaling the resulting
58integral by 8. The computation is done using the substitution $u = \sin\gamma$,
59$du = \cos\gamma\,d\gamma$, giving
60
61.. math::
62
63    \langle\Phi^2\rangle &= 8 \int_0^{\pi/2} \int_0^1 \Phi^2(qr) du d\phi \\
64    r^2 &= b^2(p_a \sin^2(\phi)(1 - u^2) + 1 + p_c u^2)
65
66To provide easy access to the orientation of the triaxial ellipsoid,
67we define the axis of the cylinder using the angles $\theta$, $\phi$
68and $\psi$. These angles are defined on
69:numref:`triaxial-ellipsoid-angles` .
70The angle $\psi$ is the rotational angle around its own $c$ axis
71against the $q$ plane. For example, $\psi = 0$ when the
72$a$ axis is parallel to the $x$ axis of the detector.
73
74.. _triaxial-ellipsoid-angles:
75
76.. figure:: img/triaxial_ellipsoid_angle_projection.jpg
77
78    The angles for oriented ellipsoid.
79
80The radius-of-gyration for this system is  $R_g^2 = (R_a R_b R_c)^2/5$.
81
82The contrast is defined as SLD(ellipsoid) - SLD(solvent).  In the
83parameters, $R_a$ is the minor equatorial radius, $R_b$ is the major
84equatorial radius, and $R_c$ is the polar radius of the ellipsoid.
85
86NB: The 2nd virial coefficient of the triaxial solid ellipsoid is
87calculated based on the polar radius $R_p = R_c$ and equatorial
88radius $R_e = \sqrt{R_a R_b}$, and used as the effective radius for
89$S(q)$ when $P(q) \cdot S(q)$ is applied.
90
91Validation
92----------
93
94Validation of our code was done by comparing the output of the
951D calculation to the angular average of the output of 2D calculation
96over all possible angles.
97
98
99References
100----------
101
102[1] Finnigan, J.A., Jacobs, D.J., 1971.
103*Light scattering by ellipsoidal particles in solution*,
104J. Phys. D: Appl. Phys. 4, 72-77. doi:10.1088/0022-3727/4/1/310
105
106"""
107
108from numpy import inf
109
110name = "triaxial_ellipsoid"
111title = "Ellipsoid of uniform scattering length density with three independent axes."
112
113description = """\
114Note: During fitting ensure that the inequality ra<rb<rc is not
115        violated. Otherwise the calculation will
116        not be correct.
117"""
118category = "shape:ellipsoid"
119
120#             ["name", "units", default, [lower, upper], "type","description"],
121parameters = [["sld", "1e-6/Ang^2", 4, [-inf, inf], "sld",
122               "Ellipsoid scattering length density"],
123              ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld",
124               "Solvent scattering length density"],
125              ["radius_equat_minor", "Ang", 20, [0, inf], "volume",
126               "Minor equatorial radius, Ra"],
127              ["radius_equat_major", "Ang", 400, [0, inf], "volume",
128               "Major equatorial radius, Rb"],
129              ["radius_polar", "Ang", 10, [0, inf], "volume",
130               "Polar radius, Rc"],
131              ["theta", "degrees", 60, [-inf, inf], "orientation",
132               "In plane angle"],
133              ["phi", "degrees", 60, [-inf, inf], "orientation",
134               "Out of plane angle"],
135              ["psi", "degrees", 60, [-inf, inf], "orientation",
136               "Out of plane angle"],
137             ]
138
139source = ["lib/sas_3j1x_x.c", "lib/gauss76.c", "triaxial_ellipsoid.c"]
140
141def ER(radius_equat_minor, radius_equat_major, radius_polar):
142    """
143        Returns the effective radius used in the S*P calculation
144    """
145    import numpy as np
146    from .ellipsoid import ER as ellipsoid_ER
147    return ellipsoid_ER(radius_polar, np.sqrt(radius_equat_minor * radius_equat_major))
148
149demo = dict(scale=1, background=0,
150            sld=6, sld_solvent=1,
151            theta=30, phi=15, psi=5,
152            radius_equat_minor=25, radius_equat_major=36, radius_polar=50,
153            radius_equat_minor_pd=0, radius_equat_minor_pd_n=1,
154            radius_equat_major_pd=0, radius_equat_major_pd_n=1,
155            radius_polar_pd=.2, radius_polar_pd_n=30,
156            theta_pd=15, theta_pd_n=45,
157            phi_pd=15, phi_pd_n=1,
158            psi_pd=15, psi_pd_n=1)
Note: See TracBrowser for help on using the repository browser.