Changeset 318b5bbb in sasview for sansmodels/src/c_models/cylinder.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/cylinder.cpp
r20efe7b r318b5bbb 28 28 #include "libCylinder.h" 29 29 #include "libStructureFactor.h" 30 #include "libmultifunc/libfunc.h" 30 31 } 31 32 #include "cylinder.h" … … 41 42 double cyl_theta; 42 43 double cyl_phi; 44 double M0_sld_cyl; 45 double M_theta_cyl; 46 double M_phi_cyl; 47 double M0_sld_solv; 48 double M_theta_solv; 49 double M_phi_solv; 50 double Up_frac_i; 51 double Up_frac_f; 52 double Up_theta; 43 53 } CylinderParameters; 44 54 … … 54 64 cyl_theta = Parameter(0.0, true); 55 65 cyl_phi = Parameter(0.0, true); 66 M0_sld_cyl = Parameter(0.0e-6); 67 M_theta_cyl = Parameter(0.0); 68 M_phi_cyl = Parameter(0.0); 69 M0_sld_solv = Parameter(0.0e-6); 70 M_theta_solv = Parameter(0.0); 71 M_phi_solv = Parameter(0.0); 72 Up_frac_i = Parameter(0.5); 73 Up_frac_f = Parameter(0.5); 74 Up_theta = Parameter(0.0); 56 75 } 57 76 … … 122 141 */ 123 142 static double cylinder_analytical_2D_scaled(CylinderParameters *pars, double q, double q_x, double q_y) { 124 double cyl_x, cyl_y, cyl_z; 125 double q_z; 126 double alpha, vol, cos_val; 127 double answer; 128 //convert angle degree to radian 129 double pi = 4.0*atan(1.0); 130 double theta = pars->cyl_theta * pi/180.0; 131 double phi = pars->cyl_phi * pi/180.0; 143 double cyl_x, cyl_y;//, cyl_z; 144 //double q_z; 145 double alpha, vol, cos_val; 146 double answer = 0.0; 147 double form = 0.0; 148 //convert angle degree to radian 149 double pi = 4.0*atan(1.0); 150 double theta = pars->cyl_theta * pi/180.0; 151 double phi = pars->cyl_phi * pi/180.0; 152 double sld_solv = pars->sldSolv; 153 double sld_cyl = pars->sldCyl; 154 double m_max = pars->M0_sld_cyl; 155 double m_max_solv = pars->M0_sld_solv; 156 double contrast = 0.0; 132 157 133 158 // Cylinder orientation 134 cyl_x = sin(theta) * cos(phi); 135 cyl_y = sin(theta) * sin(phi); 136 cyl_z = cos(theta); 137 159 cyl_x = cos(theta) * cos(phi); 160 cyl_y = sin(theta); 161 //cyl_z = -cos(theta) * sin(phi); 138 162 // q vector 139 q_z = 0.0;163 //q_z = 0.0; 140 164 141 165 // Compute the angle btw vector q and the 142 166 // axis of the cylinder 143 cos_val = cyl_x*q_x + cyl_y*q_y + cyl_z*q_z;167 cos_val = cyl_x*q_x + cyl_y*q_y;// + cyl_z*q_z; 144 168 145 169 // The following test should always pass … … 157 181 } 158 182 // Call the IGOR library function to get the kernel 159 answer = CylKernel(q, pars->radius, pars->length/2.0, alpha) / sin(alpha); 160 161 // Multiply by contrast^2 162 answer *= (pars->sldCyl - pars->sldSolv)*(pars->sldCyl - pars->sldSolv); 163 164 //normalize by cylinder volume 165 //NOTE that for this (Fournet) definition of the integral, one must MULTIPLY by Vcyl 183 //answer = CylKernel(q, pars->radius, pars->length/2.0, alpha) / sin(alpha); 184 185 // Call the IGOR library function to get the kernel 186 form = CylKernel(q, pars->radius, pars->length/2.0, alpha) / sin(alpha); 187 188 if (m_max < 1.0e-32 && m_max_solv < 1.0e-32){ 189 // Multiply by contrast^2 190 contrast = (pars->sldCyl - pars->sldSolv); 191 answer = contrast * contrast * form; 192 } 193 else{ 194 double qx = q_x; 195 double qy = q_y; 196 double s_theta = pars->Up_theta; 197 double m_phi = pars->M_phi_cyl; 198 double m_theta = pars->M_theta_cyl; 199 double m_phi_solv = pars->M_phi_solv; 200 double m_theta_solv = pars->M_theta_solv; 201 double in_spin = pars->Up_frac_i; 202 double out_spin = pars->Up_frac_f; 203 polar_sld p_sld; 204 polar_sld p_sld_solv; 205 p_sld = cal_msld(1, qx, qy, sld_cyl, m_max, m_theta, m_phi, 206 in_spin, out_spin, s_theta); 207 p_sld_solv = cal_msld(1, qx, qy, sld_solv, m_max_solv, m_theta_solv, m_phi_solv, 208 in_spin, out_spin, s_theta); 209 //up_up 210 if (in_spin > 0.0 && out_spin > 0.0){ 211 answer += ((p_sld.uu- p_sld_solv.uu) * (p_sld.uu- p_sld_solv.uu) * form); 212 } 213 //down_down 214 if (in_spin < 1.0 && out_spin < 1.0){ 215 answer += ((p_sld.dd - p_sld_solv.dd) * (p_sld.dd - p_sld_solv.dd) * form); 216 } 217 //up_down 218 if (in_spin > 0.0 && out_spin < 1.0){ 219 answer += ((p_sld.re_ud - p_sld_solv.re_ud) * (p_sld.re_ud - p_sld_solv.re_ud) * form); 220 answer += ((p_sld.im_ud - p_sld_solv.im_ud) * (p_sld.im_ud - p_sld_solv.im_ud) * form); 221 } 222 //down_up 223 if (in_spin < 1.0 && out_spin > 0.0){ 224 answer += ((p_sld.re_du - p_sld_solv.re_du) * (p_sld.re_du - p_sld_solv.re_du) * form); 225 answer += ((p_sld.im_du - p_sld_solv.im_du) * (p_sld.im_du - p_sld_solv.im_du) * form); 226 } 227 } 228 229 //normalize by cylinder volume 230 //NOTE that for this (Fournet) definition of the integral, one must MULTIPLY by Vcyl 166 231 vol = acos(-1.0) * pars->radius * pars->radius * pars->length; 167 answer *= vol;168 169 //convert to [cm-1]170 answer *= 1.0e8;171 172 //Scale173 answer *= pars->scale;174 175 // add in the background176 answer += pars->background;177 178 return answer;232 answer *= vol; 233 234 //convert to [cm-1] 235 answer *= 1.0e8; 236 237 //Scale 238 answer *= pars->scale; 239 240 // add in the background 241 answer += pars->background; 242 243 return answer; 179 244 } 180 245 … … 208 273 dp.cyl_theta = cyl_theta(); 209 274 dp.cyl_phi = cyl_phi(); 210 275 dp.Up_theta = Up_theta(); 276 dp.M_phi_cyl = M_phi_cyl(); 277 dp.M_theta_cyl = M_theta_cyl(); 278 dp.M0_sld_cyl = M0_sld_cyl(); 279 dp.M_phi_solv = M_phi_solv(); 280 dp.M_theta_solv = M_theta_solv(); 281 dp.M0_sld_solv = M0_sld_solv(); 282 dp.Up_frac_i = Up_frac_i(); 283 dp.Up_frac_f = Up_frac_f(); 284 211 285 // Get the dispersion points for the radius 212 286 vector<WeightPoint> weights_rad; … … 255 329 *pow(weights_rad[i].value,2)*weights_len[j].value; 256 330 if (weights_theta.size()>1) { 257 _ptvalue *= fabs( sin(weights_theta[k].value*pi/180.0));331 _ptvalue *= fabs(cos(weights_theta[k].value*pi/180.0)); 258 332 } 259 333 sum += _ptvalue;
Note: See TracChangeset
for help on using the changeset viewer.