Changeset f9bf661 in sasview for sansmodels/src/sans/models/c_models
- Timestamp:
- Sep 11, 2009 10:38:53 AM (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:
- c1e865a
- Parents:
- 72f719b
- Location:
- sansmodels/src/sans/models/c_models
- Files:
-
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/c_models/CBinaryHSModel.cpp
r9ce41c6 rf9bf661 18 18 * 19 19 * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY 20 * DO NOT MODIFY THIS FILE, MODIFY binaryH s.h20 * DO NOT MODIFY THIS FILE, MODIFY binaryHS.h 21 21 * AND RE-RUN THE GENERATOR SCRIPT 22 22 * … … 33 33 #include <math.h> 34 34 #include <time.h> 35 #include "binaryH s.h"35 #include "binaryHS.h" 36 36 } 37 37 -
sansmodels/src/sans/models/c_models/DiamCyl.cpp
r5eb9154 rf9bf661 141 141 /** 142 142 * Function to calculate effective radius 143 * @param pars: parameters of the sphere144 143 * @return: effective radius value 145 144 */ -
sansmodels/src/sans/models/c_models/DiamEllip.cpp
r5eb9154 rf9bf661 139 139 /** 140 140 * Function to calculate effective radius 141 * @param pars: parameters of the sphere142 141 * @return: effective radius value 143 142 */ -
sansmodels/src/sans/models/c_models/Hardsphere.cpp
r5eb9154 rf9bf661 122 122 /** 123 123 * Function to calculate effective radius 124 * @param pars: parameters of the sphere125 124 * @return: effective radius value 126 125 */ -
sansmodels/src/sans/models/c_models/HayterMSA.cpp
r8b677ec rf9bf661 136 136 /** 137 137 * Function to calculate effective radius 138 * @param pars: parameters of the sphere139 138 * @return: effective radius value 140 139 */ -
sansmodels/src/sans/models/c_models/SquareWell.cpp
r5eb9154 rf9bf661 128 128 /** 129 129 * Function to calculate effective radius 130 * @param pars: parameters of the sphere131 130 * @return: effective radius value 132 131 */ -
sansmodels/src/sans/models/c_models/StickyHS.cpp
r5eb9154 rf9bf661 130 130 /** 131 131 * Function to calculate effective radius 132 * @param pars: parameters of the sphere133 132 * @return: effective radius value 134 133 */ -
sansmodels/src/sans/models/c_models/binaryHS.cpp
r5eb9154 rf9bf661 118 118 /** 119 119 * Function to calculate effective radius 120 * @param pars: parameters of the sphere121 120 * @return: effective radius value 122 121 */ -
sansmodels/src/sans/models/c_models/binaryHS_PSF11.cpp
r5eb9154 rf9bf661 116 116 /** 117 117 * Function to calculate effective radius 118 * @param pars: parameters of the sphere119 118 * @return: effective radius value 120 119 */ -
sansmodels/src/sans/models/c_models/coreshellcylinder.cpp
r5eb9154 rf9bf661 216 216 /** 217 217 * Function to calculate effective radius 218 * @param pars: parameters of the sphere219 218 * @return: effective radius value 220 219 */ -
sansmodels/src/sans/models/c_models/coreshellsphere.cpp
r5eb9154 rf9bf661 116 116 /** 117 117 * Function to calculate effective radius 118 * @param pars: parameters of the sphere119 118 * @return: effective radius value 120 119 */ -
sansmodels/src/sans/models/c_models/cylinder.cpp
r5eb9154 rf9bf661 183 183 return (*this).operator()(qx, qy); 184 184 } 185 185 /** 186 * Function to calculate effective radius 187 * @return: effective radius value 188 */ 189 double CylinderModel :: calculate_ER() { 190 CylinderParameters dp; 191 192 dp.radius = radius(); 193 dp.length = length(); 194 double rad_out = 0.0; 195 196 // Perform the computation, with all weight points 197 double sum = 0.0; 198 double norm = 0.0; 199 200 // Get the dispersion points for the major shell 201 vector<WeightPoint> weights_length; 202 length.get_weights(weights_length); 203 204 // Get the dispersion points for the minor shell 205 vector<WeightPoint> weights_radius ; 206 radius.get_weights(weights_radius); 207 208 // Loop over major shell weight points 209 for(int i=0; i< (int)weights_length.size(); i++) { 210 dp.length = weights_length[i].value; 211 for(int k=0; k< (int)weights_radius.size(); k++) { 212 dp.radius = weights_radius[k].value; 213 //Note: output of "DiamCyl(dp.length,dp.radius)" is DIAMETER. 214 sum +=weights_length[i].weight 215 * weights_radius[k].weight*DiamCyl(dp.length,dp.radius)/2.0; 216 norm += weights_length[i].weight* weights_radius[k].weight; 217 } 218 } 219 if (norm != 0){ 220 //return the averaged value 221 rad_out = sum/norm;} 222 else{ 223 //return normal value 224 //Note: output of "DiamCyl(dp.length,dp.radius)" is DIAMETER. 225 rad_out = DiamCyl(dp.length,dp.radius)/2.0;} 226 227 return rad_out; 228 } 186 229 // Testing code 187 230 int main(void) … … 234 277 return 0; 235 278 } 236 /** 237 * Function to calculate effective radius 238 * @param pars: parameters of the sphere 239 * @return: effective radius value 240 */ 241 double CylinderModel :: calculate_ER() { 242 CylinderParameters dp; 243 244 dp.radius = radius(); 245 dp.length = length(); 246 double rad_out = 0.0; 247 248 // Perform the computation, with all weight points 249 double sum = 0.0; 250 double norm = 0.0; 251 252 // Get the dispersion points for the major shell 253 vector<WeightPoint> weights_length; 254 length.get_weights(weights_length); 255 256 // Get the dispersion points for the minor shell 257 vector<WeightPoint> weights_radius ; 258 radius.get_weights(weights_radius); 259 260 // Loop over major shell weight points 261 for(int i=0; i< (int)weights_length.size(); i++) { 262 dp.length = weights_length[i].value; 263 for(int k=0; k< (int)weights_radius.size(); k++) { 264 dp.radius = weights_radius[k].value; 265 //Note: output of "DiamCyl(dp.length,dp.radius)" is DIAMETER. 266 sum +=weights_length[i].weight 267 * weights_radius[k].weight*DiamCyl(dp.length,dp.radius)/2.0; 268 norm += weights_length[i].weight* weights_radius[k].weight; 269 } 270 } 271 if (norm != 0){ 272 //return the averaged value 273 rad_out = sum/norm;} 274 else{ 275 //return normal value 276 //Note: output of "DiamCyl(dp.length,dp.radius)" is DIAMETER. 277 rad_out = DiamCyl(dp.length,dp.radius)/2.0;} 278 279 return rad_out; 280 } 279 -
sansmodels/src/sans/models/c_models/ellipsoid.cpp
r5eb9154 rf9bf661 186 186 /** 187 187 * Function to calculate effective radius 188 * @param pars: parameters of the sphere189 188 * @return: effective radius value 190 189 */ -
sansmodels/src/sans/models/c_models/ellipticalcylinder.cpp
r5eb9154 rf9bf661 29 29 extern "C" { 30 30 #include "libCylinder.h" 31 #include "libStructureFactor.h" 31 32 #include "elliptical_cylinder.h" 32 33 } … … 222 223 /** 223 224 * Function to calculate effective radius 224 * @param pars: parameters of the sphere225 225 * @return: effective radius value 226 226 */ 227 227 double EllipticalCylinderModel :: calculate_ER() { 228 //NOT implemented yet!!! 229 } 228 EllipticalCylinderParameters dp; 229 dp.r_minor = r_minor(); 230 dp.r_ratio = r_ratio(); 231 dp.length = length(); 232 double rad_out = 0.0; 233 double pi = 4.0*atan(1.0); 234 double suf_rad = sqrt(dp.r_minor*dp.r_minor*dp.r_ratio); 235 236 // Perform the computation, with all weight points 237 double sum = 0.0; 238 double norm = 0.0; 239 240 // Get the dispersion points for the r_minor 241 vector<WeightPoint> weights_rad; 242 r_minor.get_weights(weights_rad); 243 244 // Get the dispersion points for the r_ratio 245 vector<WeightPoint> weights_rat; 246 r_ratio.get_weights(weights_rat); 247 248 // Get the dispersion points for the length 249 vector<WeightPoint> weights_len; 250 length.get_weights(weights_len); 251 252 // Loop over minor radius weight points 253 for(int i=0; i<weights_rad.size(); i++) { 254 dp.r_minor = weights_rad[i].value; 255 256 // Loop over length weight points 257 for(int j=0; j<weights_len.size(); j++) { 258 dp.length = weights_len[j].value; 259 260 // Loop over r_ration weight points 261 for(int m=0; m<weights_rat.size(); m++) { 262 dp.r_ratio = weights_rat[m].value; 263 //Calculate surface averaged radius 264 suf_rad = sqrt(dp.r_minor * dp.r_minor * dp.r_ratio); 265 266 //Note: output of "DiamCyl(dp.length,dp.radius)" is DIAMETER. 267 sum +=weights_rad[i].weight *weights_len[j].weight 268 * weights_rat[m].weight*DiamCyl(dp.length, suf_rad)/2.0; 269 norm += weights_rad[i].weight *weights_len[j].weight* weights_rat[m].weight; 270 } 271 } 272 } 273 if (norm != 0){ 274 //return the averaged value 275 rad_out = sum/norm;} 276 else{ 277 //return normal value 278 //Note: output of "DiamCyl(dp.length,dp.radius)" is DIAMETER. 279 rad_out = DiamCyl(dp.length, suf_rad)/2.0;} 280 281 return rad_out; 282 } -
sansmodels/src/sans/models/c_models/flexiblecylinder.cpp
r5eb9154 rf9bf661 127 127 /** 128 128 * Function to calculate effective radius 129 * @param pars: parameters of the sphere130 129 * @return: effective radius value 131 130 */ -
sansmodels/src/sans/models/c_models/hollowcylinder.cpp
r5eb9154 rf9bf661 210 210 /** 211 211 * Function to calculate effective radius 212 * @param pars: parameters of the sphere213 212 * @return: effective radius value 214 213 */ -
sansmodels/src/sans/models/c_models/lamellar.cpp
r5eb9154 rf9bf661 102 102 /** 103 103 * Function to calculate effective radius 104 * @param pars: parameters of the sphere105 104 * @return: effective radius value 106 105 */ -
sansmodels/src/sans/models/c_models/lamellarFF_HG.cpp
r5eb9154 rf9bf661 115 115 /** 116 116 * Function to calculate effective radius 117 * @param pars: parameters of the sphere118 117 * @return: effective radius value 119 118 */ -
sansmodels/src/sans/models/c_models/lamellarPS.cpp
r5eb9154 rf9bf661 111 111 /** 112 112 * Function to calculate effective radius 113 * @param pars: parameters of the sphere114 113 * @return: effective radius value 115 114 */ -
sansmodels/src/sans/models/c_models/lamellarPS_HG.cpp
r5eb9154 rf9bf661 131 131 /** 132 132 * Function to calculate effective radius 133 * @param pars: parameters of the sphere134 133 * @return: effective radius value 135 134 */ -
sansmodels/src/sans/models/c_models/modelTemplate.txt
r5eb9154 rf9bf661 82 82 def calculate_ER(self): 83 83 """ Calculate the effective radius for P(q)*S(q) 84 @param x: input q, or [q,phi]85 84 @return: the value of the effective radius 86 85 """ -
sansmodels/src/sans/models/c_models/multishell.cpp
r5eb9154 rf9bf661 122 122 /** 123 123 * Function to calculate effective radius 124 * @param pars: parameters of the sphere125 124 * @return: effective radius value 126 125 */ -
sansmodels/src/sans/models/c_models/parallelepiped.cpp
r5eb9154 rf9bf661 30 30 extern "C" { 31 31 #include "libCylinder.h" 32 #include "libStructureFactor.h" 32 33 #include "parallelepiped.h" 33 34 } … … 36 37 scale = Parameter(1.0); 37 38 short_a = Parameter(35.0, true); 38 short_a.set_m ax(1.0);39 short_a.set_min(1.0); 39 40 short_b = Parameter(75.0, true); 40 41 short_b.set_min(1.0); … … 95 96 for(int k=0; k< (int)weights_long_c.size(); k++) { 96 97 dp[3] = weights_long_c[k].value; 97 98 98 sum += weights_short_a[i].weight * weights_short_b[j].weight 99 99 * weights_long_c[k].weight * Parallelepiped(dp, q); … … 104 104 } 105 105 } 106 106 107 return sum/norm + background(); 107 108 } … … 226 227 /** 227 228 * Function to calculate effective radius 228 * @param pars: parameters of the sphere229 229 * @return: effective radius value 230 230 */ 231 231 double ParallelepipedModel :: calculate_ER() { 232 //NOT implemented yet!!! 233 } 232 ParallelepipedParameters dp; 233 dp.short_a = short_a(); 234 dp.short_b = short_b(); 235 dp.long_c = long_c(); 236 double rad_out = 0.0; 237 double pi = 4.0*atan(1.0); 238 double suf_rad = sqrt(dp.short_a*dp.short_b/pi); 239 240 // Perform the computation, with all weight points 241 double sum = 0.0; 242 double norm = 0.0; 243 244 // Get the dispersion points for the short_edgeA 245 vector<WeightPoint> weights_short_a; 246 short_a.get_weights(weights_short_a); 247 248 // Get the dispersion points for the longer_edgeB 249 vector<WeightPoint> weights_short_b; 250 short_b.get_weights(weights_short_b); 251 252 // Get angular averaging for the longuest_edgeC 253 vector<WeightPoint> weights_long_c; 254 long_c.get_weights(weights_long_c); 255 256 // Loop over radius weight points 257 for(int i=0; i< (int)weights_short_a.size(); i++) { 258 dp.short_a = weights_short_a[i].value; 259 260 // Loop over longer_edgeB weight points 261 for(int j=0; j< (int)weights_short_b.size(); j++) { 262 dp.short_b = weights_short_b[j].value; 263 264 // Average over longuest_edgeC distribution 265 for(int k=0; k< (int)weights_long_c.size(); k++) { 266 dp.long_c = weights_long_c[k].value; 267 //Calculate surface averaged radius 268 //This is rough approximation. 269 suf_rad = sqrt(dp.short_a*dp.short_b/pi); 270 271 //Note: output of "DiamCyl(dp.length,dp.radius)" is DIAMETER. 272 sum +=weights_short_a[i].weight* weights_short_b[j].weight 273 * weights_long_c[k].weight*DiamCyl(dp.long_c, suf_rad)/2.0; 274 norm += weights_short_a[i].weight* weights_short_b[j].weight*weights_long_c[k].weight; 275 } 276 } 277 } 278 279 if (norm != 0){ 280 //return the averaged value 281 rad_out = sum/norm;} 282 else{ 283 //return normal value 284 //Note: output of "DiamCyl(length,radius)" is DIAMETER. 285 rad_out = DiamCyl(dp.long_c, suf_rad)/2.0;} 286 return rad_out; 287 288 } -
sansmodels/src/sans/models/c_models/sphere.cpp
r5eb9154 rf9bf661 98 98 /** 99 99 * Function to calculate effective radius 100 * @param pars: parameters of the sphere101 100 * @return: effective radius value 102 101 */ -
sansmodels/src/sans/models/c_models/spheroid.cpp
r5eb9154 rf9bf661 247 247 /** 248 248 * Function to calculate effective radius 249 * @param pars: parameters of the sphere250 249 * @return: effective radius value 251 250 */ -
sansmodels/src/sans/models/c_models/stackeddisks.cpp
r5eb9154 rf9bf661 219 219 /** 220 220 * Function to calculate effective radius 221 * @param pars: parameters of the sphere222 221 * @return: effective radius value 223 222 */ -
sansmodels/src/sans/models/c_models/triaxialellipsoid.cpp
r5eb9154 rf9bf661 29 29 extern "C" { 30 30 #include "libCylinder.h" 31 #include "libStructureFactor.h" 31 32 #include "triaxial_ellipsoid.h" 32 33 } … … 219 220 /** 220 221 * Function to calculate effective radius 221 * @param pars: parameters of the sphere222 222 * @return: effective radius value 223 223 */ 224 224 double TriaxialEllipsoidModel :: calculate_ER() { 225 //NOT implemented yet!!! 226 } 225 TriaxialEllipsoidParameters dp; 226 227 dp.semi_axisA = semi_axisA(); 228 dp.semi_axisB = semi_axisB(); 229 //polar axis C 230 dp.semi_axisC = semi_axisC(); 231 232 double rad_out = 0.0; 233 //Surface average radius at the equat. cross section. 234 double suf_rad = sqrt(dp.semi_axisA * dp.semi_axisB); 235 236 // Perform the computation, with all weight points 237 double sum = 0.0; 238 double norm = 0.0; 239 240 // Get the dispersion points for the semi_axis A 241 vector<WeightPoint> weights_semi_axisA; 242 semi_axisA.get_weights(weights_semi_axisA); 243 244 // Get the dispersion points for the semi_axis B 245 vector<WeightPoint> weights_semi_axisB; 246 semi_axisB.get_weights(weights_semi_axisB); 247 248 // Get the dispersion points for the semi_axis C 249 vector<WeightPoint> weights_semi_axisC; 250 semi_axisC.get_weights(weights_semi_axisC); 251 252 // Loop over semi axis A weight points 253 for(int i=0; i< (int)weights_semi_axisA.size(); i++) { 254 dp.semi_axisA = weights_semi_axisA[i].value; 255 256 // Loop over semi axis B weight points 257 for(int j=0; j< (int)weights_semi_axisB.size(); j++) { 258 dp.semi_axisB = weights_semi_axisB[j].value; 259 260 // Loop over semi axis C weight points 261 for(int k=0; k < (int)weights_semi_axisC.size(); k++) { 262 dp.semi_axisC = weights_semi_axisC[k].value; 263 264 //Calculate surface averaged radius 265 suf_rad = sqrt(dp.semi_axisA * dp.semi_axisB); 266 267 //Sum 268 sum += weights_semi_axisA[i].weight 269 * weights_semi_axisB[j].weight 270 * weights_semi_axisC[k].weight * DiamEllip(dp.semi_axisC, suf_rad)/2.0; 271 //Norm 272 norm += weights_semi_axisA[i].weight* weights_semi_axisB[j].weight 273 * weights_semi_axisC[k].weight; 274 } 275 } 276 } 277 if (norm != 0){ 278 //return the averaged value 279 rad_out = sum/norm;} 280 else{ 281 //return normal value 282 rad_out = DiamEllip(dp.semi_axisC, suf_rad)/2.0;} 283 284 return rad_out; 285 } -
sansmodels/src/sans/models/c_models/vesicle.cpp
r5eb9154 rf9bf661 108 108 /** 109 109 * Function to calculate effective radius 110 * @param pars: parameters of the sphere111 110 * @return: effective radius value 112 111 */
Note: See TracChangeset
for help on using the changeset viewer.