1 | __kernel void CylinderKernel(__global const float *qx, global const float *qy, __global float *_ptvalue, const float sub, |
---|
2 | const float rr, const float h, const float scale, const float radius_weight, const float length_weight, |
---|
3 | const float theta_weight, const float phi_weight, const float cyl_theta, |
---|
4 | const float 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 | float qq = sqrt(qx[i]*qx[i]+qy[i]*qy[i]); |
---|
14 | |
---|
15 | float pi = 4.0*atan(1.0); |
---|
16 | float theta = cyl_theta*pi/180.0; |
---|
17 | float phi = cyl_phi*pi/180.0; |
---|
18 | |
---|
19 | float cyl_x = cos(theta)*cos(phi); |
---|
20 | float cyl_y = sin(theta); |
---|
21 | float cos_val = cyl_x*(qx[i]/qq) + cyl_y*(qy[i]/qq); |
---|
22 | |
---|
23 | float alpha = acos(cos_val); |
---|
24 | if(alpha == 0.0){ |
---|
25 | alpha = 1.0e-26; |
---|
26 | } |
---|
27 | float besarg = qq*rr*sin(alpha); |
---|
28 | float siarg = qq*h/2*cos(alpha); |
---|
29 | |
---|
30 | float xx=0.0; float y=0.0; float bj=0.0; float ans1=0.0; float ans2=0.0; float z=0.0; float answer=0.0; |
---|
31 | float contrast=0.0; float form=0.0; float be=0.0; float si=0.0; |
---|
32 | |
---|
33 | float ax = fabs(besarg); |
---|
34 | |
---|
35 | if(ax < 8.0) { |
---|
36 | y=besarg*besarg; |
---|
37 | ans1=besarg*(72362614232.0+y*(-7895059235.0+y*(242396853.1+y*(-2972611.439+y*(15704.48260+y*(-30.16036606)))))); |
---|
38 | ans2=144725228442.0+y*(2300535178.0+y*(18583304.74+y*(99447.43394+y*(376.9991397+y*1.0)))); |
---|
39 | bj=ans1/ans2; |
---|
40 | } |
---|
41 | else{ |
---|
42 | z=8.0/ax; |
---|
43 | y=z*z; |
---|
44 | xx=ax - 2.356194491; |
---|
45 | ans1=1.0+y*(0.183105e-2+y*(-0.3516396496e-4+y*(0.2457520174e-5+y*(-0.240337019e-6)))); |
---|
46 | ans2=0.04687499995+y*(-0.2002690873e-3+y*(0.8449199096e-5+y*(-0.88228987e-6+y*0.105787412e-6))); |
---|
47 | bj=sqrt(0.636619772/ax)*(cos(xx)*ans1-z*sin(xx)*ans2); |
---|
48 | |
---|
49 | if(besarg < 0.0){bj*=-1;} |
---|
50 | } |
---|
51 | |
---|
52 | float d1 = qq*rr*sin(alpha); |
---|
53 | |
---|
54 | if (besarg == 0.0) {be = sin(alpha);} |
---|
55 | else {be = bj*bj*4.0*sin(alpha)/(d1*d1);} |
---|
56 | if(siarg == 0.0) {si = 1.0;} |
---|
57 | else{si = sin(siarg)*sin(siarg)/(siarg*siarg);} |
---|
58 | |
---|
59 | form = be*si/sin(alpha); |
---|
60 | answer = sub*sub*form*acos(-1.0)*rr*rr*h*1.0e8*scale; |
---|
61 | |
---|
62 | _ptvalue[i] = radius_weight*length_weight*theta_weight*phi_weight*answer*pow(rr,2)*h; |
---|
63 | if (size>1) { |
---|
64 | _ptvalue[i] *= fabs(cos(cyl_theta*pi/180.0)); |
---|
65 | } |
---|
66 | } |
---|
67 | } |
---|
68 | |
---|
69 | |
---|
70 | |
---|
71 | |
---|
72 | |
---|
73 | |
---|
74 | |
---|
75 | |
---|
76 | |
---|
77 | |
---|
78 | |
---|
79 | |
---|
80 | |
---|
81 | |
---|
82 | |
---|
83 | |
---|
84 | |
---|
85 | |
---|
86 | |
---|
87 | |
---|
88 | |
---|
89 | |
---|
90 | |
---|
91 | |
---|
92 | |
---|
93 | |
---|
94 | |
---|
95 | |
---|
96 | |
---|