[5378e40] | 1 | __kernel void CoreShellCylinderKernel(__global const float *qx, __global const float *qy, __global float *_ptvalue, |
---|
| 2 | const float axis_theta, const float axis_phi, const float thickness, const float length, const float radius, |
---|
| 3 | const float scale, const float radius_weight, const float length_weight, const float thickness_weight, |
---|
| 4 | const float theta_weight, const float phi_weight, const float core_sld, const float shell_sld, const float solvent_sld, |
---|
| 5 | const 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 phi = axis_phi*pi/180.0; |
---|
| 14 | float cyl_x = cos(theta)*cos(phi); |
---|
| 15 | float cyl_y = sin(theta); |
---|
| 16 | float cos_val = cyl_x*qx[i]/q + cyl_y*qx[i]/q; |
---|
| 17 | float alpha = acos(cos_val); |
---|
| 18 | |
---|
| 19 | if (alpha == 0.0){ |
---|
| 20 | alpha = 1.0e-26; |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | float si1=0; float si2=0; float be1=0; float be2=0; |
---|
| 24 | |
---|
| 25 | float dr1 = core_sld-shell_sld; |
---|
| 26 | float dr2 = shell_sld-solvent_sld; |
---|
| 27 | float vol1 = pi*radius*radius*(length); |
---|
| 28 | float vol2 = pi*(radius+thickness)*(radius+thickness)*(length+2.0*thickness); |
---|
| 29 | |
---|
| 30 | float besarg1 = q*radius*sin(alpha); |
---|
| 31 | float besarg2 = q*(radius+thickness)*sin(alpha); |
---|
| 32 | float sinarg1 = q*length/2.0*cos(alpha); |
---|
| 33 | float sinarg2 = q*(length/2.0+thickness)*cos(alpha); |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | if (besarg1 == 0.0){be1 = 0.5;} |
---|
| 37 | else{ |
---|
[8faffcd] | 38 | be1 = NR_BessJ1(besarg1)/besarg1; |
---|
[5378e40] | 39 | } |
---|
| 40 | if (besarg2 == 0.0){be2 = 0.5;} |
---|
| 41 | else{ |
---|
[8faffcd] | 42 | be2 = NR_BessJ1(besarg2)/besarg2; |
---|
[5378e40] | 43 | } |
---|
| 44 | if (sinarg1 == 0.0){ |
---|
| 45 | si1 = 1.0; |
---|
| 46 | } |
---|
| 47 | else{ |
---|
| 48 | si1 = sin(sinarg1)/sinarg1; |
---|
| 49 | } |
---|
| 50 | if (sinarg2 == 0.0){ |
---|
| 51 | si2 = 1.0; |
---|
| 52 | } |
---|
| 53 | else{ |
---|
| 54 | si2 = sin(sinarg2)/sinarg2; |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | float t1 = 2.0*vol1*dr1*si1*be1; |
---|
| 58 | float t2 = 2.0*vol2*dr2*si2*be2; |
---|
| 59 | |
---|
| 60 | float answer = ((t1+t2)*(t1+t2))*sin(alpha)/fabs(sin(alpha)); |
---|
| 61 | float vol=pi*(radius+thickness)*(radius+thickness)*(length+2.0*thickness); |
---|
| 62 | answer = answer/vol*1.0e8*scale; |
---|
| 63 | |
---|
| 64 | _ptvalue[i] = radius_weight*length_weight*thickness_weight*theta_weight*phi_weight*answer; |
---|
| 65 | _ptvalue[i] *= pow(radius+thickness,2)*(length+2.0*thickness); |
---|
| 66 | |
---|
| 67 | if (size>1) { |
---|
| 68 | _ptvalue[i] *= fabs(cos(axis_theta*pi/180.0)); |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | } |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | |
---|