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