Ignore:
Timestamp:
Dec 18, 2012 10:55:24 AM (12 years ago)
Author:
Jae Cho <jhjcho@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
6550b64
Parents:
0203ade
Message:

Added polarization and magnetic stuffs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/c_models/triaxialellipsoid.cpp

    re08bd5b r318b5bbb  
    4646} TriaxialEllipsoidParameters; 
    4747 
    48 static double triaxial_ellipsoid_kernel(TriaxialEllipsoidParameters *pars, double q, double alpha, double nu) { 
     48static double triaxial_ellipsoid_kernel(TriaxialEllipsoidParameters *pars, double q, double cos_val, double cos_nu, double cos_mu) { 
    4949  double t,a,b,c; 
    5050  double kernel; 
     
    5454  c = pars->semi_axisC ; 
    5555 
    56   t = q * sqrt(a*a*cos(nu)*cos(nu)+b*b*sin(nu)*sin(nu)*sin(alpha)*sin(alpha)+c*c*cos(alpha)*cos(alpha)); 
     56  t = q * sqrt(a*a*cos_nu*cos_nu+b*b*cos_mu*cos_mu+c*c*cos_val*cos_val); 
    5757  if (t==0.0){ 
    5858    kernel  = 1.0; 
     
    7373 */ 
    7474static double triaxial_ellipsoid_analytical_2D_scaled(TriaxialEllipsoidParameters *pars, double q, double q_x, double q_y) { 
    75   double cyl_x, cyl_y, cyl_z, ell_x, ell_y; 
    76   double q_z; 
    77   double cos_nu,nu; 
    78   double alpha, vol, cos_val; 
     75  double cyl_x, cyl_y, ella_x, ella_y, ellb_x, ellb_y; 
     76  //double q_z; 
     77  double cos_nu, cos_mu; 
     78  double vol, cos_val; 
    7979  double answer; 
    8080  double pi = 4.0*atan(1.0); 
     
    8686 
    8787  // Cylinder orientation 
    88   cyl_x = sin(theta) * cos(phi); 
    89   cyl_y = sin(theta) * sin(phi); 
    90   cyl_z = cos(theta); 
     88  cyl_x = cos(theta) * cos(phi); 
     89  cyl_y = sin(theta); 
     90  //cyl_z = -cos(theta) * sin(phi); 
    9191 
    9292  // q vector 
    93   q_z = 0.0; 
     93  //q_z = 0.0; 
    9494 
    9595  //dx = 1.0; 
     
    9797  // Compute the angle btw vector q and the 
    9898  // axis of the cylinder 
    99   cos_val = cyl_x*q_x + cyl_y*q_y + cyl_z*q_z; 
     99  cos_val = cyl_x*q_x + cyl_y*q_y;// + cyl_z*q_z; 
    100100 
    101101  // The following test should always pass 
     
    107107  // Note: cos(alpha) = 0 and 1 will get an 
    108108  // undefined value from CylKernel 
    109   alpha = acos( cos_val ); 
     109  //alpha = acos( cos_val ); 
    110110 
    111111  //ellipse orientation: 
     
    116116  // the wave vector q. 
    117117 
    118   //x- y- component on the detector plane. 
    119   ell_x =  cos(psi); 
    120   ell_y =  sin(psi); 
    121  
     118  //x- y- component of a-axis on the detector plane. 
     119  ella_x =  -cos(phi)*sin(psi) * sin(theta)+sin(phi)*cos(psi); 
     120  ella_y =  sin(psi)*cos(theta); 
     121   
     122  //x- y- component of b-axis on the detector plane. 
     123  ellb_x =  -sin(theta)*cos(psi)*cos(phi)-sin(psi)*sin(phi); 
     124  ellb_y =  cos(theta)*cos(psi); 
     125   
    122126  // calculate the axis of the ellipse wrt q-coord. 
    123   cos_nu = ell_x*q_x + ell_y*q_y; 
    124   nu = acos(cos_nu); 
    125  
     127  cos_nu = ella_x*q_x + ella_y*q_y; 
     128  cos_mu = ellb_x*q_x + ellb_y*q_y; 
     129   
     130  // The following test should always pass 
     131  if (fabs(cos_val)>1.0) { 
     132    //printf("parallel_ana_2D: Unexpected error: cos(alpha)>1\n"); 
     133    cos_val = 1.0; 
     134  } 
     135   if (fabs(cos_nu)>1.0) { 
     136    //printf("parallel_ana_2D: Unexpected error: cos(alpha)>1\n"); 
     137    cos_nu = 1.0; 
     138  } 
     139   if (fabs(cos_mu)>1.0) { 
     140    //printf("parallel_ana_2D: Unexpected error: cos(alpha)>1\n"); 
     141    cos_mu = 1.0; 
     142  }  
    126143  // Call the IGOR library function to get the kernel 
    127   answer = triaxial_ellipsoid_kernel(pars, q, alpha, nu); 
     144  answer = triaxial_ellipsoid_kernel(pars, q, cos_val, cos_nu, cos_mu); 
    128145 
    129146  // Multiply by contrast^2 
     
    325342              * weights_semi_axisA[i].value*weights_semi_axisB[j].value*weights_semi_axisC[k].value; 
    326343              if (weights_theta.size()>1) { 
    327                 _ptvalue *= fabs(sin(weights_theta[k].value*pi/180.0)); 
     344                _ptvalue *= fabs(cos(weights_theta[k].value*pi/180.0)); 
    328345              } 
    329346              sum += _ptvalue; 
Note: See TracChangeset for help on using the changeset viewer.