[d86f0fc] | 1 | static double |
---|
| 2 | form_volume(double length_a, double b2a_ratio, double c2a_ratio) |
---|
[deb7ee0] | 3 | { |
---|
[ab2aea8] | 4 | double length_b = length_a * b2a_ratio; |
---|
| 5 | double length_c = length_a * c2a_ratio; |
---|
| 6 | double vol_shell = 2.0 * (length_a*length_b + length_a*length_c + length_b*length_c); |
---|
[deb7ee0] | 7 | return vol_shell; |
---|
| 8 | } |
---|
| 9 | |
---|
[d277229] | 10 | static double |
---|
| 11 | effective_radius(int mode, double length_a, double b2a_ratio, double c2a_ratio) |
---|
| 12 | { |
---|
| 13 | if (mode == 1) { |
---|
| 14 | return cbrt(0.75*cube(length_a)*b2a_ratio*c2a_ratio/M_PI); |
---|
| 15 | } else if (mode == 2) { |
---|
| 16 | return 0.5 * length_a; |
---|
| 17 | } else if (mode == 3) { |
---|
| 18 | return 0.5 * length_a*b2a_ratio; |
---|
| 19 | } else if (mode == 4) { |
---|
| 20 | return 0.5 * length_a*c2a_ratio; |
---|
| 21 | } else if (mode == 5) { |
---|
| 22 | return length_a*sqrt(b2a_ratio/M_PI); |
---|
| 23 | } else if (mode == 6) { |
---|
| 24 | return 0.5*sqrt(square(length_a) * (1.0 + square(b2a_ratio))); |
---|
| 25 | } else { |
---|
| 26 | return 0.5*sqrt(square(length_a) * (1.0 + square(b2a_ratio) + square(c2a_ratio))); |
---|
| 27 | } |
---|
| 28 | } |
---|
| 29 | |
---|
[71b751d] | 30 | static void |
---|
| 31 | Fq(double q, |
---|
| 32 | double *F1, |
---|
| 33 | double *F2, |
---|
[deb7ee0] | 34 | double sld, |
---|
| 35 | double solvent_sld, |
---|
[a807206] | 36 | double length_a, |
---|
[deb7ee0] | 37 | double b2a_ratio, |
---|
| 38 | double c2a_ratio) |
---|
| 39 | { |
---|
[ab2aea8] | 40 | const double length_b = length_a * b2a_ratio; |
---|
| 41 | const double length_c = length_a * c2a_ratio; |
---|
| 42 | const double a_half = 0.5 * length_a; |
---|
| 43 | const double b_half = 0.5 * length_b; |
---|
| 44 | const double c_half = 0.5 * length_c; |
---|
[deb7ee0] | 45 | |
---|
| 46 | //Integration limits to use in Gaussian quadrature |
---|
[ab2aea8] | 47 | const double v1a = 0.0; |
---|
| 48 | const double v1b = M_PI_2; //theta integration limits |
---|
| 49 | const double v2a = 0.0; |
---|
| 50 | const double v2b = M_PI_2; //phi integration limits |
---|
[74768cb] | 51 | |
---|
[71b751d] | 52 | double outer_sum_F1 = 0.0; |
---|
| 53 | double outer_sum_F2 = 0.0; |
---|
[74768cb] | 54 | for(int i=0; i<GAUSS_N; i++) { |
---|
| 55 | const double theta = 0.5 * ( GAUSS_Z[i]*(v1b-v1a) + v1a + v1b ); |
---|
[deb7ee0] | 56 | |
---|
[ab2aea8] | 57 | double sin_theta, cos_theta; |
---|
| 58 | double sin_c, cos_c; |
---|
| 59 | SINCOS(theta, sin_theta, cos_theta); |
---|
| 60 | SINCOS(q*c_half*cos_theta, sin_c, cos_c); |
---|
[deb7ee0] | 61 | |
---|
| 62 | // To check potential problems if denominator goes to zero here !!! |
---|
[ab2aea8] | 63 | const double termAL_theta = 8.0 * cos_c / (q*q*sin_theta*sin_theta); |
---|
| 64 | const double termAT_theta = 8.0 * sin_c / (q*q*sin_theta*cos_theta); |
---|
| 65 | |
---|
[71b751d] | 66 | double inner_sum_F1 = 0.0; |
---|
| 67 | double inner_sum_F2 = 0.0; |
---|
[74768cb] | 68 | for(int j=0; j<GAUSS_N; j++) { |
---|
| 69 | const double phi = 0.5 * ( GAUSS_Z[j]*(v2b-v2a) + v2a + v2b ); |
---|
[deb7ee0] | 70 | |
---|
[ab2aea8] | 71 | double sin_phi, cos_phi; |
---|
| 72 | double sin_a, cos_a; |
---|
| 73 | double sin_b, cos_b; |
---|
| 74 | SINCOS(phi, sin_phi, cos_phi); |
---|
| 75 | SINCOS(q*a_half*sin_theta*sin_phi, sin_a, cos_a); |
---|
| 76 | SINCOS(q*b_half*sin_theta*cos_phi, sin_b, cos_b); |
---|
[deb7ee0] | 77 | |
---|
| 78 | // Amplitude AL from eqn. (7c) |
---|
[ab2aea8] | 79 | const double AL = termAL_theta |
---|
| 80 | * sin_a*sin_b / (sin_phi*cos_phi); |
---|
[deb7ee0] | 81 | |
---|
| 82 | // Amplitude AT from eqn. (9) |
---|
[ab2aea8] | 83 | const double AT = termAT_theta |
---|
| 84 | * ( cos_a*sin_b/cos_phi + cos_b*sin_a/sin_phi ); |
---|
[deb7ee0] | 85 | |
---|
[71b751d] | 86 | inner_sum_F1 += GAUSS_W[j] * (AL+AT); |
---|
| 87 | inner_sum_F2 += GAUSS_W[j] * square(AL+AT); |
---|
[ab2aea8] | 88 | } |
---|
[deb7ee0] | 89 | |
---|
[71b751d] | 90 | inner_sum_F1 *= 0.5 * (v2b-v2a); |
---|
| 91 | inner_sum_F2 *= 0.5 * (v2b-v2a); |
---|
| 92 | outer_sum_F1 += GAUSS_W[i] * inner_sum_F1 * sin_theta; |
---|
| 93 | outer_sum_F2 += GAUSS_W[i] * inner_sum_F2 * sin_theta; |
---|
[deb7ee0] | 94 | } |
---|
| 95 | |
---|
[71b751d] | 96 | outer_sum_F1 *= 0.5*(v1b-v1a); |
---|
| 97 | outer_sum_F2 *= 0.5*(v1b-v1a); |
---|
[deb7ee0] | 98 | |
---|
| 99 | // Normalize as in Eqn. (15) without the volume factor (as cancels with (V*DelRho)^2 normalization) |
---|
| 100 | // The factor 2 is due to the different theta integration limit (pi/2 instead of pi) |
---|
[71b751d] | 101 | const double form_avg = outer_sum_F1/M_PI_2; |
---|
| 102 | const double form_squared_avg = outer_sum_F2/M_PI_2; |
---|
[deb7ee0] | 103 | |
---|
| 104 | // Multiply by contrast^2. Factor corresponding to volume^2 cancels with previous normalization. |
---|
[71b751d] | 105 | const double contrast = sld - solvent_sld; |
---|
[deb7ee0] | 106 | |
---|
| 107 | // Convert from [1e-12 A-1] to [cm-1] |
---|
[71b751d] | 108 | *F1 = 1e-2 * contrast * form_avg; |
---|
| 109 | *F2 = 1e-4 * contrast * contrast * form_squared_avg; |
---|
[deb7ee0] | 110 | } |
---|