1 | double form_volume(double bell_radius, double radius, double length); |
---|
2 | double Iq(double q, double sld, double solvent_sld, |
---|
3 | double bell_radius, double radius, double length); |
---|
4 | double Iqxy(double qx, double qy, double sld, double solvent_sld, |
---|
5 | double bell_radius, double radius, double length, |
---|
6 | double theta, double phi); |
---|
7 | |
---|
8 | //barbell kernel - same as dumbell |
---|
9 | static double |
---|
10 | _bell_kernel(double q, double h, double bell_radius, |
---|
11 | double half_length, double sin_alpha, double cos_alpha) |
---|
12 | { |
---|
13 | // translate a point in [-1,1] to a point in [lower,upper] |
---|
14 | const double upper = 1.0; |
---|
15 | const double lower = h/bell_radius; |
---|
16 | const double zm = 0.5*(upper-lower); |
---|
17 | const double zb = 0.5*(upper+lower); |
---|
18 | |
---|
19 | // cos term in integral is: |
---|
20 | // cos (q (R t - h + L/2) cos(alpha)) |
---|
21 | // so turn it into: |
---|
22 | // cos (m t + b) |
---|
23 | // where: |
---|
24 | // m = q R cos(alpha) |
---|
25 | // b = q(L/2-h) cos(alpha) |
---|
26 | const double m = q*bell_radius*cos_alpha; // cos argument slope |
---|
27 | const double b = q*(half_length-h)*cos_alpha; // cos argument intercept |
---|
28 | const double qrst = q*bell_radius*sin_alpha; // Q*R*sin(theta) |
---|
29 | double total = 0.0; |
---|
30 | for (int i = 0; i < 76; i++){ |
---|
31 | const double t = Gauss76Z[i]*zm + zb; |
---|
32 | const double radical = 1.0 - t*t; |
---|
33 | const double bj = J1c(qrst*sqrt(radical)); |
---|
34 | const double Fq = cos(m*t + b) * radical * bj; |
---|
35 | total += Gauss76Wt[i] * Fq; |
---|
36 | } |
---|
37 | // translate dx in [-1,1] to dx in [lower,upper] |
---|
38 | const double integral = total*zm; |
---|
39 | const double bell_Fq = 2*M_PI*cube(bell_radius)*integral; |
---|
40 | return bell_Fq; |
---|
41 | } |
---|
42 | |
---|
43 | double form_volume(double bell_radius, |
---|
44 | double radius, |
---|
45 | double length) |
---|
46 | { |
---|
47 | |
---|
48 | // bell radius should never be less than radius when this is called |
---|
49 | const double hdist = sqrt(square(bell_radius) - square(radius)); |
---|
50 | const double p1 = 2.0/3.0*cube(bell_radius); |
---|
51 | const double p2 = square(bell_radius)*hdist; |
---|
52 | const double p3 = cube(hdist)/3.0; |
---|
53 | |
---|
54 | return M_PI*square(radius)*length + 2.0*M_PI*(p1+p2-p3); |
---|
55 | } |
---|
56 | |
---|
57 | double Iq(double q, double sld, double solvent_sld, |
---|
58 | double bell_radius, double radius, double length) |
---|
59 | { |
---|
60 | // Exclude invalid inputs. |
---|
61 | if (bell_radius < radius) return NAN; |
---|
62 | const double h = -sqrt(bell_radius*bell_radius - radius*radius); |
---|
63 | const double half_length = 0.5*length; |
---|
64 | |
---|
65 | // translate a point in [-1,1] to a point in [0, pi/2] |
---|
66 | const double zm = M_PI_4; |
---|
67 | const double zb = M_PI_4; |
---|
68 | double total = 0.0; |
---|
69 | for (int i = 0; i < 76; i++){ |
---|
70 | const double alpha= Gauss76Z[i]*zm + zb; |
---|
71 | double sin_alpha, cos_alpha; // slots to hold sincos function output |
---|
72 | SINCOS(alpha, sin_alpha, cos_alpha); |
---|
73 | |
---|
74 | const double bell_Fq = _bell_kernel(q, h, bell_radius, half_length, sin_alpha, cos_alpha); |
---|
75 | const double bj = J1c(q*radius*sin_alpha); |
---|
76 | const double si = sinc(q*half_length*cos_alpha); |
---|
77 | const double cyl_Fq = M_PI*radius*radius*length*bj*si; |
---|
78 | const double Aq = bell_Fq + cyl_Fq; |
---|
79 | total += Gauss76Wt[i] * Aq * Aq * sin_alpha; |
---|
80 | } |
---|
81 | // translate dx in [-1,1] to dx in [lower,upper] |
---|
82 | const double form = total*zm; |
---|
83 | |
---|
84 | //Contrast |
---|
85 | const double s = (sld - solvent_sld); |
---|
86 | return 1.0e-4 * s * s * form; |
---|
87 | } |
---|
88 | |
---|
89 | |
---|
90 | double Iqxy(double qx, double qy, |
---|
91 | double sld, double solvent_sld, |
---|
92 | double bell_radius, double radius, double length, |
---|
93 | double theta, double phi) |
---|
94 | { |
---|
95 | // Compute angle alpha between q and the cylinder axis |
---|
96 | double sn, cn; // slots to hold sincos function output |
---|
97 | SINCOS(theta*M_PI_180, sn, cn); |
---|
98 | const double q = sqrt(qx*qx+qy*qy); |
---|
99 | const double cos_val = cn*cos(phi*M_PI_180)*(qx/q) + sn*(qy/q); |
---|
100 | const double alpha = acos(cos_val); // rod angle relative to q |
---|
101 | |
---|
102 | // Exclude invalid inputs. |
---|
103 | if (bell_radius < radius) return NAN; |
---|
104 | const double h = -sqrt(square(bell_radius) - square(radius)); |
---|
105 | const double half_length = 0.5*length; |
---|
106 | |
---|
107 | double sin_alpha, cos_alpha; // slots to hold sincos function output |
---|
108 | SINCOS(alpha, sin_alpha, cos_alpha); |
---|
109 | const double bell_Fq = _bell_kernel(q, h, bell_radius, half_length, sin_alpha, cos_alpha); |
---|
110 | const double bj = J1c(q*radius*sin_alpha); |
---|
111 | const double si = sinc(q*half_length*cos_alpha); |
---|
112 | const double cyl_Fq = M_PI*radius*radius*length*bj*si; |
---|
113 | const double Aq = cyl_Fq + bell_Fq; |
---|
114 | |
---|
115 | // Multiply by contrast^2 and convert to cm-1 |
---|
116 | const double s = (sld - solvent_sld); |
---|
117 | return 1.0e-4 * square(s * Aq); |
---|
118 | } |
---|