source: sasmodels/Kernel-TriaxialEllipse.cpp @ 8a21ba3

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

Added Triaxial Ellipse Code and Kernel
Functions in Kernel are separated from the rest of Kernel code

  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[2de9a5e]1__kernel void TriaxialEllipseKernel(__global const real *qx, __global const real *qy, __global real *_ptvalue,
2const real sub, const real scale, const real axisA, const real axisB, const real axisC, const real axis_phi,
3const real axis_theta, const real axis_psi, const real axisA_weight, const real axisB_weight, const real axisC_weight,
4const real psi_weight, const real phi_weight, const real theta_weight, const int total, const int size)
5{
6    int i = get_global_id(0);
7    if(i < total)
8    {
9        real q = sqrt(qx[i]*qx[i]+qy[i]*qy[i]);
10        real q_x = qx[i]/q;
11        real q_y = qy[i]/q;
12        real pi = 4.0*atan(1.0);
[be5d7df]13        real answer=0;
[2de9a5e]14       
15        //convert angle degree to radian
16        real theta = axis_theta*pi/180.0;
17        real phi = axis_phi*pi/180.0;
18        real psi = axis_psi*pi/180.0;
19        real cos_val = cos(theta)*cos(phi)*q_x + sin(theta)*q_y;
20       
21        // calculate the axis of the ellipse wrt q-coord.
22        real cos_nu = (-cos(phi)*sin(psi)*sin(theta)+sin(phi)*cos(psi))*q_x + sin(psi)*cos(theta)*q_y;
23        real cos_mu = (-sin(theta)*cos(psi)*cos(phi)-sin(psi)*sin(phi))*q_x + cos(theta)*cos(psi)*q_y;
24        real t = q*sqrt(axisA*axisA*cos_nu*cos_nu+axisB*axisB*cos_mu*cos_mu+axisC*axisC*cos_val*cos_val);
25
26        if (t==0.0){
27            answer = 1.0;
28        }
29        else{
30            answer  = 3.0*(sin(t)-t*cos(t))/(t*t*t);
31        }
32        answer*=answer*sub*sub*4.0*pi/3.0*axisA*axisB*axisC*1.0e8*scale;
33
34        _ptvalue[i] = axisA_weight*axisB_weight*axisC_weight*theta_weight*phi_weight*psi_weight*answer*axisA*axisB*axisC;
35        if (size>1)
36        {
37            _ptvalue[i] *= fabs(cos(theta*pi/180.0));
38        }
39    }
40}
41
42
43
44
Note: See TracBrowser for help on using the repository browser.