1 | static double |
---|
2 | form_volume(double length_a, double b2a_ratio, double c2a_ratio) |
---|
3 | { |
---|
4 | return length_a * (length_a*b2a_ratio) * (length_a*c2a_ratio); |
---|
5 | } |
---|
6 | |
---|
7 | static double |
---|
8 | Iq(double q, |
---|
9 | double sld, |
---|
10 | double solvent_sld, |
---|
11 | double length_a, |
---|
12 | double b2a_ratio, |
---|
13 | double c2a_ratio) |
---|
14 | { |
---|
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; |
---|
20 | |
---|
21 | //Integration limits to use in Gaussian quadrature |
---|
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 |
---|
26 | |
---|
27 | double outer_sum = 0.0; |
---|
28 | for(int i=0; i<GAUSS_N; i++) { |
---|
29 | const double theta = 0.5 * ( GAUSS_Z[i]*(v1b-v1a) + v1a + v1b ); |
---|
30 | double sin_theta, cos_theta; |
---|
31 | SINCOS(theta, sin_theta, cos_theta); |
---|
32 | |
---|
33 | const double termC = sas_sinx_x(q * c_half * cos_theta); |
---|
34 | |
---|
35 | double inner_sum = 0.0; |
---|
36 | for(int j=0; j<GAUSS_N; j++) { |
---|
37 | double phi = 0.5 * ( GAUSS_Z[j]*(v2b-v2a) + v2a + v2b ); |
---|
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 |
---|
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); |
---|
44 | const double AP = termA * termB * termC; |
---|
45 | inner_sum += GAUSS_W[j] * AP * AP; |
---|
46 | } |
---|
47 | inner_sum = 0.5 * (v2b-v2a) * inner_sum; |
---|
48 | outer_sum += GAUSS_W[i] * inner_sum * sin_theta; |
---|
49 | } |
---|
50 | |
---|
51 | double answer = 0.5*(v1b-v1a)*outer_sum; |
---|
52 | |
---|
53 | // Normalize by Pi (Eqn. 16). |
---|
54 | // The term (ABC)^2 does not appear because it was introduced before on |
---|
55 | // the definitions of termA, termB, termC. |
---|
56 | // The factor 2 appears because the theta integral has been defined between |
---|
57 | // 0 and pi/2, instead of 0 to pi. |
---|
58 | answer /= M_PI_2; //Form factor P(q) |
---|
59 | |
---|
60 | // Multiply by contrast^2 and volume^2 |
---|
61 | const double volume = length_a * length_b * length_c; |
---|
62 | answer *= square((sld-solvent_sld)*volume); |
---|
63 | |
---|
64 | // Convert from [1e-12 A-1] to [cm-1] |
---|
65 | answer *= 1.0e-4; |
---|
66 | |
---|
67 | return answer; |
---|
68 | } |
---|
69 | |
---|
70 | static void |
---|
71 | Fq(double q, |
---|
72 | double *F1, |
---|
73 | double *F2, |
---|
74 | double sld, |
---|
75 | double solvent_sld, |
---|
76 | double length_a, |
---|
77 | double b2a_ratio, |
---|
78 | double c2a_ratio) |
---|
79 | { |
---|
80 | const double length_b = length_a * b2a_ratio; |
---|
81 | const double length_c = length_a * c2a_ratio; |
---|
82 | const double a_half = 0.5 * length_a; |
---|
83 | const double b_half = 0.5 * length_b; |
---|
84 | const double c_half = 0.5 * length_c; |
---|
85 | |
---|
86 | //Integration limits to use in Gaussian quadrature |
---|
87 | const double v1a = 0.0; |
---|
88 | const double v1b = M_PI_2; //theta integration limits |
---|
89 | const double v2a = 0.0; |
---|
90 | const double v2b = M_PI_2; //phi integration limits |
---|
91 | |
---|
92 | double outer_sum_F1 = 0.0; |
---|
93 | double outer_sum_F2 = 0.0; |
---|
94 | for(int i=0; i<GAUSS_N; i++) { |
---|
95 | const double theta = 0.5 * ( GAUSS_Z[i]*(v1b-v1a) + v1a + v1b ); |
---|
96 | double sin_theta, cos_theta; |
---|
97 | SINCOS(theta, sin_theta, cos_theta); |
---|
98 | |
---|
99 | const double termC = sas_sinx_x(q * c_half * cos_theta); |
---|
100 | |
---|
101 | double inner_sum_F1 = 0.0; |
---|
102 | double inner_sum_F2 = 0.0; |
---|
103 | for(int j=0; j<GAUSS_N; j++) { |
---|
104 | double phi = 0.5 * ( GAUSS_Z[j]*(v2b-v2a) + v2a + v2b ); |
---|
105 | double sin_phi, cos_phi; |
---|
106 | SINCOS(phi, sin_phi, cos_phi); |
---|
107 | |
---|
108 | // Amplitude AP from eqn. (12), rewritten to avoid round-off effects when arg=0 |
---|
109 | const double termA = sas_sinx_x(q * a_half * sin_theta * sin_phi); |
---|
110 | const double termB = sas_sinx_x(q * b_half * sin_theta * cos_phi); |
---|
111 | const double AP = termA * termB * termC; |
---|
112 | inner_sum_F1 += GAUSS_W[j] * AP; |
---|
113 | inner_sum_F2 += GAUSS_W[j] * AP * AP; |
---|
114 | } |
---|
115 | inner_sum_F1 = 0.5 * (v2b-v2a) * inner_sum_F1; |
---|
116 | inner_sum_F2 = 0.5 * (v2b-v2a) * inner_sum_F2; |
---|
117 | outer_sum_F1 += GAUSS_W[i] * inner_sum_F1 * sin_theta; |
---|
118 | outer_sum_F2 += GAUSS_W[i] * inner_sum_F2 * sin_theta; |
---|
119 | } |
---|
120 | |
---|
121 | outer_sum_F1 *= 0.5*(v1b-v1a); |
---|
122 | outer_sum_F2 *= 0.5*(v1b-v1a); |
---|
123 | |
---|
124 | // Normalize by Pi (Eqn. 16). |
---|
125 | // The term (ABC)^2 does not appear because it was introduced before on |
---|
126 | // the definitions of termA, termB, termC. |
---|
127 | // The factor 2 appears because the theta integral has been defined between |
---|
128 | // 0 and pi/2, instead of 0 to pi. |
---|
129 | outer_sum_F1 /= M_PI_2; |
---|
130 | outer_sum_F2 /= M_PI_2; |
---|
131 | |
---|
132 | // Multiply by contrast and volume |
---|
133 | const double s = (sld-solvent_sld) * (length_a * length_b * length_c); |
---|
134 | |
---|
135 | // Convert from [1e-12 A-1] to [cm-1] |
---|
136 | *F1 = 1e-2 * s * outer_sum_F1; |
---|
137 | *F2 = 1e-4 * s * s * outer_sum_F2; |
---|
138 | } |
---|
139 | |
---|
140 | |
---|
141 | static double |
---|
142 | Iqabc(double qa, double qb, double qc, |
---|
143 | double sld, |
---|
144 | double solvent_sld, |
---|
145 | double length_a, |
---|
146 | double b2a_ratio, |
---|
147 | double c2a_ratio) |
---|
148 | { |
---|
149 | const double length_b = length_a * b2a_ratio; |
---|
150 | const double length_c = length_a * c2a_ratio; |
---|
151 | const double a_half = 0.5 * length_a; |
---|
152 | const double b_half = 0.5 * length_b; |
---|
153 | const double c_half = 0.5 * length_c; |
---|
154 | |
---|
155 | // Amplitude AP from eqn. (13) |
---|
156 | const double termA = sas_sinx_x(qa * a_half); |
---|
157 | const double termB = sas_sinx_x(qb * b_half); |
---|
158 | const double termC = sas_sinx_x(qc * c_half); |
---|
159 | const double AP = termA * termB * termC; |
---|
160 | |
---|
161 | // Multiply by contrast and volume |
---|
162 | const double s = (sld-solvent_sld) * (length_a * length_b * length_c); |
---|
163 | |
---|
164 | // Convert from [1e-12 A-1] to [cm-1] |
---|
165 | return 1.0e-4 * square(s * AP); |
---|
166 | } |
---|