Changeset 318b5bbb in sasview for sansmodels/src/c_models/triaxialellipsoid.cpp
- Timestamp:
- Dec 18, 2012 10:55:24 AM (12 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/c_models/triaxialellipsoid.cpp
re08bd5b r318b5bbb 46 46 } TriaxialEllipsoidParameters; 47 47 48 static double triaxial_ellipsoid_kernel(TriaxialEllipsoidParameters *pars, double q, double alpha, double nu) {48 static double triaxial_ellipsoid_kernel(TriaxialEllipsoidParameters *pars, double q, double cos_val, double cos_nu, double cos_mu) { 49 49 double t,a,b,c; 50 50 double kernel; … … 54 54 c = pars->semi_axisC ; 55 55 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); 57 57 if (t==0.0){ 58 58 kernel = 1.0; … … 73 73 */ 74 74 static 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; 79 79 double answer; 80 80 double pi = 4.0*atan(1.0); … … 86 86 87 87 // 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); 91 91 92 92 // q vector 93 q_z = 0.0;93 //q_z = 0.0; 94 94 95 95 //dx = 1.0; … … 97 97 // Compute the angle btw vector q and the 98 98 // 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; 100 100 101 101 // The following test should always pass … … 107 107 // Note: cos(alpha) = 0 and 1 will get an 108 108 // undefined value from CylKernel 109 alpha = acos( cos_val );109 //alpha = acos( cos_val ); 110 110 111 111 //ellipse orientation: … … 116 116 // the wave vector q. 117 117 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 122 126 // 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 } 126 143 // 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); 128 145 129 146 // Multiply by contrast^2 … … 325 342 * weights_semi_axisA[i].value*weights_semi_axisB[j].value*weights_semi_axisC[k].value; 326 343 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)); 328 345 } 329 346 sum += _ptvalue;
Note: See TracChangeset
for help on using the changeset viewer.