Changes in sasmodels/models/parallelepiped.py [3330bb4:afd4692] in sasmodels
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/parallelepiped.py
r3330bb4 rafd4692 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 mustsatisfy the condition that $A < B < C$.24 This requirement is not enforced in the model, so it is up to the25 user to check this during the analysis.24 The edge of the solid used to have to satisfy the condition that $A < B < C$. 25 After some improvements to the effective radius calculation, used with 26 an S(Q), it is beleived that this is no longer the case. 26 27 27 28 The 1D scattering intensity $I(q)$ is calculated as: … … 71 72 72 73 NB: The 2nd virial coefficient of the parallelepiped is calculated based on 73 the averaged effective radius $(=\sqrt{A B / \pi})$ and 74 the averaged effective radius, after appropriately sorting the three 75 dimensions, to give an oblate or prolate particle, $(=\sqrt{AB/\pi})$ and 74 76 length $(= C)$ values, and used as the effective radius for 75 77 $S(q)$ when $P(q) \cdot S(q)$ is applied. … … 102 104 .. _parallelepiped-orientation: 103 105 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 the106 .. figure:: img/parallelepiped_angle_definition.png 107 108 Definition of the angles for oriented parallelepiped, shown with $A<B<C$. 109 110 .. figure:: img/parallelepiped_angle_projection.png 111 112 Examples of the angles for an oriented parallelepiped against the 111 113 detector plane. 112 114 … … 116 118 .. math:: 117 119 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]^2120 P(q_x, q_y) = \left[\frac{\sin(\tfrac{1}{2}qA\cos\alpha)}{(\tfrac{1}{2}qA\cos\alpha)}\right]^2 121 \left[\frac{\sin(\tfrac{1}{2}qB\cos\beta)}{(\tfrac{1}{2}qB\cos\beta)}\right]^2 122 \left[\frac{\sin(\tfrac{1}{2}qC\cos\gamma)}{(\tfrac{1}{2}qC\cos\gamma)}\right]^2 121 123 122 124 with … … 154 156 angles. 155 157 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 158 159 159 References … … 163 163 164 164 R Nayuk and K Huber, *Z. Phys. Chem.*, 226 (2012) 837-854 165 166 Authorship and Verification 167 ---------------------------- 168 169 * **Author:** This model is based on form factor calculations implemented 170 in a c-library provided by the NIST Center for Neutron Research (Kline, 2006). 171 * **Last Modified by:** Paul Kienzle **Date:** April 05, 2017 172 * **Last Reviewed by:** Richard Heenan **Date:** April 06, 2017 173 165 174 """ 166 175 167 176 import numpy as np 168 from numpy import pi, inf, sqrt 177 from numpy import pi, inf, sqrt, sin, cos 169 178 170 179 name = "parallelepiped" … … 180 189 mu = q*B 181 190 V: Volume of the rectangular parallelepiped 182 alpha: angle between the long axis of the 191 alpha: angle between the long axis of the 183 192 parallelepiped and the q-vector for 1D 184 193 """ … … 208 217 def ER(length_a, length_b, length_c): 209 218 """ 210 219 Return effective radius (ER) for P(q)*S(q) 211 220 """ 212 221 # now that axes can be in any size order, need to sort a,b,c where a~b and c is either much smaller 222 # or much larger 223 abc = np.vstack((length_a, length_b, length_c)) 224 abc = np.sort(abc, axis=0) 225 selector = (abc[1] - abc[0]) > (abc[2] - abc[1]) 226 length = np.where(selector, abc[0], abc[2]) 213 227 # 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))228 radius = np.sqrt(np.where(~selector, abc[0]*abc[1], abc[1]*abc[2]) / pi) 229 230 ddd = 0.75 * radius * (2*radius*length + (length + radius)*(length + pi*radius)) 217 231 return 0.5 * (ddd) ** (1. / 3.) 218 232 … … 230 244 phi_pd=10, phi_pd_n=1, 231 245 psi_pd=10, psi_pd_n=10) 232 233 qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5)246 # rkh 7/4/17 add random unit test for 2d, note make all params different, 2d values not tested against other codes or models 247 qx, qy = 0.2 * cos(pi/6.), 0.2 * sin(pi/6.) 234 248 tests = [[{}, 0.2, 0.17758004974], 235 249 [{}, [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]],250 [{'theta':10.0, 'phi':20.0}, (qx, qy), 0.0089517140475], 251 [{'theta':10.0, 'phi':20.0}, [(qx, qy)], [0.0089517140475]], 238 252 ] 239 253 del qx, qy # not necessary to delete, but cleaner
Note: See TracChangeset
for help on using the changeset viewer.