1 | __kernel void CylinderKernel(__global const real *qx, global const real *qy, __global real *_ptvalue, const real sub, |
---|
2 | const real rr, const real h, const real scale, const real radius_weight, const real length_weight, |
---|
3 | const real theta_weight, const real phi_weight, const real cyl_theta, |
---|
4 | const real cyl_phi, const int count, const int size) |
---|
5 | { |
---|
6 | // qq is the q-value for the calculation (1/A) |
---|
7 | // rr is the radius of the cylinder (A) |
---|
8 | // h is the -LENGTH of the cylinder = L (A) |
---|
9 | int i = get_global_id(0); |
---|
10 | |
---|
11 | if(i < count) |
---|
12 | { |
---|
13 | real qq = sqrt(qx[i]*qx[i]+qy[i]*qy[i]); |
---|
14 | |
---|
15 | real pi = 4.0*atan(1.0); |
---|
16 | real theta = cyl_theta*pi/180.0; |
---|
17 | real phi = cyl_phi*pi/180.0; |
---|
18 | |
---|
19 | real cyl_x = cos(theta)*cos(phi); |
---|
20 | real cyl_y = sin(theta); |
---|
21 | real cos_val = cyl_x*(qx[i]/qq) + cyl_y*(qy[i]/qq); |
---|
22 | |
---|
23 | real alpha = acos(cos_val); |
---|
24 | if(alpha == 0.0){ |
---|
25 | alpha = 1.0e-26; |
---|
26 | } |
---|
27 | real besarg = qq*rr*sin(alpha); |
---|
28 | real siarg = qq*h/2*cos(alpha); |
---|
29 | real be=0.0; real si=0.0; |
---|
30 | |
---|
31 | real bj = NR_BessJ1(besarg); |
---|
32 | |
---|
33 | real d1 = qq*rr*sin(alpha); |
---|
34 | |
---|
35 | if (besarg == 0.0){ |
---|
36 | be = sin(alpha); |
---|
37 | } |
---|
38 | else{ |
---|
39 | be = bj*bj*4.0*sin(alpha)/(d1*d1); |
---|
40 | } |
---|
41 | if(siarg == 0.0){ |
---|
42 | si = 1.0; |
---|
43 | } |
---|
44 | else{ |
---|
45 | si = sin(siarg)*sin(siarg)/(siarg*siarg); |
---|
46 | } |
---|
47 | |
---|
48 | real form = be*si/sin(alpha); |
---|
49 | real answer = sub*sub*form*acos(-1.0)*rr*rr*h*1.0e8*scale; |
---|
50 | |
---|
51 | _ptvalue[i] = radius_weight*length_weight*theta_weight*phi_weight*answer*pow(rr,2)*h; |
---|
52 | if (size>1) { |
---|
53 | _ptvalue[i] *= fabs(cos(cyl_theta*pi/180.0)); |
---|
54 | } |
---|
55 | } |
---|
56 | } |
---|
57 | |
---|
58 | |
---|
59 | |
---|
60 | |
---|
61 | |
---|
62 | |
---|
63 | |
---|
64 | |
---|
65 | |
---|
66 | |
---|
67 | |
---|
68 | |
---|
69 | |
---|
70 | |
---|
71 | |
---|
72 | |
---|
73 | |
---|
74 | |
---|
75 | |
---|
76 | |
---|
77 | |
---|
78 | |
---|
79 | |
---|
80 | |
---|
81 | |
---|
82 | |
---|
83 | |
---|
84 | |
---|
85 | |
---|