Changeset 16a8c63 in sasmodels
- Timestamp:
- Apr 7, 2017 10:59:30 AM (8 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 3fd0499, 1f65db5
- Parents:
- e6ab0d3 (diff), 43ff77c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- sasmodels/models
- Files:
-
- 6 added
- 5 deleted
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/barbell.py
rfcb33e4 r0b56f38 87 87 * **Last Reviewed by:** Richard Heenan **Date:** January 4, 2017 88 88 """ 89 from numpy import inf 89 from numpy import inf, sin, cos, pi 90 90 91 91 name = "barbell" … … 125 125 phi_pd=15, phi_pd_n=0, 126 126 ) 127 q = 0.1 128 # april 6 2017, rkh add unit tests, NOT compared with any other calc method, assume correct! 129 qx = q*cos(pi/6.0) 130 qy = q*sin(pi/6.0) 131 tests = [[{}, 0.075, 25.5691260532], 132 [{'theta':80., 'phi':10.}, (qx, qy), 3.04233067789], 133 ] 134 del qx, qy # not necessary to delete, but cleaner -
sasmodels/models/bcc_paracrystal.py
r925ad6e re2d6e3b 99 99 """ 100 100 101 from numpy import inf 101 from numpy import inf, pi 102 102 103 103 name = "bcc_paracrystal" … … 141 141 psi_pd=15, psi_pd_n=0, 142 142 ) 143 # april 6 2017, rkh add unit tests, NOT compared with any other calc method, assume correct! 144 # add 2d test later 145 q =4.*pi/220. 146 tests = [ 147 [{ }, 148 [0.001, q, 0.215268], [1.46601394721, 2.85851284174, 0.00866710287078]], 149 ] -
sasmodels/models/capped_cylinder.py
rfcb33e4 r0b56f38 91 91 92 92 """ 93 from numpy import inf 93 from numpy import inf, sin, cos, pi 94 94 95 95 name = "capped_cylinder" … … 145 145 theta_pd=15, theta_pd_n=45, 146 146 phi_pd=15, phi_pd_n=1) 147 q = 0.1 148 # april 6 2017, rkh add unit tests, NOT compared with any other calc method, assume correct! 149 qx = q*cos(pi/6.0) 150 qy = q*sin(pi/6.0) 151 tests = [[{}, 0.075, 26.0698570695], 152 [{'theta':80., 'phi':10.}, (qx, qy), 0.561811990502], 153 ] 154 del qx, qy # not necessary to delete, but cleaner -
sasmodels/models/core_shell_bicelle.py
r3b9a526 r0b56f38 88 88 """ 89 89 90 from numpy import inf, sin, cos 90 from numpy import inf, sin, cos, pi 91 91 92 92 name = "core_shell_bicelle" … … 155 155 theta=90, 156 156 phi=0) 157 q = 0.1 158 # april 6 2017, rkh add unit tests, NOT compared with any other calc method, assume correct! 159 qx = q*cos(pi/6.0) 160 qy = q*sin(pi/6.0) 161 tests = [[{}, 0.05, 7.4883545957], 162 [{'theta':80., 'phi':10.}, (qx, qy), 2.81048892474 ], 163 ] 164 del qx, qy # not necessary to delete, but cleaner 157 165 158 #qx, qy = 0.4 * cos(pi/2.0), 0.5 * sin(0) -
sasmodels/models/core_shell_bicelle_elliptical.py
r15a90c1 r16a8c63 99 99 """ 100 100 101 from numpy import inf, sin, cos 101 from numpy import inf, sin, cos, pi 102 102 103 103 name = "core_shell_bicelle_elliptical" … … 150 150 psi=0) 151 151 152 #qx, qy = 0.4 * cos(pi/2.0), 0.5 * sin(0) 152 q = 0.1 153 # april 6 2017, rkh added a 2d unit test, NOT READY YET pull #890 branch assume correct! 154 qx = q*cos(pi/6.0) 155 qy = q*sin(pi/6.0) 153 156 154 157 tests = [ … … 159 162 'sld_core':4.0, 'sld_face':7.0, 'sld_rim':1.0, 'sld_solvent':6.0, 'background':0.0}, 160 163 0.015, 286.540286], 161 ] 164 # [{'theta':80., 'phi':10.}, (qx, qy), 7.88866563001 ], 165 ] 166 167 del qx, qy # not necessary to delete, but cleaner -
sasmodels/models/core_shell_cylinder.py
rfcb33e4 r0b56f38 73 73 """ 74 74 75 from numpy import pi, inf 75 from numpy import pi, inf, sin, cos 76 76 77 77 name = "core_shell_cylinder" … … 151 151 theta_pd=15, theta_pd_n=45, 152 152 phi_pd=15, phi_pd_n=1) 153 153 q = 0.1 154 # april 6 2017, rkh add unit tests, NOT compared with any other calc method, assume correct! 155 qx = q*cos(pi/6.0) 156 qy = q*sin(pi/6.0) 157 tests = [[{}, 0.075, 10.8552692237], 158 [{}, (qx, qy), 0.444618752741 ], 159 ] 160 del qx, qy # not necessary to delete, but cleaner -
sasmodels/models/ellipsoid.py
r4b0a294 r0b56f38 120 120 """ 121 121 122 from numpy import inf 122 from numpy import inf, sin, cos, pi 123 123 124 124 name = "ellipsoid" … … 190 190 theta_pd=15, theta_pd_n=45, 191 191 phi_pd=15, phi_pd_n=1) 192 q = 0.1 193 # april 6 2017, rkh add unit tests, NOT compared with any other calc method, assume correct! 194 qx = q*cos(pi/6.0) 195 qy = q*sin(pi/6.0) 196 tests = [[{}, 0.05, 54.8525847025], 197 [{'theta':80., 'phi':10.}, (qx, qy), 1.74134670026 ], 198 ] 199 del qx, qy # not necessary to delete, but cleaner -
sasmodels/models/elliptical_cylinder.py
r15a90c1 r16a8c63 109 109 """ 110 110 111 from numpy import pi, inf, sqrt 111 from numpy import pi, inf, sqrt, sin, cos 112 112 113 113 name = "elliptical_cylinder" … … 150 150 + (length + radius) * (length + pi * radius)) 151 151 return 0.5 * (ddd) ** (1. / 3.) 152 q = 0.1 153 # april 6 2017, rkh added a 2d unit test, NOT READY YET pull #890 branch assume correct! 154 qx = q*cos(pi/6.0) 155 qy = q*sin(pi/6.0) 152 156 153 157 tests = [ … … 159 163 'sld_solvent':1.0, 'background':0.0}, 160 164 0.001, 675.504402], 165 # [{'theta':80., 'phi':10.}, (qx, qy), 7.88866563001 ], 161 166 ] -
sasmodels/models/fcc_paracrystal.py
r925ad6e re2d6e3b 90 90 """ 91 91 92 from numpy import inf 92 from numpy import inf, pi 93 93 94 94 name = "fcc_paracrystal" … … 128 128 psi_pd=15, psi_pd_n=0, 129 129 ) 130 # april 6 2017, rkh add unit tests, NOT compared with any other calc method, assume correct! 131 # add 2d test later 132 q =4.*pi/220. 133 tests = [ 134 [{ }, 135 [0.001, q, 0.215268], [0.275164706668, 5.7776842567, 0.00958167119232]], 136 ] -
sasmodels/models/hollow_cylinder.py
raea2e2a r0b56f38 60 60 """ 61 61 62 from numpy import pi, inf 62 from numpy import pi, inf, sin, cos 63 63 64 64 name = "hollow_cylinder" … … 129 129 theta_pd=10, theta_pd_n=5, 130 130 ) 131 131 q = 0.1 132 # april 6 2017, rkh added a 2d unit test, assume correct! 133 qx = q*cos(pi/6.0) 134 qy = q*sin(pi/6.0) 132 135 # Parameters for unit tests 133 136 tests = [ 134 137 [{}, 0.00005, 1764.926], 135 138 [{}, 'VR', 1.8], 136 [{}, 0.001, 1756.76] 137 ] 139 [{}, 0.001, 1756.76], 140 [{}, (qx, qy), 2.36885476192 ], 141 ] 142 del qx, qy # not necessary to delete, but cleaner -
sasmodels/models/stacked_disks.py
rc3ccaec r0b56f38 103 103 """ 104 104 105 from numpy import inf 105 from numpy import inf, sin, cos, pi 106 106 107 107 name = "stacked_disks" … … 152 152 # After redefinition of spherical coordinates - 153 153 # tests had in old coords theta=0, phi=0; new coords theta=90, phi=0 154 # but should not matter here as so far all the tests are 1D not 2D 154 q = 0.1 155 # april 6 2017, rkh added a 2d unit test, assume correct! 156 qx = q*cos(pi/6.0) 157 qy = q*sin(pi/6.0) 155 158 tests = [ 156 159 # Accuracy tests based on content in test/utest_extra_models.py. … … 186 189 [{'thick_core': 10.0, 187 190 'thick_layer': 15.0, 191 'radius': 100.0, 192 'n_stacking': 5, 193 'sigma_d': 0.0, 194 'sld_core': 4.0, 195 'sld_layer': -0.4, 196 'solvent_sd': 5.0, 197 'theta': 90.0, 198 'phi': 20.0, 199 'scale': 0.01, 200 'background': 0.001}, 201 (qx, qy), 0.0491167089952 ], 202 [{'thick_core': 10.0, 203 'thick_layer': 15.0, 188 204 'radius': 3000.0, 189 205 'n_stacking': 5, … … 228 244 'background': 0.001, 229 245 }, ([0.4, 0.5]), [0.00105074, 0.00121761]], 246 [{'thick_core': 10.0, 247 'thick_layer': 15.0, 248 'radius': 3000.0, 249 'n_stacking': 1.0, 250 'sigma_d': 0.0, 251 'sld_core': 4.0, 252 'sld_layer': -0.4, 253 'solvent_sd': 5.0, 254 'theta': 90.0, 255 'phi': 20.0, 256 'scale': 0.01, 257 'background': 0.001, 258 }, (qx, qy), 0.0341738733124 ], 230 259 231 260 [{'thick_core': 10.0, -
sasmodels/models/triaxial_ellipsoid.py
r15a90c1 r16a8c63 86 86 The contrast $\Delta\rho$ is defined as SLD(ellipsoid) - SLD(solvent). In the 87 87 parameters, $R_a$ is the minor equatorial radius, $R_b$ is the major 88 equatorial radius, and $R_c$ is the polar radius of the ellipsoid. 88 equatorial radius, and $R_c$ is the polar radius of the ellipsoid. 89 89 90 90 NB: The 2nd virial coefficient of the triaxial solid ellipsoid is … … 117 117 """ 118 118 119 from numpy import inf 119 from numpy import inf, sin, cos, pi 120 120 121 121 name = "triaxial_ellipsoid" … … 157 157 from .ellipsoid import ER as ellipsoid_ER 158 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 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 160 # or much larger 161 161 radii = np.vstack((radius_equat_major, radius_equat_minor, radius_polar)) … … 177 177 psi_pd=15, psi_pd_n=1) 178 178 179 # TODO: need some unit tests! 179 q = 0.1 180 # april 6 2017, rkh add unit tests, NOT compared with any other calc method, assume correct! 181 # add 2d test after pull #890 182 qx = q*cos(pi/6.0) 183 qy = q*sin(pi/6.0) 184 tests = [[{}, 0.05, 24.8839548033], 185 # [{'theta':80., 'phi':10.}, (qx, qy), 9999. ], 186 ] 187 del qx, qy # not necessary to delete, but cleaner -
sasmodels/models/core_shell_parallelepiped.py
r933af72 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/parallelepiped.py
red0827a 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
Note: See TracChangeset
for help on using the changeset viewer.