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

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

Added a fit2 (fits two different models at different angles)
(preliminary) Added CoreshellCyl? and CapCyl? Kernels
(preliminary) Updated kernels to include functions

  • Property mode set to 100644
File size: 1.7 KB
Line 
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 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
Note: See TracBrowser for help on using the repository browser.