Changeset 011e0e4 in sasview for sansmodels/src/c_models/coreshellcylinder.cpp
- Timestamp:
- Jan 5, 2012 2:23:15 PM (13 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:
- 98fdccd
- Parents:
- 0ba3b08
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/c_models/coreshellcylinder.cpp
r67424cd r011e0e4 18 18 * sansmodels/src/libigor 19 19 * 20 * TODO: refactor so that we pull in the old sansmodels.c_extensions21 20 */ 22 21 23 22 #include <math.h> 24 #include "models.hh"25 23 #include "parameters.hh" 26 24 #include <stdio.h> 27 25 using namespace std; 26 #include "core_shell_cylinder.h" 28 27 29 28 extern "C" { 30 29 #include "libCylinder.h" 31 30 #include "libStructureFactor.h" 32 #include "core_shell_cylinder.h" 33 } 31 } 32 33 typedef struct { 34 double scale; 35 double radius; 36 double thickness; 37 double length; 38 double core_sld; 39 double shell_sld; 40 double solvent_sld; 41 double background; 42 double axis_theta; 43 double axis_phi; 44 } CoreShellCylinderParameters; 45 46 47 /** 48 * Function to evaluate 2D scattering function 49 * @param pars: parameters of the core-shell cylinder 50 * @param q: q-value 51 * @param q_x: q_x / q 52 * @param q_y: q_y / q 53 * @return: function value 54 */ 55 static double core_shell_cylinder_analytical_2D_scaled(CoreShellCylinderParameters *pars, double q, double q_x, double q_y) { 56 double cyl_x, cyl_y, cyl_z; 57 double q_z; 58 double alpha, vol, cos_val; 59 double answer; 60 //convert angle degree to radian 61 double pi = 4.0*atan(1.0); 62 double theta = pars->axis_theta * pi/180.0; 63 double phi = pars->axis_phi * pi/180.0; 64 65 // Cylinder orientation 66 cyl_x = sin(theta) * cos(phi); 67 cyl_y = sin(theta) * sin(phi); 68 cyl_z = cos(theta); 69 70 // q vector 71 q_z = 0; 72 73 // Compute the angle btw vector q and the 74 // axis of the cylinder 75 cos_val = cyl_x*q_x + cyl_y*q_y + cyl_z*q_z; 76 77 // The following test should always pass 78 if (fabs(cos_val)>1.0) { 79 printf("core_shell_cylinder_analytical_2D: Unexpected error: cos(alpha)=%g\n", cos_val); 80 return 0; 81 } 82 83 alpha = acos( cos_val ); 84 85 // Call the IGOR library function to get the kernel 86 answer = CoreShellCylKernel(q, pars->radius, pars->thickness, 87 pars->core_sld,pars->shell_sld, 88 pars->solvent_sld, pars->length/2.0, alpha) / fabs(sin(alpha)); 89 90 //normalize by cylinder volume 91 vol=pi*(pars->radius+pars->thickness) 92 *(pars->radius+pars->thickness) 93 *(pars->length+2.0*pars->thickness); 94 answer /= vol; 95 96 //convert to [cm-1] 97 answer *= 1.0e8; 98 99 //Scale 100 answer *= pars->scale; 101 102 // add in the background 103 answer += pars->background; 104 105 return answer; 106 } 107 108 /** 109 * Function to evaluate 2D scattering function 110 * @param pars: parameters of the core-shell cylinder 111 * @param q: q-value 112 * @return: function value 113 */ 114 static double core_shell_cylinder_analytical_2DXY(CoreShellCylinderParameters *pars, double qx, double qy) { 115 double q; 116 q = sqrt(qx*qx+qy*qy); 117 return core_shell_cylinder_analytical_2D_scaled(pars, q, qx/q, qy/q); 118 } 119 34 120 35 121 CoreShellCylinderModel :: CoreShellCylinderModel() {
Note: See TracChangeset
for help on using the changeset viewer.