[d86f0fc] | 1 | static double |
---|
| 2 | form_volume(double length_a, double b2a_ratio, double c2a_ratio) |
---|
[deb7ee0] | 3 | { |
---|
[a807206] | 4 | return length_a * (length_a*b2a_ratio) * (length_a*c2a_ratio); |
---|
[deb7ee0] | 5 | } |
---|
| 6 | |
---|
[d86f0fc] | 7 | static double |
---|
| 8 | Iq(double q, |
---|
[deb7ee0] | 9 | double sld, |
---|
| 10 | double solvent_sld, |
---|
[a807206] | 11 | double length_a, |
---|
[deb7ee0] | 12 | double b2a_ratio, |
---|
| 13 | double c2a_ratio) |
---|
| 14 | { |
---|
[ab2aea8] | 15 | const double length_b = length_a * b2a_ratio; |
---|
| 16 | const double length_c = length_a * c2a_ratio; |
---|
| 17 | const double a_half = 0.5 * length_a; |
---|
| 18 | const double b_half = 0.5 * length_b; |
---|
| 19 | const double c_half = 0.5 * length_c; |
---|
[deb7ee0] | 20 | |
---|
| 21 | //Integration limits to use in Gaussian quadrature |
---|
[ab2aea8] | 22 | const double v1a = 0.0; |
---|
| 23 | const double v1b = M_PI_2; //theta integration limits |
---|
| 24 | const double v2a = 0.0; |
---|
| 25 | const double v2b = M_PI_2; //phi integration limits |
---|
[8de1477] | 26 | |
---|
[ab2aea8] | 27 | double outer_sum = 0.0; |
---|
[74768cb] | 28 | for(int i=0; i<GAUSS_N; i++) { |
---|
| 29 | const double theta = 0.5 * ( GAUSS_Z[i]*(v1b-v1a) + v1a + v1b ); |
---|
[ab2aea8] | 30 | double sin_theta, cos_theta; |
---|
| 31 | SINCOS(theta, sin_theta, cos_theta); |
---|
| 32 | |
---|
[1e7b0db0] | 33 | const double termC = sas_sinx_x(q * c_half * cos_theta); |
---|
[ab2aea8] | 34 | |
---|
| 35 | double inner_sum = 0.0; |
---|
[74768cb] | 36 | for(int j=0; j<GAUSS_N; j++) { |
---|
| 37 | double phi = 0.5 * ( GAUSS_Z[j]*(v2b-v2a) + v2a + v2b ); |
---|
[ab2aea8] | 38 | double sin_phi, cos_phi; |
---|
| 39 | SINCOS(phi, sin_phi, cos_phi); |
---|
| 40 | |
---|
| 41 | // Amplitude AP from eqn. (12), rewritten to avoid round-off effects when arg=0 |
---|
[1e7b0db0] | 42 | const double termA = sas_sinx_x(q * a_half * sin_theta * sin_phi); |
---|
| 43 | const double termB = sas_sinx_x(q * b_half * sin_theta * cos_phi); |
---|
[ab2aea8] | 44 | const double AP = termA * termB * termC; |
---|
[74768cb] | 45 | inner_sum += GAUSS_W[j] * AP * AP; |
---|
[ab2aea8] | 46 | } |
---|
| 47 | inner_sum = 0.5 * (v2b-v2a) * inner_sum; |
---|
[74768cb] | 48 | outer_sum += GAUSS_W[i] * inner_sum * sin_theta; |
---|
[deb7ee0] | 49 | } |
---|
| 50 | |
---|
[ab2aea8] | 51 | double answer = 0.5*(v1b-v1a)*outer_sum; |
---|
[deb7ee0] | 52 | |
---|
[8de1477] | 53 | // Normalize by Pi (Eqn. 16). |
---|
| 54 | // The term (ABC)^2 does not appear because it was introduced before on |
---|
[deb7ee0] | 55 | // the definitions of termA, termB, termC. |
---|
[8de1477] | 56 | // The factor 2 appears because the theta integral has been defined between |
---|
[deb7ee0] | 57 | // 0 and pi/2, instead of 0 to pi. |
---|
[3a48772] | 58 | answer /= M_PI_2; //Form factor P(q) |
---|
[deb7ee0] | 59 | |
---|
| 60 | // Multiply by contrast^2 and volume^2 |
---|
[ab2aea8] | 61 | const double volume = length_a * length_b * length_c; |
---|
| 62 | answer *= square((sld-solvent_sld)*volume); |
---|
[deb7ee0] | 63 | |
---|
[8de1477] | 64 | // Convert from [1e-12 A-1] to [cm-1] |
---|
[deb7ee0] | 65 | answer *= 1.0e-4; |
---|
| 66 | |
---|
| 67 | return answer; |
---|
| 68 | } |
---|
[8de1477] | 69 | |
---|
| 70 | |
---|
[d86f0fc] | 71 | static double |
---|
| 72 | Iqabc(double qa, double qb, double qc, |
---|
[8de1477] | 73 | double sld, |
---|
| 74 | double solvent_sld, |
---|
| 75 | double length_a, |
---|
| 76 | double b2a_ratio, |
---|
| 77 | double c2a_ratio) |
---|
| 78 | { |
---|
| 79 | const double length_b = length_a * b2a_ratio; |
---|
| 80 | const double length_c = length_a * c2a_ratio; |
---|
| 81 | const double a_half = 0.5 * length_a; |
---|
| 82 | const double b_half = 0.5 * length_b; |
---|
| 83 | const double c_half = 0.5 * length_c; |
---|
| 84 | const double volume = length_a * length_b * length_c; |
---|
| 85 | |
---|
| 86 | // Amplitude AP from eqn. (13) |
---|
| 87 | |
---|
| 88 | const double termA = sas_sinx_x(qa * a_half); |
---|
| 89 | const double termB = sas_sinx_x(qb * b_half); |
---|
| 90 | const double termC = sas_sinx_x(qc * c_half); |
---|
| 91 | |
---|
| 92 | const double AP = termA * termB * termC; |
---|
| 93 | |
---|
| 94 | // Multiply by contrast^2. Factor corresponding to volume^2 cancels with previous normalization. |
---|
| 95 | const double delrho = sld - solvent_sld; |
---|
| 96 | |
---|
| 97 | // Convert from [1e-12 A-1] to [cm-1] |
---|
| 98 | return 1.0e-4 * square(volume * delrho * AP); |
---|
| 99 | } |
---|