Changeset 82c11d3 in sasview for sansmodels/src/c_models/vesicle.cpp
- Timestamp:
- Jan 5, 2012 6:24:51 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:
- 20d91bd
- Parents:
- 98fdccd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/c_models/vesicle.cpp
r67424cd r82c11d3 21 21 22 22 #include <math.h> 23 #include "models.hh"24 23 #include "parameters.hh" 25 24 #include <stdio.h> 26 25 using namespace std; 26 #include "vesicle.h" 27 27 28 28 extern "C" { 29 #include "libSphere.h" 30 #include "vesicle.h" 29 #include "libSphere.h" 31 30 } 32 31 32 typedef struct { 33 double scale; 34 double radius; 35 double thickness; 36 double core_sld; 37 double shell_sld; 38 double background; 39 } VesicleParameters; 40 33 41 VesicleModel :: VesicleModel() { 34 35 36 37 38 39 40 41 42 scale = Parameter(1.0); 43 radius = Parameter(100.0, true); 44 radius.set_min(0.0); 45 thickness = Parameter(30.0, true); 46 thickness.set_min(0.0); 47 core_sld = Parameter(6.36e-6); 48 shell_sld = Parameter(5.0e-7); 49 background = Parameter(0.0); 42 50 } 43 51 … … 49 57 */ 50 58 double VesicleModel :: operator()(double q) { 51 59 double dp[6]; 52 60 53 54 55 56 57 58 59 60 61 // Fill parameter array for IGOR library 62 // Add the background after averaging 63 dp[0] = scale(); 64 dp[1] = radius(); 65 dp[2] = thickness(); 66 dp[3] = core_sld(); 67 dp[4] = shell_sld(); 68 dp[5] = 0.0; 61 69 62 70 63 64 65 66 67 68 71 // Get the dispersion points for the core radius 72 vector<WeightPoint> weights_radius; 73 radius.get_weights(weights_radius); 74 // Get the dispersion points for the thickness 75 vector<WeightPoint> weights_thickness; 76 thickness.get_weights(weights_thickness); 69 77 70 71 72 73 78 // Perform the computation, with all weight points 79 double sum = 0.0; 80 double norm = 0.0; 81 double vol = 0.0; 74 82 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 83 // Loop over radius weight points 84 for(int i=0; i< (int)weights_radius.size(); i++) { 85 dp[1] = weights_radius[i].value; 86 for(int j=0; j< (int)weights_thickness.size(); j++) { 87 dp[2] = weights_thickness[j].value; 88 sum += weights_radius[i].weight 89 * weights_thickness[j].weight * VesicleForm(dp, q) 90 *(pow(weights_radius[i].value+weights_thickness[j].value,3)-pow(weights_radius[i].value,3)); 91 //Find average volume 92 vol += weights_radius[i].weight * weights_thickness[j].weight 93 *(pow(weights_radius[i].value+weights_thickness[j].value,3)-pow(weights_radius[i].value,3)); 94 norm += weights_radius[i].weight * weights_thickness[j].weight; 95 } 96 } 97 if (vol != 0.0 && norm != 0.0) { 98 //Re-normalize by avg volume 99 sum = sum/(vol/norm);} 92 100 93 101 return sum/norm + background(); 94 102 } 95 103 … … 101 109 */ 102 110 double VesicleModel :: operator()(double qx, double qy) { 103 104 111 double q = sqrt(qx*qx + qy*qy); 112 return (*this).operator()(q); 105 113 } 106 114 … … 113 121 */ 114 122 double VesicleModel :: evaluate_rphi(double q, double phi) { 115 123 return (*this).operator()(q); 116 124 } 117 125 /** … … 120 128 */ 121 129 double VesicleModel :: calculate_ER() { 122 130 VesicleParameters dp; 123 131 124 125 132 dp.radius = radius(); 133 dp.thickness = thickness(); 126 134 127 135 double rad_out = 0.0; 128 136 129 130 131 137 // Perform the computation, with all weight points 138 double sum = 0.0; 139 double norm = 0.0; 132 140 133 141 134 135 136 142 // Get the dispersion points for the major shell 143 vector<WeightPoint> weights_thickness; 144 thickness.get_weights(weights_thickness); 137 145 138 139 140 146 // Get the dispersion points for the minor shell 147 vector<WeightPoint> weights_radius ; 148 radius.get_weights(weights_radius); 141 149 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 150 // Loop over major shell weight points 151 for(int j=0; j< (int)weights_thickness.size(); j++) { 152 dp.thickness = weights_thickness[j].value; 153 for(int k=0; k< (int)weights_radius.size(); k++) { 154 dp.radius = weights_radius[k].value; 155 sum += weights_thickness[j].weight 156 * weights_radius[k].weight*(dp.radius+dp.thickness); 157 norm += weights_thickness[j].weight* weights_radius[k].weight; 158 } 159 } 160 if (norm != 0){ 161 //return the averaged value 162 rad_out = sum/norm;} 163 else{ 164 //return normal value 165 rad_out = (dp.radius+dp.thickness);} 158 166 159 167 return rad_out; 160 168 }
Note: See TracChangeset
for help on using the changeset viewer.