Changeset 37805e9 in sasview for sansmodels
- Timestamp:
- Jan 5, 2012 11:14:43 AM (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:
- 6e10cff
- Parents:
- a8eab1c
- Location:
- sansmodels/src
- Files:
-
- 2 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/c_extensions/spheresld.h
r67424cd r37805e9 1 1 #if !defined(o_h) 2 2 #define sphere_sld_h 3 #include "parameters.hh" 3 4 4 5 /** … … 30 31 //[ORIENTATION_PARAMS]= <text> </text> 31 32 32 typedef struct { 33 /// number of shells 34 // [DEFAULT]=n_shells=1 35 int n_shells; 33 class SphereSLDModel{ 34 public: 35 // Model parameters 36 /// number of shells 37 // [DEFAULT]=n_shells=1 38 Parameter n_shells; 36 39 /// Scale factor 37 40 // [DEFAULT]=scale= 1.0 38 doublescale;39 /// 41 Parameter scale; 42 /// thick_inter0 [A] 40 43 // [DEFAULT]=thick_inter0=50.0 [A] 41 doublethick_inter0;42 ///func_inter043 44 doublefunc_inter0;45 ///sld_core0 [1/A^(2)]46 47 doublesld_core0;48 ///sld_solv [1/A^(2)]49 50 doublesld_solv;51 52 53 doublebackground;44 Parameter thick_inter0; 45 /// func_inter0 46 // [DEFAULT]=func_inter0= 0 47 Parameter func_inter0; 48 /// sld_core0 [1/A^(2)] 49 // [DEFAULT]=sld_core0= 2.07e-6 [1/A^(2)] 50 Parameter sld_core0; 51 /// sld_solv [1/A^(2)] 52 // [DEFAULT]=sld_solv= 1.0e-6 [1/A^(2)] 53 Parameter sld_solv; 54 /// Background 55 // [DEFAULT]=background=0 56 Parameter background; 54 57 55 58 // [DEFAULT]=sld_flat1=4.0e-06 [1/A^(2)] 56 doublesld_flat1;59 Parameter sld_flat1; 57 60 // [DEFAULT]=sld_flat2=3.5e-06 [1/A^(2)] 58 doublesld_flat2;61 Parameter sld_flat2; 59 62 // [DEFAULT]=sld_flat3=4.0e-06 [1/A^(2)] 60 doublesld_flat3;63 Parameter sld_flat3; 61 64 // [DEFAULT]=sld_flat4=3.5e-06 [1/A^(2)] 62 doublesld_flat4;65 Parameter sld_flat4; 63 66 // [DEFAULT]=sld_flat5=4.0e-06 [1/A^(2)] 64 doublesld_flat5;67 Parameter sld_flat5; 65 68 // [DEFAULT]=sld_flat6=3.5e-06 [1/A^(2)] 66 doublesld_flat6;69 Parameter sld_flat6; 67 70 // [DEFAULT]=sld_flat7=4.0e-06 [1/A^(2)] 68 doublesld_flat7;71 Parameter sld_flat7; 69 72 // [DEFAULT]=sld_flat8=3.5e-06 [1/A^(2)] 70 doublesld_flat8;73 Parameter sld_flat8; 71 74 // [DEFAULT]=sld_flat9=4.0e-06 [1/A^(2)] 72 doublesld_flat9;75 Parameter sld_flat9; 73 76 // [DEFAULT]=sld_flat10=3.5e-06 [1/A^(2)] 74 doublesld_flat10;77 Parameter sld_flat10; 75 78 76 79 // [DEFAULT]=thick_inter1=50.0 [A] 77 doublethick_inter1;80 Parameter thick_inter1; 78 81 // [DEFAULT]=thick_inter2=50.0 [A] 79 doublethick_inter2;82 Parameter thick_inter2; 80 83 // [DEFAULT]=thick_inter3=50.0 [A] 81 doublethick_inter3;84 Parameter thick_inter3; 82 85 // [DEFAULT]=thick_inter4=50.0 [A] 83 doublethick_inter4;86 Parameter thick_inter4; 84 87 // [DEFAULT]=thick_inter5=50.0 [A] 85 doublethick_inter5;88 Parameter thick_inter5; 86 89 // [DEFAULT]=thick_inter6=50.0 [A] 87 doublethick_inter6;90 Parameter thick_inter6; 88 91 // [DEFAULT]=thick_inter7=50.0 [A] 89 doublethick_inter7;92 Parameter thick_inter7; 90 93 // [DEFAULT]=thick_inter8=50.0 [A] 91 doublethick_inter8;94 Parameter thick_inter8; 92 95 // [DEFAULT]=thick_inter9=50.0 [A] 93 doublethick_inter9;96 Parameter thick_inter9; 94 97 // [DEFAULT]=thick_inter10=50.0 [A] 95 doublethick_inter10;98 Parameter thick_inter10; 96 99 97 100 // [DEFAULT]=thick_flat1=100 [A] 98 doublethick_flat1;101 Parameter thick_flat1; 99 102 // [DEFAULT]=thick_flat2=100 [A] 100 doublethick_flat2;103 Parameter thick_flat2; 101 104 // [DEFAULT]=thick_flat3=100 [A] 102 doublethick_flat3;105 Parameter thick_flat3; 103 106 // [DEFAULT]=thick_flat4=100 [A] 104 doublethick_flat4;107 Parameter thick_flat4; 105 108 // [DEFAULT]=thick_flat5=100 [A] 106 doublethick_flat5;109 Parameter thick_flat5; 107 110 // [DEFAULT]=thick_flat6=100 [A] 108 doublethick_flat6;111 Parameter thick_flat6; 109 112 // [DEFAULT]=thick_flat7=100 [A] 110 doublethick_flat7;113 Parameter thick_flat7; 111 114 // [DEFAULT]=thick_flat8=100 [A] 112 doublethick_flat8;115 Parameter thick_flat8; 113 116 // [DEFAULT]=thick_flat9=100 [A] 114 doublethick_flat9;117 Parameter thick_flat9; 115 118 // [DEFAULT]=thick_flat10=100 [A] 116 doublethick_flat10;119 Parameter thick_flat10; 117 120 118 121 // [DEFAULT]=func_inter1=0 119 doublefunc_inter1;122 Parameter func_inter1; 120 123 // [DEFAULT]=func_inter2=0 121 doublefunc_inter2;124 Parameter func_inter2; 122 125 // [DEFAULT]=func_inter3=0 123 doublefunc_inter3;126 Parameter func_inter3; 124 127 // [DEFAULT]=func_inter4=0 125 doublefunc_inter4;128 Parameter func_inter4; 126 129 // [DEFAULT]=func_inter5=0 127 doublefunc_inter5;130 Parameter func_inter5; 128 131 // [DEFAULT]=func_inter6=0 129 doublefunc_inter6;132 Parameter func_inter6; 130 133 // [DEFAULT]=func_inter7=0 131 doublefunc_inter7;134 Parameter func_inter7; 132 135 // [DEFAULT]=func_inter8=0 133 doublefunc_inter8;136 Parameter func_inter8; 134 137 // [DEFAULT]=func_inter9=0 135 doublefunc_inter9;138 Parameter func_inter9; 136 139 // [DEFAULT]=func_inter10=0 137 doublefunc_inter10;140 Parameter func_inter10; 138 141 139 142 // [DEFAULT]=nu_inter1=2.5 140 doublenu_inter1;143 Parameter nu_inter1; 141 144 // [DEFAULT]=nu_inter2=2.5 142 doublenu_inter2;145 Parameter nu_inter2; 143 146 // [DEFAULT]=nu_inter3=2.5 144 doublenu_inter3;147 Parameter nu_inter3; 145 148 // [DEFAULT]=nu_inter4=2.5 146 doublenu_inter4;149 Parameter nu_inter4; 147 150 // [DEFAULT]=nu_inter5=2.5 148 doublenu_inter5;151 Parameter nu_inter5; 149 152 // [DEFAULT]=nu_inter6=2.5 150 doublenu_inter6;153 Parameter nu_inter6; 151 154 // [DEFAULT]=nu_inter7=2.5 152 doublenu_inter7;155 Parameter nu_inter7; 153 156 // [DEFAULT]=nu_inter8=2.5 154 doublenu_inter8;157 Parameter nu_inter8; 155 158 // [DEFAULT]=nu_inter9=2.5 156 doublenu_inter9;159 Parameter nu_inter9; 157 160 // [DEFAULT]=nu_inter10=2.5 158 doublenu_inter10;161 Parameter nu_inter10; 159 162 160 163 // [DEFAULT]=npts_inter=35.0 161 doublenpts_inter;164 Parameter npts_inter; 162 165 // [DEFAULT]=nu_inter0=2.5 163 doublenu_inter0;166 Parameter nu_inter0; 164 167 // [DEFAULT]=rad_core0=50.0 [A] 165 double rad_core0; 166 } SphereSLDParameters; 168 Parameter rad_core0; 167 169 168 double sphere_sld_kernel(double dq[], double q); 170 // Constructor 171 SphereSLDModel(); 169 172 170 /// 1D scattering function 171 double sphere_sld_analytical_1D(SphereSLDParameters *pars, double q); 173 // Operators to get I(Q) 174 double operator()(double q); 175 double operator()(double qx, double qy); 176 double calculate_ER(); 177 double evaluate_rphi(double q, double phi); 178 }; 172 179 173 /// 2D scattering function174 double sphere_sld_analytical_2D(SphereSLDParameters *pars, double q, double phi);175 double sphere_sld_analytical_2DXY(SphereSLDParameters *pars, double qx, double qy);176 180 177 181 #endif -
sansmodels/src/c_models/models.hh
ra8eab1c r37805e9 30 30 31 31 32 33 class SphereSLDModel{34 public:35 // Model parameters36 Parameter n_shells;37 Parameter scale;38 Parameter thick_inter0;39 Parameter func_inter0;40 Parameter sld_core0;41 Parameter sld_solv;42 Parameter background;43 44 Parameter sld_flat1;45 Parameter sld_flat2;46 Parameter sld_flat3;47 Parameter sld_flat4;48 Parameter sld_flat5;49 Parameter sld_flat6;50 Parameter sld_flat7;51 Parameter sld_flat8;52 Parameter sld_flat9;53 Parameter sld_flat10;54 55 Parameter thick_inter1;56 Parameter thick_inter2;57 Parameter thick_inter3;58 Parameter thick_inter4;59 Parameter thick_inter5;60 Parameter thick_inter6;61 Parameter thick_inter7;62 Parameter thick_inter8;63 Parameter thick_inter9;64 Parameter thick_inter10;65 66 Parameter thick_flat1;67 Parameter thick_flat2;68 Parameter thick_flat3;69 Parameter thick_flat4;70 Parameter thick_flat5;71 Parameter thick_flat6;72 Parameter thick_flat7;73 Parameter thick_flat8;74 Parameter thick_flat9;75 Parameter thick_flat10;76 77 Parameter func_inter1;78 Parameter func_inter2;79 Parameter func_inter3;80 Parameter func_inter4;81 Parameter func_inter5;82 Parameter func_inter6;83 Parameter func_inter7;84 Parameter func_inter8;85 Parameter func_inter9;86 Parameter func_inter10;87 88 Parameter nu_inter1;89 Parameter nu_inter2;90 Parameter nu_inter3;91 Parameter nu_inter4;92 Parameter nu_inter5;93 Parameter nu_inter6;94 Parameter nu_inter7;95 Parameter nu_inter8;96 Parameter nu_inter9;97 Parameter nu_inter10;98 99 Parameter npts_inter;100 Parameter nu_inter0;101 Parameter rad_core0;102 103 // Constructor104 SphereSLDModel();105 106 // Operators to get I(Q)107 double operator()(double q);108 double operator()(double qx, double qy);109 double calculate_ER();110 double evaluate_rphi(double q, double phi);111 };112 32 113 33 -
sansmodels/src/c_models/refl.cpp
r2d1b700 r37805e9 13 13 #define lamda 4.62 14 14 15 double re_kernel(double dp[], double q) {15 static double re_kernel(double dp[], double q) { 16 16 int n = dp[0]; 17 17 int i,j; -
sansmodels/src/c_models/spheresld.cpp
r67424cd r37805e9 1 1 2 2 #include <math.h> 3 #include "models.hh"4 3 #include "parameters.hh" 5 4 #include <stdio.h> 5 #include <stdlib.h> 6 7 extern "C" { 8 #include "libmultifunc/librefl.h" 9 } 10 11 #include "spheresld.h" 12 6 13 using namespace std; 7 14 8 extern "C" { 9 #include "spheresld.h" 15 // Convenience structure 16 typedef struct { 17 /// number of shells 18 // [DEFAULT]=n_shells=1 19 int n_shells; 20 /// Scale factor 21 // [DEFAULT]=scale= 1.0 22 double scale; 23 /// thick_inter0 [A] 24 // [DEFAULT]=thick_inter0=50.0 [A] 25 double thick_inter0; 26 /// func_inter0 27 // [DEFAULT]=func_inter0= 0 28 double func_inter0; 29 /// sld_core0 [1/A^(2)] 30 // [DEFAULT]=sld_core0= 2.07e-6 [1/A^(2)] 31 double sld_core0; 32 /// sld_solv [1/A^(2)] 33 // [DEFAULT]=sld_solv= 1.0e-6 [1/A^(2)] 34 double sld_solv; 35 /// Background 36 // [DEFAULT]=background=0 37 double background; 38 39 // [DEFAULT]=sld_flat1=4.0e-06 [1/A^(2)] 40 double sld_flat1; 41 // [DEFAULT]=sld_flat2=3.5e-06 [1/A^(2)] 42 double sld_flat2; 43 // [DEFAULT]=sld_flat3=4.0e-06 [1/A^(2)] 44 double sld_flat3; 45 // [DEFAULT]=sld_flat4=3.5e-06 [1/A^(2)] 46 double sld_flat4; 47 // [DEFAULT]=sld_flat5=4.0e-06 [1/A^(2)] 48 double sld_flat5; 49 // [DEFAULT]=sld_flat6=3.5e-06 [1/A^(2)] 50 double sld_flat6; 51 // [DEFAULT]=sld_flat7=4.0e-06 [1/A^(2)] 52 double sld_flat7; 53 // [DEFAULT]=sld_flat8=3.5e-06 [1/A^(2)] 54 double sld_flat8; 55 // [DEFAULT]=sld_flat9=4.0e-06 [1/A^(2)] 56 double sld_flat9; 57 // [DEFAULT]=sld_flat10=3.5e-06 [1/A^(2)] 58 double sld_flat10; 59 60 // [DEFAULT]=thick_inter1=50.0 [A] 61 double thick_inter1; 62 // [DEFAULT]=thick_inter2=50.0 [A] 63 double thick_inter2; 64 // [DEFAULT]=thick_inter3=50.0 [A] 65 double thick_inter3; 66 // [DEFAULT]=thick_inter4=50.0 [A] 67 double thick_inter4; 68 // [DEFAULT]=thick_inter5=50.0 [A] 69 double thick_inter5; 70 // [DEFAULT]=thick_inter6=50.0 [A] 71 double thick_inter6; 72 // [DEFAULT]=thick_inter7=50.0 [A] 73 double thick_inter7; 74 // [DEFAULT]=thick_inter8=50.0 [A] 75 double thick_inter8; 76 // [DEFAULT]=thick_inter9=50.0 [A] 77 double thick_inter9; 78 // [DEFAULT]=thick_inter10=50.0 [A] 79 double thick_inter10; 80 81 // [DEFAULT]=thick_flat1=100 [A] 82 double thick_flat1; 83 // [DEFAULT]=thick_flat2=100 [A] 84 double thick_flat2; 85 // [DEFAULT]=thick_flat3=100 [A] 86 double thick_flat3; 87 // [DEFAULT]=thick_flat4=100 [A] 88 double thick_flat4; 89 // [DEFAULT]=thick_flat5=100 [A] 90 double thick_flat5; 91 // [DEFAULT]=thick_flat6=100 [A] 92 double thick_flat6; 93 // [DEFAULT]=thick_flat7=100 [A] 94 double thick_flat7; 95 // [DEFAULT]=thick_flat8=100 [A] 96 double thick_flat8; 97 // [DEFAULT]=thick_flat9=100 [A] 98 double thick_flat9; 99 // [DEFAULT]=thick_flat10=100 [A] 100 double thick_flat10; 101 102 // [DEFAULT]=func_inter1=0 103 double func_inter1; 104 // [DEFAULT]=func_inter2=0 105 double func_inter2; 106 // [DEFAULT]=func_inter3=0 107 double func_inter3; 108 // [DEFAULT]=func_inter4=0 109 double func_inter4; 110 // [DEFAULT]=func_inter5=0 111 double func_inter5; 112 // [DEFAULT]=func_inter6=0 113 double func_inter6; 114 // [DEFAULT]=func_inter7=0 115 double func_inter7; 116 // [DEFAULT]=func_inter8=0 117 double func_inter8; 118 // [DEFAULT]=func_inter9=0 119 double func_inter9; 120 // [DEFAULT]=func_inter10=0 121 double func_inter10; 122 123 // [DEFAULT]=nu_inter1=2.5 124 double nu_inter1; 125 // [DEFAULT]=nu_inter2=2.5 126 double nu_inter2; 127 // [DEFAULT]=nu_inter3=2.5 128 double nu_inter3; 129 // [DEFAULT]=nu_inter4=2.5 130 double nu_inter4; 131 // [DEFAULT]=nu_inter5=2.5 132 double nu_inter5; 133 // [DEFAULT]=nu_inter6=2.5 134 double nu_inter6; 135 // [DEFAULT]=nu_inter7=2.5 136 double nu_inter7; 137 // [DEFAULT]=nu_inter8=2.5 138 double nu_inter8; 139 // [DEFAULT]=nu_inter9=2.5 140 double nu_inter9; 141 // [DEFAULT]=nu_inter10=2.5 142 double nu_inter10; 143 144 // [DEFAULT]=npts_inter=35.0 145 double npts_inter; 146 // [DEFAULT]=nu_inter0=2.5 147 double nu_inter0; 148 // [DEFAULT]=rad_core0=50.0 [A] 149 double rad_core0; 150 } SphereSLDParameters; 151 152 153 static double sphere_sld_kernel(double dp[], double q) { 154 int n = dp[0]; 155 int i,j,k; 156 157 double scale = dp[1]; 158 double thick_inter_core = dp[2]; 159 double sld_core = dp[4]; 160 double sld_solv = dp[5]; 161 double background = dp[6]; 162 double npts = dp[57]; //number of sub_layers in each interface 163 double nsl=npts;//21.0; //nsl = Num_sub_layer: MUST ODD number in double //no other number works now 164 int n_s; 165 166 double sld_i,sld_f,dz,bes,fun,f,vol,vol_pre,vol_sub,qr,r,contr,f2; 167 double sign,slope=0.0; 168 double pi; 169 170 int* fun_type; 171 double* sld; 172 double* thick_inter; 173 double* thick; 174 double* fun_coef; 175 176 double total_thick=0.0; 177 178 fun_type = (int*)malloc((n+2)*sizeof(int)); 179 sld = (double*)malloc((n+2)*sizeof(double)); 180 thick_inter = (double*)malloc((n+2)*sizeof(double)); 181 thick = (double*)malloc((n+2)*sizeof(double)); 182 fun_coef = (double*)malloc((n+2)*sizeof(double)); 183 184 fun_type[0] = dp[3]; 185 fun_coef[0] = fabs(dp[58]); 186 for (i =1; i<=n; i++){ 187 sld[i] = dp[i+6]; 188 thick_inter[i]= dp[i+16]; 189 thick[i] = dp[i+26]; 190 fun_type[i] = dp[i+36]; 191 fun_coef[i] = fabs(dp[i+46]); 192 total_thick += thick[i] + thick_inter[i]; 193 } 194 sld[0] = sld_core; 195 sld[n+1] = sld_solv; 196 thick[0] = dp[59]; 197 thick[n+1] = total_thick/5.0; 198 thick_inter[0] = thick_inter_core; 199 thick_inter[n+1] = 0.0; 200 fun_coef[n+1] = 0.0; 201 202 pi = 4.0*atan(1.0); 203 f = 0.0; 204 r = 0.0; 205 vol = 0.0; 206 vol_pre = 0.0; 207 vol_sub = 0.0; 208 sld_f = sld_core; 209 210 //floor_nsl = floor(nsl/2.0); 211 212 dz = 0.0; 213 // iteration for # of shells + core + solvent 214 for (i=0;i<=n+1; i++){ 215 //iteration for N sub-layers 216 //if (fabs(thick[i]) <= 1e-24){ 217 // continue; 218 //} 219 // iteration for flat and interface 220 for (j=0;j<2;j++){ 221 // iteration for sub_shells in the interface 222 // starts from #1 sub-layer 223 for (n_s=1;n_s<=nsl; n_s++){ 224 // for solvent, it doesn't have an interface 225 if (i==n+1 && j==1) 226 break; 227 // for flat layers 228 if (j==0){ 229 dz = thick[i]; 230 sld_i = sld[i]; 231 slope = 0.0; 232 } 233 // for interfacial sub_shells 234 else{ 235 dz = thick_inter[i]/nsl; 236 // find sld_i at the outer boundary of sub-layer #n_s 237 sld_i = intersldfunc(fun_type[i],nsl, n_s, fun_coef[i], sld[i], sld[i+1]); 238 // calculate slope 239 slope= (sld_i -sld_f)/dz; 240 } 241 contr = sld_f-slope*r; 242 // iteration for the left and right boundary of the shells(or sub_shells) 243 for (k=0; k<2; k++){ 244 // At r=0, the contribution to I is zero, so skip it. 245 if ( i == 0 && j == 0 && k == 0){ 246 continue; 247 } 248 // On the top of slovent there is no interface; skip it. 249 if (i == n+1 && k == 1){ 250 continue; 251 } 252 // At the right side (outer) boundary 253 if ( k == 1){ 254 sign = 1.0; 255 r += dz; 256 } 257 // At the left side (inner) boundary 258 else{ 259 sign = -1.0; 260 } 261 qr = q * r; 262 fun = 0.0; 263 if(qr == 0.0){ 264 // sigular point 265 bes = sign * 1.0; 266 } 267 else{ 268 // for flat sub-layer 269 bes = sign * 3.0 * (sin(qr) - qr * cos(qr)) / (qr * qr * qr); 270 // with linear slope 271 if (fabs(slope) > 0.0 ){ 272 fun = sign * 3.0 * r * (2.0*qr*sin(qr)-((qr*qr)-2.0)*cos(qr))/(qr * qr * qr * qr); 273 } 274 } 275 // update total volume 276 vol = 4.0 * pi / 3.0 * r * r * r; 277 // we won't do the following volume correction for now. 278 // substrate empty area of volume 279 //if (k == 1 && fabs(sld_in[i]-sld_solv) < 1e-04*fabs(sld_solv) && fun_type[i]==0){ 280 // vol_sub += (vol_pre - vol); 281 //} 282 f += vol * (bes * contr + fun * slope); 283 } 284 // remember this sld as sld_f 285 sld_f =sld_i; 286 // no sub-layer iteration (n_s loop) for the flat layer 287 if (j==0) 288 break; 289 } 290 } 291 } 292 //vol += vol_sub; 293 f2 = f * f / vol * 1.0e8; 294 f2 *= scale; 295 f2 += background; 296 297 free(fun_type); 298 free(sld); 299 free(thick_inter); 300 free(thick); 301 free(fun_coef); 302 303 return (f2); 10 304 } 11 305 306 12 307 SphereSLDModel :: SphereSLDModel() { 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 308 n_shells = Parameter(1.0); 309 scale = Parameter(1.0); 310 thick_inter0 = Parameter(1.0, true); 311 thick_inter0.set_min(0.0); 312 func_inter0 = Parameter(0); 313 sld_core0 = Parameter(2.07e-06); 314 sld_solv = Parameter(1.0e-06); 315 background = Parameter(0.0); 316 317 318 sld_flat1 = Parameter(2.7e-06); 319 sld_flat2 = Parameter(3.5e-06); 320 sld_flat3 = Parameter(4.0e-06); 321 sld_flat4 = Parameter(3.5e-06); 322 sld_flat5 = Parameter(4.0e-06); 323 sld_flat6 = Parameter(3.5e-06); 324 sld_flat7 = Parameter(4.0e-06); 325 sld_flat8 = Parameter(3.5e-06); 326 sld_flat9 = Parameter(4.0e-06); 327 sld_flat10 = Parameter(3.5e-06); 328 329 330 thick_inter1 = Parameter(1.0); 331 thick_inter2 = Parameter(1.0); 332 thick_inter3 = Parameter(1.0); 333 thick_inter4 = Parameter(1.0); 334 thick_inter5 = Parameter(1.0); 335 thick_inter6 = Parameter(1.0); 336 thick_inter7 = Parameter(1.0); 337 thick_inter8 = Parameter(1.0); 338 thick_inter9 = Parameter(1.0); 339 thick_inter10 = Parameter(1.0); 340 341 342 thick_flat1 = Parameter(100.0); 343 thick_flat2 = Parameter(100.0); 344 thick_flat3 = Parameter(100.0); 345 thick_flat4 = Parameter(100.0); 346 thick_flat5 = Parameter(100.0); 347 thick_flat6 = Parameter(100.0); 348 thick_flat7 = Parameter(100.0); 349 thick_flat8 = Parameter(100.0); 350 thick_flat9 = Parameter(100.0); 351 thick_flat10 = Parameter(100.0); 352 353 354 func_inter1 = Parameter(0); 355 func_inter2 = Parameter(0); 356 func_inter3 = Parameter(0); 357 func_inter4 = Parameter(0); 358 func_inter5 = Parameter(0); 359 func_inter6 = Parameter(0); 360 func_inter7 = Parameter(0); 361 func_inter8 = Parameter(0); 362 func_inter9 = Parameter(0); 363 func_inter10 = Parameter(0); 364 365 nu_inter1 = Parameter(2.5); 366 nu_inter2 = Parameter(2.5); 367 nu_inter3 = Parameter(2.5); 368 nu_inter4 = Parameter(2.5); 369 nu_inter5 = Parameter(2.5); 370 nu_inter6 = Parameter(2.5); 371 nu_inter7 = Parameter(2.5); 372 nu_inter8 = Parameter(2.5); 373 nu_inter9 = Parameter(2.5); 374 nu_inter10 = Parameter(2.5); 375 376 npts_inter = Parameter(35.0); 377 nu_inter0 = Parameter(2.5); 378 rad_core0 = Parameter(60.0, true); 379 rad_core0.set_min(0.0); 85 380 } 86 381 … … 91 386 */ 92 387 double SphereSLDModel :: operator()(double q) { 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 388 double dp[60]; 389 // Fill parameter array for IGOR library 390 // Add the background after averaging 391 dp[0] = n_shells(); 392 dp[1] = scale(); 393 dp[2] = thick_inter0(); 394 dp[3] = func_inter0(); 395 dp[4] = sld_core0(); 396 dp[5] = sld_solv(); 397 dp[6] = 0.0; 398 399 dp[7] = sld_flat1(); 400 dp[8] = sld_flat2(); 401 dp[9] = sld_flat3(); 402 dp[10] = sld_flat4(); 403 dp[11] = sld_flat5(); 404 dp[12] = sld_flat6(); 405 dp[13] = sld_flat7(); 406 dp[14] = sld_flat8(); 407 dp[15] = sld_flat9(); 408 dp[16] = sld_flat10(); 409 410 dp[17] = thick_inter1(); 411 dp[18] = thick_inter2(); 412 dp[19] = thick_inter3(); 413 dp[20] = thick_inter4(); 414 dp[21] = thick_inter5(); 415 dp[22] = thick_inter6(); 416 dp[23] = thick_inter7(); 417 dp[24] = thick_inter8(); 418 dp[25] = thick_inter9(); 419 dp[26] = thick_inter10(); 420 421 dp[27] = thick_flat1(); 422 dp[28] = thick_flat2(); 423 dp[29] = thick_flat3(); 424 dp[30] = thick_flat4(); 425 dp[31] = thick_flat5(); 426 dp[32] = thick_flat6(); 427 dp[33] = thick_flat7(); 428 dp[34] = thick_flat8(); 429 dp[35] = thick_flat9(); 430 dp[36] = thick_flat10(); 431 432 dp[37] = func_inter1(); 433 dp[38] = func_inter2(); 434 dp[39] = func_inter3(); 435 dp[40] = func_inter4(); 436 dp[41] = func_inter5(); 437 dp[42] = func_inter6(); 438 dp[43] = func_inter7(); 439 dp[44] = func_inter8(); 440 dp[45] = func_inter9(); 441 dp[46] = func_inter10(); 442 443 dp[47] = nu_inter1(); 444 dp[48] = nu_inter2(); 445 dp[49] = nu_inter3(); 446 dp[50] = nu_inter4(); 447 dp[51] = nu_inter5(); 448 dp[52] = nu_inter6(); 449 dp[53] = nu_inter7(); 450 dp[54] = nu_inter8(); 451 dp[55] = nu_inter9(); 452 dp[56] = nu_inter10(); 453 454 455 dp[57] = npts_inter(); 456 dp[58] = nu_inter0(); 457 dp[59] = rad_core0(); 458 459 // No polydispersion supported in this model. 460 // Get the dispersion points for the radius 461 vector<WeightPoint> weights_rad_core0; 462 rad_core0.get_weights(weights_rad_core0); 463 vector<WeightPoint> weights_thick_inter0; 464 thick_inter0.get_weights(weights_thick_inter0); 465 // Perform the computation, with all weight points 466 double sum = 0.0; 467 double norm = 0.0; 468 double vol = 0.0; 469 470 // Loop over core weight points 471 for(size_t i=0; i<weights_rad_core0.size(); i++) { 472 dp[59] = weights_rad_core0[i].value; 473 // Loop over thick_inter0 weight points 474 for(size_t j=0; j<weights_thick_inter0.size(); j++) { 475 dp[2] = weights_thick_inter0[j].value; 476 477 //Un-normalize Sphere by volume 478 sum += weights_rad_core0[i].weight * weights_thick_inter0[j].weight 479 * sphere_sld_kernel(dp,q) * pow((weights_rad_core0[i].value + 480 weights_thick_inter0[j].value),3.0); 481 //Find average volume 482 vol += weights_rad_core0[i].weight * weights_thick_inter0[j].weight 483 * pow((weights_rad_core0[i].value+weights_thick_inter0[j].value),3.0); 484 485 norm += weights_rad_core0[i].weight * weights_thick_inter0[j].weight; 486 } 487 } 488 489 if (vol != 0.0 && norm != 0.0) { 490 //Re-normalize by avg volume 491 sum = sum/(vol/norm);} 492 493 return sum/norm + background(); 199 494 } 200 495 … … 206 501 */ 207 502 double SphereSLDModel :: operator()(double qx, double qy) { 208 209 503 double q = sqrt(qx*qx + qy*qy); 504 return (*this).operator()(q); 210 505 } 211 506 … … 218 513 */ 219 514 double SphereSLDModel :: evaluate_rphi(double q, double phi) { 220 515 return (*this).operator()(q); 221 516 } 222 517 … … 231 526 // sld of solvent. 232 527 double SphereSLDModel :: calculate_ER() { 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 528 SphereSLDParameters dp; 529 530 dp.n_shells = n_shells(); 531 532 dp.rad_core0 = rad_core0(); 533 dp.thick_flat1 = thick_flat1(); 534 dp.thick_flat2 = thick_flat2(); 535 dp.thick_flat3 = thick_flat3(); 536 dp.thick_flat4 = thick_flat4(); 537 dp.thick_flat5 = thick_flat5(); 538 dp.thick_flat6 = thick_flat6(); 539 dp.thick_flat7 = thick_flat7(); 540 dp.thick_flat8 = thick_flat8(); 541 dp.thick_flat9 = thick_flat9(); 542 dp.thick_flat10 = thick_flat10(); 543 544 dp.thick_inter0 = thick_inter0(); 545 dp.thick_inter1 = thick_inter1(); 546 dp.thick_inter2 = thick_inter2(); 547 dp.thick_inter3 = thick_inter3(); 548 dp.thick_inter4 = thick_inter4(); 549 dp.thick_inter5 = thick_inter5(); 550 dp.thick_inter6 = thick_inter6(); 551 dp.thick_inter7 = thick_inter7(); 552 dp.thick_inter8 = thick_inter8(); 553 dp.thick_inter9 = thick_inter9(); 554 dp.thick_inter10 = thick_inter10(); 555 556 double rad_out = 0.0; 557 double out = 0.0; 558 // Perform the computation, with all weight points 559 double sum = 0.0; 560 double norm = 0.0; 561 562 // Get the dispersion points for the radius 563 vector<WeightPoint> weights_rad_core0; 564 rad_core0.get_weights(weights_rad_core0); 565 566 // Get the dispersion points for the thick 1 567 vector<WeightPoint> weights_thick_inter0; 568 thick_inter0.get_weights(weights_thick_inter0); 569 // Loop over radius weight points 570 for(size_t i=0; i<weights_rad_core0.size(); i++) { 571 dp.rad_core0 = weights_rad_core0[i].value; 572 // Loop over radius weight points 573 for(size_t j=0; j<weights_thick_inter0.size(); j++) { 574 dp.thick_inter0 = weights_thick_inter0[j].value; 575 rad_out = dp.rad_core0 + dp.thick_inter0; 576 if (dp.n_shells > 0) 577 rad_out += dp.thick_flat1 + dp.thick_inter1; 578 if (dp.n_shells > 1) 579 rad_out += dp.thick_flat2 + dp.thick_inter2; 580 if (dp.n_shells > 2) 581 rad_out += dp.thick_flat3 + dp.thick_inter3; 582 if (dp.n_shells > 3) 583 rad_out += dp.thick_flat4 + dp.thick_inter4; 584 if (dp.n_shells > 4) 585 rad_out += dp.thick_flat5 + dp.thick_inter5; 586 if (dp.n_shells > 5) 587 rad_out += dp.thick_flat6 + dp.thick_inter6; 588 if (dp.n_shells > 6) 589 rad_out += dp.thick_flat7 + dp.thick_inter7; 590 if (dp.n_shells > 7) 591 rad_out += dp.thick_flat8 + dp.thick_inter8; 592 if (dp.n_shells > 8) 593 rad_out += dp.thick_flat9 + dp.thick_inter9; 594 if (dp.n_shells > 9) 595 rad_out += dp.thick_flat10 + dp.thick_inter10; 596 sum += weights_rad_core0[i].weight*weights_thick_inter0[j].weight 597 * (rad_out); 598 norm += weights_rad_core0[i].weight*weights_thick_inter0[j].weight; 599 } 600 } 601 if (norm != 0){ 602 //return the averaged value 603 out = sum/norm;} 604 else{ 605 //return normal value 606 out = dp.rad_core0 + dp.thick_inter0; 607 if (dp.n_shells > 0) 608 out += dp.thick_flat1 + dp.thick_inter1; 609 if (dp.n_shells > 1) 610 out += dp.thick_flat2 + dp.thick_inter2; 611 if (dp.n_shells > 2) 612 out += dp.thick_flat3 + dp.thick_inter3; 613 if (dp.n_shells > 3) 614 out += dp.thick_flat4 + dp.thick_inter4; 615 if (dp.n_shells > 4) 616 out += dp.thick_flat5 + dp.thick_inter5; 617 if (dp.n_shells > 5) 618 out += dp.thick_flat6 + dp.thick_inter6; 619 if (dp.n_shells > 6) 620 out += dp.thick_flat7 + dp.thick_inter7; 621 if (dp.n_shells > 7) 622 out += dp.thick_flat8 + dp.thick_inter8; 623 if (dp.n_shells > 8) 624 out += dp.thick_flat9 + dp.thick_inter9; 625 if (dp.n_shells > 9) 626 out += dp.thick_flat10 + dp.thick_inter10; 627 } 628 629 return out; 335 630 336 631 }
Note: See TracChangeset
for help on using the changeset viewer.