[2a0b2b1] | 1 | static double |
---|
[7e0b281] | 2 | fcc_Zq(double qa, double qb, double qc, double dnn, double d_factor) |
---|
[2a0b2b1] | 3 | { |
---|
[7e0b281] | 4 | #if 0 // Equations as written in Matsuoka |
---|
| 5 | const double a1 = ( qa + qb)/2.0; |
---|
| 6 | const double a2 = (-qa + qc)/2.0; |
---|
| 7 | const double a3 = (-qa + qb)/2.0; |
---|
| 8 | #else |
---|
| 9 | const double a1 = ( qa + qb)/2.0; |
---|
| 10 | const double a2 = ( qa + qc)/2.0; |
---|
| 11 | const double a3 = ( qb + qc)/2.0; |
---|
| 12 | #endif |
---|
[2a0b2b1] | 13 | |
---|
| 14 | // Numerator: (1 - exp(a)^2)^3 |
---|
| 15 | // => (-(exp(2a) - 1))^3 |
---|
| 16 | // => -expm1(2a)^3 |
---|
[7e0b281] | 17 | // Denominator: prod(1 - 2 cos(d ak) exp(a) + exp(2a)) |
---|
| 18 | // => prod(exp(a)^2 - 2 cos(d ak) exp(a) + 1) |
---|
| 19 | // => prod((exp(a) - 2 cos(d ak)) * exp(a) + 1) |
---|
| 20 | const double arg = -0.5*square(dnn*d_factor)*(a1*a1 + a2*a2 + a3*a3); |
---|
| 21 | const double exp_arg = exp(arg); |
---|
| 22 | const double Zq = -cube(expm1(2.0*arg)) |
---|
| 23 | / ( ((exp_arg - 2.0*cos(dnn*a1))*exp_arg + 1.0) |
---|
| 24 | * ((exp_arg - 2.0*cos(dnn*a2))*exp_arg + 1.0) |
---|
| 25 | * ((exp_arg - 2.0*cos(dnn*a3))*exp_arg + 1.0)); |
---|
[2a0b2b1] | 26 | |
---|
[7e0b281] | 27 | return Zq; |
---|
[3271e20] | 28 | } |
---|
| 29 | |
---|
[82d239a] | 30 | |
---|
[2a0b2b1] | 31 | // occupied volume fraction calculated from lattice symmetry and sphere radius |
---|
| 32 | static double |
---|
[7e0b281] | 33 | fcc_volume_fraction(double radius, double dnn) |
---|
[2a0b2b1] | 34 | { |
---|
| 35 | return 4.0*sphere_volume(M_SQRT1_2*radius/dnn); |
---|
[3271e20] | 36 | } |
---|
| 37 | |
---|
[2a0b2b1] | 38 | static double |
---|
| 39 | form_volume(double radius) |
---|
| 40 | { |
---|
[ad90df9] | 41 | return sphere_volume(radius); |
---|
[3271e20] | 42 | } |
---|
| 43 | |
---|
| 44 | |
---|
[2a0b2b1] | 45 | static double Iq(double q, double dnn, |
---|
[3271e20] | 46 | double d_factor, double radius, |
---|
[2a0b2b1] | 47 | double sld, double solvent_sld) |
---|
| 48 | { |
---|
| 49 | // translate a point in [-1,1] to a point in [0, 2 pi] |
---|
| 50 | const double phi_m = M_PI; |
---|
| 51 | const double phi_b = M_PI; |
---|
| 52 | // translate a point in [-1,1] to a point in [0, pi] |
---|
| 53 | const double theta_m = M_PI_2; |
---|
| 54 | const double theta_b = M_PI_2; |
---|
| 55 | |
---|
| 56 | double outer_sum = 0.0; |
---|
| 57 | for(int i=0; i<150; i++) { |
---|
| 58 | double inner_sum = 0.0; |
---|
| 59 | const double theta = Gauss150Z[i]*theta_m + theta_b; |
---|
| 60 | double sin_theta, cos_theta; |
---|
| 61 | SINCOS(theta, sin_theta, cos_theta); |
---|
| 62 | const double qc = q*cos_theta; |
---|
| 63 | const double qab = q*sin_theta; |
---|
| 64 | for(int j=0;j<150;j++) { |
---|
| 65 | const double phi = Gauss150Z[j]*phi_m + phi_b; |
---|
| 66 | double sin_phi, cos_phi; |
---|
| 67 | SINCOS(phi, sin_phi, cos_phi); |
---|
| 68 | const double qa = qab*cos_phi; |
---|
| 69 | const double qb = qab*sin_phi; |
---|
[7e0b281] | 70 | const double form = fcc_Zq(qa, qb, qc, dnn, d_factor); |
---|
| 71 | inner_sum += Gauss150Wt[j] * form; |
---|
[2a0b2b1] | 72 | } |
---|
| 73 | inner_sum *= phi_m; // sum(f(x)dx) = sum(f(x)) dx |
---|
| 74 | outer_sum += Gauss150Wt[i] * inner_sum * sin_theta; |
---|
| 75 | } |
---|
| 76 | outer_sum *= theta_m; |
---|
[7e0b281] | 77 | const double Zq = outer_sum/(4.0*M_PI); |
---|
[2a0b2b1] | 78 | const double Pq = sphere_form(q, radius, sld, solvent_sld); |
---|
| 79 | |
---|
[7e0b281] | 80 | return fcc_volume_fraction(radius, dnn) * Pq * Zq; |
---|
[3271e20] | 81 | } |
---|
| 82 | |
---|
[2a0b2b1] | 83 | |
---|
| 84 | static double Iqxy(double qx, double qy, |
---|
[11ca2ab] | 85 | double dnn, double d_factor, double radius, |
---|
| 86 | double sld, double solvent_sld, |
---|
| 87 | double theta, double phi, double psi) |
---|
| 88 | { |
---|
[50beefe] | 89 | double q, zhat, yhat, xhat; |
---|
| 90 | ORIENT_ASYMMETRIC(qx, qy, theta, phi, psi, q, xhat, yhat, zhat); |
---|
[2a0b2b1] | 91 | const double qa = q*xhat; |
---|
| 92 | const double qb = q*yhat; |
---|
| 93 | const double qc = q*zhat; |
---|
| 94 | |
---|
| 95 | q = sqrt(qa*qa + qb*qb + qc*qc); |
---|
| 96 | const double Pq = sphere_form(q, radius, sld, solvent_sld); |
---|
[7e0b281] | 97 | const double Zq = fcc_Zq(qa, qb, qc, dnn, d_factor); |
---|
| 98 | return fcc_volume_fraction(radius, dnn) * Pq * Zq; |
---|
[2a0b2b1] | 99 | } |
---|