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