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