[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 | |
---|
[d277229] | 15 | static double |
---|
| 16 | effective_radius(int mode, double length_a, double b2a_ratio, double c2a_ratio, double thickness) |
---|
| 17 | { |
---|
| 18 | if (mode == 1) { |
---|
| 19 | return cbrt(0.75*cube(length_a)*b2a_ratio*c2a_ratio/M_PI); |
---|
| 20 | } else if (mode == 2) { |
---|
| 21 | return 0.5 * length_a; |
---|
| 22 | } else if (mode == 3) { |
---|
| 23 | return 0.5 * length_a*b2a_ratio; |
---|
| 24 | } else if (mode == 4) { |
---|
| 25 | return 0.5 * length_a*c2a_ratio; |
---|
| 26 | } else if (mode == 5) { |
---|
| 27 | return length_a*sqrt(b2a_ratio/M_PI); |
---|
| 28 | } else if (mode == 6) { |
---|
| 29 | return 0.5*sqrt(square(length_a) * (1.0 + square(b2a_ratio))); |
---|
| 30 | } else { |
---|
| 31 | return 0.5*sqrt(square(length_a) * (1.0 + square(b2a_ratio) + square(c2a_ratio))); |
---|
| 32 | } |
---|
| 33 | } |
---|
| 34 | |
---|
[71b751d] | 35 | static void |
---|
| 36 | Fq(double q, |
---|
| 37 | double *F1, |
---|
| 38 | double *F2, |
---|
[deb7ee0] | 39 | double sld, |
---|
| 40 | double solvent_sld, |
---|
[a807206] | 41 | double length_a, |
---|
[deb7ee0] | 42 | double b2a_ratio, |
---|
| 43 | double c2a_ratio, |
---|
| 44 | double thickness) |
---|
| 45 | { |
---|
[6f676fb] | 46 | const double length_b = length_a * b2a_ratio; |
---|
| 47 | const double length_c = length_a * c2a_ratio; |
---|
| 48 | const double a_half = 0.5 * length_a; |
---|
| 49 | const double b_half = 0.5 * length_b; |
---|
| 50 | const double c_half = 0.5 * length_c; |
---|
| 51 | const double vol_total = length_a * length_b * length_c; |
---|
| 52 | const double vol_core = 8.0 * (a_half-thickness) * (b_half-thickness) * (c_half-thickness); |
---|
[deb7ee0] | 53 | |
---|
[ab2aea8] | 54 | //Integration limits to use in Gaussian quadrature |
---|
[6f676fb] | 55 | const double v1a = 0.0; |
---|
| 56 | const double v1b = M_PI_2; //theta integration limits |
---|
| 57 | const double v2a = 0.0; |
---|
| 58 | const double v2b = M_PI_2; //phi integration limits |
---|
[8de1477] | 59 | |
---|
[71b751d] | 60 | double outer_sum_F1 = 0.0; |
---|
| 61 | double outer_sum_F2 = 0.0; |
---|
[74768cb] | 62 | for(int i=0; i<GAUSS_N; i++) { |
---|
[deb7ee0] | 63 | |
---|
[74768cb] | 64 | const double theta = 0.5 * ( GAUSS_Z[i]*(v1b-v1a) + v1a + v1b ); |
---|
[6f676fb] | 65 | double sin_theta, cos_theta; |
---|
| 66 | SINCOS(theta, sin_theta, cos_theta); |
---|
[deb7ee0] | 67 | |
---|
[1e7b0db0] | 68 | const double termC1 = sas_sinx_x(q * c_half * cos(theta)); |
---|
| 69 | const double termC2 = sas_sinx_x(q * (c_half-thickness)*cos(theta)); |
---|
[deb7ee0] | 70 | |
---|
[71b751d] | 71 | double inner_sum_F1 = 0.0; |
---|
| 72 | double inner_sum_F2 = 0.0; |
---|
[74768cb] | 73 | for(int j=0; j<GAUSS_N; j++) { |
---|
[deb7ee0] | 74 | |
---|
[74768cb] | 75 | const double phi = 0.5 * ( GAUSS_Z[j]*(v2b-v2a) + v2a + v2b ); |
---|
[6f676fb] | 76 | double sin_phi, cos_phi; |
---|
| 77 | SINCOS(phi, sin_phi, cos_phi); |
---|
[deb7ee0] | 78 | |
---|
| 79 | // Amplitude AP from eqn. (13), rewritten to avoid round-off effects when arg=0 |
---|
| 80 | |
---|
[1e7b0db0] | 81 | const double termA1 = sas_sinx_x(q * a_half * sin_theta * sin_phi); |
---|
| 82 | const double termA2 = sas_sinx_x(q * (a_half-thickness) * sin_theta * sin_phi); |
---|
[deb7ee0] | 83 | |
---|
[1e7b0db0] | 84 | const double termB1 = sas_sinx_x(q * b_half * sin_theta * cos_phi); |
---|
| 85 | const double termB2 = sas_sinx_x(q * (b_half-thickness) * sin_theta * cos_phi); |
---|
[deb7ee0] | 86 | |
---|
[6f676fb] | 87 | const double AP1 = vol_total * termA1 * termB1 * termC1; |
---|
| 88 | const double AP2 = vol_core * termA2 * termB2 * termC2; |
---|
[deb7ee0] | 89 | |
---|
[71b751d] | 90 | inner_sum_F1 += GAUSS_W[j] * (AP1-AP2); |
---|
| 91 | inner_sum_F2 += GAUSS_W[j] * square(AP1-AP2); |
---|
[ab2aea8] | 92 | } |
---|
[71b751d] | 93 | inner_sum_F1 *= 0.5 * (v2b-v2a); |
---|
| 94 | inner_sum_F2 *= 0.5 * (v2b-v2a); |
---|
[deb7ee0] | 95 | |
---|
[71b751d] | 96 | outer_sum_F1 += GAUSS_W[i] * inner_sum_F1 * sin(theta); |
---|
| 97 | outer_sum_F2 += GAUSS_W[i] * inner_sum_F2 * sin(theta); |
---|
[deb7ee0] | 98 | } |
---|
[71b751d] | 99 | outer_sum_F1 *= 0.5*(v1b-v1a); |
---|
| 100 | outer_sum_F2 *= 0.5*(v1b-v1a); |
---|
[deb7ee0] | 101 | |
---|
| 102 | // Normalize as in Eqn. (15) without the volume factor (as cancels with (V*DelRho)^2 normalization) |
---|
| 103 | // The factor 2 is due to the different theta integration limit (pi/2 instead of pi) |
---|
[71b751d] | 104 | const double form_avg = outer_sum_F1/M_PI_2; |
---|
| 105 | const double form_squared_avg = outer_sum_F2/M_PI_2; |
---|
[deb7ee0] | 106 | |
---|
| 107 | // Multiply by contrast^2. Factor corresponding to volume^2 cancels with previous normalization. |
---|
[71b751d] | 108 | const double contrast = sld - solvent_sld; |
---|
[deb7ee0] | 109 | |
---|
| 110 | // Convert from [1e-12 A-1] to [cm-1] |
---|
[71b751d] | 111 | *F1 = 1.0e-2 * contrast * form_avg; |
---|
| 112 | *F2 = 1.0e-4 * contrast * contrast * form_squared_avg; |
---|
[deb7ee0] | 113 | } |
---|
[8de1477] | 114 | |
---|
[d86f0fc] | 115 | static double |
---|
| 116 | Iqabc(double qa, double qb, double qc, |
---|
[8de1477] | 117 | double sld, |
---|
| 118 | double solvent_sld, |
---|
| 119 | double length_a, |
---|
| 120 | double b2a_ratio, |
---|
| 121 | double c2a_ratio, |
---|
| 122 | double thickness) |
---|
| 123 | { |
---|
| 124 | const double length_b = length_a * b2a_ratio; |
---|
| 125 | const double length_c = length_a * c2a_ratio; |
---|
| 126 | const double a_half = 0.5 * length_a; |
---|
| 127 | const double b_half = 0.5 * length_b; |
---|
| 128 | const double c_half = 0.5 * length_c; |
---|
| 129 | const double vol_total = length_a * length_b * length_c; |
---|
| 130 | const double vol_core = 8.0 * (a_half-thickness) * (b_half-thickness) * (c_half-thickness); |
---|
| 131 | |
---|
| 132 | // Amplitude AP from eqn. (13) |
---|
| 133 | |
---|
| 134 | const double termA1 = sas_sinx_x(qa * a_half); |
---|
| 135 | const double termA2 = sas_sinx_x(qa * (a_half-thickness)); |
---|
| 136 | |
---|
| 137 | const double termB1 = sas_sinx_x(qb * b_half); |
---|
| 138 | const double termB2 = sas_sinx_x(qb * (b_half-thickness)); |
---|
| 139 | |
---|
| 140 | const double termC1 = sas_sinx_x(qc * c_half); |
---|
| 141 | const double termC2 = sas_sinx_x(qc * (c_half-thickness)); |
---|
| 142 | |
---|
| 143 | const double AP1 = vol_total * termA1 * termB1 * termC1; |
---|
| 144 | const double AP2 = vol_core * termA2 * termB2 * termC2; |
---|
| 145 | |
---|
| 146 | // Multiply by contrast^2. Factor corresponding to volume^2 cancels with previous normalization. |
---|
| 147 | const double delrho = sld - solvent_sld; |
---|
| 148 | |
---|
| 149 | // Convert from [1e-12 A-1] to [cm-1] |
---|
| 150 | return 1.0e-4 * square(delrho * (AP1-AP2)); |
---|
[71b751d] | 151 | } |
---|