Changeset 496b252 in sasmodels


Ignore:
Timestamp:
Jul 11, 2014 3:09:57 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:
8a21ba3
Parents:
be5d7df
Message:

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

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • Kernel-CoreShellCylinder.cpp

    r2de9a5e r496b252  
    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, 
     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, 
    55const int size, const int total) 
    66{ 
     
    88    if(i < total) 
    99    { 
    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); 
     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); 
    1616 
    1717        if (alpha == 0.0){ 
     
    1919        } 
    2020 
    21         float si1=0; float si2=0; float be1=0; float be2=0; 
     21        real si1=0; real si2=0; real be1=0; real be2=0; 
    2222 
    23         float vol2 = pi*(radius+thickness)*(radius+thickness)*(length+2.0*thickness); 
     23        real vol2 = pi*(radius+thickness)*(radius+thickness)*(length+2.0*thickness); 
    2424 
    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); 
     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); 
    2929 
    3030 
     
    4949            si2 = sin(sinarg2)/sinarg2; 
    5050        } 
    51         float tt = 2.0*vol2*(shell_sld-solvent_sld)*si2*be2 + 2.0*(pi*radius*radius*(length))*(core_sld-shell_sld)*si1*be1; 
     51        real tt = 2.0*vol2*(shell_sld-solvent_sld)*si2*be2 + 2.0*(pi*radius*radius*(length))*(core_sld-shell_sld)*si1*be1; 
    5252 
    53         float answer = (tt*tt)*sin(alpha)/fabs(sin(alpha)); 
    54         float vol=pi*(radius+thickness)*(radius+thickness)*(length+2.0*thickness); 
     53        real answer = (tt*tt)*sin(alpha)/fabs(sin(alpha)); 
     54        real vol=pi*(radius+thickness)*(radius+thickness)*(length+2.0*thickness); 
    5555        answer = answer/vol*1.0e8*scale; 
    5656 
  • Kernel-Lamellar.cpp

    r2de9a5e r496b252  
    77    { 
    88        real q = sqrt(qx[i]*qx[i]+qy[i]*qy[i]); 
    9         real pi = 4.0*atan(1.0); 
    10         real Pq = 2.0*sub*(sub/q)/q*(1.0-cos(q*bi_thick)); 
    11         ret[i] = 2.0*pi*scale*Pq/(q*q)/bi_thick*1.0e8 ; 
     9        ret[i] = 2.0*4.0*atan(1.0)*scale*2.0*sub*(sub/q)/q*(1.0-cos(q*bi_thick))/(q*q)/bi_thick*1.0e8 ; 
    1210    } 
    1311} 
  • code_coreshellcyl.py

    r2de9a5e r496b252  
    5757        size = len(axis_theta.weight) 
    5858 
     59        real = np.float32 if self.qx.dtype == np.dtype('float32') else np.float64 
    5960        for i in xrange(len(radius.weight)): 
    6061            for j in xrange(len(length.weight)): 
     
    6465 
    6566                            self.prg.CoreShellCylinderKernel(queue, self.qx.shape, None, self.qx_b, self.qy_b, self.res_b, 
    66                                     np.float32(axis_theta.value[k]), np.float32(axis_phi.value[l]), np.float32(thickness.value[f]), 
    67                                     np.float32(length.value[j]), np.float32(radius.value[i]), np.float32(pars['scale']), 
    68                                     np.float32(radius.weight[i]), np.float32(length.weight[j]), np.float32(thickness.weight[f]), 
    69                                     np.float32(axis_theta.weight[k]), np.float32(axis_phi.weight[l]), np.float32(pars['core_sld']), 
    70                                     np.float32(pars['shell_sld']), np.float32(pars['solvent_sld']),np.uint32(size), 
     67                                    real(axis_theta.value[k]), real(axis_phi.value[l]), real(thickness.value[f]), 
     68                                    real(length.value[j]), real(radius.value[i]), real(pars['scale']), 
     69                                    real(radius.weight[i]), real(length.weight[j]), real(thickness.weight[f]), 
     70                                    real(axis_theta.weight[k]), real(axis_phi.weight[l]), real(pars['core_sld']), 
     71                                    real(pars['shell_sld']), real(pars['solvent_sld']),np.uint32(size), 
    7172                                    np.uint32(self.qx.size)) 
    7273                            cl.enqueue_copy(queue, self.res, self.res_b) 
  • code_triaxialellipse.py

    rbe5d7df r496b252  
    5858        size = len(theta.weight) 
    5959        sub = pars['sldEll'] - pars['sldSolv'] 
     60 
    6061        real = np.float32 if self.qx.dtype == np.dtype('float32') else np.float64 
    61  
    6262        for a in xrange(len(axisA.weight)): 
    6363            for b in xrange(len(axisB.weight)): 
  • fit.py

    r2de9a5e r496b252  
    1818                              cyl_theta=0, cyl_phi=0, radius_pd=0.1, radius_pd_n=10, radius_pd_nsigma=3,length_pd=0.1, 
    1919                              length_pd_n=5, length_pd_nsigma=3, cyl_theta_pd=0.1, cyl_theta_pd_n=5, cyl_theta_pd_nsigma=3, 
    20                               cyl_phi_pd=0.1, cyl_phi_pd_n=10, cyl_phi_pd_nsigma=3, dtype='float32') 
     20                              cyl_phi_pd=0.1, cyl_phi_pd_n=10, cyl_phi_pd_nsigma=3, dtype='float') 
    2121model.radius.range(0,100) 
    2222model.length.range(0, 1000) 
    2323model.cyl_theta.range(0,90) 
    2424model.cyl_phi.range(0,90) 
     25""" 
    2526 
     27""" 
    2628model = SasModel(data, GpuEllipse, scale=.027, radius_a=60, radius_b=180, sldEll=.297e-6, sldSolv=5.773e-6, background=4.9, 
    2729                 axis_theta=0, axis_phi=90, radius_a_pd=0.1, radius_a_pd_n=10, radius_a_pd_nsigma=3, radius_b_pd=0.1, radius_b_pd_n=10, 
    2830                 radius_b_pd_nsigma=3, axis_theta_pd=0.1, axis_theta_pd_n=6, axis_theta_pd_nsigma=3, axis_phi_pd=0.1, 
    29                  axis_phi_pd_n=6, axis_phi_pd_nsigma=3, dtype='float32') 
     31                 axis_phi_pd_n=6, axis_phi_pd_nsigma=3, dtype='float') 
     32""" 
    3033 
     34""" 
    3135model = SasModel(data, GpuLamellar, scale=1, bi_thick=100, sld_bi=.291e-6, sld_sol=5.77e-6, background=0, 
    32                  bi_thick_pd=0.1, bi_thick_pd_n=35, bi_thick_pd_nsigma=3, dtype='float32') 
     36                 bi_thick_pd=0.1, bi_thick_pd_n=35, bi_thick_pd_nsigma=3, dtype='float') 
     37""" 
    3338 
    3439 
     
    3742                 length_pd=0.1, length_pd_n=10, length_pd_nsigma=3, thickness_pd=0.1, thickness_pd_n=2, thickness_pd_nsigma=3, 
    3843                 axis_theta_pd=0.1, axis_theta_pd_n=2, axis_theta_pd_nsigma=3, axis_phi_pd=0.1, axis_phi_pd_n=2, 
    39                  axis_phi_pd_nsigma=3, dtype='float32') 
     44                 axis_phi_pd_nsigma=3, dtype='float') 
    4045 
     46 
     47 
     48""" 
    4149model = SasModel(data, GpuCapCylinder, scale=1, rad_cyl=20, rad_cap=40, length=400, sld_capcyl=1e-6, sld_solv=6.3e-6, 
    4250                 background=0, theta=0, phi=0, rad_cyl_pd=.1, rad_cyl_pd_n=10, rad_cyl_nsigma=3, rad_cap_pd=.1, rad_cap_pd_n=1, 
    4351                 rad_cap_pd_nsigma=3, length_pd=.1, length_pd_n=10, length_pd_nsigma=3, theta_pd=.1, theta_pd_n=4, 
    44                  theta_pd_nsigma=3, phi_pd=.1, phi_pd_n=4, phi_pd_nsigma=3, dtype='float32') 
     52                 theta_pd_nsigma=3, phi_pd=.1, phi_pd_n=4, phi_pd_nsigma=3, dtype='float') 
     53""" 
     54 
    4555""" 
    4656model = SasModel(data, GpuTriEllipse, scale=1, axisA=35, axisB=100, axisC=400, sldEll=1e-6, sldSolv=6.3e-6, 
     
    4959                 axisA_pd=.1, axisA_pd_n=4, axisA_pd_nsigma=3, axisB_pd=.1, axisB_pd_n=4, axisB_pd_nsigma=3, 
    5060                 axisC_pd=.1, axisC_pd_n=4, axisC_pd_nsigma=3, dtype='float') 
     61""" 
     62 
    5163 
    5264model.scale.range(0,1) 
Note: See TracChangeset for help on using the changeset viewer.