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