[d86f0fc] | 1 | static double |
---|
| 2 | form_volume(double length_a, double b2a_ratio, double c2a_ratio, double thickness) |
---|
[deb7ee0] | 3 | { |
---|
[ab2aea8] | 4 | double length_b = length_a * b2a_ratio; |
---|
| 5 | double length_c = length_a * c2a_ratio; |
---|
[a807206] | 6 | double a_core = length_a - 2.0*thickness; |
---|
[ab2aea8] | 7 | double b_core = length_b - 2.0*thickness; |
---|
| 8 | double c_core = length_c - 2.0*thickness; |
---|
[deb7ee0] | 9 | double vol_core = a_core * b_core * c_core; |
---|
[ab2aea8] | 10 | double vol_total = length_a * length_b * length_c; |
---|
[deb7ee0] | 11 | double vol_shell = vol_total - vol_core; |
---|
| 12 | return vol_shell; |
---|
| 13 | } |
---|
| 14 | |
---|
[d86f0fc] | 15 | static double |
---|
| 16 | Iq(double q, |
---|
[deb7ee0] | 17 | double sld, |
---|
| 18 | double solvent_sld, |
---|
[a807206] | 19 | double length_a, |
---|
[deb7ee0] | 20 | double b2a_ratio, |
---|
| 21 | double c2a_ratio, |
---|
| 22 | double thickness) |
---|
| 23 | { |
---|
[6f676fb] | 24 | const double length_b = length_a * b2a_ratio; |
---|
| 25 | const double length_c = length_a * c2a_ratio; |
---|
| 26 | const double a_half = 0.5 * length_a; |
---|
| 27 | const double b_half = 0.5 * length_b; |
---|
| 28 | const double c_half = 0.5 * length_c; |
---|
| 29 | const double vol_total = length_a * length_b * length_c; |
---|
| 30 | const double vol_core = 8.0 * (a_half-thickness) * (b_half-thickness) * (c_half-thickness); |
---|
[deb7ee0] | 31 | |
---|
[ab2aea8] | 32 | //Integration limits to use in Gaussian quadrature |
---|
[6f676fb] | 33 | const double v1a = 0.0; |
---|
| 34 | const double v1b = M_PI_2; //theta integration limits |
---|
| 35 | const double v2a = 0.0; |
---|
| 36 | const double v2b = M_PI_2; //phi integration limits |
---|
[8de1477] | 37 | |
---|
[ab2aea8] | 38 | double outer_sum = 0.0; |
---|
[74768cb] | 39 | for(int i=0; i<GAUSS_N; i++) { |
---|
[deb7ee0] | 40 | |
---|
[74768cb] | 41 | const double theta = 0.5 * ( GAUSS_Z[i]*(v1b-v1a) + v1a + v1b ); |
---|
[6f676fb] | 42 | double sin_theta, cos_theta; |
---|
| 43 | SINCOS(theta, sin_theta, cos_theta); |
---|
[deb7ee0] | 44 | |
---|
[1e7b0db0] | 45 | const double termC1 = sas_sinx_x(q * c_half * cos(theta)); |
---|
| 46 | const double termC2 = sas_sinx_x(q * (c_half-thickness)*cos(theta)); |
---|
[deb7ee0] | 47 | |
---|
[ab2aea8] | 48 | double inner_sum = 0.0; |
---|
[74768cb] | 49 | for(int j=0; j<GAUSS_N; j++) { |
---|
[deb7ee0] | 50 | |
---|
[74768cb] | 51 | const double phi = 0.5 * ( GAUSS_Z[j]*(v2b-v2a) + v2a + v2b ); |
---|
[6f676fb] | 52 | double sin_phi, cos_phi; |
---|
| 53 | SINCOS(phi, sin_phi, cos_phi); |
---|
[deb7ee0] | 54 | |
---|
| 55 | // Amplitude AP from eqn. (13), rewritten to avoid round-off effects when arg=0 |
---|
| 56 | |
---|
[1e7b0db0] | 57 | const double termA1 = sas_sinx_x(q * a_half * sin_theta * sin_phi); |
---|
| 58 | const double termA2 = sas_sinx_x(q * (a_half-thickness) * sin_theta * sin_phi); |
---|
[deb7ee0] | 59 | |
---|
[1e7b0db0] | 60 | const double termB1 = sas_sinx_x(q * b_half * sin_theta * cos_phi); |
---|
| 61 | const double termB2 = sas_sinx_x(q * (b_half-thickness) * sin_theta * cos_phi); |
---|
[deb7ee0] | 62 | |
---|
[6f676fb] | 63 | const double AP1 = vol_total * termA1 * termB1 * termC1; |
---|
| 64 | const double AP2 = vol_core * termA2 * termB2 * termC2; |
---|
[deb7ee0] | 65 | |
---|
[74768cb] | 66 | inner_sum += GAUSS_W[j] * square(AP1-AP2); |
---|
[ab2aea8] | 67 | } |
---|
[6f676fb] | 68 | inner_sum *= 0.5 * (v2b-v2a); |
---|
[deb7ee0] | 69 | |
---|
[74768cb] | 70 | outer_sum += GAUSS_W[i] * inner_sum * sin(theta); |
---|
[deb7ee0] | 71 | } |
---|
[6f676fb] | 72 | outer_sum *= 0.5*(v1b-v1a); |
---|
[deb7ee0] | 73 | |
---|
| 74 | // Normalize as in Eqn. (15) without the volume factor (as cancels with (V*DelRho)^2 normalization) |
---|
| 75 | // The factor 2 is due to the different theta integration limit (pi/2 instead of pi) |
---|
[6f676fb] | 76 | const double form = outer_sum/M_PI_2; |
---|
[deb7ee0] | 77 | |
---|
| 78 | // Multiply by contrast^2. Factor corresponding to volume^2 cancels with previous normalization. |
---|
[6f676fb] | 79 | const double delrho = sld - solvent_sld; |
---|
[deb7ee0] | 80 | |
---|
| 81 | // Convert from [1e-12 A-1] to [cm-1] |
---|
[6f676fb] | 82 | return 1.0e-4 * delrho * delrho * form; |
---|
[deb7ee0] | 83 | } |
---|
[8de1477] | 84 | |
---|
[d86f0fc] | 85 | static double |
---|
| 86 | Iqabc(double qa, double qb, double qc, |
---|
[8de1477] | 87 | double sld, |
---|
| 88 | double solvent_sld, |
---|
| 89 | double length_a, |
---|
| 90 | double b2a_ratio, |
---|
| 91 | double c2a_ratio, |
---|
| 92 | double thickness) |
---|
| 93 | { |
---|
| 94 | const double length_b = length_a * b2a_ratio; |
---|
| 95 | const double length_c = length_a * c2a_ratio; |
---|
| 96 | const double a_half = 0.5 * length_a; |
---|
| 97 | const double b_half = 0.5 * length_b; |
---|
| 98 | const double c_half = 0.5 * length_c; |
---|
| 99 | const double vol_total = length_a * length_b * length_c; |
---|
| 100 | const double vol_core = 8.0 * (a_half-thickness) * (b_half-thickness) * (c_half-thickness); |
---|
| 101 | |
---|
| 102 | // Amplitude AP from eqn. (13) |
---|
| 103 | |
---|
| 104 | const double termA1 = sas_sinx_x(qa * a_half); |
---|
| 105 | const double termA2 = sas_sinx_x(qa * (a_half-thickness)); |
---|
| 106 | |
---|
| 107 | const double termB1 = sas_sinx_x(qb * b_half); |
---|
| 108 | const double termB2 = sas_sinx_x(qb * (b_half-thickness)); |
---|
| 109 | |
---|
| 110 | const double termC1 = sas_sinx_x(qc * c_half); |
---|
| 111 | const double termC2 = sas_sinx_x(qc * (c_half-thickness)); |
---|
| 112 | |
---|
| 113 | const double AP1 = vol_total * termA1 * termB1 * termC1; |
---|
| 114 | const double AP2 = vol_core * termA2 * termB2 * termC2; |
---|
| 115 | |
---|
| 116 | // Multiply by contrast^2. Factor corresponding to volume^2 cancels with previous normalization. |
---|
| 117 | const double delrho = sld - solvent_sld; |
---|
| 118 | |
---|
| 119 | // Convert from [1e-12 A-1] to [cm-1] |
---|
| 120 | return 1.0e-4 * square(delrho * (AP1-AP2)); |
---|
| 121 | } |
---|