Changes in sasmodels/models/parallelepiped.py [3330bb4:34a9e4e] in sasmodels
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/parallelepiped.py
r3330bb4 r34a9e4e 9 9 ---------- 10 10 11 |This model calculates the scattering from a rectangular parallelepiped12 |(\:numref:`parallelepiped-image`\).13 |If you need to apply polydispersity, see also :ref:`rectangular-prism`.11 This model calculates the scattering from a rectangular parallelepiped 12 (\:numref:`parallelepiped-image`\). 13 If you need to apply polydispersity, see also :ref:`rectangular-prism`. 14 14 15 15 .. _parallelepiped-image: 16 16 17 17 18 .. figure:: img/parallelepiped_geometry.jpg 18 19 … … 21 22 .. note:: 22 23 23 The edge of the solid must satisfy the condition that $A < B < C$. 24 This requirement is not enforced in the model, so it is up to the 25 user to check this during the analysis. 24 The three dimensions of the parallelepiped (strictly here a cuboid) may be given in 25 $any$ size order. To avoid multiple fit solutions, especially 26 with Monte-Carlo fit methods, it may be advisable to restrict their ranges. There may 27 be a number of closely similar "best fits", so some trial and error, or fixing of some 28 dimensions at expected values, may help. 26 29 27 30 The 1D scattering intensity $I(q)$ is calculated as: … … 67 70 \mu &= qB 68 71 69 70 72 The scattering intensity per unit volume is returned in units of |cm^-1|. 71 73 72 74 NB: The 2nd virial coefficient of the parallelepiped is calculated based on 73 the averaged effective radius $(=\sqrt{A B / \pi})$ and 75 the averaged effective radius, after appropriately sorting the three 76 dimensions, to give an oblate or prolate particle, $(=\sqrt{AB/\pi})$ and 74 77 length $(= C)$ values, and used as the effective radius for 75 78 $S(q)$ when $P(q) \cdot S(q)$ is applied. … … 102 105 .. _parallelepiped-orientation: 103 106 104 .. figure:: img/parallelepiped_angle_definition. jpg105 106 Definition of the angles for oriented parallelepiped s.107 108 .. figure:: img/parallelepiped_angle_projection. jpg109 110 Examples of the angles for oriented parallelepipedsagainst the107 .. figure:: img/parallelepiped_angle_definition.png 108 109 Definition of the angles for oriented parallelepiped, shown with $A<B<C$. 110 111 .. figure:: img/parallelepiped_angle_projection.png 112 113 Examples of the angles for an oriented parallelepiped against the 111 114 detector plane. 112 115 116 On introducing "Orientational Distribution" in the angles, "distribution of theta" and "distribution of phi" parameters will 117 appear. These are actually rotations about axes $\delta_1$ and $\delta_2$ of the parallelepiped, perpendicular to the $a$ x $c$ and $b$ x $c$ faces. 118 (When $\theta = \phi = 0$ these are parallel to the $Y$ and $X$ axes of the instrument.) The third orientation distribution, in $\psi$, is 119 about the $c$ axis of the particle, perpendicular to the $a$ x $b$ face. Some experimentation may be required to 120 understand the 2d patterns fully. (Earlier implementations had numerical integration issues in some circumstances when orientation 121 distributions passed through 90 degrees, such situations, with very broad distributions, should still be approached with care.) 122 123 113 124 For a given orientation of the parallelepiped, the 2D form factor is 114 125 calculated as … … 116 127 .. math:: 117 128 118 P(q_x, q_y) = \left[\frac{\sin( qA\cos\alpha/2)}{(qA\cos\alpha/2)}\right]^2119 \left[\frac{\sin( qB\cos\beta/2)}{(qB\cos\beta/2)}\right]^2120 \left[\frac{\sin( qC\cos\gamma/2)}{(qC\cos\gamma/2)}\right]^2129 P(q_x, q_y) = \left[\frac{\sin(\tfrac{1}{2}qA\cos\alpha)}{(\tfrac{1}{2}qA\cos\alpha)}\right]^2 130 \left[\frac{\sin(\tfrac{1}{2}qB\cos\beta)}{(\tfrac{1}{2}qB\cos\beta)}\right]^2 131 \left[\frac{\sin(\tfrac{1}{2}qC\cos\gamma)}{(\tfrac{1}{2}qC\cos\gamma)}\right]^2 121 132 122 133 with … … 154 165 angles. 155 166 156 This model is based on form factor calculations implemented in a c-library157 provided by the NIST Center for Neutron Research (Kline, 2006).158 167 159 168 References … … 163 172 164 173 R Nayuk and K Huber, *Z. Phys. Chem.*, 226 (2012) 837-854 174 175 Authorship and Verification 176 ---------------------------- 177 178 * **Author:** This model is based on form factor calculations implemented 179 in a c-library provided by the NIST Center for Neutron Research (Kline, 2006). 180 * **Last Modified by:** Paul Kienzle **Date:** April 05, 2017 181 * **Last Reviewed by:** Richard Heenan **Date:** April 06, 2017 182 165 183 """ 166 184 167 185 import numpy as np 168 from numpy import pi, inf, sqrt 186 from numpy import pi, inf, sqrt, sin, cos 169 187 170 188 name = "parallelepiped" … … 180 198 mu = q*B 181 199 V: Volume of the rectangular parallelepiped 182 alpha: angle between the long axis of the 200 alpha: angle between the long axis of the 183 201 parallelepiped and the q-vector for 1D 184 202 """ … … 196 214 ["length_c", "Ang", 400, [0, inf], "volume", 197 215 "Larger side of the parallelepiped"], 198 ["theta", "degrees", 60, [- inf, inf], "orientation",199 " In planeangle"],200 ["phi", "degrees", 60, [- inf, inf], "orientation",201 " Out of plane angle"],202 ["psi", "degrees", 60, [- inf, inf], "orientation",203 " Rotation angle around its own c axis against q plane"],216 ["theta", "degrees", 60, [-360, 360], "orientation", 217 "c axis to beam angle"], 218 ["phi", "degrees", 60, [-360, 360], "orientation", 219 "rotation about beam"], 220 ["psi", "degrees", 60, [-360, 360], "orientation", 221 "rotation about c axis"], 204 222 ] 205 223 … … 208 226 def ER(length_a, length_b, length_c): 209 227 """ 210 228 Return effective radius (ER) for P(q)*S(q) 211 229 """ 212 230 # now that axes can be in any size order, need to sort a,b,c where a~b and c is either much smaller 231 # or much larger 232 abc = np.vstack((length_a, length_b, length_c)) 233 abc = np.sort(abc, axis=0) 234 selector = (abc[1] - abc[0]) > (abc[2] - abc[1]) 235 length = np.where(selector, abc[0], abc[2]) 213 236 # surface average radius (rough approximation) 214 surf_rad = sqrt(length_a * length_b/ pi)215 216 ddd = 0.75 * surf_rad * (2 * surf_rad * length_c + (length_c + surf_rad) * (length_c + pi * surf_rad))237 radius = np.sqrt(np.where(~selector, abc[0]*abc[1], abc[1]*abc[2]) / pi) 238 239 ddd = 0.75 * radius * (2*radius*length + (length + radius)*(length + pi*radius)) 217 240 return 0.5 * (ddd) ** (1. / 3.) 218 241 … … 230 253 phi_pd=10, phi_pd_n=1, 231 254 psi_pd=10, psi_pd_n=10) 232 233 qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5)255 # rkh 7/4/17 add random unit test for 2d, note make all params different, 2d values not tested against other codes or models 256 qx, qy = 0.2 * cos(pi/6.), 0.2 * sin(pi/6.) 234 257 tests = [[{}, 0.2, 0.17758004974], 235 258 [{}, [0.2], [0.17758004974]], 236 [{'theta':10.0, 'phi': 10.0}, (qx, qy), 0.00560296014],237 [{'theta':10.0, 'phi': 10.0}, [(qx, qy)], [0.00560296014]],259 [{'theta':10.0, 'phi':20.0}, (qx, qy), 0.0089517140475], 260 [{'theta':10.0, 'phi':20.0}, [(qx, qy)], [0.0089517140475]], 238 261 ] 239 262 del qx, qy # not necessary to delete, but cleaner
Note: See TracChangeset
for help on using the changeset viewer.