Changeset 2a0b2b1 in sasmodels for sasmodels/models/capped_cylinder.c
- Timestamp:
- Apr 14, 2017 8:30:29 AM (7 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- fdd56a1
- Parents:
- 9901384
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/capped_cylinder.c
r592343f r2a0b2b1 14 14 // radius_cap is the radius of the lens 15 15 // length is the cylinder length, or the separation between the lens halves 16 // alpha is the angle of the cylinder wrt q.16 // theta is the angle of the cylinder wrt q. 17 17 static double 18 _cap_kernel(double q , double h, double radius_cap,19 double half_length, double sin_alpha, double cos_alpha)18 _cap_kernel(double qab, double qc, double h, double radius_cap, 19 double half_length) 20 20 { 21 21 // translate a point in [-1,1] to a point in [lower,upper] … … 26 26 27 27 // cos term in integral is: 28 // cos (q (R t - h + L/2) cos( alpha))28 // cos (q (R t - h + L/2) cos(theta)) 29 29 // so turn it into: 30 30 // cos (m t + b) 31 31 // where: 32 // m = q R cos( alpha)33 // b = q(L/2-h) cos( alpha)34 const double m = q*radius_cap*cos_alpha; // cos argument slope35 const double b = q*(half_length-h)*cos_alpha; // cos argument intercept36 const double q rst = q*radius_cap*sin_alpha; // Q*R*sin(theta)32 // m = q R cos(theta) 33 // b = q(L/2-h) cos(theta) 34 const double m = radius_cap*qc; // cos argument slope 35 const double b = (half_length-h)*qc; // cos argument intercept 36 const double qab_r = radius_cap*qab; // Q*R*sin(theta) 37 37 double total = 0.0; 38 38 for (int i=0; i<76 ;i++) { 39 39 const double t = Gauss76Z[i]*zm + zb; 40 40 const double radical = 1.0 - t*t; 41 const double bj = sas_2J1x_x(q rst*sqrt(radical));41 const double bj = sas_2J1x_x(qab_r*sqrt(radical)); 42 42 const double Fq = cos(m*t + b) * radical * bj; 43 43 total += Gauss76Wt[i] * Fq; … … 50 50 51 51 static double 52 _fq(double q, double h, double radius_cap, double radius, double half_length, 53 double sin_alpha, double cos_alpha) 52 _fq(double qab, double qc, double h, double radius_cap, double radius, double half_length) 54 53 { 55 const double cap_Fq = _cap_kernel(q , h, radius_cap, half_length, sin_alpha, cos_alpha);56 const double bj = sas_2J1x_x( q*radius*sin_alpha);57 const double si = sas_sinx_x( q*half_length*cos_alpha);54 const double cap_Fq = _cap_kernel(qab, qc, h, radius_cap, half_length); 55 const double bj = sas_2J1x_x(radius*qab); 56 const double si = sas_sinx_x(half_length*qc); 58 57 const double cyl_Fq = 2.0*M_PI*radius*radius*half_length*bj*si; 59 58 const double Aq = cap_Fq + cyl_Fq; … … 101 100 double total = 0.0; 102 101 for (int i=0; i<76 ;i++) { 103 const double alpha= Gauss76Z[i]*zm + zb; 104 double sin_alpha, cos_alpha; // slots to hold sincos function output 105 SINCOS(alpha, sin_alpha, cos_alpha); 106 107 const double Aq = _fq(q, h, radius_cap, radius, half_length, sin_alpha, cos_alpha); 108 // sin_alpha for spherical coord integration 109 total += Gauss76Wt[i] * Aq * Aq * sin_alpha; 102 const double theta = Gauss76Z[i]*zm + zb; 103 double sin_theta, cos_theta; // slots to hold sincos function output 104 SINCOS(theta, sin_theta, cos_theta); 105 const double qab = q*sin_theta; 106 const double qc = q*cos_theta; 107 const double Aq = _fq(qab, qc, h, radius_cap, radius, half_length); 108 // scale by sin_theta for spherical coord integration 109 total += Gauss76Wt[i] * Aq * Aq * sin_theta; 110 110 } 111 111 // translate dx in [-1,1] to dx in [lower,upper] … … 125 125 double q, sin_alpha, cos_alpha; 126 126 ORIENT_SYMMETRIC(qx, qy, theta, phi, q, sin_alpha, cos_alpha); 127 const double qab = q*sin_alpha; 128 const double qc = q*cos_alpha; 127 129 128 130 const double h = sqrt(radius_cap*radius_cap - radius*radius); 129 const double Aq = _fq(q , h, radius_cap, radius, 0.5*length, sin_alpha, cos_alpha);131 const double Aq = _fq(qab, qc, h, radius_cap, radius, 0.5*length); 130 132 131 133 // Multiply by contrast^2 and convert to cm-1
Note: See TracChangeset
for help on using the changeset viewer.