Changeset 0d6e865 in sasmodels for sasmodels/models/cylinder.c
- Timestamp:
- Oct 11, 2016 11:42:00 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:
- 1fdb555
- Parents:
- 19e7ca7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.