[a807206] | 1 | double form_volume(double length_a, double b2a_ratio, double c2a_ratio); |
---|
| 2 | double Iq(double q, double sld, double solvent_sld, double length_a, |
---|
[deb7ee0] | 3 | double b2a_ratio, double c2a_ratio); |
---|
| 4 | |
---|
[a807206] | 5 | double form_volume(double length_a, double b2a_ratio, double c2a_ratio) |
---|
[deb7ee0] | 6 | { |
---|
[a807206] | 7 | return length_a * (length_a*b2a_ratio) * (length_a*c2a_ratio); |
---|
[deb7ee0] | 8 | } |
---|
| 9 | |
---|
| 10 | double Iq(double q, |
---|
| 11 | double sld, |
---|
| 12 | double solvent_sld, |
---|
[a807206] | 13 | double length_a, |
---|
[deb7ee0] | 14 | double b2a_ratio, |
---|
| 15 | double c2a_ratio) |
---|
| 16 | { |
---|
[ab2aea8] | 17 | const double length_b = length_a * b2a_ratio; |
---|
| 18 | const double length_c = length_a * c2a_ratio; |
---|
| 19 | const double a_half = 0.5 * length_a; |
---|
| 20 | const double b_half = 0.5 * length_b; |
---|
| 21 | const double c_half = 0.5 * length_c; |
---|
[deb7ee0] | 22 | |
---|
| 23 | //Integration limits to use in Gaussian quadrature |
---|
[ab2aea8] | 24 | const double v1a = 0.0; |
---|
| 25 | const double v1b = M_PI_2; //theta integration limits |
---|
| 26 | const double v2a = 0.0; |
---|
| 27 | const double v2b = M_PI_2; //phi integration limits |
---|
[deb7ee0] | 28 | |
---|
[ab2aea8] | 29 | double outer_sum = 0.0; |
---|
| 30 | for(int i=0; i<76; i++) { |
---|
| 31 | const double theta = 0.5 * ( Gauss76Z[i]*(v1b-v1a) + v1a + v1b ); |
---|
| 32 | double sin_theta, cos_theta; |
---|
| 33 | SINCOS(theta, sin_theta, cos_theta); |
---|
| 34 | |
---|
[1e7b0db0] | 35 | const double termC = sas_sinx_x(q * c_half * cos_theta); |
---|
[ab2aea8] | 36 | |
---|
| 37 | double inner_sum = 0.0; |
---|
| 38 | for(int j=0; j<76; j++) { |
---|
| 39 | double phi = 0.5 * ( Gauss76Z[j]*(v2b-v2a) + v2a + v2b ); |
---|
| 40 | double sin_phi, cos_phi; |
---|
| 41 | SINCOS(phi, sin_phi, cos_phi); |
---|
| 42 | |
---|
| 43 | // Amplitude AP from eqn. (12), rewritten to avoid round-off effects when arg=0 |
---|
[1e7b0db0] | 44 | const double termA = sas_sinx_x(q * a_half * sin_theta * sin_phi); |
---|
| 45 | const double termB = sas_sinx_x(q * b_half * sin_theta * cos_phi); |
---|
[ab2aea8] | 46 | const double AP = termA * termB * termC; |
---|
| 47 | inner_sum += Gauss76Wt[j] * AP * AP; |
---|
| 48 | } |
---|
| 49 | inner_sum = 0.5 * (v2b-v2a) * inner_sum; |
---|
| 50 | outer_sum += Gauss76Wt[i] * inner_sum * sin_theta; |
---|
[deb7ee0] | 51 | } |
---|
| 52 | |
---|
[ab2aea8] | 53 | double answer = 0.5*(v1b-v1a)*outer_sum; |
---|
[deb7ee0] | 54 | |
---|
| 55 | // Normalize by Pi (Eqn. 16). |
---|
| 56 | // The term (ABC)^2 does not appear because it was introduced before on |
---|
| 57 | // the definitions of termA, termB, termC. |
---|
| 58 | // The factor 2 appears because the theta integral has been defined between |
---|
| 59 | // 0 and pi/2, instead of 0 to pi. |
---|
[3a48772] | 60 | answer /= M_PI_2; //Form factor P(q) |
---|
[deb7ee0] | 61 | |
---|
| 62 | // Multiply by contrast^2 and volume^2 |
---|
[ab2aea8] | 63 | const double volume = length_a * length_b * length_c; |
---|
| 64 | answer *= square((sld-solvent_sld)*volume); |
---|
[deb7ee0] | 65 | |
---|
| 66 | // Convert from [1e-12 A-1] to [cm-1] |
---|
| 67 | answer *= 1.0e-4; |
---|
| 68 | |
---|
| 69 | return answer; |
---|
| 70 | } |
---|