[0164899a] | 1 | |
---|
| 2 | #include <math.h> |
---|
| 3 | #include "parameters.hh" |
---|
| 4 | #include <stdio.h> |
---|
[37805e9] | 5 | #include <stdlib.h> |
---|
[0164899a] | 6 | |
---|
| 7 | extern "C" { |
---|
[37805e9] | 8 | #include "libmultifunc/librefl.h" |
---|
[0164899a] | 9 | } |
---|
| 10 | |
---|
[37805e9] | 11 | #include "spheresld.h" |
---|
| 12 | |
---|
| 13 | using namespace std; |
---|
| 14 | |
---|
| 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); |
---|
| 304 | } |
---|
| 305 | |
---|
| 306 | |
---|
[0164899a] | 307 | SphereSLDModel :: SphereSLDModel() { |
---|
[37805e9] | 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); |
---|
[0164899a] | 380 | } |
---|
| 381 | |
---|
| 382 | /** |
---|
| 383 | * Function to evaluate 1D SphereSLD function |
---|
| 384 | * @param q: q-value |
---|
| 385 | * @return: function value |
---|
| 386 | */ |
---|
| 387 | double SphereSLDModel :: operator()(double q) { |
---|
[37805e9] | 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(); |
---|
[0164899a] | 494 | } |
---|
| 495 | |
---|
| 496 | /** |
---|
| 497 | * Function to evaluate 2D SphereSLD function |
---|
| 498 | * @param q_x: value of Q along x |
---|
| 499 | * @param q_y: value of Q along y |
---|
| 500 | * @return: function value |
---|
| 501 | */ |
---|
| 502 | double SphereSLDModel :: operator()(double qx, double qy) { |
---|
[37805e9] | 503 | double q = sqrt(qx*qx + qy*qy); |
---|
| 504 | return (*this).operator()(q); |
---|
[0164899a] | 505 | } |
---|
| 506 | |
---|
| 507 | /** |
---|
| 508 | * Function to evaluate SphereSLD function |
---|
| 509 | * @param pars: parameters of the SphereSLD |
---|
| 510 | * @param q: q-value |
---|
| 511 | * @param phi: angle phi |
---|
| 512 | * @return: function value |
---|
| 513 | */ |
---|
| 514 | double SphereSLDModel :: evaluate_rphi(double q, double phi) { |
---|
[37805e9] | 515 | return (*this).operator()(q); |
---|
[0164899a] | 516 | } |
---|
| 517 | |
---|
| 518 | /** |
---|
| 519 | * Function to calculate TOTAL radius |
---|
| 520 | * ToDo: Find What is the effective radius for this model. |
---|
| 521 | * @return: effective radius value |
---|
| 522 | */ |
---|
| 523 | // No polydispersion supported in this model. |
---|
| 524 | // Calculate max radius assumming max_radius = effective radius |
---|
| 525 | // Note that this max radius is not affected by sld of layer, sld of interface, or |
---|
| 526 | // sld of solvent. |
---|
| 527 | double SphereSLDModel :: calculate_ER() { |
---|
[37805e9] | 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; |
---|
[0164899a] | 630 | |
---|
| 631 | } |
---|