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