Changeset 127 for sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/Sphere_and_Struct.ipf
- Timestamp:
- Jul 24, 2007 3:23:44 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/Sphere_and_Struct.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 // be sure to include all the necessary files... … … 21 22 Make/O/D coef_S_HS = {0.1,60,1e-6,0.01} 22 23 make/o/t parameters_S_HS = {"volume fraction","Radius (A)","contrast (-2)","bkgd (cm-1)"} 23 Edit/K=1 parameters_S_HS,coef_S_HS 24 ywave_S_HS := Sphere_HS(coef_S_HS,xwave_S_HS) 24 Edit/K=1 parameters_S_HS,coef_S_HS 25 Variable/G root:g_S_HS 26 g_S_HS := Sphere_HS(coef_S_HS,ywave_S_HS,xwave_S_HS) 27 // ywave_S_HS := Sphere_HS(coef_S_HS,xwave_S_HS) 25 28 Display/K=1 ywave_S_HS vs xwave_S_HS 26 29 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 31 34 End 32 35 33 Proc PlotSmearedSphere_HS() 34 //no input parameters necessary, it MUST use the experimental q-values 35 // from the experimental data read in from an AVE/QSIG data file 36 37 // if no gQvals wave, data must not have been loaded => abort 38 if(ResolutionWavesMissing()) 36 // - sets up a dependency to a wrapper, not the actual SmearedModelFunction 37 Proc PlotSmearedSphere_HS(str) 38 String str 39 Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 40 41 // if any of the resolution waves are missing => abort 42 if(ResolutionWavesMissingDF(str)) //updated to NOT use global strings (in GaussUtils) 39 43 Abort 40 44 endif 45 46 SetDataFolder $("root:"+str) 41 47 42 48 // Setup parameter table for model function … … 47 53 // output smeared intensity wave, dimensions are identical to experimental QSIG values 48 54 // make extra copy of experimental q-values for easy plotting 49 Duplicate/O $ gQvalssmeared_S_HS,smeared_qvals55 Duplicate/O $(str+"_q") smeared_S_HS,smeared_qvals 50 56 SetScale d,0,0,"1/cm",smeared_S_HS 51 52 smeared_S_HS := SmearedSphere_HS(smear_coef_S_HS,$gQvals) 57 58 Variable/G gs_S_HS=0 59 gs_S_HS := fSmearedSphere_HS(smear_coef_S_HS,smeared_S_HS,smeared_qvals) //this wrapper fills the STRUCT 60 53 61 Display smeared_S_HS vs smeared_qvals 54 62 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 57 65 58 66 AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 59 End 60 61 Function Sphere_HS(w,x) : FitFunc 62 Wave w 63 Variable x 64 65 Variable inten 66 67 68 SetDataFolder root: 69 End 70 71 72 //AAO function 73 Function Sphere_HS(w,yw,xw) : FitFunc 74 Wave w,yw,xw 75 67 76 //setup form factor coefficient wave 68 77 Make/O/D/N=4 form_S_HS … … 78 87 79 88 //calculate each and combine 80 inten = SphereForm(form_S_HS,x) 81 inten *= HardSphereStruct(struct_S_HS,x) 82 inten *= w[0] 83 inten += w[3] 89 Duplicate/O xw temp_S_HS_PQ,temp_S_HS_SQ //make waves for the AAO 90 SphereForm(form_S_HS,temp_S_HS_PQ,xw) 91 HardSphereStruct(struct_S_HS,temp_S_HS_SQ,xw) 92 yw = temp_S_HS_PQ * temp_S_HS_SQ 93 yw *= w[0] 94 yw += w[3] 84 95 85 96 //cleanup waves 86 97 //Killwaves/Z form_S_HS,struct_S_HS 87 98 88 return ( inten)99 return (0) 89 100 End 90 101 … … 104 115 Make/O/D coef_S_SW = {0.1,60,1e-6,1.0,1.2,0.01} 105 116 make/o/t parameters_S_SW = {"volume fraction","Radius (A)","contrast (-2)","well depth (kT)","well width (diam.)","bkgd (cm-1)"} 106 Edit/K=1 parameters_S_SW,coef_S_SW 107 ywave_S_SW := Sphere_SW(coef_S_SW,xwave_S_SW) 117 Edit/K=1 parameters_S_SW,coef_S_SW 118 Variable/G root:g_S_SW 119 g_S_SW := Sphere_SW(coef_S_SW,ywave_S_SW,xwave_S_SW) 120 // ywave_S_SW := Sphere_SW(coef_S_SW,xwave_S_SW) 108 121 Display/K=1 ywave_S_SW vs xwave_S_SW 109 122 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 114 127 End 115 128 116 Proc PlotSmearedSphere_SW() 117 //no input parameters necessary, it MUST use the experimental q-values 118 // from the experimental data read in from an AVE/QSIG data file 119 120 // if no gQvals wave, data must not have been loaded => abort 121 if(ResolutionWavesMissing()) 129 // - sets up a dependency to a wrapper, not the actual SmearedModelFunction 130 Proc PlotSmearedSphere_SW(str) 131 String str 132 Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 133 134 // if any of the resolution waves are missing => abort 135 if(ResolutionWavesMissingDF(str)) //updated to NOT use global strings (in GaussUtils) 122 136 Abort 123 137 endif 138 139 SetDataFolder $("root:"+str) 124 140 125 141 // Setup parameter table for model function … … 130 146 // output smeared intensity wave, dimensions are identical to experimental QSIG values 131 147 // make extra copy of experimental q-values for easy plotting 132 Duplicate/O $ gQvalssmeared_S_SW,smeared_qvals148 Duplicate/O $(str+"_q") smeared_S_SW,smeared_qvals 133 149 SetScale d,0,0,"1/cm",smeared_S_SW 134 135 smeared_S_SW := SmearedSphere_SW(smear_coef_S_SW,$gQvals) 150 151 Variable/G gs_S_SW=0 152 gs_S_SW := fSmearedSphere_SW(smear_coef_S_SW,smeared_S_SW,smeared_qvals) //this wrapper fills the STRUCT 153 136 154 Display smeared_S_SW vs smeared_qvals 137 155 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 140 158 141 159 AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 142 End 143 144 Function Sphere_SW(w,x) : FitFunc 145 Wave w 146 Variable x 147 148 Variable inten 149 160 161 SetDataFolder root: 162 End 163 164 165 //AAO function 166 Function Sphere_SW(w,yw,xw) : FitFunc 167 Wave w,yw,xw 168 150 169 //setup form factor coefficient wave 151 170 Make/O/D/N=4 form_S_SW … … 163 182 164 183 //calculate each and combine 165 inten = SphereForm(form_S_SW,x) 166 inten *= SquareWellStruct(struct_S_SW,x) 167 inten *= w[0] 168 inten += w[5] 184 Duplicate/O xw temp_S_SW_PQ,temp_S_SW_SQ 185 SphereForm(form_S_SW,temp_S_SW_PQ,xw) 186 SquareWellStruct(struct_S_SW,temp_S_SW_SQ,xw) 187 yw = temp_S_SW_PQ * temp_S_SW_SQ 188 yw *= w[0] 189 yw += w[5] 169 190 170 191 //cleanup waves 171 192 //Killwaves/Z form_S_SW,struct_S_SW 172 193 173 return ( inten)194 return (0) 174 195 End 175 196 … … 193 214 Make/O/D coef_S_SC = {0.2,50,3e-6,20,0,298,78,0.0001} 194 215 make/o/t parameters_S_SC = {"volume fraction","Radius (A)","contrast (-2)","charge","movalent salt(M)","Temperature (K)","dielectric const","bkgd (cm-1)"} 195 Edit/K=1 parameters_S_SC,coef_S_SC 196 ywave_S_SC := Sphere_SC(coef_S_SC,xwave_S_SC) 216 Edit/K=1 parameters_S_SC,coef_S_SC 217 Variable/G root:g_S_SC 218 g_S_SC := Sphere_SC(coef_S_SC,ywave_S_SC,xwave_S_SC) 219 // ywave_S_SC := Sphere_SC(coef_S_SC,xwave_S_SC) 197 220 Display/K=1 ywave_S_SC vs xwave_S_SC 198 221 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 203 226 End 204 227 205 Proc PlotSmearedSphere_SC() 206 //no input parameters necessary, it MUST use the experimental q-values 207 // from the experimental data read in from an AVE/QSIG data file 208 209 // if no gQvals wave, data must not have been loaded => abort 210 if(ResolutionWavesMissing()) 228 // - sets up a dependency to a wrapper, not the actual SmearedModelFunction 229 Proc PlotSmearedSphere_SC(str) 230 String str 231 Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 232 233 // if any of the resolution waves are missing => abort 234 if(ResolutionWavesMissingDF(str)) //updated to NOT use global strings (in GaussUtils) 211 235 Abort 212 236 endif 237 238 SetDataFolder $("root:"+str) 213 239 214 240 if (DataFolderExists("root:HayPenMSA")) … … 226 252 // output smeared intensity wave, dimensions are identical to experimental QSIG values 227 253 // make extra copy of experimental q-values for easy plotting 228 Duplicate/O $ gQvalssmeared_S_SC,smeared_qvals254 Duplicate/O $(str+"_q") smeared_S_SC,smeared_qvals 229 255 SetScale d,0,0,"1/cm",smeared_S_SC 230 231 smeared_S_SC := SmearedSphere_SC(smear_coef_S_SC,$gQvals) 256 257 Variable/G gs_S_SC=0 258 gs_S_SC := fSmearedSphere_SC(smear_coef_S_SC,smeared_S_SC,smeared_qvals) //this wrapper fills the STRUCT 259 232 260 Display smeared_S_SC vs smeared_qvals 233 261 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 236 264 237 265 AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 238 End 239 240 Function Sphere_SC(w,x) : FitFunc 241 Wave w242 Variable x 243 244 // Variable timer=StartMSTimer 245 Variable inten246 266 267 SetDataFolder root: 268 End 269 270 271 //AAO function 272 Function Sphere_SC(w,yw,xw) : FitFunc 273 Wave w,yw,xw 274 247 275 //setup form factor coefficient wave 248 276 Make/O/D/N=4 form_S_SC … … 262 290 263 291 //calculate each and combine 264 inten = SphereForm(form_S_SC,x) 265 inten *= HayterPenfoldMSA(struct_S_SC,x) 266 inten *= w[0] 267 inten += w[7] 292 Duplicate/O xw temp_S_SC_PQ,temp_S_SC_SQ 293 SphereForm(form_S_SC,temp_S_SC_PQ,xw) 294 HayterPenfoldMSA(struct_S_SC,temp_S_SC_SQ,xw) 295 yw = temp_S_SC_PQ * temp_S_SC_SQ 296 yw *= w[0] 297 yw += w[7] 268 298 269 299 //cleanup waves 270 300 //Killwaves/Z form_S_SC,struct_S_SC 271 //Print "ps elapsed time = ",StopMSTimer(timer) 272 return (inten) 301 return (0) 273 302 End 274 303 … … 288 317 Make/O/D coef_S_SHS = {0.1,60,1e-6,0.05,0.2,0.01} 289 318 make/o/t parameters_S_SHS = {"volume fraction","Radius (A)","contrast (-2)","perturbation parameter (0.1)","stickiness, tau","bkgd (cm-1)"} 290 Edit/K=1 parameters_S_SHS,coef_S_SHS 291 ywave_S_SHS := Sphere_SHS(coef_S_SHS,xwave_S_SHS) 319 Edit/K=1 parameters_S_SHS,coef_S_SHS 320 Variable/G root:g_S_SHS 321 g_S_SHS := Sphere_SHS(coef_S_SHS,ywave_S_SHS,xwave_S_SHS) 322 // ywave_S_SHS := Sphere_SHS(coef_S_SHS,xwave_S_SHS) 292 323 Display/K=1 ywave_S_SHS vs xwave_S_SHS 293 324 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 298 329 End 299 330 300 Proc PlotSmearedSphere_SHS() 301 //no input parameters necessary, it MUST use the experimental q-values 302 // from the experimental data read in from an AVE/QSIG data file 303 304 // if no gQvals wave, data must not have been loaded => abort 305 if(ResolutionWavesMissing()) 331 // - sets up a dependency to a wrapper, not the actual SmearedModelFunction 332 Proc PlotSmearedSphere_SHS(str) 333 String str 334 Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 335 336 // if any of the resolution waves are missing => abort 337 if(ResolutionWavesMissingDF(str)) //updated to NOT use global strings (in GaussUtils) 306 338 Abort 307 339 endif 340 341 SetDataFolder $("root:"+str) 308 342 309 343 // Setup parameter table for model function … … 314 348 // output smeared intensity wave, dimensions are identical to experimental QSIG values 315 349 // make extra copy of experimental q-values for easy plotting 316 Duplicate/O $ gQvalssmeared_S_SHS,smeared_qvals350 Duplicate/O $(str+"_q") smeared_S_SHS,smeared_qvals 317 351 SetScale d,0,0,"1/cm",smeared_S_SHS 318 319 smeared_S_SHS := SmearedSphere_SHS(smear_coef_S_SHS,$gQvals) 352 353 Variable/G gs_S_SHS=0 354 gs_S_SHS := fSmearedSphere_SHS(smear_coef_S_SHS,smeared_S_SHS,smeared_qvals) //this wrapper fills the STRUCT 355 320 356 Display smeared_S_SHS vs smeared_qvals 321 357 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 324 360 325 361 AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 326 End 327 328 Function Sphere_SHS(w,x) : FitFunc 329 Wave w 330 Variable x 331 332 Variable inten 362 363 SetDataFolder root: 364 End 365 366 367 //AAO function 368 Function Sphere_SHS(w,yw,xw) : FitFunc 369 Wave w,yw,xw 333 370 334 371 //setup form factor coefficient wave … … 347 384 348 385 //calculate each and combine 349 inten = SphereForm(form_S_SHS,x) 350 inten *= StickyHS_Struct(struct_S_SHS,x) 351 inten *= w[0] 352 inten += w[5] 386 Duplicate/O xw temp_S_SHS_PQ,temp_S_SHS_SQ 387 SphereForm(form_S_SHS,temp_S_SHS_PQ,xw) 388 StickyHS_Struct(struct_S_SHS,temp_S_SHS_SQ,xw) 389 yw = temp_S_SHS_PQ * temp_S_SHS_SQ 390 yw *= w[0] 391 yw += w[5] 353 392 354 393 //cleanup waves 355 394 //Killwaves/Z form_S_SHS,struct_S_SHS 356 395 357 return ( inten)396 return (0) 358 397 End 359 398 … … 361 400 362 401 // this is all there is to the smeared calculation! 363 Function SmearedSphere_HS(w,x) :FitFunc 364 Wave w 365 Variable x 366 367 Variable ans 368 SVAR sq = gSig_Q 369 SVAR qb = gQ_bar 370 SVAR sh = gShadow 371 SVAR gQ = gQVals 372 373 //the name of your unsmeared model is the first argument 374 ans = Smear_Model_20(Sphere_HS,$sq,$qb,$sh,$gQ,w,x) 375 376 return(ans) 377 End 378 402 Function SmearedSphere_HS(s) :FitFunc 403 Struct ResSmearAAOStruct &s 404 405 // the name of your unsmeared model is the first argument 406 s.yW = Smear_Model_20(Sphere_HS,s.coefW,s.xW,s.resW) 407 408 return(0) 409 End 410 379 411 // this is all there is to the smeared calculation! 380 Function SmearedSphere_SW(w,x) :FitFunc 381 Wave w 382 Variable x 383 384 Variable ans 385 SVAR sq = gSig_Q 386 SVAR qb = gQ_bar 387 SVAR sh = gShadow 388 SVAR gQ = gQVals 389 390 //the name of your unsmeared model is the first argument 391 ans = Smear_Model_20(Sphere_SW,$sq,$qb,$sh,$gQ,w,x) 392 393 return(ans) 412 Function SmearedSphere_SW(s) :FitFunc 413 Struct ResSmearAAOStruct &s 414 415 // the name of your unsmeared model is the first argument 416 s.yW = Smear_Model_20(Sphere_SW,s.coefW,s.xW,s.resW) 417 418 return(0) 394 419 End 395 420 396 421 // this is all there is to the smeared calculation! 397 Function SmearedSphere_SC(w,x) :FitFunc 398 Wave w 399 Variable x 400 401 Variable ans 402 SVAR sq = gSig_Q 403 SVAR qb = gQ_bar 404 SVAR sh = gShadow 405 SVAR gQ = gQVals 406 407 //the name of your unsmeared model is the first argument 408 ans = Smear_Model_20(Sphere_SC,$sq,$qb,$sh,$gQ,w,x) 409 410 return(ans) 422 Function SmearedSphere_SC(s) :FitFunc 423 Struct ResSmearAAOStruct &s 424 425 // the name of your unsmeared model is the first argument 426 s.yW = Smear_Model_20(Sphere_SC,s.coefW,s.xW,s.resW) 427 428 return(0) 411 429 End 412 430 413 431 // this is all there is to the smeared calculation! 414 Function SmearedSphere_SHS(w,x) :FitFunc 415 Wave w 416 Variable x 417 418 Variable ans 419 SVAR sq = gSig_Q 420 SVAR qb = gQ_bar 421 SVAR sh = gShadow 422 SVAR gQ = gQVals 423 424 //the name of your unsmeared model is the first argument 425 ans = Smear_Model_20(Sphere_SHS,$sq,$qb,$sh,$gQ,w,x) 426 427 return(ans) 428 End 432 Function SmearedSphere_SHS(s) :FitFunc 433 Struct ResSmearAAOStruct &s 434 435 // the name of your unsmeared model is the first argument 436 s.yW = Smear_Model_20(Sphere_SHS,s.coefW,s.xW,s.resW) 437 438 return(0) 439 End 440 441 //wrapper to calculate the smeared model as an AAO-Struct 442 // fills the struct and calls the ususal function with the STRUCT parameter 443 // 444 // used only for the dependency, not for fitting 445 // 446 Function fSmearedSphere_HS(coefW,yW,xW) 447 Wave coefW,yW,xW 448 449 String str = getWavesDataFolder(yW,0) 450 String DF="root:"+str+":" 451 452 WAVE resW = $(DF+str+"_res") 453 454 STRUCT ResSmearAAOStruct fs 455 WAVE fs.coefW = coefW 456 WAVE fs.yW = yW 457 WAVE fs.xW = xW 458 WAVE fs.resW = resW 459 460 Variable err 461 err = SmearedSphere_HS(fs) 462 463 return (0) 464 End 465 466 //wrapper to calculate the smeared model as an AAO-Struct 467 // fills the struct and calls the ususal function with the STRUCT parameter 468 // 469 // used only for the dependency, not for fitting 470 // 471 Function fSmearedSphere_SW(coefW,yW,xW) 472 Wave coefW,yW,xW 473 474 String str = getWavesDataFolder(yW,0) 475 String DF="root:"+str+":" 476 477 WAVE resW = $(DF+str+"_res") 478 479 STRUCT ResSmearAAOStruct fs 480 WAVE fs.coefW = coefW 481 WAVE fs.yW = yW 482 WAVE fs.xW = xW 483 WAVE fs.resW = resW 484 485 Variable err 486 err = SmearedSphere_SW(fs) 487 488 return (0) 489 End 490 491 //wrapper to calculate the smeared model as an AAO-Struct 492 // fills the struct and calls the ususal function with the STRUCT parameter 493 // 494 // used only for the dependency, not for fitting 495 // 496 Function fSmearedSphere_SC(coefW,yW,xW) 497 Wave coefW,yW,xW 498 499 String str = getWavesDataFolder(yW,0) 500 String DF="root:"+str+":" 501 502 WAVE resW = $(DF+str+"_res") 503 504 STRUCT ResSmearAAOStruct fs 505 WAVE fs.coefW = coefW 506 WAVE fs.yW = yW 507 WAVE fs.xW = xW 508 WAVE fs.resW = resW 509 510 Variable err 511 err = SmearedSphere_SC(fs) 512 513 return (0) 514 End 515 516 //wrapper to calculate the smeared model as an AAO-Struct 517 // fills the struct and calls the ususal function with the STRUCT parameter 518 // 519 // used only for the dependency, not for fitting 520 // 521 Function fSmearedSphere_SHS(coefW,yW,xW) 522 Wave coefW,yW,xW 523 524 String str = getWavesDataFolder(yW,0) 525 String DF="root:"+str+":" 526 527 WAVE resW = $(DF+str+"_res") 528 529 STRUCT ResSmearAAOStruct fs 530 WAVE fs.coefW = coefW 531 WAVE fs.yW = yW 532 WAVE fs.xW = xW 533 WAVE fs.resW = resW 534 535 Variable err 536 err = SmearedSphere_SHS(fs) 537 538 return (0) 539 End
Note: See TracChangeset
for help on using the changeset viewer.