Changeset 7e0b281 in sasmodels for explore/sc.c
- Timestamp:
- Apr 17, 2017 6:34:52 PM (8 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 64ca163
- Parents:
- cb038a2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
explore/sc.c
rfdd56a1 r7e0b281 1 1 static double 2 _sq_sc(double qa, double qb, double qc, double dnn, double d_factor)2 sc_Zq(double qa, double qb, double qc, double dnn, double d_factor) 3 3 { 4 4 // Rewriting equations for efficiency, accuracy and readability, and so … … 8 8 const double a3 = qc; 9 9 10 const double arg = 0.5*square(dnn*d_factor)*(a1*a1 + a2*a2 + a3*a3);10 const double arg = -0.5*square(dnn*d_factor)*(a1*a1 + a2*a2 + a3*a3); 11 11 12 12 // Numerator: (1 - exp(a)^2)^3 … … 16 16 // => exp(a)^2 - 2 cos(xk) exp(a) + 1 17 17 // => (exp(a) - 2 cos(xk)) * exp(a) + 1 18 const double exp_arg = exp( -arg);19 const double Sq = -cube(expm1(-2.0*arg))18 const double exp_arg = exp(arg); 19 const double Zq = -cube(expm1(2.0*arg)) 20 20 / ( ((exp_arg - 2.0*cos(dnn*a1))*exp_arg + 1.0) 21 21 * ((exp_arg - 2.0*cos(dnn*a2))*exp_arg + 1.0) 22 22 * ((exp_arg - 2.0*cos(dnn*a3))*exp_arg + 1.0)); 23 23 24 return Sq;24 return Zq; 25 25 } 26 26 27 27 // occupied volume fraction calculated from lattice symmetry and sphere radius 28 28 static double 29 _sc_volume_fraction(double radius, double dnn)29 sc_volume_fraction(double radius, double dnn) 30 30 { 31 31 return sphere_volume(radius/dnn); … … 98 98 const double qa = qab*cos_phi; 99 99 const double qb = qab*sin_phi; 100 const double f q = _sq_sc(qa, qb, qc, dnn, d_factor);101 inner_sum += f q;100 const double form = sc_Zq(qa, qb, qc, dnn, d_factor); 101 inner_sum += form; 102 102 } 103 103 inner_sum *= phi_m; // sum(f(x)dx) = sum(f(x)) dx … … 106 106 outer_sum *= theta_m/(n*n); 107 107 #endif 108 double Sq;108 double Zq; 109 109 if (sym > 0.) { 110 Sq = outer_sum/M_PI_2;110 Zq = outer_sum/M_PI_2; 111 111 } else { 112 Sq = outer_sum/(4.0*M_PI);112 Zq = outer_sum/(4.0*M_PI); 113 113 } 114 114 115 return Zq; 115 116 const double Pq = sphere_form(q, radius, sld, solvent_sld); 116 117 return _sc_volume_fraction(radius, dnn) * Pq * Sq; 117 return sc_volume_fraction(radius, dnn) * Pq * Zq; 118 118 } 119 119 … … 133 133 q = sqrt(qa*qa + qb*qb + qc*qc); 134 134 const double Pq = sphere_form(q, radius, sld, solvent_sld); 135 const double Sq = _sq_sc(qa, qb, qc, dnn, d_factor);136 return _sc_volume_fraction(radius, dnn) * Pq * Sq;135 const double Zq = sc_Zq(qa, qb, qc, dnn, d_factor); 136 return sc_volume_fraction(radius, dnn) * Pq * Zq; 137 137 }
Note: See TracChangeset
for help on using the changeset viewer.