1 | static double |
---|
2 | form_volume(double radius_polar, double radius_equatorial) |
---|
3 | { |
---|
4 | return M_4PI_3*radius_polar*radius_equatorial*radius_equatorial; |
---|
5 | } |
---|
6 | |
---|
7 | static double |
---|
8 | radius_from_volume(double radius_polar, double radius_equatorial) |
---|
9 | { |
---|
10 | return cbrt(radius_polar*radius_equatorial*radius_equatorial); |
---|
11 | } |
---|
12 | |
---|
13 | static double |
---|
14 | radius_from_curvature(double radius_polar, double radius_equatorial) |
---|
15 | { |
---|
16 | // Trivial cases |
---|
17 | if (radius_polar == radius_equatorial) return radius_polar; |
---|
18 | if (radius_polar * radius_equatorial == 0.) return 0.; |
---|
19 | |
---|
20 | // see equation (26) in A.Isihara, J.Chem.Phys. 18(1950)1446-1449 |
---|
21 | const double ratio = (radius_polar < radius_equatorial |
---|
22 | ? radius_polar / radius_equatorial |
---|
23 | : radius_equatorial / radius_polar); |
---|
24 | const double e1 = sqrt(1.0 - ratio*ratio); |
---|
25 | const double b1 = 1.0 + asin(e1) / (e1 * ratio); |
---|
26 | const double bL = (1.0 + e1) / (1.0 - e1); |
---|
27 | const double b2 = 1.0 + 0.5 * ratio * ratio / e1 * log(bL); |
---|
28 | const double delta = 0.75 * b1 * b2; |
---|
29 | const double ddd = 2.0 * (delta + 1.0) * radius_polar * radius_equatorial * radius_equatorial; |
---|
30 | return 0.5 * cbrt(ddd); |
---|
31 | } |
---|
32 | |
---|
33 | static double |
---|
34 | effective_radius(int mode, double radius_polar, double radius_equatorial) |
---|
35 | { |
---|
36 | switch (mode) { |
---|
37 | default: |
---|
38 | case 1: // average curvature |
---|
39 | return radius_from_curvature(radius_polar, radius_equatorial); |
---|
40 | case 2: // equivalent volume sphere |
---|
41 | return radius_from_volume(radius_polar, radius_equatorial); |
---|
42 | case 3: // min radius |
---|
43 | return (radius_polar < radius_equatorial ? radius_polar : radius_equatorial); |
---|
44 | case 4: // max radius |
---|
45 | return (radius_polar > radius_equatorial ? radius_polar : radius_equatorial); |
---|
46 | } |
---|
47 | } |
---|
48 | |
---|
49 | |
---|
50 | static void |
---|
51 | Fq(double q, |
---|
52 | double *F1, |
---|
53 | double *F2, |
---|
54 | double sld, |
---|
55 | double sld_solvent, |
---|
56 | double radius_polar, |
---|
57 | double radius_equatorial) |
---|
58 | { |
---|
59 | // Using ratio v = Rp/Re, we can implement the form given in Guinier (1955) |
---|
60 | // i(h) = int_0^pi/2 Phi^2(h a sqrt(cos^2 + v^2 sin^2) cos dT |
---|
61 | // = int_0^pi/2 Phi^2(h a sqrt((1-sin^2) + v^2 sin^2) cos dT |
---|
62 | // = int_0^pi/2 Phi^2(h a sqrt(1 + sin^2(v^2-1)) cos dT |
---|
63 | // u-substitution of |
---|
64 | // u = sin, du = cos dT |
---|
65 | // i(h) = int_0^1 Phi^2(h a sqrt(1 + u^2(v^2-1)) du |
---|
66 | const double v_square_minus_one = square(radius_polar/radius_equatorial) - 1.0; |
---|
67 | // translate a point in [-1,1] to a point in [0, 1] |
---|
68 | // const double u = GAUSS_Z[i]*(upper-lower)/2 + (upper+lower)/2; |
---|
69 | const double zm = 0.5; |
---|
70 | const double zb = 0.5; |
---|
71 | double total_F2 = 0.0; |
---|
72 | double total_F1 = 0.0; |
---|
73 | for (int i=0;i<GAUSS_N;i++) { |
---|
74 | const double u = GAUSS_Z[i]*zm + zb; |
---|
75 | const double r = radius_equatorial*sqrt(1.0 + u*u*v_square_minus_one); |
---|
76 | const double f = sas_3j1x_x(q*r); |
---|
77 | total_F2 += GAUSS_W[i] * f * f; |
---|
78 | total_F1 += GAUSS_W[i] * f; |
---|
79 | } |
---|
80 | // translate dx in [-1,1] to dx in [lower,upper] |
---|
81 | total_F1 *= zm; |
---|
82 | total_F2 *= zm; |
---|
83 | const double s = (sld - sld_solvent) * form_volume(radius_polar, radius_equatorial); |
---|
84 | *F1 = 1e-2 * s * total_F1; |
---|
85 | *F2 = 1e-4 * s * s * total_F2; |
---|
86 | } |
---|
87 | |
---|
88 | static double |
---|
89 | Iqac(double qab, double qc, |
---|
90 | double sld, |
---|
91 | double sld_solvent, |
---|
92 | double radius_polar, |
---|
93 | double radius_equatorial) |
---|
94 | { |
---|
95 | const double qr = sqrt(square(radius_equatorial*qab) + square(radius_polar*qc)); |
---|
96 | const double f = sas_3j1x_x(qr); |
---|
97 | const double s = (sld - sld_solvent) * form_volume(radius_polar, radius_equatorial); |
---|
98 | |
---|
99 | return 1.0e-4 * square(f * s); |
---|
100 | } |
---|