1 | //#define INVALID(v) (v.radius_core >= v.radius) |
---|
2 | |
---|
3 | static double |
---|
4 | shell_volume(double radius, double thickness, double length) |
---|
5 | { |
---|
6 | return M_PI*length*(square(radius+thickness) - radius*radius); |
---|
7 | } |
---|
8 | |
---|
9 | static double |
---|
10 | form_volume(double radius, double thickness, double length) |
---|
11 | { |
---|
12 | return M_PI*length*square(radius+thickness); |
---|
13 | } |
---|
14 | |
---|
15 | static double |
---|
16 | radius_from_excluded_volume(double radius, double thickness, double length) |
---|
17 | { |
---|
18 | const double radius_tot = radius + thickness; |
---|
19 | return 0.5*cbrt(0.75*radius_tot*(2.0*radius_tot*length + (radius_tot + length)*(M_PI*radius_tot + length))); |
---|
20 | } |
---|
21 | |
---|
22 | static double |
---|
23 | radius_from_volume(double radius, double thickness, double length) |
---|
24 | { |
---|
25 | const double volume_outer_cyl = M_PI*square(radius + thickness)*length; |
---|
26 | return cbrt(volume_outer_cyl/M_4PI_3); |
---|
27 | } |
---|
28 | |
---|
29 | static double |
---|
30 | radius_from_diagonal(double radius, double thickness, double length) |
---|
31 | { |
---|
32 | return sqrt(square(radius + thickness) + 0.25*square(length)); |
---|
33 | } |
---|
34 | |
---|
35 | static double |
---|
36 | effective_radius(int mode, double radius, double thickness, double length) |
---|
37 | { |
---|
38 | switch (mode) { |
---|
39 | default: |
---|
40 | case 1: // excluded volume |
---|
41 | return radius_from_excluded_volume(radius, thickness, length); |
---|
42 | case 2: // equivalent volume sphere |
---|
43 | return radius_from_volume(radius, thickness, length); |
---|
44 | case 3: // outer radius |
---|
45 | return radius + thickness; |
---|
46 | case 4: // half length |
---|
47 | return 0.5*length; |
---|
48 | case 5: // half outer min dimension |
---|
49 | return (radius + thickness < 0.5*length ? radius + thickness : 0.5*length); |
---|
50 | case 6: // half outer max dimension |
---|
51 | return (radius + thickness > 0.5*length ? radius + thickness : 0.5*length); |
---|
52 | case 7: // half outer diagonal |
---|
53 | return radius_from_diagonal(radius,thickness,length); |
---|
54 | } |
---|
55 | } |
---|
56 | |
---|
57 | static double |
---|
58 | _fq(double qab, double qc, |
---|
59 | double radius, double thickness, double length) |
---|
60 | { |
---|
61 | const double lam1 = sas_2J1x_x((radius+thickness)*qab); |
---|
62 | const double lam2 = sas_2J1x_x(radius*qab); |
---|
63 | const double gamma_sq = square(radius/(radius+thickness)); |
---|
64 | //Note: lim_{thickness -> 0} psi = sas_J0(radius*qab) |
---|
65 | //Note: lim_{radius -> 0} psi = sas_2J1x_x(thickness*qab) |
---|
66 | const double psi = (lam1 - gamma_sq*lam2)/(1.0 - gamma_sq); //SRK 10/19/00 |
---|
67 | const double t2 = sas_sinx_x(0.5*length*qc); |
---|
68 | return psi*t2; |
---|
69 | } |
---|
70 | |
---|
71 | static void |
---|
72 | Fq(double q, double *F1, double *F2, double radius, double thickness, double length, |
---|
73 | double sld, double solvent_sld) |
---|
74 | { |
---|
75 | const double lower = 0.0; |
---|
76 | const double upper = 1.0; //limits of numerical integral |
---|
77 | |
---|
78 | double total_F1 = 0.0; //initialize intergral |
---|
79 | double total_F2 = 0.0; |
---|
80 | for (int i=0;i<GAUSS_N;i++) { |
---|
81 | const double cos_theta = 0.5*( GAUSS_Z[i] * (upper-lower) + lower + upper ); |
---|
82 | const double sin_theta = sqrt(1.0 - cos_theta*cos_theta); |
---|
83 | const double form = _fq(q*sin_theta, q*cos_theta, |
---|
84 | radius, thickness, length); |
---|
85 | total_F1 += GAUSS_W[i] * form; |
---|
86 | total_F2 += GAUSS_W[i] * form * form; |
---|
87 | } |
---|
88 | total_F1 *= 0.5*(upper-lower); |
---|
89 | total_F2 *= 0.5*(upper-lower); |
---|
90 | const double s = (sld - solvent_sld) * shell_volume(radius, thickness, length); |
---|
91 | *F1 = 1e-2 * s * total_F1; |
---|
92 | *F2 = 1e-4 * s*s * total_F2; |
---|
93 | } |
---|
94 | |
---|
95 | |
---|
96 | static double |
---|
97 | Iqac(double qab, double qc, |
---|
98 | double radius, double thickness, double length, |
---|
99 | double sld, double solvent_sld) |
---|
100 | { |
---|
101 | const double form = _fq(qab, qc, radius, thickness, length); |
---|
102 | const double s = (sld - solvent_sld) * shell_volume(radius, thickness, length); |
---|
103 | return 1.0e-4*square(s * form); |
---|
104 | } |
---|