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