Changeset 44aa1ed in sasview for sansmodels/src/sans/models
- Timestamp:
- Aug 21, 2009 4:14:53 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:
- 2339ff1e
- Parents:
- 14c3887
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/c_extensions/ellipsoid.c
rae3ce4e r44aa1ed 11 11 /** 12 12 * Test kernel for validation 13 * 13 * 14 14 * @param q: q-value 15 15 * @param r_small: small axis length … … 23 23 double cos_alpha; 24 24 double sph_func; 25 25 26 26 sin_alpha = sin(angle); 27 27 cos_alpha = cos(angle); 28 28 29 29 // Modified length for phase 30 length = r_small*sqrt(sin_alpha*sin_alpha + 30 length = r_small*sqrt(sin_alpha*sin_alpha + 31 31 r_long*r_long/(r_small*r_small)*cos_alpha*cos_alpha); 32 32 33 33 // Spherical scattering ampliture, with modified length for ellipsoid 34 34 sph_func = 3*( sin(q*length) - q*length*cos(q*length) ) / (q*q*q*length*length*length); 35 35 36 36 return sph_func*sph_func; 37 37 } … … 45 45 double ellipsoid_analytical_1D(EllipsoidParameters *pars, double q) { 46 46 double dp[5]; 47 47 48 48 dp[0] = pars->scale; 49 49 dp[1] = pars->radius_a; … … 51 51 dp[3] = pars->contrast; 52 52 dp[4] = pars->background; 53 53 54 54 return EllipsoidForm(dp, q); 55 55 } 56 56 57 57 /** 58 58 * Function to evaluate 2D scattering function … … 65 65 q = sqrt(qx*qx+qy*qy); 66 66 return ellipsoid_analytical_2D_scaled(pars, q, qx/q, qy/q); 67 } 67 } 68 68 69 69 /** … … 76 76 double ellipsoid_analytical_2D(EllipsoidParameters *pars, double q, double phi) { 77 77 return ellipsoid_analytical_2D_scaled(pars, q, cos(phi), sin(phi)); 78 } 78 } 79 79 80 80 /** … … 91 91 double theta, alpha, f, vol, sin_val, cos_val; 92 92 double answer; 93 93 94 94 // Ellipsoid orientation 95 95 cyl_x = sin(pars->axis_theta) * cos(pars->axis_phi); 96 96 cyl_y = sin(pars->axis_theta) * sin(pars->axis_phi); 97 97 cyl_z = cos(pars->axis_theta); 98 98 99 99 // q vector 100 100 q_z = 0; 101 101 102 102 // Compute the angle btw vector q and the 103 103 // axis of the cylinder 104 104 cos_val = cyl_x*q_x + cyl_y*q_y + cyl_z*q_z; 105 105 106 106 // The following test should always pass 107 107 if (fabs(cos_val)>1.0) { … … 109 109 return 0; 110 110 } 111 111 112 112 // Angle between rotation axis and q vector 113 113 alpha = acos( cos_val ); 114 114 115 115 // Call the IGOR library function to get the kernel 116 answer = EllipsoidKernel(q, pars->radius_ b, pars->radius_a, cos_val);117 116 answer = EllipsoidKernel(q, pars->radius_a, pars->radius_b, cos_val); 117 118 118 // Multiply by contrast^2 119 119 answer *= pars->contrast*pars->contrast; 120 120 121 121 //normalize by cylinder volume 122 122 vol = 4.0/3.0 * acos(-1.0) * pars->radius_b * pars->radius_b * pars->radius_a; 123 123 answer *= vol; 124 124 125 125 //convert to [cm-1] 126 126 answer *= 1.0e8; 127 127 128 128 //Scale 129 129 answer *= pars->scale; 130 130 131 131 // add in the background 132 132 answer += pars->background; 133 133 134 134 return answer; 135 135 }
Note: See TracChangeset
for help on using the changeset viewer.