Changeset 8a20be5 in sasmodels for Kernel-Cylinder.cpp


Ignore:
Timestamp:
Jul 10, 2014 3:05:08 PM (10 years ago)
Author:
HMP1 <helen.park@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
8faffcd
Parents:
5378e40
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Kernel-Cylinder.cpp

    r5378e40 r8a20be5  
    1 __kernel void CylinderKernel(__global const float *qx, global const float *qy, __global float *_ptvalue, const float sub, 
    2 const float rr, const float h, const float scale, const float radius_weight, const float length_weight, 
    3 const float theta_weight, const float phi_weight, const float cyl_theta, 
    4 const float cyl_phi, const int count, const int size) 
     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) 
    55{ 
    66        // qq is the q-value for the calculation (1/A) 
     
    1111    if(i < count) 
    1212    { 
    13         float qq = sqrt(qx[i]*qx[i]+qy[i]*qy[i]); 
     13        real qq = sqrt(qx[i]*qx[i]+qy[i]*qy[i]); 
    1414 
    15         float pi = 4.0*atan(1.0); 
    16         float theta = cyl_theta*pi/180.0; 
    17         float phi = cyl_phi*pi/180.0; 
     15        real pi = 4.0*atan(1.0); 
     16        real theta = cyl_theta*pi/180.0; 
     17        real phi = cyl_phi*pi/180.0; 
    1818 
    19         float cyl_x = cos(theta)*cos(phi); 
    20         float cyl_y = sin(theta); 
    21         float cos_val = cyl_x*(qx[i]/qq) + cyl_y*(qy[i]/qq); 
     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); 
    2222 
    23         float alpha = acos(cos_val); 
     23        real alpha = acos(cos_val); 
    2424        if(alpha == 0.0){ 
    2525            alpha = 1.0e-26; 
    2626        } 
    27         float besarg = qq*rr*sin(alpha); 
    28         float siarg = qq*h/2*cos(alpha); 
     27        real besarg = qq*rr*sin(alpha); 
     28        real siarg = qq*h/2*cos(alpha); 
     29        real be=0.0; real si=0.0; 
    2930 
    30             float xx=0.0; float y=0.0; float bj=0.0; float ans1=0.0; float ans2=0.0; float z=0.0; float answer=0.0; 
    31             float contrast=0.0; float form=0.0; float be=0.0; float si=0.0; 
     31        real bj = NR_BessJ1(besarg); 
    3232 
    33         float ax = fabs(besarg); 
     33        real d1 = qq*rr*sin(alpha); 
    3434 
    35         if(ax < 8.0) { 
    36             y=besarg*besarg; 
    37             ans1=besarg*(72362614232.0+y*(-7895059235.0+y*(242396853.1+y*(-2972611.439+y*(15704.48260+y*(-30.16036606)))))); 
    38             ans2=144725228442.0+y*(2300535178.0+y*(18583304.74+y*(99447.43394+y*(376.9991397+y*1.0)))); 
    39             bj=ans1/ans2; 
     35        if (besarg == 0.0){ 
     36            be = sin(alpha); 
    4037        } 
    4138        else{ 
    42             z=8.0/ax; 
    43             y=z*z; 
    44             xx=ax - 2.356194491; 
    45             ans1=1.0+y*(0.183105e-2+y*(-0.3516396496e-4+y*(0.2457520174e-5+y*(-0.240337019e-6)))); 
    46             ans2=0.04687499995+y*(-0.2002690873e-3+y*(0.8449199096e-5+y*(-0.88228987e-6+y*0.105787412e-6))); 
    47             bj=sqrt(0.636619772/ax)*(cos(xx)*ans1-z*sin(xx)*ans2); 
    48  
    49             if(besarg < 0.0){bj*=-1;} 
     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); 
    5046        } 
    5147 
    52         float d1 = qq*rr*sin(alpha); 
    53  
    54         if (besarg == 0.0) {be = sin(alpha);} 
    55         else {be = bj*bj*4.0*sin(alpha)/(d1*d1);} 
    56         if(siarg == 0.0) {si = 1.0;} 
    57         else{si = sin(siarg)*sin(siarg)/(siarg*siarg);} 
    58  
    59         form = be*si/sin(alpha); 
    60         answer = sub*sub*form*acos(-1.0)*rr*rr*h*1.0e8*scale; 
     48        real form = be*si/sin(alpha); 
     49        real answer = sub*sub*form*acos(-1.0)*rr*rr*h*1.0e8*scale; 
    6150 
    6251        _ptvalue[i] = radius_weight*length_weight*theta_weight*phi_weight*answer*pow(rr,2)*h; 
     
    6453            _ptvalue[i] *= fabs(cos(cyl_theta*pi/180.0)); 
    6554        } 
    66 } 
     55    } 
    6756} 
    6857 
Note: See TracChangeset for help on using the changeset viewer.