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