source: sasmodels/Kernel-CoreShellCylinder.cpp @ 2de9a5e

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

Update for Aaron

  • Property mode set to 100644
File size: 2.2 KB
Line 
1__kernel void CoreShellCylinderKernel(__global const float *qx, __global const float *qy, __global float *_ptvalue,
2const float axis_theta, const float axis_phi, const float thickness, const float length, const float radius,
3const float scale, const float radius_weight, const float length_weight, const float thickness_weight,
4const float theta_weight, const float phi_weight, const float core_sld, const float shell_sld, const float solvent_sld,
5const int size, const int total)
6{
7    int i = get_global_id(0);
8    if(i < total)
9    {
10        float q = sqrt(qx[i]*qx[i]+qy[i]*qy[i]);
11        float pi = 4.0*atan(1.0);
12        float theta = axis_theta*pi/180.0;
13        float cyl_x = cos(theta)*cos(axis_phi*pi/180.0);
14        float cyl_y = sin(theta);
15        float alpha = acos(cyl_x*qx[i]/q + cyl_y*qx[i]/q);
16
17        if (alpha == 0.0){
18        alpha = 1.0e-26;
19        }
20
21        float si1=0; float si2=0; float be1=0; float be2=0;
22
23        float vol2 = pi*(radius+thickness)*(radius+thickness)*(length+2.0*thickness);
24
25        float besarg1 = q*radius*sin(alpha);
26        float besarg2 = q*(radius+thickness)*sin(alpha);
27        float sinarg1 = q*length/2.0*cos(alpha);
28        float 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        float tt = 2.0*vol2*(shell_sld-solvent_sld)*si2*be2 + 2.0*(pi*radius*radius*(length))*(core_sld-shell_sld)*si1*be1;
52
53        float answer = (tt*tt)*sin(alpha)/fabs(sin(alpha));
54        float 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.