1 | static double |
---|
2 | form_volume(double length_a, double b2a_ratio, double c2a_ratio) |
---|
3 | { |
---|
4 | double length_b = length_a * b2a_ratio; |
---|
5 | double length_c = length_a * c2a_ratio; |
---|
6 | double vol_shell = 2.0 * (length_a*length_b + length_a*length_c + length_b*length_c); |
---|
7 | return vol_shell; |
---|
8 | } |
---|
9 | |
---|
10 | static void |
---|
11 | Fq(double q, |
---|
12 | double *F1, |
---|
13 | double *F2, |
---|
14 | double sld, |
---|
15 | double solvent_sld, |
---|
16 | double length_a, |
---|
17 | double b2a_ratio, |
---|
18 | double c2a_ratio) |
---|
19 | { |
---|
20 | const double length_b = length_a * b2a_ratio; |
---|
21 | const double length_c = length_a * c2a_ratio; |
---|
22 | const double a_half = 0.5 * length_a; |
---|
23 | const double b_half = 0.5 * length_b; |
---|
24 | const double c_half = 0.5 * length_c; |
---|
25 | |
---|
26 | //Integration limits to use in Gaussian quadrature |
---|
27 | const double v1a = 0.0; |
---|
28 | const double v1b = M_PI_2; //theta integration limits |
---|
29 | const double v2a = 0.0; |
---|
30 | const double v2b = M_PI_2; //phi integration limits |
---|
31 | |
---|
32 | double outer_sum_F1 = 0.0; |
---|
33 | double outer_sum_F2 = 0.0; |
---|
34 | for(int i=0; i<GAUSS_N; i++) { |
---|
35 | const double theta = 0.5 * ( GAUSS_Z[i]*(v1b-v1a) + v1a + v1b ); |
---|
36 | |
---|
37 | double sin_theta, cos_theta; |
---|
38 | double sin_c, cos_c; |
---|
39 | SINCOS(theta, sin_theta, cos_theta); |
---|
40 | SINCOS(q*c_half*cos_theta, sin_c, cos_c); |
---|
41 | |
---|
42 | // To check potential problems if denominator goes to zero here !!! |
---|
43 | const double termAL_theta = 8.0 * cos_c / (q*q*sin_theta*sin_theta); |
---|
44 | const double termAT_theta = 8.0 * sin_c / (q*q*sin_theta*cos_theta); |
---|
45 | |
---|
46 | double inner_sum_F1 = 0.0; |
---|
47 | double inner_sum_F2 = 0.0; |
---|
48 | for(int j=0; j<GAUSS_N; j++) { |
---|
49 | const double phi = 0.5 * ( GAUSS_Z[j]*(v2b-v2a) + v2a + v2b ); |
---|
50 | |
---|
51 | double sin_phi, cos_phi; |
---|
52 | double sin_a, cos_a; |
---|
53 | double sin_b, cos_b; |
---|
54 | SINCOS(phi, sin_phi, cos_phi); |
---|
55 | SINCOS(q*a_half*sin_theta*sin_phi, sin_a, cos_a); |
---|
56 | SINCOS(q*b_half*sin_theta*cos_phi, sin_b, cos_b); |
---|
57 | |
---|
58 | // Amplitude AL from eqn. (7c) |
---|
59 | const double AL = termAL_theta |
---|
60 | * sin_a*sin_b / (sin_phi*cos_phi); |
---|
61 | |
---|
62 | // Amplitude AT from eqn. (9) |
---|
63 | const double AT = termAT_theta |
---|
64 | * ( cos_a*sin_b/cos_phi + cos_b*sin_a/sin_phi ); |
---|
65 | |
---|
66 | inner_sum_F1 += GAUSS_W[j] * (AL+AT); |
---|
67 | inner_sum_F2 += GAUSS_W[j] * square(AL+AT); |
---|
68 | } |
---|
69 | |
---|
70 | inner_sum_F1 *= 0.5 * (v2b-v2a); |
---|
71 | inner_sum_F2 *= 0.5 * (v2b-v2a); |
---|
72 | outer_sum_F1 += GAUSS_W[i] * inner_sum_F1 * sin_theta; |
---|
73 | outer_sum_F2 += GAUSS_W[i] * inner_sum_F2 * sin_theta; |
---|
74 | } |
---|
75 | |
---|
76 | outer_sum_F1 *= 0.5*(v1b-v1a); |
---|
77 | outer_sum_F2 *= 0.5*(v1b-v1a); |
---|
78 | |
---|
79 | // Normalize as in Eqn. (15) without the volume factor (as cancels with (V*DelRho)^2 normalization) |
---|
80 | // The factor 2 is due to the different theta integration limit (pi/2 instead of pi) |
---|
81 | const double form_avg = outer_sum_F1/M_PI_2; |
---|
82 | const double form_squared_avg = outer_sum_F2/M_PI_2; |
---|
83 | |
---|
84 | // Multiply by contrast^2. Factor corresponding to volume^2 cancels with previous normalization. |
---|
85 | const double contrast = sld - solvent_sld; |
---|
86 | |
---|
87 | // Convert from [1e-12 A-1] to [cm-1] |
---|
88 | *F1 = 1e-2 * contrast * form_avg; |
---|
89 | *F2 = 1e-4 * contrast * contrast * form_squared_avg; |
---|
90 | } |
---|