Changes in / [43ff77c:16a8c63] in sasmodels
- Location:
- sasmodels/models
- Files:
-
- 6 added
- 5 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/core_shell_bicelle_elliptical.py
r0b56f38 r15a90c1 80 80 81 81 82 .. figure:: img/elliptical_cylinder_angle_definition. jpg82 .. figure:: img/elliptical_cylinder_angle_definition.png 83 83 84 Definition of the angles for the oriented core_shell_bicelle_elliptical model.85 Note that *theta* and *phi* are currently defined differently to those for the core_shell_bicelle model. 84 Definition of the angles for the oriented core_shell_bicelle_elliptical particles. 85 86 86 87 87 -
sasmodels/models/core_shell_parallelepiped.py
rcb0dc22 r1916c52 10 10 11 11 .. note:: 12 This model was originally ported from NIST IGOR macros. However, t is not13 yet fully understood by the SasView developers and is currently review.12 This model was originally ported from NIST IGOR macros. However, it is not 13 yet fully understood by the SasView developers and is currently under review. 14 14 15 15 The form factor is normalized by the particle volume $V$ such that … … 51 51 52 52 F_{a}(Q,\alpha,\beta)= 53 \left[\frac{\sin( Q(L_A+2t_A)/2\sin\alpha \sin\beta)}{Q(L_A+2t_A)/2\sin\alpha\sin\beta}54 - \frac{\sin( QL_A/2\sin\alpha \sin\beta)}{QL_A/2\sin\alpha \sin\beta} \right]55 \left[\frac{\sin( QL_B/2\sin\alpha \sin\beta)}{QL_B/2\sin\alpha \sin\beta} \right]56 \left[\frac{\sin( QL_C/2\sin\alpha \sin\beta)}{QL_C/2\sin\alpha \sin\beta} \right]53 \left[\frac{\sin(\tfrac{1}{2}Q(L_A+2t_A)\sin\alpha \sin\beta)}{\tfrac{1}{2}Q(L_A+2t_A)\sin\alpha\sin\beta} 54 - \frac{\sin(\tfrac{1}{2}QL_A\sin\alpha \sin\beta)}{\tfrac{1}{2}QL_A\sin\alpha \sin\beta} \right] 55 \left[\frac{\sin(\tfrac{1}{2}QL_B\sin\alpha \sin\beta)}{\tfrac{1}{2}QL_B\sin\alpha \sin\beta} \right] 56 \left[\frac{\sin(\tfrac{1}{2}QL_C\sin\alpha \sin\beta)}{\tfrac{1}{2}QL_C\sin\alpha \sin\beta} \right] 57 57 58 58 .. note:: 59 59 60 Why does t_B not appear in the above equation? 60 61 For the calculation of the form factor to be valid, the sides of the solid 61 MUST be chosen such that** $A < B < C$.62 MUST (perhaps not any more?) be chosen such that** $A < B < C$. 62 63 If this inequality is not satisfied, the model will not report an error, 63 64 but the calculation will not be correct and thus the result wrong. … … 80 81 NB: The 2nd virial coefficient of the core_shell_parallelepiped is calculated 81 82 based on the the averaged effective radius $(=\sqrt{(A+2t_A)(B+2t_B)/\pi})$ 82 and length $(C+2t_C)$ values, and used as the effective radius 83 for $S(Q)$ when $P(Q) * S(Q)$ is applied. 83 and length $(C+2t_C)$ values, after appropriately 84 sorting the three dimensions to give an oblate or prolate particle, to give an 85 effective radius, for $S(Q)$ when $P(Q) * S(Q)$ is applied. 84 86 85 87 To provide easy access to the orientation of the parallelepiped, we define the … … 90 92 *x*-axis of the detector. 91 93 92 .. figure:: img/parallelepiped_angle_definition. jpg94 .. figure:: img/parallelepiped_angle_definition.png 93 95 94 96 Definition of the angles for oriented core-shell parallelepipeds. 95 97 96 .. figure:: img/parallelepiped_angle_projection. jpg98 .. figure:: img/parallelepiped_angle_projection.png 97 99 98 100 Examples of the angles for oriented core-shell parallelepipeds against the … … 119 121 120 122 import numpy as np 121 from numpy import pi, inf, sqrt 123 from numpy import pi, inf, sqrt, cos, sin 122 124 123 125 name = "core_shell_parallelepiped" … … 193 195 psi_pd=10, psi_pd_n=1) 194 196 195 qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5) 197 # rkh 7/4/17 add random unit test for 2d, note make all params different, 2d values not tested against other codes or models 198 qx, qy = 0.2 * cos(pi/6.), 0.2 * sin(pi/6.) 196 199 tests = [[{}, 0.2, 0.533149288477], 197 200 [{}, [0.2], [0.533149288477]], 198 [{'theta':10.0, 'phi': 10.0}, (qx, qy), 0.032102135569],199 [{'theta':10.0, 'phi': 10.0}, [(qx, qy)], [0.032102135569]],201 [{'theta':10.0, 'phi':20.0}, (qx, qy), 0.0853299803222], 202 [{'theta':10.0, 'phi':20.0}, [(qx, qy)], [0.0853299803222]], 200 203 ] 201 204 del qx, qy # not necessary to delete, but cleaner -
sasmodels/models/cylinder.py
rb7e8b94 r15a90c1 64 64 65 65 Definition of the angles for oriented cylinders. 66 67 .. figure:: img/cylinder_angle_projection.png 68 69 Examples for oriented cylinders. 66 70 67 71 The $\theta$ and $\phi$ parameters only appear in the model when fitting 2d data. -
sasmodels/models/elliptical_cylinder.py
r0b56f38 r15a90c1 64 64 oriented system. 65 65 66 .. figure:: img/elliptical_cylinder_angle_definition. jpg66 .. figure:: img/elliptical_cylinder_angle_definition.png 67 67 68 Definition of angles for 2D 68 Definition of angles for oriented elliptical cylinder, where axis_ratio >1, 69 and angle $\Psi$ is a rotation around the axis of the cylinder. 69 70 70 .. figure:: img/ cylinder_angle_projection.jpg71 .. figure:: img/elliptical_cylinder_angle_projection.png 71 72 72 73 Examples of the angles for oriented elliptical cylinders against the 73 detector plane .74 detector plane, with $\Psi$ = 0. 74 75 75 76 NB: The 2nd virial coefficient of the cylinder is calculated based on the -
sasmodels/models/parallelepiped.py
r8e68ea0 r1916c52 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 an S(Q), 26 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 75 sorting the three dimensions, to give an oblate or prolate particle, $(=\sqrt{A B / \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 in a c-library 170 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" … … 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 -
sasmodels/models/triaxial_ellipsoid.py
r0b56f38 r15a90c1 65 65 To provide easy access to the orientation of the triaxial ellipsoid, 66 66 we define the axis of the cylinder using the angles $\theta$, $\phi$ 67 and $\psi$. These angles are defined on 68 :numref:`triaxial-ellipsoid-angles` . 67 and $\psi$. These angles are defined analogously to the elliptical_cylinder below 68 69 .. figure:: img/elliptical_cylinder_angle_definition.png 70 71 Definition of angles for oriented triaxial ellipsoid, where radii shown here are $a < b << c$ 72 and angle $\Psi$ is a rotation around the axis of the particle. 73 69 74 The angle $\psi$ is the rotational angle around its own $c$ axis 70 75 against the $q$ plane. For example, $\psi = 0$ when the … … 73 78 .. _triaxial-ellipsoid-angles: 74 79 75 .. figure:: img/triaxial_ellipsoid_angle_projection. jpg80 .. figure:: img/triaxial_ellipsoid_angle_projection.png 76 81 77 The angles for oriented ellipsoid.82 Some example angles for oriented ellipsoid. 78 83 79 84 The radius-of-gyration for this system is $R_g^2 = (R_a R_b R_c)^2/5$. … … 147 152 def ER(radius_equat_minor, radius_equat_major, radius_polar): 148 153 """ 149 154 Returns the effective radius used in the S*P calculation 150 155 """ 151 156 import numpy as np 152 157 from .ellipsoid import ER as ellipsoid_ER 153 # now that radii can be in any size order, radii need sorting a,b,c where a~b and c is either much smaller or much larger 154 # also need some unit tests! 155 156 return ellipsoid_ER(radius_polar, np.sqrt(radius_equat_minor * radius_equat_major)) 158 159 # now that radii can be in any size order, radii need sorting a,b,c where a~b and c is either much smaller 160 # or much larger 161 radii = np.vstack((radius_equat_major, radius_equat_minor, radius_polar)) 162 radii = np.sort(radii, axis=0) 163 selector = (radii[1] - radii[0]) > (radii[2] - radii[1]) 164 polar = np.where(selector, radii[0], radii[2]) 165 equatorial = np.sqrt(np.where(~selector, radii[0]*radii[1], radii[1]*radii[2])) 166 return ellipsoid_ER(polar, equatorial) 157 167 158 168 demo = dict(scale=1, background=0, … … 166 176 phi_pd=15, phi_pd_n=1, 167 177 psi_pd=15, psi_pd_n=1) 178 168 179 q = 0.1 169 180 # april 6 2017, rkh add unit tests, NOT compared with any other calc method, assume correct!
Note: See TracChangeset
for help on using the changeset viewer.