source: sasmodels/Kernel-CoreShellCylinder.cpp @ 496b252

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

core shell cylinder is fixed; float converted to real so is interchangeable

  • Property mode set to 100644
File size: 2.2 KB
Line 
1__kernel void CoreShellCylinderKernel(__global const real *qx, __global const real *qy, __global real *_ptvalue,
2const real axis_theta, const real axis_phi, const real thickness, const real length, const real radius,
3const real scale, const real radius_weight, const real length_weight, const real thickness_weight,
4const real theta_weight, const real phi_weight, const real core_sld, const real shell_sld, const real solvent_sld,
5const int size, const int total)
6{
7    int i = get_global_id(0);
8    if(i < total)
9    {
10        real q = sqrt(qx[i]*qx[i]+qy[i]*qy[i]);
11        real pi = 4.0*atan(1.0);
12        real theta = axis_theta*pi/180.0;
13        real cyl_x = cos(theta)*cos(axis_phi*pi/180.0);
14        real cyl_y = sin(theta);
15        real alpha = acos(cyl_x*qx[i]/q + cyl_y*qy[i]/q);
16
17        if (alpha == 0.0){
18        alpha = 1.0e-26;
19        }
20
21        real si1=0; real si2=0; real be1=0; real be2=0;
22
23        real vol2 = pi*(radius+thickness)*(radius+thickness)*(length+2.0*thickness);
24
25        real besarg1 = q*radius*sin(alpha);
26        real besarg2 = q*(radius+thickness)*sin(alpha);
27        real sinarg1 = q*length/2.0*cos(alpha);
28        real sinarg2 = q*(length/2.0+thickness)*cos(alpha);
29
30
31        if (besarg1 == 0.0){be1 = 0.5;}
32        else{
33            be1 = NR_BessJ1(besarg1)/besarg1;
34        }
35        if (besarg2 == 0.0){be2 = 0.5;}
36        else{
37            be2 = NR_BessJ1(besarg2)/besarg2;
38        }
39        if (sinarg1 == 0.0){
40            si1 = 1.0;
41        }
42        else{
43            si1 = sin(sinarg1)/sinarg1;
44        }
45        if (sinarg2 == 0.0){
46            si2 = 1.0;
47        }
48        else{
49            si2 = sin(sinarg2)/sinarg2;
50        }
51        real tt = 2.0*vol2*(shell_sld-solvent_sld)*si2*be2 + 2.0*(pi*radius*radius*(length))*(core_sld-shell_sld)*si1*be1;
52
53        real answer = (tt*tt)*sin(alpha)/fabs(sin(alpha));
54        real vol=pi*(radius+thickness)*(radius+thickness)*(length+2.0*thickness);
55        answer = answer/vol*1.0e8*scale;
56
57        _ptvalue[i] = radius_weight*length_weight*thickness_weight*theta_weight*phi_weight*answer;
58        _ptvalue[i] *= pow(radius+thickness,2)*(length+2.0*thickness);
59
60        if (size>1) {
61        _ptvalue[i] *= fabs(cos(axis_theta*pi/180.0));
62        }
63
64    }
65}
66
67
68
Note: See TracBrowser for help on using the repository browser.