1 | #define INVALID(v) (v.radius<0 || v.length<0) |
---|
2 | |
---|
3 | static double |
---|
4 | form_volume(double radius, double length) |
---|
5 | { |
---|
6 | return M_PI*radius*radius*length; |
---|
7 | } |
---|
8 | |
---|
9 | static double |
---|
10 | fq(double qab, double qc, double radius, double length) |
---|
11 | { |
---|
12 | return sas_2J1x_x(qab*radius) * sas_sinx_x(qc*0.5*length); |
---|
13 | } |
---|
14 | |
---|
15 | static double |
---|
16 | orient_avg_1D(double q, double radius, double length) |
---|
17 | { |
---|
18 | // translate a point in [-1,1] to a point in [0, pi/2] |
---|
19 | const double zm = M_PI_4; |
---|
20 | const double zb = M_PI_4; |
---|
21 | |
---|
22 | double total = 0.0; |
---|
23 | for (int i=0; i<76 ;i++) { |
---|
24 | const double theta = Gauss76Z[i]*zm + zb; |
---|
25 | double sin_theta, cos_theta; // slots to hold sincos function output |
---|
26 | // theta (theta,phi) the projection of the cylinder on the detector plane |
---|
27 | SINCOS(theta , sin_theta, cos_theta); |
---|
28 | const double form = fq(q*sin_theta, q*cos_theta, radius, length); |
---|
29 | total += Gauss76Wt[i] * form * form * sin_theta; |
---|
30 | } |
---|
31 | // translate dx in [-1,1] to dx in [lower,upper] |
---|
32 | return total*zm; |
---|
33 | } |
---|
34 | |
---|
35 | static double |
---|
36 | Iq(double q, |
---|
37 | double sld, |
---|
38 | double solvent_sld, |
---|
39 | double radius, |
---|
40 | double length) |
---|
41 | { |
---|
42 | const double s = (sld - solvent_sld) * form_volume(radius, length); |
---|
43 | return 1.0e-4 * s * s * orient_avg_1D(q, radius, length); |
---|
44 | } |
---|
45 | |
---|
46 | static double |
---|
47 | Iqxy(double qab, double qc, |
---|
48 | double sld, |
---|
49 | double solvent_sld, |
---|
50 | double radius, |
---|
51 | double length) |
---|
52 | { |
---|
53 | const double s = (sld-solvent_sld) * form_volume(radius, length); |
---|
54 | const double form = fq(qab, qc, radius, length); |
---|
55 | return 1.0e-4 * square(s * form); |
---|
56 | } |
---|