1 | // vd = volume * delta_rho |
---|
2 | // besarg = q * R * sin(theta) |
---|
3 | // siarg = q * L/2 * cos(theta) |
---|
4 | static double _cyl(double vd, double besarg, double siarg) |
---|
5 | { |
---|
6 | return vd * sas_sinx_x(siarg) * sas_2J1x_x(besarg); |
---|
7 | } |
---|
8 | |
---|
9 | static double |
---|
10 | form_volume(double radius, double thickness, double length) |
---|
11 | { |
---|
12 | return M_PI*square(radius+thickness)*(length+2.0*thickness); |
---|
13 | } |
---|
14 | |
---|
15 | static double |
---|
16 | radius_from_volume(double radius, double thickness, double length) |
---|
17 | { |
---|
18 | const double volume_outer_cyl = form_volume(radius,thickness,length); |
---|
19 | return cbrt(volume_outer_cyl/M_4PI_3); |
---|
20 | } |
---|
21 | |
---|
22 | static double |
---|
23 | radius_from_diagonal(double radius, double thickness, double length) |
---|
24 | { |
---|
25 | const double radius_outer = radius + thickness; |
---|
26 | const double length_outer = length + 2.0*thickness; |
---|
27 | return sqrt(radius_outer*radius_outer + 0.25*length_outer*length_outer); |
---|
28 | } |
---|
29 | |
---|
30 | static double |
---|
31 | effective_radius(int mode, double radius, double thickness, double length) |
---|
32 | { |
---|
33 | switch (mode) { |
---|
34 | default: |
---|
35 | case 1: // equivalent sphere |
---|
36 | return radius_from_volume(radius, thickness, length); |
---|
37 | case 2: // outer radius |
---|
38 | return radius + thickness; |
---|
39 | case 3: // half outer length |
---|
40 | return 0.5*length + thickness; |
---|
41 | case 4: // half min outer length |
---|
42 | return (radius < 0.5*length ? radius + thickness : 0.5*length + thickness); |
---|
43 | case 5: // half max outer length |
---|
44 | return (radius > 0.5*length ? radius + thickness : 0.5*length + thickness); |
---|
45 | case 6: // half outer diagonal |
---|
46 | return radius_from_diagonal(radius,thickness,length); |
---|
47 | } |
---|
48 | } |
---|
49 | |
---|
50 | static void |
---|
51 | Fq(double q, |
---|
52 | double *F1, |
---|
53 | double *F2, |
---|
54 | double core_sld, |
---|
55 | double shell_sld, |
---|
56 | double solvent_sld, |
---|
57 | double radius, |
---|
58 | double thickness, |
---|
59 | double length) |
---|
60 | { |
---|
61 | // precalculate constants |
---|
62 | const double core_r = radius; |
---|
63 | const double core_h = 0.5*length; |
---|
64 | const double core_vd = form_volume(radius,0,length) * (core_sld-shell_sld); |
---|
65 | const double shell_r = (radius + thickness); |
---|
66 | const double shell_h = (0.5*length + thickness); |
---|
67 | const double shell_vd = form_volume(radius,thickness,length) * (shell_sld-solvent_sld); |
---|
68 | double total_F1 = 0.0; |
---|
69 | double total_F2 = 0.0; |
---|
70 | for (int i=0; i<GAUSS_N ;i++) { |
---|
71 | // translate a point in [-1,1] to a point in [0, pi/2] |
---|
72 | //const double theta = ( GAUSS_Z[i]*(upper-lower) + upper + lower )/2.0; |
---|
73 | double sin_theta, cos_theta; |
---|
74 | const double theta = GAUSS_Z[i]*M_PI_4 + M_PI_4; |
---|
75 | SINCOS(theta, sin_theta, cos_theta); |
---|
76 | const double qab = q*sin_theta; |
---|
77 | const double qc = q*cos_theta; |
---|
78 | const double fq = _cyl(core_vd, core_r*qab, core_h*qc) |
---|
79 | + _cyl(shell_vd, shell_r*qab, shell_h*qc); |
---|
80 | total_F1 += GAUSS_W[i] * fq * sin_theta; |
---|
81 | total_F2 += GAUSS_W[i] * fq * fq * sin_theta; |
---|
82 | } |
---|
83 | // translate dx in [-1,1] to dx in [lower,upper] |
---|
84 | //const double form = (upper-lower)/2.0*total; |
---|
85 | *F1 = 1.0e-2 * total_F1 * M_PI_4; |
---|
86 | *F2 = 1.0e-4 * total_F2 * M_PI_4; |
---|
87 | } |
---|
88 | |
---|
89 | static double |
---|
90 | Iqac(double qab, double qc, |
---|
91 | double core_sld, |
---|
92 | double shell_sld, |
---|
93 | double solvent_sld, |
---|
94 | double radius, |
---|
95 | double thickness, |
---|
96 | double length) |
---|
97 | { |
---|
98 | const double core_r = radius; |
---|
99 | const double core_h = 0.5*length; |
---|
100 | const double core_vd = form_volume(radius,0,length) * (core_sld-shell_sld); |
---|
101 | const double shell_r = (radius + thickness); |
---|
102 | const double shell_h = (0.5*length + thickness); |
---|
103 | const double shell_vd = form_volume(radius,thickness,length) * (shell_sld-solvent_sld); |
---|
104 | |
---|
105 | const double fq = _cyl(core_vd, core_r*qab, core_h*qc) |
---|
106 | + _cyl(shell_vd, shell_r*qab, shell_h*qc); |
---|
107 | return 1.0e-4 * fq * fq; |
---|
108 | } |
---|