Changeset ea07075 in sasview for sansmodels/src/sans/models/c_extensions/flexible_cylinder.c
- Timestamp:
- Aug 3, 2009 5:41:22 PM (15 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:
- e6fa43e
- Parents:
- 2a1be2d9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/c_extensions/flexible_cylinder.c
r5068697 rea07075 19 19 double flexible_cylinder_analytical_1D(FlexibleCylinderParameters *pars, double q) { 20 20 double dp[6]; 21 21 22 22 // Fill paramater array 23 23 dp[0] = pars->scale; … … 29 29 30 30 // Call library function to evaluate model 31 return FlexExclVolCyl(dp, q); 31 return FlexExclVolCyl(dp, q); 32 32 } 33 33 /** … … 40 40 double q; 41 41 q = sqrt(qx*qx+qy*qy); 42 return flexible_cylinder_analytical_ 2D_scaled(pars, q, qx/q, qy/q);43 } 42 return flexible_cylinder_analytical_1D(pars, q); 43 } 44 44 45 45 … … 52 52 */ 53 53 double flexible_cylinder_analytical_2D(FlexibleCylinderParameters *pars, double q, double phi) { 54 return flexible_cylinder_analytical_2D_scaled(pars, q, cos(phi), sin(phi)); 55 } 56 57 /** 58 * Function to evaluate 2D scattering function 59 * @param pars: parameters of the flexible cylinder 60 * @param q: q-value 61 * @param q_x: q_x / q 62 * @param q_y: q_y / q 63 * @return: function value 64 */ 65 double flexible_cylinder_analytical_2D_scaled(FlexibleCylinderParameters *pars, double q, double q_x, double q_y) { 66 double cyl_x, cyl_y, cyl_z; 67 double q_z; 68 double alpha, vol, cos_val; 69 double answer; 70 71 54 return flexible_cylinder_analytical_1D(pars, q); 55 } 72 56 73 // parallelepiped orientation74 cyl_x = sin(pars->axis_theta) * cos(pars->axis_phi);75 cyl_y = sin(pars->axis_theta) * sin(pars->axis_phi);76 cyl_z = cos(pars->axis_theta);77 78 // q vector79 q_z = 0;80 81 // Compute the angle btw vector q and the82 // axis of the parallelepiped83 cos_val = cyl_x*q_x + cyl_y*q_y + cyl_z*q_z;84 85 // The following test should always pass86 if (fabs(cos_val)>1.0) {87 printf("parallel_ana_2D: Unexpected error: cos(alpha)>1\n");88 return 0;89 }90 91 // Note: cos(alpha) = 0 and 1 will get an92 // undefined value from PPKernel93 alpha = acos( cos_val );94 57 95 // Call the IGOR library function to get the kernel96 answer = CylKernel(q, pars->radius, pars->length/2.0, alpha) / sin(alpha);97 98 // Multiply by contrast^299 answer *= pars->contrast*pars->contrast;100 101 //normalize by cylinder volume102 //NOTE that for this (Fournet) definition of the integral, one must MULTIPLY by Vparallel103 vol = acos(-1.0) * pars->radius * pars->radius * pars->length;104 answer *= vol;105 106 //convert to [cm-1]107 answer *= 1.0e8;108 109 //Scale110 answer *= pars->scale;111 112 // add in the background113 answer += pars->background;114 115 return answer;116 }117 118
Note: See TracChangeset
for help on using the changeset viewer.