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 | static double |
---|
18 | form_volume(double radius, double thickness, double length) |
---|
19 | { |
---|
20 | double v_shell = M_PI*length*(square(radius+thickness) - radius*radius); |
---|
21 | return v_shell; |
---|
22 | } |
---|
23 | |
---|
24 | static double |
---|
25 | radius_from_volume(double radius, double thickness, double length) |
---|
26 | { |
---|
27 | const double volume_outer_cyl = M_PI*square(radius + thickness)*length; |
---|
28 | return cbrt(0.75*volume_outer_cyl/M_PI); |
---|
29 | } |
---|
30 | |
---|
31 | static double |
---|
32 | radius_from_diagonal(double radius, double thickness, double length) |
---|
33 | { |
---|
34 | return sqrt(square(radius + thickness) + 0.25*square(length)); |
---|
35 | } |
---|
36 | |
---|
37 | static double |
---|
38 | effective_radius(int mode, double radius, double thickness, double length) |
---|
39 | { |
---|
40 | if (mode == 1) { |
---|
41 | return radius_from_volume(radius, thickness, length); |
---|
42 | } else if (mode == 2) { |
---|
43 | return radius + thickness; |
---|
44 | } else if (mode == 3) { |
---|
45 | return 0.5*length; |
---|
46 | } else if (mode == 4) { |
---|
47 | return (radius + thickness < 0.5*length ? radius + thickness : 0.5*length); |
---|
48 | } else if (mode == 5) { |
---|
49 | return (radius + thickness > 0.5*length ? radius + thickness : 0.5*length); |
---|
50 | } else { |
---|
51 | return radius_from_diagonal(radius,thickness,length); |
---|
52 | } |
---|
53 | } |
---|
54 | |
---|
55 | static void |
---|
56 | Fq(double q, double *F1, double *F2, double radius, double thickness, double length, |
---|
57 | double sld, double solvent_sld) |
---|
58 | { |
---|
59 | const double lower = 0.0; |
---|
60 | const double upper = 1.0; //limits of numerical integral |
---|
61 | |
---|
62 | double total_F1 = 0.0; //initialize intergral |
---|
63 | double total_F2 = 0.0; |
---|
64 | for (int i=0;i<GAUSS_N;i++) { |
---|
65 | const double cos_theta = 0.5*( GAUSS_Z[i] * (upper-lower) + lower + upper ); |
---|
66 | const double sin_theta = sqrt(1.0 - cos_theta*cos_theta); |
---|
67 | const double form = _fq(q*sin_theta, q*cos_theta, |
---|
68 | radius, thickness, length); |
---|
69 | total_F1 += GAUSS_W[i] * form; |
---|
70 | total_F2 += GAUSS_W[i] * form * form; |
---|
71 | } |
---|
72 | total_F1 *= 0.5*(upper-lower); |
---|
73 | total_F2 *= 0.5*(upper-lower); |
---|
74 | const double s = (sld - solvent_sld) * form_volume(radius, thickness, length); |
---|
75 | *F1 = 1e-2 * s * total_F1; |
---|
76 | *F2 = 1e-4 * s*s * total_F2; |
---|
77 | } |
---|
78 | |
---|
79 | |
---|
80 | static double |
---|
81 | Iqac(double qab, double qc, |
---|
82 | double radius, double thickness, double length, |
---|
83 | double sld, double solvent_sld) |
---|
84 | { |
---|
85 | const double form = _fq(qab, qc, radius, thickness, length); |
---|
86 | const double s = (sld - solvent_sld) * form_volume(radius, thickness, length); |
---|
87 | return 1.0e-4*square(s * form); |
---|
88 | } |
---|