Changeset 1fdb555 in sasmodels for sasmodels/models
- Timestamp:
- Oct 11, 2016 11:42:26 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:
- ef5a314
- Parents:
- 0d6e865 (diff), 483a022 (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:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/core_shell_bicelle.py
r0d6e865 r1fdb555 40 40 .. math:: 41 41 42 I(Q,\alpha) = \frac{\text{scale}}{V } \cdot42 I(Q,\alpha) = \frac{\text{scale}}{V_t} \cdot 43 43 F(Q,\alpha)^2 + \text{background} 44 44 -
sasmodels/models/multilayer_vesicle.py
r19e7ca7 r041bc75 15 15 16 16 See the :ref:`core-shell-sphere` model for more documentation. 17 18 The 1D scattering intensity is calculated in the following way (Guinier, 1955) 19 20 .. math:: 21 22 P(q) = \frac{\text{scale.volfraction}}{V_t} F^2(q) + \text{background} 23 24 where 25 26 .. math:: 27 28 F(q) = (\rho_{shell}-\rho_{solv}) \sum_{i=1}^{n\_pairs} \left[ 29 3V(R_i)\frac{\sin(qR_i)-qR_i\cos(qR_i)}{(qR_i)^3} \\ 30 - 3V(R_i+t_s)\frac{\sin(q(R_i+t_s))-q(R_i+t_s)\cos(q(R_i+t_s))}{(q(R_i+t_s))^3} 31 \right] 32 33 34 where $R_i = r_c + (i-1)(t_s + t_w)$ 35 36 where $V_t$ is the volume of the whole particle, $V(R)$ is the volume of a sphere 37 of radius $R$, $r_c$ is the radius of the core, $\rho_{shell}$ is the scattering length 38 density of a shell, $\rho_{solv}$ is the scattering length density of the solvent. 39 17 40 18 41 The 2D scattering intensity is the same as 1D, regardless of the orientation -
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_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
re9b1663d 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.