Changes in / [483a022:1fdb555] in sasmodels
- Location:
- sasmodels
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/kernel_template.c
r6a0d6aa r0d6e865 264 264 #if defined(IQXY_HAS_THETA) 265 265 // Force a nominal value for the spherical correction even when 266 // theta is + 90/-90 so that there are no divide by zero problems.267 // For cos(theta) fixed at 90, we effectively multiply top and bottom266 // theta is +0/180 so that there are no divide by zero problems. 267 // For sin(theta) fixed at 0 and 180, we effectively multiply top and bottom 268 268 // by 1e-6, so the effect cancels. 269 269 const double spherical_correction = fmax(fabs(cos(M_PI_180*theta)), 1.e-6); -
sasmodels/kernelpy.py
r14a15a3 r0d6e865 10 10 11 11 import numpy as np # type: ignore 12 from numpy import pi, cos #type: ignore12 from numpy import pi, sin, cos #type: ignore 13 13 14 14 from . import details … … 220 220 partial_weight = np.prod(pd_weight[pd_offset+pd_index][1:]) 221 221 if call_details.theta_par >= 0: 222 cor = cos(pi / 180 * parameters[call_details.theta_par])222 cor = sin(pi / 180 * parameters[call_details.theta_par]) 223 223 spherical_correction = max(abs(cor), 1e-6) 224 224 p0_index = loop_index%p0_length -
sasmodels/models/barbell.c
r2222134 r0d6e865 95 95 // Compute angle alpha between q and the cylinder axis 96 96 double sn, cn; // slots to hold sincos function output 97 SINCOS( theta*M_PI_180, sn, cn);98 const double q = sqrt(qx*qx +qy*qy);99 const double cos_val = cn*cos(phi*M_PI_180)*(qx/q) + sn*(qy/q);97 SINCOS(phi*M_PI_180, sn, cn); 98 const double q = sqrt(qx*qx + qy*qy); 99 const double cos_val = (q==0. ? 1.0 : (cn*qx + sn*qy)*sin(theta*M_PI_180)/q); 100 100 const double alpha = acos(cos_val); // rod angle relative to q 101 101 -
sasmodels/models/barbell.py
rb0c4271 r0d6e865 72 72 Definition of the angles for oriented 2D barbells. 73 73 74 .. figure:: img/cylinder_angle_projection.jpg75 :width: 600px76 77 Examples of the angles for oriented pp against the detector plane.78 74 79 75 References -
sasmodels/models/capped_cylinder.c
r2222134 r0d6e865 116 116 // Compute angle alpha between q and the cylinder axis 117 117 double sn, cn; 118 SINCOS( theta*M_PI_180, sn, cn);118 SINCOS(phi*M_PI_180, sn, cn); 119 119 const double q = sqrt(qx*qx+qy*qy); 120 const double cos_val = cn*cos(phi*M_PI_180)*(qx/q) + sn*(qy/q);120 const double cos_val = (q==0. ? 1.0 : (cn*qx + sn*qy)*sin(theta*M_PI_180)/q); 121 121 const double alpha = acos(cos_val); // rod angle relative to q 122 122 -
sasmodels/models/capped_cylinder.py
rb0c4271 r0d6e865 75 75 Definition of the angles for oriented 2D cylinders. 76 76 77 .. figure:: img/cylinder_angle_projection.jpg78 :width: 600px79 80 Examples of the angles for oriented 2D cylinders against the detector plane.81 77 82 78 References … … 132 128 ["radius_cap", "Ang", 20, [0, inf], "volume", "Cap radius"], 133 129 ["length", "Ang", 400, [0, inf], "volume", "Cylinder length"], 134 ["theta", "degrees", 60, [-inf, inf], "orientation", " In planeangle"],135 ["phi", "degrees", 60, [-inf, inf], "orientation", " Out of planeangle"],130 ["theta", "degrees", 60, [-inf, inf], "orientation", "inclination angle"], 131 ["phi", "degrees", 60, [-inf, inf], "orientation", "deflection angle"], 136 132 ] 137 133 # pylint: enable=bad-whitespace, line-too-long -
sasmodels/models/core_shell_bicelle.c
r2222134 r0d6e865 117 117 118 118 // Cylinder orientation 119 const double cyl_x = cos(theta) * cos(phi);120 const double cyl_y = sin(theta) ;119 const double cyl_x = sin(theta) * cos(phi); 120 const double cyl_y = sin(theta) * sin(phi); 121 121 122 122 // Compute the angle btw vector q and the axis of the cylinder -
sasmodels/models/core_shell_bicelle.py
r041bc75 r0d6e865 71 71 Definition of the angles for the oriented core shell bicelle tmodel. 72 72 73 .. figure:: img/cylinder_angle_projection.jpg74 :width: 600px75 76 Examples of the angles for oriented pp against the detector plane.77 73 78 74 References … … 161 157 162 158 qx, qy = 0.4 * cos(90), 0.5 * sin(0) 163 tests = [164 # Accuracy tests based on content in test/utest_other_models.py165 [{'radius': 20.0,166 'thick_rim': 10.0,167 'thick_face': 10.0,168 'length': 400.0,169 'sld_core': 1.0,170 'sld_face': 4.0,171 'sld_rim': 4.0,172 'sld_solvent': 1.0,173 'background': 0.0,174 }, 0.001, 353.550],175 176 [{'radius': 20.0,177 'thick_rim': 10.0,178 'thick_face': 10.0,179 'length': 400.0,180 'sld_core': 1.0,181 'sld_face': 4.0,182 'sld_rim': 4.0,183 'sld_solvent': 1.0,184 'theta': 90.0,185 'phi': 0.0,186 'background': 0.00,187 }, (qx, qy), 24.9167],188 189 # Additional tests with larger range of parameters190 [{'radius': 3.0,191 'thick_rim': 100.0,192 'thick_face': 100.0,193 'length': 1200.0,194 'sld_core': 5.0,195 'sld_face': 41.0,196 'sld_rim': 42.0,197 'sld_solvent': 21.0,198 }, 0.05, 1670.1828],199 ] -
sasmodels/models/core_shell_cylinder.c
r43b7eea r0d6e865 69 69 70 70 // Compute angle alpha between q and the cylinder axis 71 SINCOS( theta*M_PI_180, sn, cn);71 SINCOS(phi*M_PI_180, sn, cn); 72 72 // # The following correction factor exists in sasview, but it can't be 73 73 // # right, so we are leaving it out for now. 74 74 // const double correction = fabs(cn)*M_PI_2; 75 75 const double q = sqrt(qx*qx+qy*qy); 76 const double cos_val = cn*cos(phi*M_PI_180)*(qx/q) + sn*(qy/q);76 const double cos_val = (q==0. ? 1.0 : (cn*qx + sn*qy)*sin(theta*M_PI_180)/q); 77 77 const double alpha = acos(cos_val); 78 78 -
sasmodels/models/core_shell_ellipsoid.c
r5031ca3 r0d6e865 96 96 97 97 // ellipsoid orientation, the axis of the rotation is consistent with the ploar axis. 98 const double cyl_x = cos(theta) * cos(phi);99 const double cyl_y = sin(theta) ;98 const double cyl_x = sin(theta) * cos(phi); 99 const double cyl_y = sin(theta) * sin(phi); 100 100 101 101 const double sldcs = core_sld - shell_sld; -
sasmodels/models/cylinder.c
r03cac08 r0d6e865 1 1 double form_volume(double radius, double length); 2 double fq(double q, double sn, double cn,double radius, double length); 3 double orient_avg_1D(double q, double radius, double length); 2 4 double Iq(double q, double sld, double solvent_sld, double radius, double length); 3 5 double Iqxy(double qx, double qy, double sld, double solvent_sld, … … 11 13 } 12 14 15 double fq(double q, double sn, double cn, double radius, double length) 16 { 17 // precompute qr and qh to save time in the loop 18 const double qr = q*radius; 19 const double qh = q*0.5*length; 20 return sas_J1c(qr*sn) * sinc(qh*cn) ; 21 } 22 23 double orient_avg_1D(double q, double radius, double length) 24 { 25 // translate a point in [-1,1] to a point in [0, pi/2] 26 const double zm = M_PI_4; 27 const double zb = M_PI_4; 28 29 double total = 0.0; 30 for (int i=0; i<76 ;i++) { 31 const double alpha = Gauss76Z[i]*zm + zb; 32 double sn, cn; // slots to hold sincos function output 33 // alpha(theta,phi) the projection of the cylinder on the detector plane 34 SINCOS(alpha, sn, cn); 35 total += Gauss76Wt[i] * fq(q, sn, cn, radius, length)* fq(q, sn, cn, radius, length) * sn; 36 } 37 // translate dx in [-1,1] to dx in [lower,upper] 38 return total*zm; 39 } 40 13 41 double Iq(double q, 14 42 double sld, … … 17 45 double length) 18 46 { 19 // precompute qr and qh to save time in the loop20 const double qr = q*radius;21 const double qh = q*0.5*length;22 23 // translate a point in [-1,1] to a point in [0, pi/2]24 const double zm = M_PI_4;25 const double zb = M_PI_4;26 27 double total = 0.0;28 for (int i=0; i<76 ;i++) {29 const double alpha = Gauss76Z[i]*zm + zb;30 double sn, cn;31 SINCOS(alpha, sn, cn);32 const double fq = sinc(qh*cn) * sas_J1c(qr*sn);33 total += Gauss76Wt[i] * fq*fq * sn;34 }35 // translate dx in [-1,1] to dx in [lower,upper]36 const double form = total*zm;37 47 const double s = (sld - solvent_sld) * form_volume(radius, length); 38 return 1.0e-4 * s * s * form;48 return 1.0e-4 * s * s * orient_avg_1D(q, radius, length); 39 49 } 40 50 … … 51 61 52 62 // Compute angle alpha between q and the cylinder axis 53 SINCOS( theta*M_PI_180, sn, cn);63 SINCOS(phi*M_PI_180, sn, cn); 54 64 const double q = sqrt(qx*qx + qy*qy); 55 const double cos_val = (q==0. ? 1.0 : (cn*cos(phi*M_PI_180)*qx + sn*qy)/q); 65 const double cos_val = (q==0. ? 1.0 : (cn*qx + sn*qy)*sin(theta*M_PI_180)/q); 66 56 67 const double alpha = acos(cos_val); 57 68 58 69 SINCOS(alpha, sn, cn); 59 const double fq = sinc(q*0.5*length*cn) * sas_J1c(q*radius*sn);60 70 const double s = (sld-solvent_sld) * form_volume(radius, length); 61 return 1.0e-4 * square(s * fq );71 return 1.0e-4 * square(s * fq(q, sn, cn, radius, length)); 62 72 } -
sasmodels/models/cylinder.py
r416f5c7 r0d6e865 35 35 .. math:: 36 36 37 F^2(q)=\int_{0}^{\pi/2}{F^2(q,\ alpha)\sin(\alpha)d\alpha}37 F^2(q)=\int_{0}^{\pi/2}{F^2(q,\theta)\sin(\theta)d\theta} 38 38 39 39 … … 48 48 Definition of the angles for oriented cylinders. 49 49 50 .. figure:: img/cylinder_angle_projection.jpg51 52 Examples of the angles for oriented cylinders against the detector plane.53 50 54 51 NB: The 2nd virial coefficient of the cylinder is calculated based on the … … 77 74 78 75 P(q) = \int_0^{\pi/2} d\phi 79 \int_0^\pi p(\ theta, \phi) P_0(q,\alpha) \sin \theta\ d\theta76 \int_0^\pi p(\alpha) P_0(q,\alpha) \sin \alpha\ d\alpha 80 77 81 78 82 where $p(\theta,\phi) $ is the probability distribution for the orientation79 where $p(\theta,\phi) = 1$ is the probability distribution for the orientation 83 80 and $P_0(q,\alpha)$ is the scattering intensity for the fully oriented 84 81 system, and then comparing to the 1D result. … … 87 84 ---------- 88 85 89 None 90 86 J. S. Pedersen, Adv. Colloid Interface Sci. 70, 171-210 (1997). 87 G. Fournet, Bull. Soc. Fr. Mineral. Cristallogr. 74, 39-113 (1951). 91 88 """ 92 89 … … 123 120 "Cylinder length"], 124 121 ["theta", "degrees", 60, [-inf, inf], "orientation", 125 " In plane angle"],122 "latitude"], 126 123 ["phi", "degrees", 60, [-inf, inf], "orientation", 127 " Out of plane angle"],124 "longitude"], 128 125 ] 129 126 130 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "cylinder.c"]127 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "cylinder.c"] 131 128 132 129 def ER(radius, length): … … 148 145 149 146 qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5) 150 tests = [[{}, 0.2, 0.042761386790780453], 151 [{}, [0.2], [0.042761386790780453]], 152 [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.03514647218513852], 153 [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.03514647218513852]], 154 ] 147 # After redefinition of angles, find new tests values 148 #tests = [[{}, 0.2, 0.042761386790780453], 149 # [{}, [0.2], [0.042761386790780453]], 150 # [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.03514647218513852], 151 # [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.03514647218513852]], 152 # ] 155 153 del qx, qy # not necessary to delete, but cleaner 156 154 # ADDED by: RKH ON: 18Mar2016 renamed sld's etc -
sasmodels/models/ellipsoid.c
ra807206 r0d6e865 52 52 53 53 const double q = sqrt(qx*qx + qy*qy); 54 SINCOS(theta*M_PI_180, sn, cn); 55 // TODO: check if this is actually sin(alpha), not cos(alpha) 56 const double cos_alpha = cn*cos(phi*M_PI_180)*(qx/q) + sn*(qy/q); 57 const double form = _ellipsoid_kernel(q, radius_polar, radius_equatorial, cos_alpha); 54 SINCOS(phi*M_PI_180, sn, cn); 55 const double cos_alpha = (q==0. ? 1.0 : (cn*qx + sn*qy)*sin(theta*M_PI_180)/q); 56 const double alpha = acos(cos_alpha); 57 SINCOS(alpha, sn, cn); 58 const double form = _ellipsoid_kernel(q, radius_polar, radius_equatorial, sn); 58 59 const double s = (sld - sld_solvent) * form_volume(radius_polar, radius_equatorial); 59 60 -
sasmodels/models/ellipsoid.py
r416f5c7 r0d6e865 57 57 The $\theta$ and $\phi$ parameters are not used for the 1D output. 58 58 59 .. _ellipsoid-geometry:60 59 61 .. figure:: img/ellipsoid_angle_projection.jpg62 63 The angles for oriented ellipsoid, shown here as oblate, $a$ = $R_p$ and $b$ = $R_e$64 60 65 61 Validation -
sasmodels/models/hollow_cylinder.c
raea2e2a r0d6e865 54 54 55 55 // Cylinder orientation 56 cyl_x = cos(theta) * cos(phi);57 cyl_y = sin(theta) ;56 cyl_x = sin(theta) * cos(phi); 57 cyl_y = sin(theta) * sin(phi); 58 58 //cyl_z = -cos(theta) * sin(phi); 59 59 -
sasmodels/models/stacked_disks.c
ra807206 r0d6e865 142 142 143 143 // parallelepiped orientation 144 const double cyl_x = ct * cp;145 const double cyl_y = st ;144 const double cyl_x = st * cp; 145 const double cyl_y = st * sp; 146 146 147 147 // Compute the angle btw vector q and the -
sasmodels/models/stacked_disks.py
r7c57861 r0d6e865 77 77 the axis of the cylinder using two angles $\theta$ and $\varphi$. 78 78 79 .. figure:: img/ stacked_disks_angle_definition.jpg80 81 Examples of the angles for oriented stacked disksagainst79 .. figure:: img/cylinder_angle_definition.jpg 80 81 Examples of the angles against 82 82 the detector plane. 83 83 84 .. figure:: img/stacked_disks_angle_projection.jpg85 86 Examples of the angles for oriented pp against the detector plane.87 84 88 85 Our model uses the form factor calculations implemented in a c-library provided
Note: See TracChangeset
for help on using the changeset viewer.