1 | |
---|
2 | // Converted from Igor function gfn4, using the same pattern as ellipsoid |
---|
3 | // for evaluating the parts of the integral. |
---|
4 | // FUNCTION gfn4: CONTAINS F(Q,A,B,MU)**2 AS GIVEN |
---|
5 | // BY (53) & (58-59) IN CHEN AND |
---|
6 | // KOTLARCHYK REFERENCE |
---|
7 | // |
---|
8 | // <OBLATE ELLIPSOID> |
---|
9 | static double |
---|
10 | _cs_ellipsoid_kernel(double qab, double qc, |
---|
11 | double equat_core, double polar_core, |
---|
12 | double equat_shell, double polar_shell, |
---|
13 | double sld_core_shell, double sld_shell_solvent) |
---|
14 | { |
---|
15 | const double qr_core = sqrt(square(equat_core*qab) + square(polar_core*qc)); |
---|
16 | const double si_core = sas_3j1x_x(qr_core); |
---|
17 | const double volume_core = M_4PI_3*equat_core*equat_core*polar_core; |
---|
18 | const double fq_core = si_core*volume_core*sld_core_shell; |
---|
19 | |
---|
20 | const double qr_shell = sqrt(square(equat_shell*qab) + square(polar_shell*qc)); |
---|
21 | const double si_shell = sas_3j1x_x(qr_shell); |
---|
22 | const double volume_shell = M_4PI_3*equat_shell*equat_shell*polar_shell; |
---|
23 | const double fq_shell = si_shell*volume_shell*sld_shell_solvent; |
---|
24 | |
---|
25 | return fq_core + fq_shell; |
---|
26 | } |
---|
27 | |
---|
28 | static double |
---|
29 | form_volume(double radius_equat_core, |
---|
30 | double x_core, |
---|
31 | double thick_shell, |
---|
32 | double x_polar_shell) |
---|
33 | { |
---|
34 | const double equat_shell = radius_equat_core + thick_shell; |
---|
35 | const double polar_shell = radius_equat_core*x_core + thick_shell*x_polar_shell; |
---|
36 | double vol = M_4PI_3*equat_shell*equat_shell*polar_shell; |
---|
37 | return vol; |
---|
38 | } |
---|
39 | |
---|
40 | static double |
---|
41 | radius_from_volume(double radius_equat_core, double x_core, double thick_shell, double x_polar_shell) |
---|
42 | { |
---|
43 | const double volume_ellipsoid = form_volume(radius_equat_core, x_core, thick_shell, x_polar_shell); |
---|
44 | return cbrt(volume_ellipsoid/M_4PI_3); |
---|
45 | } |
---|
46 | |
---|
47 | static double |
---|
48 | radius_from_curvature(double radius_equat_core, double x_core, double thick_shell, double x_polar_shell) |
---|
49 | { |
---|
50 | // Trivial cases |
---|
51 | if (1.0 == x_core && 1.0 == x_polar_shell) return radius_equat_core + thick_shell; |
---|
52 | if ((radius_equat_core + thick_shell)*(radius_equat_core*x_core + thick_shell*x_polar_shell) == 0.) return 0.; |
---|
53 | |
---|
54 | // see equation (26) in A.Isihara, J.Chem.Phys. 18(1950)1446-1449 |
---|
55 | const double radius_equat_tot = radius_equat_core + thick_shell; |
---|
56 | const double radius_polar_tot = radius_equat_core*x_core + thick_shell*x_polar_shell; |
---|
57 | const double ratio = (radius_polar_tot < radius_equat_tot |
---|
58 | ? radius_polar_tot / radius_equat_tot |
---|
59 | : radius_equat_tot / radius_polar_tot); |
---|
60 | const double e1 = sqrt(1.0 - ratio*ratio); |
---|
61 | const double b1 = 1.0 + asin(e1) / (e1 * ratio); |
---|
62 | const double bL = (1.0 + e1) / (1.0 - e1); |
---|
63 | const double b2 = 1.0 + 0.5 * ratio * ratio / e1 * log(bL); |
---|
64 | const double delta = 0.75 * b1 * b2; |
---|
65 | const double ddd = 2.0 * (delta + 1.0) * radius_polar_tot * radius_equat_tot * radius_equat_tot; |
---|
66 | return 0.5 * cbrt(ddd); |
---|
67 | } |
---|
68 | |
---|
69 | static double |
---|
70 | radius_effective(int mode, double radius_equat_core, double x_core, double thick_shell, double x_polar_shell) |
---|
71 | { |
---|
72 | const double radius_equat_tot = radius_equat_core + thick_shell; |
---|
73 | const double radius_polar_tot = radius_equat_core*x_core + thick_shell*x_polar_shell; |
---|
74 | |
---|
75 | switch (mode) { |
---|
76 | default: |
---|
77 | case 1: // average outer curvature |
---|
78 | return radius_from_curvature(radius_equat_core, x_core, thick_shell, x_polar_shell); |
---|
79 | case 2: // equivalent volume sphere |
---|
80 | return radius_from_volume(radius_equat_core, x_core, thick_shell, x_polar_shell); |
---|
81 | case 3: // min outer radius |
---|
82 | return (radius_polar_tot < radius_equat_tot ? radius_polar_tot : radius_equat_tot); |
---|
83 | case 4: // max outer radius |
---|
84 | return (radius_polar_tot > radius_equat_tot ? radius_polar_tot : radius_equat_tot); |
---|
85 | } |
---|
86 | } |
---|
87 | |
---|
88 | static void |
---|
89 | Fq(double q, |
---|
90 | double *F1, |
---|
91 | double *F2, |
---|
92 | double radius_equat_core, |
---|
93 | double x_core, |
---|
94 | double thick_shell, |
---|
95 | double x_polar_shell, |
---|
96 | double core_sld, |
---|
97 | double shell_sld, |
---|
98 | double solvent_sld) |
---|
99 | { |
---|
100 | const double sld_core_shell = core_sld - shell_sld; |
---|
101 | const double sld_shell_solvent = shell_sld - solvent_sld; |
---|
102 | |
---|
103 | const double polar_core = radius_equat_core*x_core; |
---|
104 | const double equat_shell = radius_equat_core + thick_shell; |
---|
105 | const double polar_shell = radius_equat_core*x_core + thick_shell*x_polar_shell; |
---|
106 | |
---|
107 | // translate from [-1, 1] => [0, 1] |
---|
108 | const double m = 0.5; |
---|
109 | const double b = 0.5; |
---|
110 | double total_F1 = 0.0; //initialize intergral |
---|
111 | double total_F2 = 0.0; //initialize intergral |
---|
112 | for(int i=0;i<GAUSS_N;i++) { |
---|
113 | const double cos_theta = GAUSS_Z[i]*m + b; |
---|
114 | const double sin_theta = sqrt(1.0 - cos_theta*cos_theta); |
---|
115 | double fq = _cs_ellipsoid_kernel(q*sin_theta, q*cos_theta, |
---|
116 | radius_equat_core, polar_core, |
---|
117 | equat_shell, polar_shell, |
---|
118 | sld_core_shell, sld_shell_solvent); |
---|
119 | total_F1 += GAUSS_W[i] * fq; |
---|
120 | total_F2 += GAUSS_W[i] * fq * fq; |
---|
121 | } |
---|
122 | total_F1 *= m; |
---|
123 | total_F2 *= m; |
---|
124 | |
---|
125 | // convert to [cm-1] |
---|
126 | *F1 = 1.0e-2 * total_F1; |
---|
127 | *F2 = 1.0e-4 * total_F2; |
---|
128 | } |
---|
129 | |
---|
130 | |
---|
131 | static double |
---|
132 | Iqac(double qab, double qc, |
---|
133 | double radius_equat_core, |
---|
134 | double x_core, |
---|
135 | double thick_shell, |
---|
136 | double x_polar_shell, |
---|
137 | double core_sld, |
---|
138 | double shell_sld, |
---|
139 | double solvent_sld) |
---|
140 | { |
---|
141 | const double sld_core_shell = core_sld - shell_sld; |
---|
142 | const double sld_shell_solvent = shell_sld - solvent_sld; |
---|
143 | |
---|
144 | const double polar_core = radius_equat_core*x_core; |
---|
145 | const double equat_shell = radius_equat_core + thick_shell; |
---|
146 | const double polar_shell = radius_equat_core*x_core + thick_shell*x_polar_shell; |
---|
147 | |
---|
148 | double fq = _cs_ellipsoid_kernel(qab, qc, |
---|
149 | radius_equat_core, polar_core, |
---|
150 | equat_shell, polar_shell, |
---|
151 | sld_core_shell, sld_shell_solvent); |
---|
152 | |
---|
153 | //convert to [cm-1] |
---|
154 | return 1.0e-4 * fq * fq; |
---|
155 | } |
---|