source: sasmodels/Kernel/Kernel-Cylinder.cpp @ 8cdb9f1

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 8cdb9f1 was a42fec0, checked in by HMP1 <helen.park@…>, 10 years ago

Speed-up of 3X, compare.py working

  • Property mode set to 100644
File size: 1.6 KB
RevLine 
[099e053]1__kernel void CylinderKernel(__global const real *qx, global const real *qy, __global real *_ptvalue, const real sub,
2const real rr, const real h, const real scale, const real radius_weight, const real length_weight,
3const real theta_weight, const real phi_weight, const real cyl_theta,
4const 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 be=0.0; real si=0.0;
14        real qq = sqrt(qx[i]*qx[i]+qy[i]*qy[i]);
15
16        real pi = 4.0*atan(1.0);
17        real theta = cyl_theta*pi/180.0;
18        real cos_val = cos(theta)*cos(cyl_phi*pi/180.0)*(qx[i]/qq) + sin(theta)*(qy[i]/qq);
19
20        real alpha = acos(cos_val);
21        if(alpha == 0.0){
22            alpha = 1.0e-26;
23        }
24        real besarg = qq*rr*sin(alpha);
25        real siarg = qq*h/2*cos(alpha);
26
27        real bj = NR_BessJ1(besarg);
28        real d1 = qq*rr*sin(alpha);
29
30        if (besarg == 0.0){
31            be = sin(alpha);
32        }
33        else{
34            be = bj*bj*4.0*sin(alpha)/(d1*d1);
35        }
36        if(siarg == 0.0){
37            si = 1.0;
38        }else{
39            si = sin(siarg)*sin(siarg)/(siarg*siarg);
40        }
41        real form = be*si/sin(alpha);
42        real answer = sub*sub*form*acos(-1.0)*rr*rr*h*1.0e8*scale;
43
[a42fec0]44        _ptvalue[i] += radius_weight*length_weight*theta_weight*phi_weight*answer*pow(rr,2)*h;
45
[099e053]46       // if (size>1) {
47         //   _ptvalue[i] *= fabs(cos(cyl_theta*pi/180.0));
48      //  }
49    }
50}
51
52
53
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
Note: See TracBrowser for help on using the repository browser.