[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 | { |
---|
| 17 | double termA, termB, termC; |
---|
| 18 | |
---|
[a807206] | 19 | double b_side = length_a * b2a_ratio; |
---|
| 20 | double c_side = length_a * c2a_ratio; |
---|
| 21 | double volume = length_a * b_side * c_side; |
---|
| 22 | double a_half = 0.5 * length_a; |
---|
[deb7ee0] | 23 | double b_half = 0.5 * b_side; |
---|
| 24 | double c_half = 0.5 * c_side; |
---|
| 25 | |
---|
| 26 | //Integration limits to use in Gaussian quadrature |
---|
| 27 | double v1a = 0.0; |
---|
[87bc707] | 28 | double v1b = M_PI_2; //theta integration limits |
---|
[deb7ee0] | 29 | double v2a = 0.0; |
---|
[87bc707] | 30 | double v2b = M_PI_2; //phi integration limits |
---|
[deb7ee0] | 31 | |
---|
| 32 | //Order of integration |
---|
| 33 | int nordi=76; |
---|
| 34 | int nordj=76; |
---|
| 35 | |
---|
| 36 | double sumi = 0.0; |
---|
| 37 | |
---|
| 38 | for(int i=0; i<nordi; i++) { |
---|
| 39 | |
---|
| 40 | double theta = 0.5 * ( Gauss76Z[i]*(v1b-v1a) + v1a + v1b ); |
---|
| 41 | |
---|
| 42 | double arg = q * c_half * cos(theta); |
---|
| 43 | if (fabs(arg) > 1.e-16) {termC = sin(arg)/arg;} else {termC = 1.0;} |
---|
| 44 | |
---|
| 45 | double sumj = 0.0; |
---|
| 46 | |
---|
| 47 | for(int j=0; j<nordj; j++) { |
---|
| 48 | |
---|
| 49 | double phi = 0.5 * ( Gauss76Z[j]*(v2b-v2a) + v2a + v2b ); |
---|
| 50 | |
---|
| 51 | // Amplitude AP from eqn. (12), rewritten to avoid round-off effects when arg=0 |
---|
| 52 | |
---|
| 53 | arg = q * a_half * sin(theta) * sin(phi); |
---|
| 54 | if (fabs(arg) > 1.e-16) {termA = sin(arg)/arg;} else {termA = 1.0;} |
---|
| 55 | |
---|
| 56 | arg = q * b_half * sin(theta) * cos(phi); |
---|
| 57 | if (fabs(arg) > 1.e-16) {termB = sin(arg)/arg;} else {termB = 1.0;} |
---|
| 58 | |
---|
| 59 | double AP = termA * termB * termC; |
---|
| 60 | |
---|
| 61 | sumj += Gauss76Wt[j] * (AP*AP); |
---|
| 62 | |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | sumj = 0.5 * (v2b-v2a) * sumj; |
---|
| 66 | sumi += Gauss76Wt[i] * sumj * sin(theta); |
---|
| 67 | |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | double answer = 0.5*(v1b-v1a)*sumi; |
---|
| 71 | |
---|
| 72 | // Normalize by Pi (Eqn. 16). |
---|
| 73 | // The term (ABC)^2 does not appear because it was introduced before on |
---|
| 74 | // the definitions of termA, termB, termC. |
---|
| 75 | // The factor 2 appears because the theta integral has been defined between |
---|
| 76 | // 0 and pi/2, instead of 0 to pi. |
---|
[3a48772] | 77 | answer /= M_PI_2; //Form factor P(q) |
---|
[deb7ee0] | 78 | |
---|
| 79 | // Multiply by contrast^2 and volume^2 |
---|
| 80 | answer *= (sld-solvent_sld)*(sld-solvent_sld)*volume*volume; |
---|
| 81 | |
---|
| 82 | // Convert from [1e-12 A-1] to [cm-1] |
---|
| 83 | answer *= 1.0e-4; |
---|
| 84 | |
---|
| 85 | return answer; |
---|
| 86 | |
---|
| 87 | } |
---|