[5d4777d] | 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 | |
---|
[eb69cce] | 14 | P(q,\alpha) = \frac{\text{scale}}{V} F^2(q) + \text{background} |
---|
[5d4777d] | 15 | |
---|
| 16 | where |
---|
| 17 | |
---|
| 18 | .. math:: |
---|
| 19 | |
---|
[eb69cce] | 20 | F(q) = \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} |
---|
[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$, |
---|
| 33 | $V$ 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 | 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 |
---|
| 41 | :ref:`cylinder orientation figure <cylinder-orientation>`. |
---|
[5d4777d] | 42 | For the ellipsoid, $\theta$ is the angle between the rotational axis |
---|
| 43 | and the $z$-axis. |
---|
| 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 | |
---|
[19dcb933] | 49 | .. _ellipsoid-1d: |
---|
| 50 | |
---|
[eb69cce] | 51 | .. figure:: img/ellipsoid_1d.jpg |
---|
[5d4777d] | 52 | |
---|
| 53 | The output of the 1D scattering intensity function for randomly oriented |
---|
| 54 | ellipsoids given by the equation above. |
---|
| 55 | |
---|
| 56 | |
---|
[eb69cce] | 57 | The $\theta$ and $\phi$ parameters are not used for the 1D output. |
---|
[5d4777d] | 58 | |
---|
[19dcb933] | 59 | .. _ellipsoid-geometry: |
---|
| 60 | |
---|
[eb69cce] | 61 | .. figure:: img/ellipsoid_geometry.jpg |
---|
[5d4777d] | 62 | |
---|
| 63 | The angles for oriented ellipsoid. |
---|
| 64 | |
---|
| 65 | Validation |
---|
| 66 | ---------- |
---|
| 67 | |
---|
| 68 | Validation of our code was done by comparing the output of the 1D model |
---|
| 69 | to the output of the software provided by the NIST (Kline, 2006). |
---|
[19dcb933] | 70 | :num:`Figure ellipsoid-comparison-1d` below shows a comparison of |
---|
[5d4777d] | 71 | the 1D output of our model and the output of the NIST software. |
---|
| 72 | |
---|
| 73 | .. _ellipsoid-comparison-1d: |
---|
| 74 | |
---|
[19dcb933] | 75 | .. figure:: img/ellipsoid_comparison_1d.jpg |
---|
[5d4777d] | 76 | |
---|
| 77 | Comparison of the SasView scattering intensity for an ellipsoid |
---|
| 78 | with the output of the NIST SANS analysis software. The parameters |
---|
[19dcb933] | 79 | were set to: *scale* = 1.0, *rpolar* = 20 |Ang|, |
---|
| 80 | *requatorial* =400 |Ang|, *contrast* = 3e-6 |Ang^-2|, |
---|
| 81 | and *background* = 0.01 |cm^-1|. |
---|
[5d4777d] | 82 | |
---|
| 83 | Averaging over a distribution of orientation is done by evaluating the |
---|
| 84 | equation above. Since we have no other software to compare the |
---|
| 85 | implementation of the intensity for fully oriented ellipsoids, we can |
---|
| 86 | compare the result of averaging our 2D output using a uniform distribution |
---|
[19dcb933] | 87 | $p(\theta,\phi) = 1.0$. :num:`Figure #ellipsoid-comparison-2d` |
---|
[5d4777d] | 88 | shows the result of such a cross-check. |
---|
| 89 | |
---|
| 90 | .. _ellipsoid-comparison-2d: |
---|
| 91 | |
---|
[19dcb933] | 92 | .. figure:: img/ellipsoid_comparison_2d.jpg |
---|
[5d4777d] | 93 | |
---|
| 94 | Comparison of the intensity for uniformly distributed ellipsoids |
---|
| 95 | calculated from our 2D model and the intensity from the NIST SANS |
---|
[19dcb933] | 96 | analysis software. The parameters used were: *scale* = 1.0, |
---|
| 97 | *rpolar* = 20 |Ang|, *requatorial* = 400 |Ang|, |
---|
| 98 | *contrast* = 3e-6 |Ang^-2|, and *background* = 0.0 |cm^-1|. |
---|
[5d4777d] | 99 | |
---|
[eb69cce] | 100 | The discrepancy above $q$ = 0.3 |cm^-1| is due to the way the form factors |
---|
[5d4777d] | 101 | are calculated in the c-library provided by NIST. A numerical integration |
---|
[eb69cce] | 102 | has to be performed to obtain $P(q)$ for randomly oriented particles. |
---|
[5d4777d] | 103 | The NIST software performs that integration with a 76-point Gaussian |
---|
[eb69cce] | 104 | quadrature rule, which will become imprecise at high $q$ where the amplitude |
---|
| 105 | varies quickly as a function of $q$. The SasView result shown has been |
---|
[5d4777d] | 106 | obtained by summing over 501 equidistant points. Our result was found |
---|
[eb69cce] | 107 | to be stable over the range of $q$ shown for a number of points higher |
---|
[5d4777d] | 108 | than 500. |
---|
| 109 | |
---|
[eb69cce] | 110 | References |
---|
| 111 | ---------- |
---|
[5d4777d] | 112 | |
---|
| 113 | L A Feigin and D I Svergun. *Structure Analysis by Small-Angle X-Ray and Neutron Scattering*, Plenum, |
---|
| 114 | New York, 1987. |
---|
| 115 | """ |
---|
| 116 | |
---|
[3c56da87] | 117 | from numpy import inf |
---|
[5d4777d] | 118 | |
---|
| 119 | name = "ellipsoid" |
---|
| 120 | title = "Ellipsoid of revolution with uniform scattering length density." |
---|
| 121 | |
---|
| 122 | description = """\ |
---|
| 123 | P(q.alpha)= scale*f(q)^2 + background, where f(q)= 3*(sld |
---|
[3e428ec] | 124 | - solvent_sld)*V*[sin(q*r(Rp,Re,alpha)) |
---|
| 125 | -q*r*cos(qr(Rp,Re,alpha))] |
---|
| 126 | /[qr(Rp,Re,alpha)]^3" |
---|
[5d4777d] | 127 | |
---|
| 128 | r(Rp,Re,alpha)= [Re^(2)*(sin(alpha))^2 |
---|
[3e428ec] | 129 | + Rp^(2)*(cos(alpha))^2]^(1/2) |
---|
[5d4777d] | 130 | |
---|
[3e428ec] | 131 | sld: SLD of the ellipsoid |
---|
| 132 | solvent_sld: SLD of the solvent |
---|
| 133 | V: volume of the ellipsoid |
---|
| 134 | Rp: polar radius of the ellipsoid |
---|
| 135 | Re: equatorial radius of the ellipsoid |
---|
[5d4777d] | 136 | """ |
---|
[a5d0d00] | 137 | category = "shape:ellipsoid" |
---|
[5d4777d] | 138 | |
---|
[3e428ec] | 139 | # ["name", "units", default, [lower, upper], "type","description"], |
---|
| 140 | parameters = [["sld", "1e-6/Ang^2", 4, [-inf, inf], "", |
---|
| 141 | "Ellipsoid scattering length density"], |
---|
| 142 | ["solvent_sld", "1e-6/Ang^2", 1, [-inf, inf], "", |
---|
| 143 | "Solvent scattering length density"], |
---|
| 144 | ["rpolar", "Ang", 20, [0, inf], "volume", |
---|
| 145 | "Polar radius"], |
---|
| 146 | ["requatorial", "Ang", 400, [0, inf], "volume", |
---|
| 147 | "Equatorial radius"], |
---|
| 148 | ["theta", "degrees", 60, [-inf, inf], "orientation", |
---|
| 149 | "In plane angle"], |
---|
| 150 | ["phi", "degrees", 60, [-inf, inf], "orientation", |
---|
| 151 | "Out of plane angle"], |
---|
| 152 | ] |
---|
| 153 | |
---|
| 154 | source = ["lib/J1.c", "lib/gauss76.c", "ellipsoid.c"] |
---|
[5d4777d] | 155 | |
---|
| 156 | def ER(rpolar, requatorial): |
---|
| 157 | import numpy as np |
---|
| 158 | |
---|
| 159 | ee = np.empty_like(rpolar) |
---|
| 160 | idx = rpolar > requatorial |
---|
[3e428ec] | 161 | ee[idx] = (rpolar[idx] ** 2 - requatorial[idx] ** 2) / rpolar[idx] ** 2 |
---|
[5d4777d] | 162 | idx = rpolar < requatorial |
---|
[3e428ec] | 163 | ee[idx] = (requatorial[idx] ** 2 - rpolar[idx] ** 2) / requatorial[idx] ** 2 |
---|
[5d4777d] | 164 | idx = rpolar == requatorial |
---|
[3e428ec] | 165 | ee[idx] = 2 * rpolar[idx] |
---|
| 166 | valid = (rpolar * requatorial != 0) |
---|
| 167 | bd = 1.0 - ee[valid] |
---|
[5d4777d] | 168 | e1 = np.sqrt(ee[valid]) |
---|
[3e428ec] | 169 | b1 = 1.0 + np.arcsin(e1) / (e1 * np.sqrt(bd)) |
---|
| 170 | bL = (1.0 + e1) / (1.0 - e1) |
---|
| 171 | b2 = 1.0 + bd / 2 / e1 * np.log(bL) |
---|
| 172 | delta = 0.75 * b1 * b2 |
---|
[5d4777d] | 173 | |
---|
| 174 | ddd = np.zeros_like(rpolar) |
---|
[3e428ec] | 175 | ddd[valid] = 2.0 * (delta + 1.0) * rpolar * requatorial ** 2 |
---|
| 176 | return 0.5 * ddd ** (1.0 / 3.0) |
---|
| 177 | |
---|
| 178 | |
---|
| 179 | demo = dict(scale=1, background=0, |
---|
| 180 | sld=6, solvent_sld=1, |
---|
| 181 | rpolar=50, requatorial=30, |
---|
| 182 | theta=30, phi=15, |
---|
| 183 | rpolar_pd=.2, rpolar_pd_n=15, |
---|
| 184 | requatorial_pd=.2, requatorial_pd_n=15, |
---|
| 185 | theta_pd=15, theta_pd_n=45, |
---|
| 186 | phi_pd=15, phi_pd_n=1) |
---|
[a503bfd] | 187 | oldname = 'EllipsoidModel' |
---|
| 188 | oldpars = dict(theta='axis_theta', phi='axis_phi', |
---|
| 189 | sld='sldEll', solvent_sld='sldSolv', |
---|
| 190 | rpolar='radius_a', requatorial='radius_b') |
---|