[5d4777d] | 1 | # triaxial ellipsoid model |
---|
| 2 | # Note: model title and parameter table are inserted automatically |
---|
| 3 | r""" |
---|
[eb69cce] | 4 | All three axes are of different lengths with $R_a \leq R_b \leq R_c$ |
---|
[5d4777d] | 5 | **Users should maintain this inequality for all calculations**. |
---|
| 6 | |
---|
| 7 | .. math:: |
---|
| 8 | |
---|
[eb69cce] | 9 | P(q) = \text{scale} V \left< F^2(q) \right> + \text{background} |
---|
[5d4777d] | 10 | |
---|
| 11 | where the volume $V = 4/3 \pi R_a R_b R_c$, and the averaging |
---|
[eb69cce] | 12 | $\left<\ldots\right>$ is applied over all orientations for 1D. |
---|
[5d4777d] | 13 | |
---|
[19dcb933] | 14 | .. figure:: img/triaxial_ellipsoid_geometry.jpg |
---|
[5d4777d] | 15 | |
---|
| 16 | Ellipsoid schematic. |
---|
| 17 | |
---|
| 18 | Definition |
---|
| 19 | ---------- |
---|
| 20 | |
---|
| 21 | The form factor calculated is |
---|
| 22 | |
---|
| 23 | .. math:: |
---|
| 24 | |
---|
[eb69cce] | 25 | P(q) = \frac{\text{scale}}{V}\int_0^1\int_0^1 |
---|
| 26 | \Phi^2(qR_a^2\cos^2( \pi x/2) + qR_b^2\sin^2(\pi y/2)(1-y^2) + R_c^2y^2) |
---|
[5d4777d] | 27 | dx dy |
---|
| 28 | |
---|
| 29 | where |
---|
| 30 | |
---|
| 31 | .. math:: |
---|
| 32 | |
---|
| 33 | \Phi(u) = 3 u^{-3} (\sin u - u \cos u) |
---|
| 34 | |
---|
| 35 | To provide easy access to the orientation of the triaxial ellipsoid, |
---|
| 36 | we define the axis of the cylinder using the angles $\theta$, $\phi$ |
---|
| 37 | and $\psi$. These angles are defined on |
---|
[19dcb933] | 38 | :num:`figure #triaxial-ellipsoid-angles`. |
---|
[5d4777d] | 39 | The angle $\psi$ is the rotational angle around its own $c$ axis |
---|
[eb69cce] | 40 | against the $q$ plane. For example, $\psi = 0$ when the |
---|
[5d4777d] | 41 | $a$ axis is parallel to the $x$ axis of the detector. |
---|
| 42 | |
---|
| 43 | .. _triaxial-ellipsoid-angles: |
---|
| 44 | |
---|
[19dcb933] | 45 | .. figure:: img/triaxial_ellipsoid_angles.jpg |
---|
[5d4777d] | 46 | |
---|
| 47 | The angles for oriented ellipsoid. |
---|
| 48 | |
---|
[19dcb933] | 49 | The radius-of-gyration for this system is $R_g^2 = (R_a R_b R_c)^2/5$. |
---|
[5d4777d] | 50 | |
---|
| 51 | The contrast is defined as SLD(ellipsoid) - SLD(solvent). In the |
---|
[eb69cce] | 52 | parameters, $R_a$ is the minor equatorial radius, $R_b$ is the major |
---|
| 53 | equatorial radius, and $R_c$ is the polar radius of the ellipsoid. |
---|
[5d4777d] | 54 | |
---|
| 55 | NB: The 2nd virial coefficient of the triaxial solid ellipsoid is |
---|
| 56 | calculated based on the polar radius $R_p = R_c$ and equatorial |
---|
| 57 | radius $R_e = \sqrt{R_a R_b}$, and used as the effective radius for |
---|
[eb69cce] | 58 | $S(q)$ when $P(q) \cdot S(q)$ is applied. |
---|
[5d4777d] | 59 | |
---|
[19dcb933] | 60 | .. figure:: img/triaxial_ellipsoid_1d.jpg |
---|
[5d4777d] | 61 | |
---|
| 62 | 1D plot using the default values (w/1000 data point). |
---|
| 63 | |
---|
| 64 | Validation |
---|
| 65 | ---------- |
---|
| 66 | |
---|
| 67 | Validation of our code was done by comparing the output of the |
---|
| 68 | 1D calculation to the angular average of the output of 2D calculation |
---|
| 69 | over all possible angles. |
---|
[19dcb933] | 70 | :num:`Figure #triaxial-ellipsoid-comparison` shows the comparison where |
---|
[5d4777d] | 71 | the solid dot refers to averaged 2D while the line represents the |
---|
| 72 | result of 1D calculation (for 2D averaging, 76, 180, and 76 points |
---|
| 73 | are taken for the angles of $\theta$, $\phi$, and $\psi$ respectively). |
---|
| 74 | |
---|
[19dcb933] | 75 | .. _triaxial-ellipsoid-comparison: |
---|
[5d4777d] | 76 | |
---|
[19dcb933] | 77 | .. figure:: img/triaxial_ellipsoid_comparison.png |
---|
[5d4777d] | 78 | |
---|
| 79 | Comparison between 1D and averaged 2D. |
---|
| 80 | |
---|
[eb69cce] | 81 | References |
---|
| 82 | ---------- |
---|
[5d4777d] | 83 | |
---|
| 84 | L A Feigin and D I Svergun, *Structure Analysis by Small-Angle X-Ray and Neutron Scattering*, Plenum, |
---|
| 85 | New York, 1987. |
---|
| 86 | """ |
---|
| 87 | |
---|
[3c56da87] | 88 | from numpy import inf |
---|
[5d4777d] | 89 | |
---|
| 90 | name = "triaxial_ellipsoid" |
---|
| 91 | title = "Ellipsoid of uniform scattering length density with three independent axes." |
---|
| 92 | |
---|
| 93 | description = """\ |
---|
| 94 | Note: During fitting ensure that the inequality ra<rb<rc is not |
---|
| 95 | violated. Otherwise the calculation will |
---|
| 96 | not be correct. |
---|
| 97 | """ |
---|
[a5d0d00] | 98 | category = "shape:ellipsoid" |
---|
[5d4777d] | 99 | |
---|
[3e428ec] | 100 | # ["name", "units", default, [lower, upper], "type","description"], |
---|
| 101 | parameters = [["sld", "1e-6/Ang^2", 4, [-inf, inf], "", |
---|
| 102 | "Ellipsoid scattering length density"], |
---|
| 103 | ["solvent_sld", "1e-6/Ang^2", 1, [-inf, inf], "", |
---|
| 104 | "Solvent scattering length density"], |
---|
| 105 | ["req_minor", "Ang", 20, [0, inf], "volume", |
---|
| 106 | "Minor equitorial radius"], |
---|
| 107 | ["req_major", "Ang", 400, [0, inf], "volume", |
---|
| 108 | "Major equatorial radius"], |
---|
| 109 | ["rpolar", "Ang", 10, [0, inf], "volume", |
---|
| 110 | "Polar radius"], |
---|
| 111 | ["theta", "degrees", 60, [-inf, inf], "orientation", |
---|
| 112 | "In plane angle"], |
---|
| 113 | ["phi", "degrees", 60, [-inf, inf], "orientation", |
---|
| 114 | "Out of plane angle"], |
---|
| 115 | ["psi", "degrees", 60, [-inf, inf], "orientation", |
---|
| 116 | "Out of plane angle"], |
---|
| 117 | ] |
---|
| 118 | |
---|
[9c461c7] | 119 | source = ["lib/J1.c", "lib/sph_j1c.c", "lib/gauss76.c", "triaxial_ellipsoid.c"] |
---|
[5d4777d] | 120 | |
---|
| 121 | def ER(req_minor, req_major, rpolar): |
---|
| 122 | import numpy as np |
---|
| 123 | from .ellipsoid import ER as ellipsoid_ER |
---|
[3e428ec] | 124 | return ellipsoid_ER(rpolar, np.sqrt(req_minor * req_major)) |
---|
| 125 | |
---|
| 126 | demo = dict(scale=1, background=0, |
---|
| 127 | sld=6, solvent_sld=1, |
---|
| 128 | theta=30, phi=15, psi=5, |
---|
| 129 | req_minor=25, req_major=36, rpolar=50, |
---|
| 130 | req_minor_pd=0, req_minor_pd_n=1, |
---|
| 131 | req_major_pd=0, req_major_pd_n=1, |
---|
| 132 | rpolar_pd=.2, rpolar_pd_n=30, |
---|
| 133 | theta_pd=15, theta_pd_n=45, |
---|
| 134 | phi_pd=15, phi_pd_n=1, |
---|
| 135 | psi_pd=15, psi_pd_n=1) |
---|
[a503bfd] | 136 | oldname = 'TriaxialEllipsoidModel' |
---|
| 137 | oldpars = dict(theta='axis_theta', phi='axis_phi', psi='axis_psi', |
---|
[3e428ec] | 138 | sld='sldEll', solvent_sld='sldSolv', |
---|
[a503bfd] | 139 | req_minor='semi_axisA', req_major='semi_axisB', |
---|
| 140 | rpolar='semi_axisC') |
---|