Ignore:
Timestamp:
Jul 25, 2007 3:07:20 PM (16 years ago)
Author:
srkline
Message:

Second round of changes to ipf files to (hopefully) complete the changes to bring all of the model functions to be:

  • this set of changes is for the "2006" set of models
  • AAO
  • new dependencies
  • smearing using structures
  • #if conditional compile for XOPS

-this needs to be FULLY tested for correctness and bugs
-packages are certainly still broken (data folders)

SRK 25 JUL 07

Location:
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006
Files:
28 edited

Legend:

Unmodified
Added
Removed
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/Beaucage.ipf

    r127 r128  
    2525        make/o/t parameters_b1 = {"scale","G1 (cm-1 sr-1)","Rg1  (A)","B1 (cm-1 sr-1)","Pow1","bkg (cm-1 sr-1)"} 
    2626        Edit parameters_b1,coef_b1 
    27         ywave_b1 := OneLevel(coef_b1,xwave_b1) 
     27         
     28        Variable/G root:g_b1 
     29        g_b1 := OneLevel(coef_b1,ywave_b1,xwave_b1) 
    2830        Display ywave_b1 vs xwave_b1 
    2931        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    4446        make/o/t parameters_b2 = {"scale","G1 (cm-1 sr-1)","Rg1  (A)","B1 (cm-1 sr-1)","Pow1","G2 (cm-1 sr-1)","Rg2  (A)","B2 (cm-1 sr-1)","Pow2","bkg (cm-1 sr-1)"} 
    4547        Edit parameters_b2,coef_b2 
    46         ywave_b2 := TwoLevel(coef_b2,xwave_b2) 
     48         
     49        Variable/G root:g_b2 
     50        g_b2 := TwoLevel(coef_b2,ywave_b2,xwave_b2) 
    4751        Display ywave_b2 vs xwave_b2 
    4852        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    6367        make/o/t parameters_b3 = {"scale","G1 (cm-1 sr-1)","Rg1  (A)","B1 (cm-1 sr-1)","Pow1","G2 (cm-1 sr-1)","Rg2  (A)","B2 (cm-1 sr-1)","Pow2","G3 (cm-1 sr-1)","Rg3  (A)","B3 (cm-1 sr-1)","Pow3","bkg (cm-1)"} 
    6468        Edit parameters_b3,coef_b3 
    65         ywave_b3 := ThreeLevel(coef_b3,xwave_b3) 
     69         
     70        Variable/G root:g_b3 
     71        g_b3 := ThreeLevel(coef_b3,ywave_b3,xwave_b3)    
    6672        Display ywave_b3 vs xwave_b3 
    6773        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    8288        make/o/t parameters_b4 = {"scale","G1 (cm-1 sr-1)","Rg1  (A)","B1 (cm-1 sr-1)","Pow1","G2 (cm-1 sr-1)","Rg2  (A)","B2 (cm-1 sr-1)","Pow2","G3 (cm-1 sr-1)","Rg3  (A)","B3 (cm-1 sr-1)","Pow3","G4 (cm-1 sr-1)","Rg4  (A)","B4 (cm-1 sr-1)","Pow4","bkg (cm-1)"} 
    8389        Edit parameters_b4,coef_b4 
    84         ywave_b4 := FourLevel(coef_b4,xwave_b4) 
     90         
     91        Variable/G root:g_b4 
     92        g_b4 := FourLevel(coef_b4,ywave_b4,xwave_b4)     
    8593        Display ywave_b4 vs xwave_b4 
    8694        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    92100/////////// macros for smeared model calculations 
    93101 
    94 Proc PlotSmearedBeau_OneLevel()                                                          
    95         //no input parameters necessary, it MUST use the experimental q-values 
    96         // from the experimental data read in from an AVE/QSIG data file 
    97         If(ResolutionWavesMissing())            //part of GaussUtils 
     102// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     103Proc PlotSmearedBeau_OneLevel(str)                                                               
     104        String str 
     105        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     106         
     107        // if any of the resolution waves are missing => abort 
     108        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    98109                Abort 
    99110        endif 
     111         
     112        SetDataFolder $("root:"+str) 
    100113         
    101114        // Setup parameter table for model function 
     
    106119        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    107120        // make extra copy of experimental q-values for easy plotting 
    108         Duplicate/O $gQvals smeared_b1,smeared_qvals                             
     121        Duplicate/O $(str+"_q") smeared_b1,smeared_qvals                                 
    109122        SetScale d,0,0,"1/cm",smeared_b1                                                         
    110  
    111         smeared_b1 := SmearedOneLevel(smear_coef_b1,$gQvals)             
     123                                         
     124        Variable/G gs_b1=0 
     125        gs_b1 := fSmearedOneLevel(smear_coef_b1,smeared_b1,smeared_qvals)       //this wrapper fills the STRUCT 
     126         
    112127        Display smeared_b1 vs smeared_qvals                                                                      
    113128        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    115130        Label left "Intensity (cm\\S-1\\M)" 
    116131        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    117 End 
    118  
    119 Proc PlotSmearedBeau_TwoLevel()                                                          
    120         //no input parameters necessary, it MUST use the experimental q-values 
    121         // from the experimental data read in from an AVE/QSIG data file 
    122         If(ResolutionWavesMissing())            //part of GaussUtils 
     132         
     133        SetDataFolder root: 
     134End 
     135         
     136// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     137Proc PlotSmearedBeau_TwoLevel(str)                                                               
     138        String str 
     139        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     140         
     141        // if any of the resolution waves are missing => abort 
     142        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    123143                Abort 
    124144        endif 
     145         
     146        SetDataFolder $("root:"+str) 
    125147         
    126148        // Setup parameter table for model function 
     
    131153        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    132154        // make extra copy of experimental q-values for easy plotting 
    133         Duplicate/O $gQvals smeared_b2,smeared_qvals                             
     155        Duplicate/O $(str+"_q") smeared_b2,smeared_qvals                                 
    134156        SetScale d,0,0,"1/cm",smeared_b2                                                         
    135  
    136         smeared_b2 := SmearedTwoLevel(smear_coef_b2,$gQvals)             
     157                                         
     158        Variable/G gs_b2=0 
     159        gs_b2 := fSmearedTwoLevel(smear_coef_b2,smeared_b2,smeared_qvals)       //this wrapper fills the STRUCT 
     160         
    137161        Display smeared_b2 vs smeared_qvals                                                                      
    138162        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    140164        Label left "Intensity (cm\\S-1\\M)" 
    141165        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    142 End 
    143  
    144 Proc PlotSmearedBeau_ThreeLevel()                                                                
    145         //no input parameters necessary, it MUST use the experimental q-values 
    146         // from the experimental data read in from an AVE/QSIG data file 
    147         If(ResolutionWavesMissing())            //part of GaussUtils 
     166         
     167        SetDataFolder root: 
     168End 
     169         
     170// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     171Proc PlotSmearedBeau_ThreeLevel(str)                                                             
     172        String str 
     173        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     174         
     175        // if any of the resolution waves are missing => abort 
     176        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    148177                Abort 
    149178        endif 
     179         
     180        SetDataFolder $("root:"+str) 
    150181         
    151182        // Setup parameter table for model function 
     
    156187        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    157188        // make extra copy of experimental q-values for easy plotting 
    158         Duplicate/O $gQvals smeared_b3,smeared_qvals                             
     189        Duplicate/O $(str+"_q") smeared_b3,smeared_qvals                                 
    159190        SetScale d,0,0,"1/cm",smeared_b3                                                         
    160  
    161         smeared_b3 := SmearedThreeLevel(smear_coef_b3,$gQvals)           
     191                                         
     192        Variable/G gs_b3=0 
     193        gs_b3 := fSmearedThreeLevel(smear_coef_b3,smeared_b3,smeared_qvals)     //this wrapper fills the STRUCT 
     194         
    162195        Display smeared_b3 vs smeared_qvals                                                                      
    163196        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    165198        Label left "Intensity (cm\\S-1\\M)" 
    166199        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    167 End 
    168  
    169 Proc PlotSmearedBeau_FourLevel()                                                                 
    170         //no input parameters necessary, it MUST use the experimental q-values 
    171         // from the experimental data read in from an AVE/QSIG data file 
    172         If(ResolutionWavesMissing())            //part of GaussUtils 
     200         
     201        SetDataFolder root: 
     202End 
     203         
     204// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     205Proc PlotSmearedBeau_FourLevel(str)                                                              
     206        String str 
     207        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     208         
     209        // if any of the resolution waves are missing => abort 
     210        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    173211                Abort 
    174212        endif 
     213         
     214        SetDataFolder $("root:"+str) 
    175215         
    176216        // Setup parameter table for model function 
     
    181221        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    182222        // make extra copy of experimental q-values for easy plotting 
    183         Duplicate/O $gQvals smeared_b4,smeared_qvals                             
     223        Duplicate/O $(str+"_q") smeared_b4,smeared_qvals                                 
    184224        SetScale d,0,0,"1/cm",smeared_b4                                                         
    185  
    186         smeared_b4 := SmearedFourLevel(smear_coef_b4,$gQvals)            
     225                                         
     226        Variable/G gs_b4=0 
     227        gs_b4 := fSmearedFourLevel(smear_coef_b4,smeared_b4,smeared_qvals)      //this wrapper fills the STRUCT 
     228         
    187229        Display smeared_b4 vs smeared_qvals                                                                      
    188230        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    190232        Label left "Intensity (cm\\S-1\\M)" 
    191233        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
     234         
     235        SetDataFolder root: 
     236End 
     237         
     238 
     239 
     240 
     241//AAO version, uses XOP if available 
     242// simply calls the original single point calculation with 
     243// a wave assignment (this will behave nicely if given point ranges) 
     244Function OneLevel(cw,yw,xw) : FitFunc 
     245        Wave cw,yw,xw 
     246         
     247#if exists("OneLevelX") 
     248        yw = OneLevelX(cw,xw) 
     249#else 
     250        yw = fOneLevel(cw,xw) 
     251#endif 
     252        return(0) 
    192253End 
    193254 
    194255//////////Function definitions 
    195256 
    196 Function OneLevel(w,x) :FitFunc 
     257Function fOneLevel(w,x) :FitFunc 
    197258        Wave w 
    198259        Variable x 
     
    218279End 
    219280 
    220 Function TwoLevel(w,x) :FitFunc 
     281//AAO version, uses XOP if available 
     282// simply calls the original single point calculation with 
     283// a wave assignment (this will behave nicely if given point ranges) 
     284Function TwoLevel(cw,yw,xw) : FitFunc 
     285        Wave cw,yw,xw 
     286         
     287#if exists("TwoLevelX") 
     288        yw = TwoLevelX(cw,xw) 
     289#else 
     290        yw = fTwoLevel(cw,xw) 
     291#endif 
     292        return(0) 
     293End 
     294 
     295Function fTwoLevel(w,x) :FitFunc 
    221296        Wave w 
    222297        Variable x 
     
    251326End 
    252327 
    253  
    254 Function ThreeLevel(w,x) :FitFunc 
     328//AAO version, uses XOP if available 
     329// simply calls the original single point calculation with 
     330// a wave assignment (this will behave nicely if given point ranges) 
     331Function ThreeLevel(cw,yw,xw) : FitFunc 
     332        Wave cw,yw,xw 
     333         
     334#if exists("ThreeLevelX") 
     335        yw = ThreeLevelX(cw,xw) 
     336#else 
     337        yw = fThreeLevel(cw,xw) 
     338#endif 
     339        return(0) 
     340End 
     341 
     342Function fThreeLevel(w,x) :FitFunc 
    255343        Wave w 
    256344        Variable x 
     
    290378End 
    291379 
    292 Function FourLevel(w,x) :FitFunc 
     380//AAO version, uses XOP if available 
     381// simply calls the original single point calculation with 
     382// a wave assignment (this will behave nicely if given point ranges) 
     383Function FourLevel(cw,yw,xw) : FitFunc 
     384        Wave cw,yw,xw 
     385         
     386#if exists("FourLevelX") 
     387        yw = FourLevelX(cw,xw) 
     388#else 
     389        yw = fFourLevel(cw,xw) 
     390#endif 
     391        return(0) 
     392End 
     393 
     394Function fFourLevel(w,x) :FitFunc 
    293395        Wave w 
    294396        Variable x 
     
    334436End 
    335437 
    336 Function SmearedOneLevel(w,x) :FitFunc 
    337         Wave w 
    338         Variable x 
    339          
    340 //      Variable timer=StartMSTimer 
    341         Variable ans 
    342         SVAR sq = gSig_Q 
    343         SVAR qb = gQ_bar 
    344         SVAR sh = gShadow 
    345         SVAR gQ = gQVals 
    346          
    347         ans = Smear_Model_20(OneLevel,$sq,$qb,$sh,$gQ,w,x)       
    348  
    349 //      Print "HS elapsed time(s) = ",StopMSTimer(timer)*1e-6 
    350         return(ans) 
    351 End 
    352  
    353 Function SmearedTwoLevel(w,x) :FitFunc 
    354         Wave w 
    355         Variable x 
    356          
    357         Variable ans 
    358         SVAR sq = gSig_Q 
    359         SVAR qb = gQ_bar 
    360         SVAR sh = gShadow 
    361         SVAR gQ = gQVals 
    362          
    363         ans = Smear_Model_20(TwoLevel,$sq,$qb,$sh,$gQ,w,x)       
    364  
    365         return(ans) 
    366 End 
    367  
    368 Function SmearedThreeLevel(w,x) :FitFunc 
    369         Wave w 
    370         Variable x 
    371          
    372         Variable ans 
    373         SVAR sq = gSig_Q 
    374         SVAR qb = gQ_bar 
    375         SVAR sh = gShadow 
    376         SVAR gQ = gQVals 
    377          
    378         ans = Smear_Model_20(ThreeLevel,$sq,$qb,$sh,$gQ,w,x)     
    379  
    380         return(ans) 
    381 End 
    382  
    383 Function SmearedFourLevel(w,x) :FitFunc 
    384         Wave w 
    385         Variable x 
    386          
    387         Variable ans 
    388         SVAR sq = gSig_Q 
    389         SVAR qb = gQ_bar 
    390         SVAR sh = gShadow 
    391         SVAR gQ = gQVals 
    392          
    393         ans = Smear_Model_20(FourLevel,$sq,$qb,$sh,$gQ,w,x)      
    394  
    395         return(ans) 
    396 End 
     438Function SmearedOneLevel(s) :FitFunc 
     439        Struct ResSmearAAOStruct &s 
     440 
     441//      the name of your unsmeared model (AAO) is the first argument 
     442        s.yW = Smear_Model_20(OneLevel,s.coefW,s.xW,s.resW) 
     443 
     444        return(0) 
     445End 
     446         
     447 
     448Function SmearedTwoLevel(s) :FitFunc 
     449        Struct ResSmearAAOStruct &s 
     450 
     451//      the name of your unsmeared model (AAO) is the first argument 
     452        s.yW = Smear_Model_20(TwoLevel,s.coefW,s.xW,s.resW) 
     453 
     454        return(0) 
     455End 
     456         
     457 
     458Function SmearedThreeLevel(s) :FitFunc 
     459        Struct ResSmearAAOStruct &s 
     460 
     461//      the name of your unsmeared model (AAO) is the first argument 
     462        s.yW = Smear_Model_20(ThreeLevel,s.coefW,s.xW,s.resW) 
     463 
     464        return(0) 
     465End 
     466 
     467Function SmearedFourLevel(s) :FitFunc 
     468        Struct ResSmearAAOStruct &s 
     469 
     470//      the name of your unsmeared model (AAO) is the first argument 
     471        s.yW = Smear_Model_20(FourLevel,s.coefW,s.xW,s.resW) 
     472 
     473        return(0) 
     474End 
     475 
     476//wrapper to calculate the smeared model as an AAO-Struct 
     477// fills the struct and calls the ususal function with the STRUCT parameter 
     478// 
     479// used only for the dependency, not for fitting 
     480// 
     481Function fSmearedOneLevel(coefW,yW,xW) 
     482        Wave coefW,yW,xW 
     483         
     484        String str = getWavesDataFolder(yW,0) 
     485        String DF="root:"+str+":" 
     486         
     487        WAVE resW = $(DF+str+"_res") 
     488         
     489        STRUCT ResSmearAAOStruct fs 
     490        WAVE fs.coefW = coefW    
     491        WAVE fs.yW = yW 
     492        WAVE fs.xW = xW 
     493        WAVE fs.resW = resW 
     494         
     495        Variable err 
     496        err = SmearedOneLevel(fs) 
     497         
     498        return (0) 
     499End 
     500 
     501//wrapper to calculate the smeared model as an AAO-Struct 
     502// fills the struct and calls the ususal function with the STRUCT parameter 
     503// 
     504// used only for the dependency, not for fitting 
     505// 
     506Function fSmearedTwoLevel(coefW,yW,xW) 
     507        Wave coefW,yW,xW 
     508         
     509        String str = getWavesDataFolder(yW,0) 
     510        String DF="root:"+str+":" 
     511         
     512        WAVE resW = $(DF+str+"_res") 
     513         
     514        STRUCT ResSmearAAOStruct fs 
     515        WAVE fs.coefW = coefW    
     516        WAVE fs.yW = yW 
     517        WAVE fs.xW = xW 
     518        WAVE fs.resW = resW 
     519         
     520        Variable err 
     521        err = SmearedTwoLevel(fs) 
     522         
     523        return (0) 
     524End 
     525 
     526//wrapper to calculate the smeared model as an AAO-Struct 
     527// fills the struct and calls the ususal function with the STRUCT parameter 
     528// 
     529// used only for the dependency, not for fitting 
     530// 
     531Function fSmearedThreeLevel(coefW,yW,xW) 
     532        Wave coefW,yW,xW 
     533         
     534        String str = getWavesDataFolder(yW,0) 
     535        String DF="root:"+str+":" 
     536         
     537        WAVE resW = $(DF+str+"_res") 
     538         
     539        STRUCT ResSmearAAOStruct fs 
     540        WAVE fs.coefW = coefW    
     541        WAVE fs.yW = yW 
     542        WAVE fs.xW = xW 
     543        WAVE fs.resW = resW 
     544         
     545        Variable err 
     546        err = SmearedThreeLevel(fs) 
     547         
     548        return (0) 
     549End 
     550 
     551//wrapper to calculate the smeared model as an AAO-Struct 
     552// fills the struct and calls the ususal function with the STRUCT parameter 
     553// 
     554// used only for the dependency, not for fitting 
     555// 
     556Function fSmearedFourLevel(coefW,yW,xW) 
     557        Wave coefW,yW,xW 
     558         
     559        String str = getWavesDataFolder(yW,0) 
     560        String DF="root:"+str+":" 
     561         
     562        WAVE resW = $(DF+str+"_res") 
     563         
     564        STRUCT ResSmearAAOStruct fs 
     565        WAVE fs.coefW = coefW    
     566        WAVE fs.yW = yW 
     567        WAVE fs.xW = xW 
     568        WAVE fs.resW = resW 
     569         
     570        Variable err 
     571        err = SmearedFourLevel(fs) 
     572         
     573        return (0) 
     574End 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/BimodalSchulzSpheres.ipf

    r127 r128  
    2626        parameters_bss[4,9] = {"volume fraction(2)","Radius (2)","polydispersity(2)","SLD(2)","SLD (solvent)","background (cm-1 sr-1)"} 
    2727        Edit parameters_bss,coef_bss 
    28         ywave_bss := BimodalSchulzSpheres(coef_bss,xwave_bss) 
     28         
     29        Variable/G root:g_bss 
     30        g_bss := BimodalSchulzSpheres(coef_bss,ywave_bss,xwave_bss) 
    2931        Display ywave_bss vs xwave_bss 
    3032        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    3638 
    3739/////////////////////////////////////////////////////////// 
    38  
    39 Proc PlotSmearedBimodalSchulzSpheres()           
    40         //no input parameters necessary, it MUST use the experimental q-values 
    41         // from the experimental data read in from an AVE/QSIG data file 
    42          
    43         // if no gQvals wave, data must not have been loaded => abort 
    44         if(ResolutionWavesMissing()) 
     40// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     41Proc PlotSmearedBimodalSchulzSpheres(str)                                                                
     42        String str 
     43        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     44         
     45        // if any of the resolution waves are missing => abort 
     46        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    4547                Abort 
    4648        endif 
     49         
     50        SetDataFolder $("root:"+str) 
    4751         
    4852        // Setup parameter table for model function 
     
    5559        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    5660        // make extra copy of experimental q-values for easy plotting 
    57         Duplicate/O $gQvals smeared_bss,smeared_qvals 
     61        Duplicate/O $(str+"_q") smeared_bss,smeared_qvals 
    5862        SetScale d,0,0,"1/cm",smeared_bss 
    59  
    60         smeared_bss := SmearedBimodalSchulzSpheres(smear_coef_bss,$gQvals) 
     63                                         
     64        Variable/G gs_bss=0 
     65        gs_bss := fSmearedBimodalSchulzSpheres(smear_coef_bss,smeared_bss,smeared_qvals)        //this wrapper fills the STRUCT 
     66         
    6167        Display smeared_bss vs smeared_qvals 
    6268        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    6470        Label left "Intensity (cm\\S-1\\M)" 
    6571        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    66 End 
     72         
     73        SetDataFolder root: 
     74End 
     75         
    6776 
    6877//  Calculates some characteristic parameters for bimodal Shulz distribution 
     
    170179// unsmeared model calculation 
    171180/////////////////////////// 
    172 Function BimodalSchulzSpheres(w,k) : FitFunc 
    173         Wave w                  // the coefficient wave 
    174         Variable k              // the x values, as a variable 
     181// now AAO function 
     182Function BimodalSchulzSpheres(w,yw,xw) : FitFunc 
     183        Wave w,yw,xw                    // the coefficient wave, y, x 
    175184 
    176185        Variable ans=0 
     
    192201         
    193202        //calculate both models and sum (add background here) 
    194         ans = SchulzSpheres(temp_coef_1,k) 
    195         ans += SchulzSpheres(temp_coef_2,k) 
    196         ans += w[9]             //background 
    197          
    198         return(ans) 
     203        Duplicate/O xw tmp_ss1,tmp_ss2 
     204        SchulzSpheres(temp_coef_1,tmp_ss1,xw) 
     205        SchulzSpheres(temp_coef_2,tmp_ss2,xw) 
     206        yw = tmp_ss1 + tmp_ss2 
     207        yw += w[9]              //background 
     208         
     209        return(0) 
    199210End 
    200211 
     
    208219End 
    209220 
     221//wrapper to calculate the smeared model as an AAO-Struct 
     222// fills the struct and calls the ususal function with the STRUCT parameter 
     223// 
     224// used only for the dependency, not for fitting 
     225// 
     226Function fSmearedBimodalSchulzSpheres(coefW,yW,xW) 
     227        Wave coefW,yW,xW 
     228         
     229        String str = getWavesDataFolder(yW,0) 
     230        String DF="root:"+str+":" 
     231         
     232        WAVE resW = $(DF+str+"_res") 
     233         
     234        STRUCT ResSmearAAOStruct fs 
     235        WAVE fs.coefW = coefW    
     236        WAVE fs.yW = yW 
     237        WAVE fs.xW = xW 
     238        WAVE fs.resW = resW 
     239         
     240        Variable err 
     241        err = SmearedBimodalSchulzSpheres(fs) 
     242         
     243        return (0) 
     244End 
     245 
    210246// this is all there is to the smeared calculation! 
    211 Function SmearedBimodalSchulzSpheres(w,x) :FitFunc 
    212         Wave w 
    213         Variable x 
    214          
    215         Variable ans 
    216         SVAR sq = gSig_Q 
    217         SVAR qb = gQ_bar 
    218         SVAR sh = gShadow 
    219         SVAR gQ = gQVals 
    220          
    221         //the name of your unsmeared model is the first argument 
    222         ans = Smear_Model_20(BimodalSchulzSpheres,$sq,$qb,$sh,$gQ,w,x) 
    223  
    224         return(ans) 
    225 End 
    226  
     247Function SmearedBimodalSchulzSpheres(s) :FitFunc 
     248        Struct ResSmearAAOStruct &s 
     249 
     250//      the name of your unsmeared model (AAO) is the first argument 
     251        s.yW = Smear_Model_20(BimodalSchulzSpheres,s.coefW,s.xW,s.resW) 
     252 
     253        return(0) 
     254End 
     255         
     256 
     257 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/BinaryHardSpheres.ipf

    r127 r128  
    5858        ModifyTable width(coef_BinaryHS)=90 
    5959         
    60         ywave_BinaryHS  := BinaryHS(coef_BinaryHS, xwave_BinaryHS) 
     60        Variable/G root:g_BinaryHS 
     61        g_BinaryHS := BinaryHS(coef_BinaryHS, ywave_BinaryHS,xwave_BinaryHS) 
    6162        Display ywave_BinaryHS vs xwave_BinaryHS 
    6263        ModifyGraph marker=29, msize=2, mode=4 
     
    6768End 
    6869 
    69 // 
    70 //this macro sets up all the necessary parameters and waves that are 
    71 //needed to calculate the  smeared model function. 
    72 // 
    73 //no input parameters are necessary, it MUST use the experimental q-values 
    74 // from the experimental data read in from an AVE/QSIG data file 
    75 //////////////////////////////////////////////////// 
    76 Proc PlotSmeared_BinaryHS()                                                             //BinaryHS 
    77          
    78         // if no gQvals wave, data must not have been loaded => abort 
    79         if(ResolutionWavesMissing()) 
     70// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     71Proc PlotSmeared_BinaryHS(str)                                                           
     72        String str 
     73        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     74         
     75        // if any of the resolution waves are missing => abort 
     76        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    8077                Abort 
    8178        endif 
     79         
     80        SetDataFolder $("root:"+str) 
    8281         
    8382        // Setup parameter table for model function 
     
    8988        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    9089        // make extra copy of experimental q-values for easy plotting 
    91         Duplicate/O $gQvals smeared_BinaryHS,smeared_qvals                              // 
     90        Duplicate/O $(str+"_q") smeared_BinaryHS,smeared_qvals                          // 
    9291        SetScale d,0,0,"1/cm",smeared_BinaryHS                                                  // 
    93  
    94         smeared_BinaryHS := BinaryHS_Smeared(smear_coef_BinaryHS,$gQvals)               // SMEARED function name 
     92                                         
     93        Variable/G gs_BinaryHS=0 
     94        gs_BinaryHS := fBinaryHS_Smeared(smear_coef_BinaryHS,smeared_BinaryHS,smeared_qvals)    //this wrapper fills the STRUCT 
     95         
    9596        Display smeared_BinaryHS vs smeared_qvals                                                                       // 
    9697        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    9899        Label left "I(q) (cm\\S-1\\M)" 
    99100        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    100 End     // end macro  
     101         
     102        SetDataFolder root: 
     103End 
     104 
     105 
     106 
     107//AAO version, uses XOP if available 
     108// simply calls the original single point calculation with 
     109// a wave assignment (this will behave nicely if given point ranges) 
     110Function BinaryHS(cw,yw,xw) : FitFunc 
     111        Wave cw,yw,xw 
     112         
     113#if exists("BinaryHSX") 
     114        yw = BinaryHSX(cw,xw) 
     115#else 
     116        yw = fBinaryHS(cw,xw) 
     117#endif 
     118        return(0) 
     119End 
     120 
    101121 
    102122//CH#1 
     
    105125// based on the wave (array) of parameters that you send it (w) 
    106126// 
    107 Function BinaryHS(w,x) : FitFunc 
     127Function fBinaryHS(w,x) : FitFunc 
    108128        Wave w 
    109129        Variable x 
     
    168188End 
    169189 
    170 Function BinaryHS_PSF11(w,x) : FitFunc 
     190//AAO version, uses XOP if available 
     191// simply calls the original single point calculation with 
     192// a wave assignment (this will behave nicely if given point ranges) 
     193Function BinaryHS_PSF11(cw,yw,xw) : FitFunc 
     194        Wave cw,yw,xw 
     195         
     196#if exists("BinaryHS_PSF11X") 
     197        yw = BinaryHS_PSF11X(cw,xw) 
     198#else 
     199        yw = fBinaryHS_PSF11(cw,xw) 
     200#endif 
     201        return(0) 
     202End 
     203 
     204Function fBinaryHS_PSF11(w,x) : FitFunc 
    171205        Wave w 
    172206        Variable x 
     
    210244End 
    211245 
    212 Function BinaryHS_PSF12(w,x) : FitFunc 
     246//AAO version, uses XOP if available 
     247// simply calls the original single point calculation with 
     248// a wave assignment (this will behave nicely if given point ranges) 
     249Function BinaryHS_PSF12(cw,yw,xw) : FitFunc 
     250        Wave cw,yw,xw 
     251         
     252#if exists("BinaryHS_PSF12X") 
     253        yw = BinaryHS_PSF12X(cw,xw) 
     254#else 
     255        yw = fBinaryHS_PSF12(cw,xw) 
     256#endif 
     257        return(0) 
     258End 
     259 
     260Function fBinaryHS_PSF12(w,x) : FitFunc 
    213261        Wave w 
    214262        Variable x 
     
    252300End 
    253301 
    254 Function BinaryHS_PSF22(w,x) : FitFunc 
     302//AAO version, uses XOP if available 
     303// simply calls the original single point calculation with 
     304// a wave assignment (this will behave nicely if given point ranges) 
     305Function BinaryHS_PSF22(cw,yw,xw) : FitFunc 
     306        Wave cw,yw,xw 
     307         
     308#if exists("BinaryHS_PSF22X") 
     309        yw = BinaryHS_PSF22X(cw,xw) 
     310#else 
     311        yw = fBinaryHS_PSF22(cw,xw) 
     312#endif 
     313        return(0) 
     314End 
     315 
     316Function fBinaryHS_PSF22(w,x) : FitFunc 
    255317        Wave w 
    256318        Variable x 
     
    387449End 
    388450         
    389          
     451 
     452//wrapper to calculate the smeared model as an AAO-Struct 
     453// fills the struct and calls the ususal function with the STRUCT parameter 
     454// 
     455// used only for the dependency, not for fitting 
     456// 
     457Function fBinaryHS_Smeared(coefW,yW,xW) 
     458        Wave coefW,yW,xW 
     459         
     460        String str = getWavesDataFolder(yW,0) 
     461        String DF="root:"+str+":" 
     462         
     463        WAVE resW = $(DF+str+"_res") 
     464         
     465        STRUCT ResSmearAAOStruct fs 
     466        WAVE fs.coefW = coefW    
     467        WAVE fs.yW = yW 
     468        WAVE fs.xW = xW 
     469        WAVE fs.resW = resW 
     470         
     471        Variable err 
     472        err = BinaryHS_Smeared(fs) 
     473         
     474        return (0) 
     475End 
     476 
    390477// this is all there is to the smeared calculation! 
    391 Function BinaryHS_Smeared(w,x) :FitFunc 
    392         Wave w 
    393         Variable x 
    394          
    395         Variable ans 
    396         SVAR sq = gSig_Q 
    397         SVAR qb = gQ_bar 
    398         SVAR sh = gShadow 
    399         SVAR gQ = gQVals 
    400          
    401         //the name of your unsmeared model is the first argument 
    402         ans = Smear_Model_20(BinaryHS,$sq,$qb,$sh,$gQ,w,x)      //CH#4 
    403  
    404         return(ans) 
    405 End 
     478Function BinaryHS_Smeared(s) :FitFunc 
     479        Struct ResSmearAAOStruct &s 
     480 
     481//      the name of your unsmeared model (AAO) is the first argument 
     482        s.yW = Smear_Model_20(BinaryHS,s.coefW,s.xW,s.resW) 
     483 
     484        return(0) 
     485End 
     486 
    406487 
    407488 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/Cylinder_PolyLength.ipf

    r127 r128  
    2828        make/o/t parameters_cypl = {"scale","radius (A)","length (A)","polydispersity of Length","SLD diff (A^-2)","incoh. bkg (cm^-1)"} 
    2929        Edit parameters_cypl,coef_cypl 
    30         ywave_cypl := Cyl_PolyLength(coef_cypl,xwave_cypl) 
     30         
     31        Variable/G root:g_cypl 
     32        g_cypl := Cyl_PolyLength(coef_cypl,ywave_cypl,xwave_cypl) 
    3133        Display ywave_cypl vs xwave_cypl 
    3234        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    3638End 
    3739 
    38 // plot the smeared version - quite slow - use only for final fit 
    39 Proc PlotSmearedCyl_PolyLength()         
    40         //no input parameters necessary, it MUST use the experimental q-values 
    41         // from the experimental data read in from an AVE/QSIG data file 
    42          
    43         // if no gQvals wave, data must not have been loaded => abort 
    44         if(ResolutionWavesMissing()) 
     40// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     41Proc PlotSmearedCyl_PolyLength(str)                                                              
     42        String str 
     43        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     44         
     45        // if any of the resolution waves are missing => abort 
     46        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    4547                Abort 
    4648        endif 
     49         
     50        SetDataFolder $("root:"+str) 
    4751         
    4852        // Setup parameter table for model function 
     
    5357        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    5458        // make extra copy of experimental q-values for easy plotting 
    55         Duplicate/O $gQvals smeared_cypl,smeared_qvals 
     59        Duplicate/O $(str+"_q") smeared_cypl,smeared_qvals 
    5660        SetScale d,0,0,"1/cm",smeared_cypl       
    57  
    58         smeared_cypl := SmearedCyl_PolyLength(smear_coef_cypl,$gQvals) 
     61                                         
     62        Variable/G gs_cypl=0 
     63        gs_cypl := fSmearedCyl_PolyLength(smear_coef_cypl,smeared_cypl,smeared_qvals)   //this wrapper fills the STRUCT 
     64         
    5965        Display smeared_cypl vs smeared_qvals 
    6066        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    6268        Label left "Intensity (cm\\S-1\\M)" 
    6369        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
     70         
     71        SetDataFolder root: 
     72End 
     73         
     74 
     75 
     76//AAO version, uses XOP if available 
     77// simply calls the original single point calculation with 
     78// a wave assignment (this will behave nicely if given point ranges) 
     79Function Cyl_PolyLength(cw,yw,xw) : FitFunc 
     80        Wave cw,yw,xw 
     81         
     82#if exists("Cyl_PolyLengthX") 
     83        yw = Cyl_PolyLengthX(cw,xw) 
     84#else 
     85        yw = fCyl_PolyLength(cw,xw) 
     86#endif 
     87        return(0) 
    6488End 
    6589 
     
    6791// both integrals are done using quadrature, although both may benefit from an 
    6892// adaptive integration 
    69 Function Cyl_PolyLength(w,x)  : FitFunc 
     93Function fCyl_PolyLength(w,x)  : FitFunc 
    7094        Wave w 
    7195        Variable x 
     
    182206        kp[4] = 0               //bkg fixed at 0 
    183207         
    184         Pq = CylinderForm(kp,qw) 
    185         //Pq = CylinderFit(kp,qw)       //from the XOP 
     208#if exists("CylinderFormX") 
     209        Pq = CylinderFormX(kp,qw) 
     210#else 
     211        Pq = fCylinderForm(kp,qw) 
     212#endif 
    186213         
    187214        // undo the normalization that CylinderForm does 
     
    208235End 
    209236 
     237//wrapper to calculate the smeared model as an AAO-Struct 
     238// fills the struct and calls the ususal function with the STRUCT parameter 
     239// 
     240// used only for the dependency, not for fitting 
     241// 
     242Function fSmearedCyl_PolyLength(coefW,yW,xW) 
     243        Wave coefW,yW,xW 
     244         
     245        String str = getWavesDataFolder(yW,0) 
     246        String DF="root:"+str+":" 
     247         
     248        WAVE resW = $(DF+str+"_res") 
     249         
     250        STRUCT ResSmearAAOStruct fs 
     251        WAVE fs.coefW = coefW    
     252        WAVE fs.yW = yW 
     253        WAVE fs.xW = xW 
     254        WAVE fs.resW = resW 
     255         
     256        Variable err 
     257        err = SmearedCyl_PolyLength(fs) 
     258         
     259        return (0) 
     260End 
     261 
    210262// this is all there is to the smeared calculation! 
    211 Function SmearedCyl_PolyLength(w,x) :FitFunc 
    212         Wave w 
    213         Variable x 
    214          
    215         Variable ans 
    216         SVAR sq = gSig_Q 
    217         SVAR qb = gQ_bar 
    218         SVAR sh = gShadow 
    219         SVAR gQ = gQVals 
    220          
    221         //the name of your unsmeared model is the first argument 
    222         ans = Smear_Model_20(Cyl_PolyLength,$sq,$qb,$sh,$gQ,w,x) 
    223  
    224         return(ans) 
    225 End 
     263Function SmearedCyl_PolyLength(s) :FitFunc 
     264        Struct ResSmearAAOStruct &s 
     265 
     266//      the name of your unsmeared model (AAO) is the first argument 
     267        s.yW = Smear_Model_20(Cyl_PolyLength,s.coefW,s.xW,s.resW) 
     268 
     269        return(0) 
     270End 
     271         
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/Cylinder_PolyRadius.ipf

    r127 r128  
    2828        make/o/t parameters_cypr = {"scale","radius (A)","length (A)","polydispersity of Radius","SLD diff (A^-2)","incoh. bkg (cm^-1)"} 
    2929        Edit parameters_cypr,coef_cypr 
    30         ywave_cypr := Cyl_PolyRadius(coef_cypr,xwave_cypr) 
     30         
     31        Variable/G root:g_cypr 
     32        g_cypr := Cyl_PolyRadius(coef_cypr,ywave_cypr,xwave_cypr) 
    3133        Display ywave_cypr vs xwave_cypr 
    3234        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    3739 
    3840/////////////////////////////////////////////////////////// 
    39  
    40 Proc PlotSmearedCyl_PolyRadius()         
    41         //no input parameters necessary, it MUST use the experimental q-values 
    42         // from the experimental data read in from an AVE/QSIG data file 
    43          
    44         // if no gQvals wave, data must not have been loaded => abort 
    45         if(ResolutionWavesMissing()) 
     41// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     42Proc PlotSmearedCyl_PolyRadius(str)                                                              
     43        String str 
     44        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     45         
     46        // if any of the resolution waves are missing => abort 
     47        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    4648                Abort 
    4749        endif 
     50         
     51        SetDataFolder $("root:"+str) 
    4852         
    4953        // Setup parameter table for model function 
     
    5458        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    5559        // make extra copy of experimental q-values for easy plotting 
    56         Duplicate/O $gQvals smeared_cypr,smeared_qvals 
     60        Duplicate/O $(str+"_q") smeared_cypr,smeared_qvals 
    5761        SetScale d,0,0,"1/cm",smeared_cypr       
    58  
    59         smeared_cypr := SmearedCyl_PolyRadius(smear_coef_cypr,$gQvals) 
     62                                         
     63        Variable/G gs_cypr=0 
     64        gs_cypr := fSmearedCyl_PolyRadius(smear_coef_cypr,smeared_cypr,smeared_qvals)   //this wrapper fills the STRUCT 
     65         
    6066        Display smeared_cypr vs smeared_qvals 
    6167        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    6369        Label left "Intensity (cm\\S-1\\M)" 
    6470        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    65 End 
    66  
    67 Function Cyl_PolyRadius(w,x) :FitFunc 
     71         
     72        SetDataFolder root: 
     73End 
     74         
     75 
     76 
     77//AAO version, uses XOP if available 
     78// simply calls the original single point calculation with 
     79// a wave assignment (this will behave nicely if given point ranges) 
     80Function Cyl_PolyRadius(cw,yw,xw) : FitFunc 
     81        Wave cw,yw,xw 
     82         
     83#if exists("Cyl_PolyRadiusX") 
     84        yw = Cyl_PolyRadiusX(cw,xw) 
     85#else 
     86        yw = fCyl_PolyRadius(cw,xw) 
     87#endif 
     88        return(0) 
     89End 
     90 
     91Function fCyl_PolyRadius(w,x) :FitFunc 
    6892        Wave w 
    6993        Variable x 
     
    185209        kp[4] = 0               //bkg fixed at 0 
    186210         
    187         Pq = CylinderForm(kp,qw) 
    188 //      Pq = CylinderFormX(kp,qw)       //from the XOP 
     211#if exists("CylinderFormX") 
     212        Pq = CylinderFormX(kp,qw) 
     213#else 
     214        Pq = fCylinderForm(kp,qw) 
     215#endif 
    189216         
    190217        // undo the normalization that CylinderForm does 
     
    210237End 
    211238 
     239//wrapper to calculate the smeared model as an AAO-Struct 
     240// fills the struct and calls the ususal function with the STRUCT parameter 
     241// 
     242// used only for the dependency, not for fitting 
     243// 
     244Function fSmearedCyl_PolyRadius(coefW,yW,xW) 
     245        Wave coefW,yW,xW 
     246         
     247        String str = getWavesDataFolder(yW,0) 
     248        String DF="root:"+str+":" 
     249         
     250        WAVE resW = $(DF+str+"_res") 
     251         
     252        STRUCT ResSmearAAOStruct fs 
     253        WAVE fs.coefW = coefW    
     254        WAVE fs.yW = yW 
     255        WAVE fs.xW = xW 
     256        WAVE fs.resW = resW 
     257         
     258        Variable err 
     259        err = SmearedCyl_PolyRadius(fs) 
     260         
     261        return (0) 
     262End 
     263 
    212264// this is all there is to the smeared calculation! 
    213 Function SmearedCyl_PolyRadius(w,x) :FitFunc 
    214         Wave w 
    215         Variable x 
    216          
    217         Variable ans 
    218         SVAR sq = gSig_Q 
    219         SVAR qb = gQ_bar 
    220         SVAR sh = gShadow 
    221         SVAR gQ = gQVals 
    222          
    223         //the name of your unsmeared model is the first argument 
    224         ans = Smear_Model_20(Cyl_PolyRadius,$sq,$qb,$sh,$gQ,w,x) 
    225  
    226         return(ans) 
    227 End 
     265Function SmearedCyl_PolyRadius(s) :FitFunc 
     266        Struct ResSmearAAOStruct &s 
     267 
     268//      the name of your unsmeared model (AAO) is the first argument 
     269        s.yW = Smear_Model_20(Cyl_PolyRadius,s.coefW,s.xW,s.resW) 
     270 
     271        return(0) 
     272End 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/Debye.ipf

    r127 r128  
    1515        make/O/T parameters_deb = {"scale","Rg (A)","bkg (cm-1)"} 
    1616        Edit parameters_deb,coef_deb 
    17         ywave_deb := Debye(coef_deb,xwave_deb) 
     17         
     18        Variable/G root:g_deb 
     19        g_deb := Debye(coef_deb,ywave_deb,xwave_deb) 
    1820        Display ywave_deb vs xwave_deb 
    1921        ModifyGraph marker=29,msize=2,mode=4,log=1 
     
    2426 
    2527/////////////////////////////////////////////////////////// 
    26 Proc PlotSmearedDebye() 
    27         //no input parameters necessary, it MUST use the experimental q-values 
    28         // from the experimental data read in from an AVE/QSIG data file 
     28// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     29Proc PlotSmearedDebye(str)                                                               
     30        String str 
     31        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
    2932         
    30         // if no gQvals wave, data must not have been loaded => abort 
    31         if(ResolutionWavesMissing()) 
     33        // if any of the resolution waves are missing => abort 
     34        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    3235                Abort 
    3336        endif 
     37         
     38        SetDataFolder $("root:"+str) 
    3439         
    3540        // Setup parameter table for model function 
     
    3944         
    4045        // output smeared intensity wave 
    41         Duplicate/O $gQvals smeared_deb,smeared_qvals 
     46        Duplicate/O $(str+"_q") smeared_deb,smeared_qvals 
    4247        SetScale d,0,0,"1/cm",smeared_deb 
    43  
    44         smeared_deb := SmearedDebye(smear_coef_deb,$gQvals) 
     48                                         
     49        Variable/G gs_deb=0 
     50        gs_deb := fSmearedDebye(smear_coef_deb,smeared_deb,smeared_qvals)       //this wrapper fills the STRUCT 
     51         
    4552        Display smeared_deb vs smeared_qvals 
    4653        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    4855        Label left "Intensity (cm\\S-1\\M)" 
    4956        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
     57         
     58        SetDataFolder root: 
    5059End 
     60         
     61 
    5162/////////////////////////////////////////////////////////////// 
    5263 
    5364 
    54 Function Debye(w,x) : FitFunc 
     65//AAO version, uses XOP if available 
     66// simply calls the original single point calculation with 
     67// a wave assignment (this will behave nicely if given point ranges) 
     68Function Debye(cw,yw,xw) : FitFunc 
     69        Wave cw,yw,xw 
     70         
     71#if exists("DebyeX") 
     72        yw = DebyeX(cw,xw) 
     73#else 
     74        yw = fDebye(cw,xw) 
     75#endif 
     76        return(0) 
     77End 
     78 
     79Function fDebye(w,x) : FitFunc 
    5580        Wave w 
    5681        Variable x 
     
    78103End 
    79104 
     105//wrapper to calculate the smeared model as an AAO-Struct 
     106// fills the struct and calls the ususal function with the STRUCT parameter 
     107// 
     108// used only for the dependency, not for fitting 
     109// 
     110Function fSmearedDebye(coefW,yW,xW) 
     111        Wave coefW,yW,xW 
     112         
     113        String str = getWavesDataFolder(yW,0) 
     114        String DF="root:"+str+":" 
     115         
     116        WAVE resW = $(DF+str+"_res") 
     117         
     118        STRUCT ResSmearAAOStruct fs 
     119        WAVE fs.coefW = coefW    
     120        WAVE fs.yW = yW 
     121        WAVE fs.xW = xW 
     122        WAVE fs.resW = resW 
     123         
     124        Variable err 
     125        err = SmearedDebye(fs) 
     126         
     127        return (0) 
     128End 
     129 
    80130// this is all there is to the smeared calculation! 
    81 Function SmearedDebye(w,x) :FitFunc 
    82         Wave w 
    83         Variable x 
     131Function SmearedDebye(s) :FitFunc 
     132        Struct ResSmearAAOStruct &s 
     133 
     134//      the name of your unsmeared model (AAO) is the first argument 
     135        s.yW = Smear_Model_20(Debye,s.coefW,s.xW,s.resW) 
     136 
     137        return(0) 
     138End 
    84139         
    85         Variable ans 
    86         SVAR sq = gSig_Q 
    87         SVAR qb = gQ_bar 
    88         SVAR sh = gShadow 
    89         SVAR gQ = gQVals 
    90          
    91         //the name of your unsmeared model is the first argument 
    92         ans = Smear_Model_20(Debye,$sq,$qb,$sh,$gQ,w,x) 
    93  
    94         return(ans) 
    95 End 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/EllipticalCylinder.ipf

    r127 r128  
    3030        make/o/t parameters_ecf = {"scale","minor radius (A)","nu = major/minor (-)","length ()","SLD diff (A^-2)","incoh. bkg (cm^-1)"} 
    3131        Edit parameters_ecf,coef_ecf 
    32         ywave_ecf := EllipCylForm(coef_ecf,xwave_ecf) 
     32         
     33        Variable/G root:g_ecf 
     34        g_ecf := EllipCyl20(coef_ecf,ywave_ecf,xwave_ecf) 
    3335        Display ywave_ecf vs xwave_ecf 
    3436        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    3941/////////////////////////////////////////////////////////// 
    4042 
    41 Proc PlotSmearedEllipCylForm()   
    42         //no input parameters necessary, it MUST use the experimental q-values 
    43         // from the experimental data read in from an AVE/QSIG data file 
    44          
    45         // if no gQvals wave, data must not have been loaded => abort 
    46         if(ResolutionWavesMissing()) 
     43// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     44Proc PlotSmearedEllipCylForm(str)                                                                
     45        String str 
     46        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     47         
     48        // if any of the resolution waves are missing => abort 
     49        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    4750                Abort 
    4851        endif 
     52         
     53        SetDataFolder $("root:"+str) 
    4954         
    5055        // Setup parameter table for model function 
     
    5560        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    5661        // make extra copy of experimental q-values for easy plotting 
    57         Duplicate/O $gQvals smeared_ecf,smeared_qvals 
     62        Duplicate/O $(str+"_q") smeared_ecf,smeared_qvals 
    5863        SetScale d,0,0,"1/cm",smeared_ecf        
    59  
    60         smeared_ecf := SmearedEllipCylForm(smear_coef_ecf,$gQvals) 
     64                                         
     65        Variable/G gs_ecf=0 
     66        gs_ecf := fSmearedEllipCylForm(smear_coef_ecf,smeared_ecf,smeared_qvals)        //this wrapper fills the STRUCT 
     67         
    6168        Display smeared_ecf vs smeared_qvals 
    6269        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    6471        Label left "Intensity (cm\\S-1\\M)" 
    6572        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
     73         
     74        SetDataFolder root: 
     75End 
     76 
     77 
     78 
     79//AAO version, uses XOP if available 
     80// simply calls the original single point calculation with 
     81// a wave assignment (this will behave nicely if given point ranges) 
     82Function EllipCyl20(cw,yw,xw) : FitFunc 
     83        Wave cw,yw,xw 
     84         
     85#if exists("EllipCyl20X") 
     86        yw = EllipCyl20X(cw,xw) 
     87#else 
     88        yw = fEllipCyl20(cw,xw) 
     89#endif 
     90        return(0) 
    6691End 
    6792 
     
    7095// 20 points of quadrature seems to be sufficient for both integrals 
    7196// 
    72 Function EllipCylForm(w,x)      : FitFunc 
     97Function fEllipCyl20(w,x)       : FitFunc 
    7398        Wave w 
    7499        Variable x 
     
    139164End 
    140165 
     166//wrapper to calculate the smeared model as an AAO-Struct 
     167// fills the struct and calls the ususal function with the STRUCT parameter 
     168// 
     169// used only for the dependency, not for fitting 
     170// 
     171Function fSmearedEllipCylForm(coefW,yW,xW) 
     172        Wave coefW,yW,xW 
     173         
     174        String str = getWavesDataFolder(yW,0) 
     175        String DF="root:"+str+":" 
     176         
     177        WAVE resW = $(DF+str+"_res") 
     178         
     179        STRUCT ResSmearAAOStruct fs 
     180        WAVE fs.coefW = coefW    
     181        WAVE fs.yW = yW 
     182        WAVE fs.xW = xW 
     183        WAVE fs.resW = resW 
     184         
     185        Variable err 
     186        err = SmearedEllipCylForm(fs) 
     187         
     188        return (0) 
     189End 
     190 
    141191// this is all there is to the smeared calculation! 
    142 Function SmearedEllipCylForm(w,x) :FitFunc 
    143         Wave w 
    144         Variable x 
    145          
    146         Variable ans 
    147         SVAR sq = gSig_Q 
    148         SVAR qb = gQ_bar 
    149         SVAR sh = gShadow 
    150         SVAR gQ = gQVals 
    151          
    152         //the name of your unsmeared model is the first argument 
    153         ans = Smear_Model_20(EllipCylForm,$sq,$qb,$sh,$gQ,w,x) 
    154  
    155         return(ans) 
    156 End 
     192Function SmearedEllipCylForm(s) :FitFunc 
     193        Struct ResSmearAAOStruct &s 
     194 
     195//      the name of your unsmeared model (AAO) is the first argument 
     196        s.yW = Smear_Model_20(EllipCyl20,s.coefW,s.xW,s.resW) 
     197 
     198        return(0) 
     199End 
     200         
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/FlexCyl_EllipCross.ipf

    r127 r128  
    2727        make/o/t parameters_fleell = {"scale","Contour Length (A)","Kuhn Length, b (A)","Minor Radius (a) (A)","Axis Ratio = major/a","contrast (A^-2)","bkgd (arb)"} 
    2828        Edit parameters_fleell,coef_fleell 
    29         ywave_fleell := FlexCyl_Ellip(coef_fleell,xwave_fleell) 
     29         
     30        Variable/G root:g_fleell 
     31        g_fleell := FlexCyl_Ellip(coef_fleell,ywave_fleell,xwave_fleell) 
    3032        Display ywave_fleell vs xwave_fleell 
    3133        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    3537End 
    3638 
    37 //setup the smeared model calculation 
    38 // 
    39 Proc PlotSmeared_FlexCyl_Ellip()         
    40         // if no gQvals wave, data must not have been loaded => abort 
     39// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     40Proc PlotSmeared_FlexCyl_Ellip(str)                                                              
     41        String str 
     42        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
    4143         
    42         if(ResolutionWavesMissing()) 
     44        // if any of the resolution waves are missing => abort 
     45        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    4346                Abort 
    4447        endif 
     48         
     49        SetDataFolder $("root:"+str) 
    4550         
    4651        // Setup parameter table for model function 
     
    5156        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    5257        // make extra copy of experimental q-values for easy plotting 
    53         Duplicate/O $gQvals smeared_fleell,smeared_qvals                                // 
     58        Duplicate/O $(str+"_q") smeared_fleell,smeared_qvals                            // 
    5459        SetScale d,0,0,"1/cm",smeared_fleell                                                    // 
    55  
    56         smeared_fleell := SmearedFlexCyl_Ellip(smear_coef_fleell,$gQvals)               // SMEARED function name 
     60                                         
     61        Variable/G gs_fleell=0 
     62        gs_fleell := fSmearedFlexCyl_Ellip(smear_coef_fleell,smeared_fleell,smeared_qvals)      //this wrapper fills the STRUCT 
     63         
    5764        Display smeared_fleell vs smeared_qvals                                                                 // 
    5865        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    6067        Label left "I(q) (cm\\S-1\\M)" 
    6168        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    62 End     // end macro  
     69         
     70        SetDataFolder root: 
     71End 
     72         
    6373 
    6474 
     75 
     76//AAO version, uses XOP if available 
     77// simply calls the original single point calculation with 
     78// a wave assignment (this will behave nicely if given point ranges) 
     79Function FlexCyl_Ellip(cw,yw,xw) : FitFunc 
     80        Wave cw,yw,xw 
     81         
     82#if exists("FlexCyl_EllipX") 
     83        yw = FlexCyl_EllipX(cw,xw) 
     84#else 
     85        yw = fFlexCyl_Ellip(cw,xw) 
     86#endif 
     87        return(0) 
     88End 
     89 
    6590// 
    66 Function FlexCyl_Ellip(ww,x) :FitFunc 
     91Function fFlexCyl_Ellip(ww,x) :FitFunc 
    6792        Wave ww 
    6893        Variable x 
     
    124149End 
    125150 
    126 // this is all there is to the smeared calculation! 
    127 Function SmearedFlexCyl_Ellip(w,x) :FitFunc 
    128         Wave w 
    129         Variable x 
     151//wrapper to calculate the smeared model as an AAO-Struct 
     152// fills the struct and calls the ususal function with the STRUCT parameter 
     153// 
     154// used only for the dependency, not for fitting 
     155// 
     156Function fSmearedFlexCyl_Ellip(coefW,yW,xW) 
     157        Wave coefW,yW,xW 
    130158         
    131         Variable ans 
    132         SVAR sq = gSig_Q 
    133         SVAR qb = gQ_bar 
    134         SVAR sh = gShadow 
    135         SVAR gQ = gQVals 
     159        String str = getWavesDataFolder(yW,0) 
     160        String DF="root:"+str+":" 
    136161         
    137         //the name of your unsmeared model is the first argument 
    138         ans = Smear_Model_20(FlexCyl_Ellip,$sq,$qb,$sh,$gQ,w,x) 
    139  
    140         return(ans) 
     162        WAVE resW = $(DF+str+"_res") 
     163         
     164        STRUCT ResSmearAAOStruct fs 
     165        WAVE fs.coefW = coefW    
     166        WAVE fs.yW = yW 
     167        WAVE fs.xW = xW 
     168        WAVE fs.resW = resW 
     169         
     170        Variable err 
     171        err = SmearedFlexCyl_Ellip(fs) 
     172         
     173        return (0) 
    141174End 
    142175 
     176// this is all there is to the smeared calculation! 
     177Function SmearedFlexCyl_Ellip(s) :FitFunc 
     178        Struct ResSmearAAOStruct &s 
     179 
     180//      the name of your unsmeared model (AAO) is the first argument 
     181        s.yW = Smear_Model_20(FlexCyl_Ellip,s.coefW,s.xW,s.resW) 
     182 
     183        return(0) 
     184End 
     185 
     186 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/FlexCyl_PolyLen.ipf

    r127 r128  
    2020        make/o/t parameters_flepl =  {"scale","Contour Length (A)","polydispersity of Contour Length","Kuhn Length, b (A)","Radius (A)","contrast (A^-2)","bkgd (cm^-1)"} 
    2121        Edit parameters_flepl,coef_flepl 
    22         ywave_flepl := FlexCyl_PolyLen(coef_flepl,xwave_flepl) 
     22         
     23        Variable/G root:g_flepl 
     24        g_flepl := FlexCyl_PolyLen(coef_flepl,ywave_flepl,xwave_flepl) 
    2325        Display ywave_flepl vs xwave_flepl 
    2426        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    2830End 
    2931 
    30 Proc PlotSmeared_FlexCyl_PolyLen()                                                              //MyModel 
    31         // if no gQvals wave, data must not have been loaded => abort 
    32          
    33         if(ResolutionWavesMissing()) 
     32// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     33Proc PlotSmeared_FlexCyl_PolyLen(str)                                                            
     34        String str 
     35        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     36         
     37        // if any of the resolution waves are missing => abort 
     38        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    3439                Abort 
    3540        endif 
     41         
     42        SetDataFolder $("root:"+str) 
    3643         
    3744        // Setup parameter table for model function 
     
    4249        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    4350        // make extra copy of experimental q-values for easy plotting 
    44         Duplicate/O $gQvals smeared_flepl,smeared_qvals                         // 
     51        Duplicate/O $(str+"_q") smeared_flepl,smeared_qvals                             // 
    4552        SetScale d,0,0,"1/cm",smeared_flepl                                                     // 
    46  
    47         smeared_flepl := SmearedFlexCyl_PolyLen(smear_coef_flepl,$gQvals)               // SMEARED function name 
     53                                         
     54        Variable/G gs_flepl=0 
     55        gs_flepl := fSmearedFlexCyl_PolyLen(smear_coef_flepl,smeared_flepl,smeared_qvals)       //this wrapper fills the STRUCT 
     56         
    4857        Display smeared_flepl vs smeared_qvals                                                                  // 
    4958        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    5160        Label left "I(q) (cm\\S-1\\M)" 
    5261        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    53 End     // end macro  
     62         
     63        SetDataFolder root: 
     64End 
     65         
    5466 
    5567Function Schulz_Point_flepl(x,avg,zz) 
     
    6577End 
    6678 
    67 Function FlexCyl_PolyLen(w,x) : FitFunc 
     79 
     80//AAO version, uses XOP if available 
     81// simply calls the original single point calculation with 
     82// a wave assignment (this will behave nicely if given point ranges) 
     83Function FlexCyl_PolyLen(cw,yw,xw) : FitFunc 
     84        Wave cw,yw,xw 
     85         
     86#if exists("FlexCyl_PolyLenX") 
     87        yw = FlexCyl_PolyLenX(cw,xw) 
     88#else 
     89        yw = fFlexCyl_PolyLen(cw,xw) 
     90#endif 
     91        return(0) 
     92End 
     93 
     94Function fFlexCyl_PolyLen(w,x) : FitFunc 
    6895        Wave w 
    6996        Variable x 
     
    172199        kp[5] = 0               //bkg fixed at 0 
    173200         
    174         Pq = FlexExclVolCyl(kp,qw) 
     201#if exists("FlexExclVolCylX") 
     202        Pq = FlexExclVolCylX(kp,qw) 
     203#else 
     204        Pq = fFlexExclVolCyl(kp,qw) 
     205#endif 
     206         
    175207        vcyl=Pi*rad*rad*len_i 
    176208        Pq *= vcyl 
     
    182214End 
    183215 
     216//wrapper to calculate the smeared model as an AAO-Struct 
     217// fills the struct and calls the ususal function with the STRUCT parameter 
     218// 
     219// used only for the dependency, not for fitting 
     220// 
     221Function fSmearedFlexCyl_PolyLen(coefW,yW,xW) 
     222        Wave coefW,yW,xW 
     223         
     224        String str = getWavesDataFolder(yW,0) 
     225        String DF="root:"+str+":" 
     226         
     227        WAVE resW = $(DF+str+"_res") 
     228         
     229        STRUCT ResSmearAAOStruct fs 
     230        WAVE fs.coefW = coefW    
     231        WAVE fs.yW = yW 
     232        WAVE fs.xW = xW 
     233        WAVE fs.resW = resW 
     234         
     235        Variable err 
     236        err = SmearedFlexCyl_PolyLen(fs) 
     237         
     238        return (0) 
     239End 
     240 
    184241// this is all there is to the smeared calculation! 
    185 Function SmearedFlexCyl_PolyLen(w,x) :FitFunc 
    186         Wave w 
    187         Variable x 
    188          
    189         Variable ans 
    190         SVAR sq = gSig_Q 
    191         SVAR qb = gQ_bar 
    192         SVAR sh = gShadow 
    193         SVAR gQ = gQVals 
    194          
    195         //the name of your unsmeared model is the first argument 
    196         ans = Smear_Model_20(FlexCyl_PolyLen,$sq,$qb,$sh,$gQ,w,x) 
    197  
    198         return(ans) 
    199 End 
     242Function SmearedFlexCyl_PolyLen(s) :FitFunc 
     243        Struct ResSmearAAOStruct &s 
     244 
     245//      the name of your unsmeared model (AAO) is the first argument 
     246        s.yW = Smear_Model_20(FlexCyl_PolyLen,s.coefW,s.xW,s.resW) 
     247 
     248        return(0) 
     249End 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/FlexCyl_PolyRadius.ipf

    r127 r128  
    1818        make/o/t parameters_fcpr = {"scale","Contour Length (A)","Kuhn Length, b (A)","Radius (A)","polydispersity of radius","contrast (A^-2)","bkgd (cm^-1)"} 
    1919        Edit parameters_fcpr,coef_fcpr 
    20         ywave_fcpr := FlexCylPolyRad(coef_fcpr,xwave_fcpr) 
     20         
     21        Variable/G root:g_fcpr 
     22        g_fcpr := FlexCyl_PolyRad(coef_fcpr,ywave_fcpr,xwave_fcpr) 
    2123        Display ywave_fcpr vs xwave_fcpr 
    2224        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    2628End 
    2729 
    28  
    29 Proc PlotSmearedFlexCyl_PolyRad()                                                                
    30         //no input parameters necessary, it MUST use the experimental q-values 
    31         // from the experimental data read in from an AVE/QSIG data file 
    32          
    33         // if no gQvals wave, data must not have been loaded => abort 
    34         if(ResolutionWavesMissing()) 
     30// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     31Proc PlotSmearedFlexCyl_PolyRad(str)                                                             
     32        String str 
     33        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     34         
     35        // if any of the resolution waves are missing => abort 
     36        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    3537                Abort 
    3638        endif 
     39         
     40        SetDataFolder $("root:"+str) 
    3741         
    3842        // Setup parameter table for model function 
     
    4347        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    4448        // make extra copy of experimental q-values for easy plotting 
    45         Duplicate/O $gQvals smeared_fcpr,smeared_qvals                           
     49        Duplicate/O $(str+"_q") smeared_fcpr,smeared_qvals                               
    4650        SetScale d,0,0,"1/cm",smeared_fcpr                                                       
    47  
    48         smeared_fcpr := SmearedFlexCyl_PolyRad(smear_coef_fcpr,$gQvals)          
     51                                         
     52        Variable/G gs_fcpr=0 
     53        gs_fcpr := fSmearedFlexCyl_PolyRad(smear_coef_fcpr,smeared_fcpr,smeared_qvals)  //this wrapper fills the STRUCT 
     54         
    4955        Display smeared_fcpr vs smeared_qvals                                                                    
    5056        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    5258        Label left "Intensity (cm\\S-1\\M)" 
    5359        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
     60         
     61        SetDataFolder root: 
     62End 
     63 
     64 
     65 
     66//AAO version, uses XOP if available 
     67// simply calls the original single point calculation with 
     68// a wave assignment (this will behave nicely if given point ranges) 
     69Function FlexCyl_PolyRad(cw,yw,xw) : FitFunc 
     70        Wave cw,yw,xw 
     71         
     72#if exists("FlexCyl_PolyRadX") 
     73        yw = FlexCyl_PolyRadX(cw,xw) 
     74#else 
     75        yw = fFlexCyl_PolyRad(cw,xw) 
     76#endif 
     77        return(0) 
    5478End 
    5579 
     
    5781// to account for the polydispersity of the radius. 
    5882// 
    59 Function FlexCylPolyRad(w,x)  : FitFunc 
     83Function fFlexCyl_PolyRad(w,x)  : FitFunc 
    6084        Wave w 
    6185        Variable x 
     
    180204        kp[5] = 0               //bkg fixed at 0 
    181205         
    182         //Pq = CylinderForm(kp,qw) 
    183         Pq = FlexExclVolCyl(kp,qw)      //from the XOP 
     206#if exists("FlexExclVolCylX") 
     207        Pq = FlexExclVolCylX(kp,qw) 
     208#else 
     209        Pq = fFlexExclVolCyl(kp,qw) 
     210#endif 
    184211         
    185212        // undo the normalization that the form factor does 
     
    205232End 
    206233 
     234//wrapper to calculate the smeared model as an AAO-Struct 
     235// fills the struct and calls the ususal function with the STRUCT parameter 
     236// 
     237// used only for the dependency, not for fitting 
     238// 
     239Function fSmearedFlexCyl_PolyRad(coefW,yW,xW) 
     240        Wave coefW,yW,xW 
     241         
     242        String str = getWavesDataFolder(yW,0) 
     243        String DF="root:"+str+":" 
     244         
     245        WAVE resW = $(DF+str+"_res") 
     246         
     247        STRUCT ResSmearAAOStruct fs 
     248        WAVE fs.coefW = coefW    
     249        WAVE fs.yW = yW 
     250        WAVE fs.xW = xW 
     251        WAVE fs.resW = resW 
     252         
     253        Variable err 
     254        err = SmearedFlexCyl_PolyRad(fs) 
     255         
     256        return (0) 
     257End 
     258 
    207259// this is all there is to the smeared calculation! 
    208 Function SmearedFlexCyl_PolyRad(w,x) :FitFunc 
    209         Wave w 
    210         Variable x 
    211          
    212         Variable ans 
    213         SVAR sq = gSig_Q 
    214         SVAR qb = gQ_bar 
    215         SVAR sh = gShadow 
    216         SVAR gQ = gQVals 
    217          
    218         //the name of your unsmeared model is the first argument 
    219         ans = Smear_Model_20(FlexCylPolyRad,$sq,$qb,$sh,$gQ,w,x) 
    220  
    221         return(ans) 
    222 End 
     260Function SmearedFlexCyl_PolyRad(s) :FitFunc 
     261        Struct ResSmearAAOStruct &s 
     262 
     263//      the name of your unsmeared model (AAO) is the first argument 
     264        s.yW = Smear_Model_20(FlexCyl_PolyRad,s.coefW,s.xW,s.resW) 
     265 
     266        return(0) 
     267End 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/FlexibleCylinder.ipf

    r127 r128  
    3030        make/o/t parameters_fle = {"scale","Contour Length (A)","Kuhn Length, b (A)","Radius (A)","contrast (A^-2)","bkgd (cm^-1)"} 
    3131        Edit parameters_fle,coef_fle 
    32         ywave_fle := FlexExclVolCyl(coef_fle,xwave_fle) 
     32         
     33        Variable/G root:g_fle 
     34        g_fle := FlexExclVolCyl(coef_fle,ywave_fle,xwave_fle) 
    3335        Display ywave_fle vs xwave_fle 
    3436        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    3941/////////////////////////////////////////////////////////// 
    4042 
    41 Proc PlotSmearedFlexExclVolCyl()                                                                 
    42         //no input parameters necessary, it MUST use the experimental q-values 
    43         // from the experimental data read in from an AVE/QSIG data file 
    44          
    45         // if no gQvals wave, data must not have been loaded => abort 
    46         if(ResolutionWavesMissing()) 
     43// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     44Proc PlotSmearedFlexExclVolCyl(str)                                                              
     45        String str 
     46        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     47         
     48        // if any of the resolution waves are missing => abort 
     49        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    4750                Abort 
    4851        endif 
     52         
     53        SetDataFolder $("root:"+str) 
    4954         
    5055        // Setup parameter table for model function 
     
    5560        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    5661        // make extra copy of experimental q-values for easy plotting 
    57         Duplicate/O $gQvals smeared_fle,smeared_qvals                            
     62        Duplicate/O $(str+"_q") smeared_fle,smeared_qvals                                
    5863        SetScale d,0,0,"1/cm",smeared_fle                                                        
    59  
    60         smeared_fle := SmearedFlexExclVolCyl(smear_coef_fle,$gQvals)             
     64                                         
     65        Variable/G gs_fle=0 
     66        gs_fle := fSmearedFlexExclVolCyl(smear_coef_fle,smeared_fle,smeared_qvals)      //this wrapper fills the STRUCT 
     67         
    6168        Display smeared_fle vs smeared_qvals                                                                     
    6269        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    6471        Label left "Intensity (cm\\S-1\\M)" 
    6572        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
     73         
     74        SetDataFolder root: 
    6675End 
    67  
    68 // 
    69 Function FlexExclVolCyl(ww,x) 
     76         
     77 
     78//AAO version, uses XOP if available 
     79// simply calls the original single point calculation with 
     80// a wave assignment (this will behave nicely if given point ranges) 
     81Function FlexExclVolCyl(cw,yw,xw) : FitFunc 
     82        Wave cw,yw,xw 
     83         
     84#if exists("FlexExclVolCylX") 
     85        yw = FlexExclVolCylX(cw,xw) 
     86#else 
     87        yw = fFlexExclVolCyl(cw,xw) 
     88#endif 
     89        return(0) 
     90End 
     91 
     92// 
     93Function fFlexExclVolCyl(ww,x) 
    7094        Wave ww 
    7195        Variable x 
     
    468492////////////////// 
    469493 
     494//wrapper to calculate the smeared model as an AAO-Struct 
     495// fills the struct and calls the ususal function with the STRUCT parameter 
     496// 
     497// used only for the dependency, not for fitting 
     498// 
     499Function fSmearedFlexExclVolCyl(coefW,yW,xW) 
     500        Wave coefW,yW,xW 
     501         
     502        String str = getWavesDataFolder(yW,0) 
     503        String DF="root:"+str+":" 
     504         
     505        WAVE resW = $(DF+str+"_res") 
     506         
     507        STRUCT ResSmearAAOStruct fs 
     508        WAVE fs.coefW = coefW    
     509        WAVE fs.yW = yW 
     510        WAVE fs.xW = xW 
     511        WAVE fs.resW = resW 
     512         
     513        Variable err 
     514        err = SmearedFlexExclVolCyl(fs) 
     515         
     516        return (0) 
     517End 
     518 
    470519// this is all there is to the smeared calculation! 
    471 Function SmearedFlexExclVolCyl(w,x) :FitFunc 
    472         Wave w 
    473         Variable x 
    474          
    475         Variable ans 
    476         SVAR sq = gSig_Q 
    477         SVAR qb = gQ_bar 
    478         SVAR sh = gShadow 
    479         SVAR gQ = gQVals 
    480          
    481         //the name of your unsmeared model is the first argument 
    482         ans = Smear_Model_20(FlexExclVolCyl,$sq,$qb,$sh,$gQ,w,x) 
    483  
    484         return(ans) 
     520Function SmearedFlexExclVolCyl(s) :FitFunc 
     521        Struct ResSmearAAOStruct &s 
     522 
     523//      the name of your unsmeared model (AAO) is the first argument 
     524        s.yW = Smear_Model_20(FlexExclVolCyl,s.coefW,s.xW,s.resW) 
     525 
     526        return(0) 
    485527End 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/Fractal.ipf

    r127 r128  
    2020        Make/O/D coef_fra = {0.05,5,2,100,2e-6,6.35e-6,0}                                                
    2121        make/o/t parameters_fra = {"Volume Fraction (scale)","Block Radius (A)","fractal dimension","correlation length (A)","SLD block (A-2)","SLD solvent (A-2)","bkgd (cm^-1 sr^-1)"}                 
    22         Edit parameters_fra,coef_fra                                                             
    23         ywave_fra := Fractal(coef_fra,xwave_fra)                         
     22        Edit parameters_fra,coef_fra             
     23         
     24        Variable/G root:g_fra 
     25        g_fra := Fractal(coef_fra,ywave_fra,xwave_fra)                   
    2426        Display ywave_fra vs xwave_fra                                                   
    2527        ModifyGraph log=1,marker=29,msize=2,mode=4                       
     
    2931End 
    3032 
    31 Proc PlotSmearedFractal() 
     33// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     34Proc PlotSmearedFractal(str)                                                             
     35        String str 
     36        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
    3237         
    33         // if no gQvals wave, data must not have been loaded => abort 
    34         If(ResolutionWavesMissing())            //part of GaussUtils 
     38        // if any of the resolution waves are missing => abort 
     39        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    3540                Abort 
    3641        endif 
     42         
     43        SetDataFolder $("root:"+str) 
    3744         
    3845        // Setup parameter table for model function 
     
    4350        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    4451        // make extra copy of experimental q-values for easy plotting 
    45         Duplicate/O $gQvals smeared_fractal,smeared_qvals                               // 
     52        Duplicate/O $(str+"_q") smeared_fractal,smeared_qvals                           // 
    4653        SetScale d,0,0,"1/cm",smeared_fractal                                                   // 
    47  
    48         smeared_fractal := SmearedFractal(smear_coef_fractal,$gQvals) 
     54                                         
     55        Variable/G gs_fractal=0 
     56        gs_fractal := fSmearedFractal(smear_coef_fractal,smeared_fractal,smeared_qvals) //this wrapper fills the STRUCT 
     57         
    4958        Display smeared_fractal vs smeared_qvals                 
    5059        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    5261        Label left "I(q) (cm\\S-1\\M)" 
    5362        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    54 End     // end macro  
     63         
     64        SetDataFolder root: 
     65End 
     66 
     67 
    5568 
    5669//calculates the physical parameters related to the  
     
    8699End 
    87100 
     101//AAO version, uses XOP if available 
     102// simply calls the original single point calculation with 
     103// a wave assignment (this will behave nicely if given point ranges) 
     104Function Fractal(cw,yw,xw) : FitFunc 
     105        Wave cw,yw,xw 
     106         
     107#if exists("FractalX") 
     108        yw = FractalX(cw,xw) 
     109#else 
     110        yw = fFractal(cw,xw) 
     111#endif 
     112        return(0) 
     113End 
     114 
    88115//fractal scattering function 
    89 Function Fractal(w,x) :FitFunc 
     116Function fFractal(w,x) :FitFunc 
    90117        wave w 
    91118        variable x 
     
    114141End 
    115142 
     143//wrapper to calculate the smeared model as an AAO-Struct 
     144// fills the struct and calls the ususal function with the STRUCT parameter 
     145// 
     146// used only for the dependency, not for fitting 
     147// 
     148Function fSmearedFractal(coefW,yW,xW) 
     149        Wave coefW,yW,xW 
     150         
     151        String str = getWavesDataFolder(yW,0) 
     152        String DF="root:"+str+":" 
     153         
     154        WAVE resW = $(DF+str+"_res") 
     155         
     156        STRUCT ResSmearAAOStruct fs 
     157        WAVE fs.coefW = coefW    
     158        WAVE fs.yW = yW 
     159        WAVE fs.xW = xW 
     160        WAVE fs.resW = resW 
     161         
     162        Variable err 
     163        err = SmearedFractal(fs) 
     164         
     165        return (0) 
     166End 
     167 
    116168//the smeared model calculation 
    117 Function SmearedFractal(w,x) :FitFunc 
    118         Wave w 
    119         Variable x 
    120          
    121         Variable ans 
    122         SVAR sq = gSig_Q 
    123         SVAR qb = gQ_bar 
    124         SVAR sh = gShadow 
    125         SVAR gQ = gQVals 
    126          
    127         ans = Smear_Model_20(Fractal,$sq,$qb,$sh,$gQ,w,x)        
     169Function SmearedFractal(s) :FitFunc 
     170        Struct ResSmearAAOStruct &s 
    128171 
    129         return(ans) 
     172//      the name of your unsmeared model (AAO) is the first argument 
     173        s.yW = Smear_Model_20(Fractal,s.coefW,s.xW,s.resW) 
     174 
     175        return(0) 
    130176End 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/GaussSpheres.ipf

    r127 r128  
    2222        make/O/T parameters_pgs = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","bkg (cm-1 sr-1)"} 
    2323        Edit parameters_pgs,coef_pgs 
    24         ywave_pgs := GaussPolySphere(coef_pgs,xwave_pgs) 
     24         
     25        Variable/G root:g_pgs 
     26        g_pgs := GaussPolySphere(coef_pgs,ywave_pgs,xwave_pgs) 
    2527        Display ywave_pgs vs xwave_pgs 
    2628        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    3032End 
    3133 
    32 Proc PlotSmearedGaussPolySpheres()                                                               
    33         //no input parameters necessary, it MUST use the experimental q-values 
    34         // from the experimental data read in from an AVE/QSIG data file 
    35          
    36         // if no gQvals wave, data must not have been loaded => abort 
    37         if(ResolutionWavesMissing()) 
     34// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     35Proc PlotSmearedGaussPolySpheres(str)                                                            
     36        String str 
     37        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     38         
     39        // if any of the resolution waves are missing => abort 
     40        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    3841                Abort 
    3942        endif 
     43         
     44        SetDataFolder $("root:"+str) 
    4045         
    4146        // Setup parameter table for model function 
     
    4651        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    4752        // make extra copy of experimental q-values for easy plotting 
    48         Duplicate/O $gQvals smeared_pgs,smeared_qvals                            
     53        Duplicate/O $(str+"_q") smeared_pgs,smeared_qvals                                
    4954        SetScale d,0,0,"1/cm",smeared_pgs                                                        
    50  
    51         smeared_pgs := SmearedGaussPolySphere(smear_coef_pgs,$gQvals)            
     55                                         
     56        Variable/G gs_pgs=0 
     57        gs_pgs := fSmearedGaussPolySphere(smear_coef_pgs,smeared_pgs,smeared_qvals)     //this wrapper fills the STRUCT 
     58         
    5259        Display smeared_pgs vs smeared_qvals                                                                     
    5360        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    5562        Label left "Intensity (cm\\S-1\\M)" 
    5663        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    57 End 
    58  
    59  
    60 Function GaussPolySphere(w,x) : FitFunc 
     64         
     65        SetDataFolder root: 
     66End 
     67         
     68 
     69 
     70 
     71//AAO version, uses XOP if available 
     72// simply calls the original single point calculation with 
     73// a wave assignment (this will behave nicely if given point ranges) 
     74Function GaussPolySphere(cw,yw,xw) : FitFunc 
     75        Wave cw,yw,xw 
     76         
     77#if exists("GaussPolySphereX") 
     78        yw = GaussPolySphereX(cw,xw) 
     79#else 
     80        yw = fGaussPolySphere(cw,xw) 
     81#endif 
     82        return(0) 
     83End 
     84 
     85Function fGaussPolySphere(w,x) : FitFunc 
    6186        wave w 
    6287        variable x 
     
    122147         
    123148        summ = 0.0              // initialize integral 
     149        Make/O/N=1 tmp_w 
    124150        for(ii=0;ii<nord;ii+=1) 
    125151                // calculate Gauss points on integration interval (r-value for evaluation) 
     
    127153                sphere_temp[1] = zi 
    128154                // calculate sphere scattering 
    129                 yy = gauWt[ii] *  Gauss_distr(sig,rad,zi) * SphereForm(sphere_temp,x) 
     155                SphereForm(sphere_temp,tmp_w,x)         // AAO calculation, one point 
     156                yy = gauWt[ii] *  Gauss_distr(sig,rad,zi) * tmp_w[0] 
    130157                yy *= 4*pi/3*zi*zi*zi           //un-normalize by current sphere volume 
    131158                 
     
    144171End 
    145172 
     173//wrapper to calculate the smeared model as an AAO-Struct 
     174// fills the struct and calls the ususal function with the STRUCT parameter 
     175// 
     176// used only for the dependency, not for fitting 
     177// 
     178Function fSmearedGaussPolySphere(coefW,yW,xW) 
     179        Wave coefW,yW,xW 
     180         
     181        String str = getWavesDataFolder(yW,0) 
     182        String DF="root:"+str+":" 
     183         
     184        WAVE resW = $(DF+str+"_res") 
     185         
     186        STRUCT ResSmearAAOStruct fs 
     187        WAVE fs.coefW = coefW    
     188        WAVE fs.yW = yW 
     189        WAVE fs.xW = xW 
     190        WAVE fs.resW = resW 
     191         
     192        Variable err 
     193        err = SmearedGaussPolySphere(fs) 
     194         
     195        return (0) 
     196End 
     197 
    146198// this is all there is to the smeared calculation! 
    147 Function SmearedGaussPolySphere(w,x) :FitFunc 
    148         Wave w 
    149         Variable x 
    150          
    151         Variable ans 
    152         SVAR sq = gSig_Q 
    153         SVAR qb = gQ_bar 
    154         SVAR sh = gShadow 
    155         SVAR gQ = gQVals 
    156          
    157         //the name of your unsmeared model is the first argument 
    158         ans = Smear_Model_20(GaussPolySphere,$sq,$qb,$sh,$gQ,w,x) 
    159  
    160         return(ans) 
    161 End 
     199Function SmearedGaussPolySphere(s) :FitFunc 
     200        Struct ResSmearAAOStruct &s 
     201 
     202//      the name of your unsmeared model (AAO) is the first argument 
     203        s.yW = Smear_Model_20(GaussPolySphere,s.coefW,s.xW,s.resW) 
     204 
     205        return(0) 
     206End 
     207 
    162208 
    163209 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/GaussSpheres_and_Struct.ipf

    r127 r128  
    2323        make/O/T parameters_pgs_HS = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","bkg (cm-1 sr-1)"} 
    2424        Edit parameters_pgs_HS,coef_pgs_HS 
    25         ywave_pgs_HS := GaussPolySphere_HS(coef_pgs_HS,xwave_pgs_HS) 
     25         
     26        Variable/G root:g_pgs_HS 
     27        g_pgs_HS := GaussPolySphere_HS(coef_pgs_HS,ywave_pgs_HS,xwave_pgs_HS) 
    2628        Display ywave_pgs_HS vs xwave_pgs_HS 
    2729        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    3133End 
    3234 
    33 Proc PlotSmearedGaussPolySphere_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()) 
     35// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     36Proc PlotSmearedGaussPolySphere_HS(str)                                                          
     37        String str 
     38        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     39         
     40        // if any of the resolution waves are missing => abort 
     41        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    3942                Abort 
    4043        endif 
     44         
     45        SetDataFolder $("root:"+str) 
    4146         
    4247        // Setup parameter table for model function 
     
    4752        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    4853        // make extra copy of experimental q-values for easy plotting 
    49         Duplicate/O $gQvals smeared_pgs_HS,smeared_qvals                                 
     54        Duplicate/O $(str+"_q") smeared_pgs_HS,smeared_qvals                             
    5055        SetScale d,0,0,"1/cm",smeared_pgs_HS                                                     
    51  
    52         smeared_pgs_HS := SmearedGaussPolySphere_HS(smear_coef_pgs_HS,$gQvals)           
     56                                         
     57        Variable/G gs_pgs_HS=0 
     58        gs_pgs_HS := fSmearedGaussPolySphere_HS(smear_coef_pgs_HS,smeared_pgs_HS,smeared_qvals) //this wrapper fills the STRUCT 
     59         
    5360        Display smeared_pgs_HS vs smeared_qvals                                                                  
    5461        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    5663        Label left "Intensity (cm\\S-1\\M)" 
    5764        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    58 End 
    59  
    60 Function GaussPolySphere_HS(w,x) : FitFunc 
    61         Wave w 
    62         Variable x 
     65         
     66        SetDataFolder root: 
     67End 
     68 
     69 
     70 
     71Function GaussPolySphere_HS(w,yw,xw) : FitFunc 
     72        Wave w,yw,xw 
    6373         
    6474        Variable inten 
     
    8898         
    8999        //calculate each and combine 
    90         inten = GaussPolySphere(form_pgs_HS,x) 
    91         inten *= HardSphereStruct(struct_pgs_HS,x) 
    92         inten *= w[0] 
    93         inten += w[5] 
     100        Duplicate/O xw tmp_pgs_HS_PQ,tmp_pgs_HS_SQ 
     101        GaussPolySphere(form_pgs_HS,tmp_pgs_HS_PQ,xw) 
     102        HardSphereStruct(struct_pgs_HS,tmp_pgs_HS_SQ,xw) 
     103        yw = tmp_pgs_HS_PQ * tmp_pgs_HS_SQ 
     104        yw *= w[0] 
     105        yw += w[5] 
    94106         
    95107        //cleanup waves 
    96108//      Killwaves/Z form_pgs_HS,struct_pgs_HS 
    97109         
    98         return (inten) 
     110        return (0) 
    99111End 
    100112 
     
    111123        make/O/T parameters_pgs_SW = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","well depth (kT)","well width (diam.)","bkg (cm-1 sr-1)"} 
    112124        Edit parameters_pgs_SW,coef_pgs_SW 
    113         ywave_pgs_SW := GaussPolySphere_SW(coef_pgs_SW,xwave_pgs_SW) 
     125         
     126        Variable/G root:g_pgs_SW 
     127        g_pgs_SW := GaussPolySphere_SW(coef_pgs_SW,ywave_pgs_SW,xwave_pgs_SW) 
    114128        Display ywave_pgs_SW vs xwave_pgs_SW 
    115129        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    119133End 
    120134 
    121 Proc PlotSmearedGaussPolySphere_SW()                                                             
    122         //no input parameters necessary, it MUST use the experimental q-values 
    123         // from the experimental data read in from an AVE/QSIG data file 
    124          
    125         // if no gQvals wave, data must not have been loaded => abort 
    126         if(ResolutionWavesMissing()) 
     135// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     136Proc PlotSmearedGaussPolySphere_SW(str)                                                          
     137        String str 
     138        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     139         
     140        // if any of the resolution waves are missing => abort 
     141        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    127142                Abort 
    128143        endif 
     144         
     145        SetDataFolder $("root:"+str) 
    129146         
    130147        // Setup parameter table for model function 
     
    135152        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    136153        // make extra copy of experimental q-values for easy plotting 
    137         Duplicate/O $gQvals smeared_pgs_SW,smeared_qvals                                 
     154        Duplicate/O $(str+"_q") smeared_pgs_SW,smeared_qvals                             
    138155        SetScale d,0,0,"1/cm",smeared_pgs_SW                                                     
    139  
    140         smeared_pgs_SW := SmearedGaussPolySphere_SW(smear_coef_pgs_SW,$gQvals)           
     156                                         
     157        Variable/G gs_pgs_SW=0 
     158        gs_pgs_SW := fSmearedGaussPolySphere_SW(smear_coef_pgs_SW,smeared_pgs_SW,smeared_qvals) //this wrapper fills the STRUCT 
     159         
    141160        Display smeared_pgs_SW vs smeared_qvals                                                                  
    142161        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    144163        Label left "Intensity (cm\\S-1\\M)" 
    145164        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    146 End 
    147  
    148 Function GaussPolySphere_SW(w,x) : FitFunc 
    149         Wave w 
    150         Variable x 
     165         
     166        SetDataFolder root: 
     167End 
     168         
     169 
     170Function GaussPolySphere_SW(w,yw,xw) : FitFunc 
     171        Wave w,yw,xw 
    151172         
    152173        Variable inten 
     
    177198         
    178199        //calculate each and combine 
    179         inten = GaussPolySphere(form_pgs_SW,x) 
    180         inten *= SquareWellStruct(struct_pgs_SW,x) 
    181         inten *= w[0] 
    182         inten += w[7] 
     200        Duplicate/O xw tmp_pgs_SW_PQ,tmp_pgs_SW_SQ 
     201        GaussPolySphere(form_pgs_SW,tmp_pgs_SW_PQ,xw) 
     202        SquareWellStruct(struct_pgs_SW,tmp_pgs_SW_SQ,xw) 
     203        yw = tmp_pgs_SW_PQ * tmp_pgs_SW_SQ 
     204        yw *= w[0] 
     205        yw += w[7] 
    183206         
    184207        //cleanup waves 
    185208//      Killwaves/Z form_pgs_SW,struct_pgs_SW 
    186209         
    187         return (inten) 
     210        return (0) 
    188211End 
    189212 
     
    208231        make/O/T parameters_pgs_SC = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","charge","movalent salt(M)","Temperature (K)","dielectric const","bkg (cm-1 sr-1)"} 
    209232        Edit parameters_pgs_SC,coef_pgs_SC 
    210         ywave_pgs_SC := GaussPolySphere_SC(coef_pgs_SC,xwave_pgs_SC) 
     233         
     234        Variable/G root:g_pgs_SC 
     235        g_pgs_SC := GaussPolySphere_SC(coef_pgs_SC,ywave_pgs_SC,xwave_pgs_SC) 
    211236        Display ywave_pgs_SC vs xwave_pgs_SC 
    212237        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    216241End 
    217242 
    218 Proc PlotSmearedGaussPolySphere_SC()                                                             
    219         //no input parameters necessary, it MUST use the experimental q-values 
    220         // from the experimental data read in from an AVE/QSIG data file 
    221          
    222         // if no gQvals wave, data must not have been loaded => abort 
    223         if(ResolutionWavesMissing()) 
     243// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     244Proc PlotSmearedGaussPolySphere_SC(str)                                                          
     245        String str 
     246        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     247         
     248        // if any of the resolution waves are missing => abort 
     249        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    224250                Abort 
    225251        endif 
    226  
     252         
     253        SetDataFolder $("root:"+str) 
     254         
    227255        if (DataFolderExists("root:HayPenMSA")) 
    228256                Make/O/D/N=17 root:HayPenMSA:gMSAWave 
     
    239267        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    240268        // make extra copy of experimental q-values for easy plotting 
    241         Duplicate/O $gQvals smeared_pgs_SC,smeared_qvals                                 
     269        Duplicate/O $(str+"_q") smeared_pgs_SC,smeared_qvals                             
    242270        SetScale d,0,0,"1/cm",smeared_pgs_SC                                                     
    243  
    244         smeared_pgs_SC := SmearedGaussPolySphere_SC(smear_coef_pgs_SC,$gQvals)           
     271                                         
     272        Variable/G gs_pgs_SC=0 
     273        gs_pgs_SC := fSmearedGaussPolySphere_SC(smear_coef_pgs_SC,smeared_pgs_SC,smeared_qvals) //this wrapper fills the STRUCT 
     274         
    245275        Display smeared_pgs_SC vs smeared_qvals                                                                  
    246276        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    248278        Label left "Intensity (cm\\S-1\\M)" 
    249279        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    250 End 
    251  
    252 Function GaussPolySphere_SC(w,x) : FitFunc 
    253         Wave w 
    254         Variable x 
     280         
     281        SetDataFolder root: 
     282End 
     283 
     284 
     285Function GaussPolySphere_SC(w,yw,xw) : FitFunc 
     286        Wave w,yw,xw 
    255287         
    256288        Variable inten 
     
    283315         
    284316        //calculate each and combine 
    285         inten = GaussPolySphere(form_pgs_SC,x) 
    286         inten *= HayterPenfoldMSA(struct_pgs_SC,x) 
    287         inten *= w[0] 
    288         inten += w[9] 
     317        Duplicate/O xw tmp_pgs_SC_PQ,tmp_pgs_SC_SQ 
     318        GaussPolySphere(form_pgs_SC,tmp_pgs_SC_PQ,xw) 
     319        HayterPenfoldMSA(struct_pgs_SC,tmp_pgs_SC_SQ,xw) 
     320        yw = tmp_pgs_SC_PQ * tmp_pgs_SC_SQ 
     321        yw *= w[0] 
     322        yw += w[9] 
    289323         
    290324        //cleanup waves 
    291325//      Killwaves/Z form_pgs_SC,struct_pgs_SC 
    292326         
    293         return (inten) 
     327        return (0) 
    294328End 
    295329 
     
    306340        make/O/T parameters_pgs_SHS = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","perturbation parameter (0.1)","stickiness, tau","bkg (cm-1 sr-1)"} 
    307341        Edit parameters_pgs_SHS,coef_pgs_SHS 
    308         ywave_pgs_SHS := GaussPolySphere_SHS(coef_pgs_SHS,xwave_pgs_SHS) 
     342         
     343        Variable/G root:g_pgs_SHS 
     344        g_pgs_SHS := GaussPolySphere_SHS(coef_pgs_SHS,ywave_pgs_SHS,xwave_pgs_SHS) 
    309345        Display ywave_pgs_SHS vs xwave_pgs_SHS 
    310346        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    314350End 
    315351 
    316 Proc PlotSmearedGaussPolySphere_SHS()                                                            
    317         //no input parameters necessary, it MUST use the experimental q-values 
    318         // from the experimental data read in from an AVE/QSIG data file 
    319          
    320         // if no gQvals wave, data must not have been loaded => abort 
    321         if(ResolutionWavesMissing()) 
     352// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     353Proc PlotSmearedGaussPolySphere_SHS(str)                                                                 
     354        String str 
     355        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     356         
     357        // if any of the resolution waves are missing => abort 
     358        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    322359                Abort 
    323360        endif 
     361         
     362        SetDataFolder $("root:"+str) 
    324363         
    325364        // Setup parameter table for model function 
     
    330369        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    331370        // make extra copy of experimental q-values for easy plotting 
    332         Duplicate/O $gQvals smeared_pgs_SHS,smeared_qvals                                
     371        Duplicate/O $(str+"_q") smeared_pgs_SHS,smeared_qvals                            
    333372        SetScale d,0,0,"1/cm",smeared_pgs_SHS                                                    
    334  
    335         smeared_pgs_SHS := SmearedGaussPolySphere_SHS(smear_coef_pgs_SHS,$gQvals)                
     373                                         
     374        Variable/G gs_pgs_SHS=0 
     375        gs_pgs_SHS := fSmearedGaussPolySphere_SHS(smear_coef_pgs_SHS,smeared_pgs_SHS,smeared_qvals)     //this wrapper fills the STRUCT 
     376         
    336377        Display smeared_pgs_SHS vs smeared_qvals                                                                         
    337378        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    339380        Label left "Intensity (cm\\S-1\\M)" 
    340381        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    341 End 
    342  
    343 Function GaussPolySphere_SHS(w,x) : FitFunc 
    344         Wave w 
    345         Variable x 
     382         
     383        SetDataFolder root: 
     384End 
     385         
     386 
     387Function GaussPolySphere_SHS(w,yw,xw) : FitFunc 
     388        Wave w,yw,xw 
    346389         
    347390        Variable inten 
     
    372415         
    373416        //calculate each and combine 
    374         inten = GaussPolySphere(form_pgs_SHS,x) 
    375         inten *= StickyHS_Struct(struct_pgs_SHS,x) 
    376         inten *= w[0] 
    377         inten += w[7] 
     417        Duplicate/O xw tmp_pgs_SHS_PQ,tmp_pgs_SHS_SQ 
     418        GaussPolySphere(form_pgs_SHS,tmp_pgs_SHS_PQ,xw) 
     419        StickyHS_Struct(struct_pgs_SHS,tmp_pgs_SHS_SQ,xw) 
     420        yw = tmp_pgs_SHS_PQ * tmp_pgs_SHS_SQ 
     421        yw *= w[0] 
     422        yw += w[7] 
    378423         
    379424        //cleanup waves 
    380425//      Killwaves/Z form_pgs_SHS,struct_pgs_SHS 
    381426         
    382         return (inten) 
     427        return (0) 
    383428End 
    384429 
     
    386431 
    387432// this is all there is to the smeared calculation! 
    388 Function SmearedGaussPolySphere_HS(w,x) :FitFunc 
    389         Wave w 
    390         Variable x 
    391          
    392         Variable ans 
    393         SVAR sq = gSig_Q 
    394         SVAR qb = gQ_bar 
    395         SVAR sh = gShadow 
    396         SVAR gQ = gQVals 
    397          
    398         //the name of your unsmeared model is the first argument 
    399         ans = Smear_Model_20(GaussPolySphere_HS,$sq,$qb,$sh,$gQ,w,x) 
    400  
    401         return(ans) 
     433Function SmearedGaussPolySphere_HS(s) : FitFunc 
     434        Struct ResSmearAAOStruct &s 
     435 
     436//      the name of your unsmeared model (AAO) is the first argument 
     437        s.yW = Smear_Model_20(GaussPolySphere_HS,s.coefW,s.xW,s.resW) 
     438 
     439        return(0) 
    402440End 
    403441 
    404442// this is all there is to the smeared calculation! 
    405 Function SmearedGaussPolySphere_SW(w,x) :FitFunc 
    406         Wave w 
    407         Variable x 
    408          
    409         Variable ans 
    410         SVAR sq = gSig_Q 
    411         SVAR qb = gQ_bar 
    412         SVAR sh = gShadow 
    413         SVAR gQ = gQVals 
    414          
    415         //the name of your unsmeared model is the first argument 
    416         ans = Smear_Model_20(GaussPolySphere_SW,$sq,$qb,$sh,$gQ,w,x) 
    417  
    418         return(ans) 
     443Function SmearedGaussPolySphere_SW(s) : FitFunc 
     444        Struct ResSmearAAOStruct &s 
     445 
     446//      the name of your unsmeared model (AAO) is the first argument 
     447        s.yW = Smear_Model_20(GaussPolySphere_SW,s.coefW,s.xW,s.resW) 
     448 
     449        return(0) 
    419450End 
    420451 
    421452// this is all there is to the smeared calculation! 
    422 Function SmearedGaussPolySphere_SC(w,x) :FitFunc 
    423         Wave w 
    424         Variable x 
    425          
    426         Variable ans 
    427         SVAR sq = gSig_Q 
    428         SVAR qb = gQ_bar 
    429         SVAR sh = gShadow 
    430         SVAR gQ = gQVals 
    431          
    432         //the name of your unsmeared model is the first argument 
    433         ans = Smear_Model_20(GaussPolySphere_SC,$sq,$qb,$sh,$gQ,w,x) 
    434  
    435         return(ans) 
     453Function SmearedGaussPolySphere_SC(s) : FitFunc 
     454        Struct ResSmearAAOStruct &s 
     455 
     456//      the name of your unsmeared model (AAO) is the first argument 
     457        s.yW = Smear_Model_20(GaussPolySphere_SC,s.coefW,s.xW,s.resW) 
     458 
     459        return(0) 
    436460End 
    437461 
    438462// this is all there is to the smeared calculation! 
    439 Function SmearedGaussPolySphere_SHS(w,x) :FitFunc 
    440         Wave w 
    441         Variable x 
    442          
    443         Variable ans 
    444         SVAR sq = gSig_Q 
    445         SVAR qb = gQ_bar 
    446         SVAR sh = gShadow 
    447         SVAR gQ = gQVals 
    448          
    449         //the name of your unsmeared model is the first argument 
    450         ans = Smear_Model_20(GaussPolySphere_SHS,$sq,$qb,$sh,$gQ,w,x) 
    451  
    452         return(ans) 
    453 End 
     463Function SmearedGaussPolySphere_SHS(s) : FitFunc 
     464        Struct ResSmearAAOStruct &s 
     465 
     466//      the name of your unsmeared model (AAO) is the first argument 
     467        s.yW = Smear_Model_20(GaussPolySphere_SHS,s.coefW,s.xW,s.resW) 
     468 
     469        return(0) 
     470End 
     471 
     472//wrapper to calculate the smeared model as an AAO-Struct 
     473// fills the struct and calls the ususal function with the STRUCT parameter 
     474// 
     475// used only for the dependency, not for fitting 
     476// 
     477Function fSmearedGaussPolySphere_HS(coefW,yW,xW) 
     478        Wave coefW,yW,xW 
     479         
     480        String str = getWavesDataFolder(yW,0) 
     481        String DF="root:"+str+":" 
     482         
     483        WAVE resW = $(DF+str+"_res") 
     484         
     485        STRUCT ResSmearAAOStruct fs 
     486        WAVE fs.coefW = coefW    
     487        WAVE fs.yW = yW 
     488        WAVE fs.xW = xW 
     489        WAVE fs.resW = resW 
     490         
     491        Variable err 
     492        err = SmearedGaussPolySphere_HS(fs) 
     493         
     494        return (0) 
     495End 
     496 
     497//wrapper to calculate the smeared model as an AAO-Struct 
     498// fills the struct and calls the ususal function with the STRUCT parameter 
     499// 
     500// used only for the dependency, not for fitting 
     501// 
     502Function fSmearedGaussPolySphere_SW(coefW,yW,xW) 
     503        Wave coefW,yW,xW 
     504         
     505        String str = getWavesDataFolder(yW,0) 
     506        String DF="root:"+str+":" 
     507         
     508        WAVE resW = $(DF+str+"_res") 
     509         
     510        STRUCT ResSmearAAOStruct fs 
     511        WAVE fs.coefW = coefW    
     512        WAVE fs.yW = yW 
     513        WAVE fs.xW = xW 
     514        WAVE fs.resW = resW 
     515         
     516        Variable err 
     517        err = SmearedGaussPolySphere_SW(fs) 
     518         
     519        return (0) 
     520End 
     521 
     522//wrapper to calculate the smeared model as an AAO-Struct 
     523// fills the struct and calls the ususal function with the STRUCT parameter 
     524// 
     525// used only for the dependency, not for fitting 
     526// 
     527Function fSmearedGaussPolySphere_SC(coefW,yW,xW) 
     528        Wave coefW,yW,xW 
     529         
     530        String str = getWavesDataFolder(yW,0) 
     531        String DF="root:"+str+":" 
     532         
     533        WAVE resW = $(DF+str+"_res") 
     534         
     535        STRUCT ResSmearAAOStruct fs 
     536        WAVE fs.coefW = coefW    
     537        WAVE fs.yW = yW 
     538        WAVE fs.xW = xW 
     539        WAVE fs.resW = resW 
     540         
     541        Variable err 
     542        err = SmearedGaussPolySphere_SC(fs) 
     543         
     544        return (0) 
     545End 
     546 
     547//wrapper to calculate the smeared model as an AAO-Struct 
     548// fills the struct and calls the ususal function with the STRUCT parameter 
     549// 
     550// used only for the dependency, not for fitting 
     551// 
     552Function fSmearedGaussPolySphere_SHS(coefW,yW,xW) 
     553        Wave coefW,yW,xW 
     554         
     555        String str = getWavesDataFolder(yW,0) 
     556        String DF="root:"+str+":" 
     557         
     558        WAVE resW = $(DF+str+"_res") 
     559         
     560        STRUCT ResSmearAAOStruct fs 
     561        WAVE fs.coefW = coefW    
     562        WAVE fs.yW = yW 
     563        WAVE fs.xW = xW 
     564        WAVE fs.resW = resW 
     565         
     566        Variable err 
     567        err = SmearedGaussPolySphere_SHS(fs) 
     568         
     569        return (0) 
     570End 
     571 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/LamellarFF.ipf

    r127 r128  
    3333        Edit parameters_LamellarFF, coef_LamellarFF 
    3434        ModifyTable width(parameters_LamellarFF)=160 
    35         ywave_LamellarFF  := LamellarFF(coef_LamellarFF, xwave_LamellarFF) 
     35         
     36        Variable/G root:g_LamellarFF 
     37        g_LamellarFF := LamellarFF(coef_LamellarFF, ywave_LamellarFF,xwave_LamellarFF) 
    3638        Display ywave_LamellarFF vs xwave_LamellarFF 
    3739        ModifyGraph marker=29, msize=2, mode=4 
     
    4345End 
    4446 
    45 // 
    46 //this macro sets up all the necessary parameters and waves that are 
    47 //needed to calculate the  smeared model function. 
    48 // 
    49 //no input parameters are necessary, it MUST use the experimental q-values 
    50 // from the experimental data read in from an AVE/QSIG data file 
    51 //////////////////////////////////////////////////// 
    52 Proc PlotSmeared_LamellarFF()                                                           //Lamellar 
     47// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     48Proc PlotSmeared_LamellarFF(str)                                                                 
     49        String str 
     50        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
    5351         
    54         // if no gQvals wave, data must not have been loaded => abort 
    55         If(ResolutionWavesMissing())            //part of GaussUtils 
     52        // if any of the resolution waves are missing => abort 
     53        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    5654                Abort 
    5755        endif 
     56         
     57        SetDataFolder $("root:"+str) 
    5858         
    5959        // Setup parameter table for model function 
     
    6464        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    6565        // make extra copy of experimental q-values for easy plotting 
    66         Duplicate/O $gQvals smeared_LamellarFF,smeared_qvals                            // 
     66        Duplicate/O $(str+"_q") smeared_LamellarFF,smeared_qvals                                // 
    6767        SetScale d,0,0,"1/cm",smeared_LamellarFF                                                        // 
    68  
    69         smeared_LamellarFF := LamellarFF_Smeared(smear_coef_LamellarFF,$gQvals)         // SMEARED function name 
     68                                         
     69        Variable/G gs_LamellarFF=0 
     70        gs_LamellarFF := fLamellarFF_Smeared(smear_coef_LamellarFF,smeared_LamellarFF,smeared_qvals)    //this wrapper fills the STRUCT 
     71         
    7072        Display smeared_LamellarFF vs smeared_qvals                                                                     // 
    7173        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    7375        Label left "I(q) (cm\\S-1\\M)" 
    7476        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    75 End     // end macro  
     77         
     78        SetDataFolder root: 
     79End 
     80//////////////////////////////////////////////////// 
     81         
     82 
     83 
     84//AAO version, uses XOP if available 
     85// simply calls the original single point calculation with 
     86// a wave assignment (this will behave nicely if given point ranges) 
     87Function LamellarFF(cw,yw,xw) : FitFunc 
     88        Wave cw,yw,xw 
     89         
     90#if exists("LamellarFFX") 
     91        yw = LamellarFFX(cw,xw) 
     92#else 
     93        yw = fLamellarFF(cw,xw) 
     94#endif 
     95        return(0) 
     96End 
    7697 
    7798//CH#1 
     
    80101// based on the wave (array) of parameters that you send it (w) 
    81102// 
    82 Function LamellarFF(w,x) : FitFunc 
     103Function fLamellarFF(w,x) : FitFunc 
    83104        Wave w 
    84105        Variable x 
     
    115136End 
    116137 
    117 //the smeared model calculation 
    118 Function LamellarFF_Smeared(w,x) :FitFunc 
    119         Wave w 
    120         Variable x 
     138//wrapper to calculate the smeared model as an AAO-Struct 
     139// fills the struct and calls the ususal function with the STRUCT parameter 
     140// 
     141// used only for the dependency, not for fitting 
     142// 
     143Function fLamellarFF_Smeared(coefW,yW,xW) 
     144        Wave coefW,yW,xW 
    121145         
    122         Variable ans 
    123         SVAR sq = gSig_Q 
    124         SVAR qb = gQ_bar 
    125         SVAR sh = gShadow 
    126         SVAR gQ = gQVals 
     146        String str = getWavesDataFolder(yW,0) 
     147        String DF="root:"+str+":" 
    127148         
    128         ans = Smear_Model_20(LamellarFF,$sq,$qb,$sh,$gQ,w,x)     
    129  
    130         return(ans) 
     149        WAVE resW = $(DF+str+"_res") 
     150         
     151        STRUCT ResSmearAAOStruct fs 
     152        WAVE fs.coefW = coefW    
     153        WAVE fs.yW = yW 
     154        WAVE fs.xW = xW 
     155        WAVE fs.resW = resW 
     156         
     157        Variable err 
     158        err = LamellarFF_Smeared(fs) 
     159         
     160        return (0) 
    131161End 
    132162 
     163//the smeared model calculation 
     164Function LamellarFF_Smeared(s) :FitFunc 
     165        Struct ResSmearAAOStruct &s 
     166 
     167//      the name of your unsmeared model (AAO) is the first argument 
     168        s.yW = Smear_Model_20(LamellarFF,s.coefW,s.xW,s.resW) 
     169 
     170        return(0) 
     171End 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/LamellarFF_HG.ipf

    r127 r128  
    3535        Edit parameters_LamellarFF_HG, coef_LamellarFF_HG 
    3636        ModifyTable width(parameters_LamellarFF_HG)=160 
    37         ywave_LamellarFF_HG  := LamellarFF_HG(coef_LamellarFF_HG, xwave_LamellarFF_HG) 
     37         
     38        Variable/G root:g_LamellarFF_HG 
     39        g_LamellarFF_HG := LamellarFF_HG(coef_LamellarFF_HG, ywave_LamellarFF_HG, xwave_LamellarFF_HG) 
    3840        Display ywave_LamellarFF_HG vs xwave_LamellarFF_HG 
    3941        ModifyGraph marker=29, msize=2, mode=4 
     
    4547End 
    4648 
    47 // 
    48 //this macro sets up all the necessary parameters and waves that are 
    49 //needed to calculate the  smeared model function. 
    50 // 
    51 //no input parameters are necessary, it MUST use the experimental q-values 
    52 // from the experimental data read in from an AVE/QSIG data file 
    53 //////////////////////////////////////////////////// 
    54 Proc PlotSmeared_LamellarFF_HG()                                                                //Lamellar 
     49// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     50Proc PlotSmeared_LamellarFF_HG(str)                                                              
     51        String str 
     52        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
    5553         
    56         // if no gQvals wave, data must not have been loaded => abort 
    57         If(ResolutionWavesMissing())            //part of GaussUtils 
     54        // if any of the resolution waves are missing => abort 
     55        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    5856                Abort 
    5957        endif 
     58         
     59        SetDataFolder $("root:"+str) 
    6060         
    6161        // Setup parameter table for model function 
     
    6666        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    6767        // make extra copy of experimental q-values for easy plotting 
    68         Duplicate/O $gQvals smeared_LamellarFF_HG,smeared_qvals                         // 
     68        Duplicate/O $(str+"_q") smeared_LamellarFF_HG,smeared_qvals                             // 
    6969        SetScale d,0,0,"1/cm",smeared_LamellarFF_HG                                                     // 
    70  
    71         smeared_LamellarFF_HG := LamellarFF_HG_Smeared(smear_coef_LamellarFF_HG,$gQvals)                // SMEARED function name 
     70                                         
     71        Variable/G gs_LamellarFF_HG=0 
     72        gs_LamellarFF_HG := fLamellarFF_HG_Smeared(smear_coef_LamellarFF_HG,smeared_LamellarFF_HG,smeared_qvals)        //this wrapper fills the STRUCT 
     73         
    7274        Display smeared_LamellarFF_HG vs smeared_qvals                                                                  // 
    7375        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    7577        Label left "I(q) (cm\\S-1\\M)" 
    7678        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    77 End     // end macro  
     79         
     80        SetDataFolder root: 
     81End 
     82 
     83 
     84 
     85//AAO version, uses XOP if available 
     86// simply calls the original single point calculation with 
     87// a wave assignment (this will behave nicely if given point ranges) 
     88Function LamellarFF_HG(cw,yw,xw) : FitFunc 
     89        Wave cw,yw,xw 
     90         
     91#if exists("LamellarFF_HGX") 
     92        yw = LamellarFF_HGX(cw,xw) 
     93#else 
     94        yw = fLamellarFF_HG(cw,xw) 
     95#endif 
     96        return(0) 
     97End 
    7898 
    7999//CH#1 
     
    82102// based on the wave (array) of parameters that you send it (w) 
    83103// 
    84 Function LamellarFF_HG(w,x) : FitFunc 
     104Function fLamellarFF_HG(w,x) : FitFunc 
    85105        Wave w 
    86106        Variable x 
     
    124144End 
    125145 
     146//wrapper to calculate the smeared model as an AAO-Struct 
     147// fills the struct and calls the ususal function with the STRUCT parameter 
     148// 
     149// used only for the dependency, not for fitting 
     150// 
     151Function fLamellarFF_HG_Smeared(coefW,yW,xW) 
     152        Wave coefW,yW,xW 
     153         
     154        String str = getWavesDataFolder(yW,0) 
     155        String DF="root:"+str+":" 
     156         
     157        WAVE resW = $(DF+str+"_res") 
     158         
     159        STRUCT ResSmearAAOStruct fs 
     160        WAVE fs.coefW = coefW    
     161        WAVE fs.yW = yW 
     162        WAVE fs.xW = xW 
     163        WAVE fs.resW = resW 
     164         
     165        Variable err 
     166        err = LamellarFF_HG_Smeared(fs) 
     167         
     168        return (0) 
     169End 
     170 
    126171//the smeared model calculation 
    127 Function LamellarFF_HG_Smeared(w,x) :FitFunc 
    128         Wave w 
    129         Variable x 
    130          
    131         Variable ans 
    132         SVAR sq = gSig_Q 
    133         SVAR qb = gQ_bar 
    134         SVAR sh = gShadow 
    135         SVAR gQ = gQVals 
    136          
    137         ans = Smear_Model_20(LamellarFF_HG,$sq,$qb,$sh,$gQ,w,x)  
     172Function LamellarFF_HG_Smeared(s) :FitFunc 
     173        Struct ResSmearAAOStruct &s 
    138174 
    139         return(ans) 
     175//      the name of your unsmeared model (AAO) is the first argument 
     176        s.yW = Smear_Model_20(LamellarFF_HG,s.coefW,s.xW,s.resW) 
     177 
     178        return(0) 
    140179End 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/LamellarPS.ipf

    r127 r128  
    6363        Edit parameters_LamellarPS, coef_LamellarPS 
    6464        ModifyTable width(parameters_LamellarPS)=160 
    65         ywave_LamellarPS  := LamellarPS(coef_LamellarPS, xwave_LamellarPS) 
     65         
     66        Variable/G root:g_LamellarPS 
     67        g_LamellarPS := LamellarPS(coef_LamellarPS, ywave_LamellarPS, xwave_LamellarPS) 
    6668        Display ywave_LamellarPS vs xwave_LamellarPS 
    6769        ModifyGraph marker=29, msize=2, mode=4 
     
    7779End 
    7880 
    79 //// 
    80 ////this macro sets up all the necessary parameters and waves that are 
    81 ////needed to calculate the  smeared model function. 
    82 //// 
    83 ////no input parameters are necessary, it MUST use the experimental q-values 
    84 //// from the experimental data read in from an AVE/QSIG data file 
    85 ////////////////////////////////////////////////////// 
    86 //Macro PlotSmeared_LamellarPS()                                                                //Lamellar 
    87 //       
    88 //       
    89 //      // if no gQvals wave, data must not have been loaded => abort 
    90 //      If(ResolutionWavesMissing())            //part of GaussUtils 
     81// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     82//Proc PlotSmeared_LamellarPS(str)                                                               
     83//      String str 
     84//      Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     85//       
     86//      // if any of the resolution waves are missing => abort 
     87//      if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    9188//              Abort 
    9289//      endif 
     90//       
     91//      SetDataFolder $("root:"+str) 
    9392//       
    9493//      // constants 
     
    102101//      // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    103102//      // make extra copy of experimental q-values for easy plotting 
    104 //      Duplicate/O $gQvals smeared_LamellarPS,smeared_qvals                            // 
     103//      Duplicate/O $(str+"_q") smeared_LamellarPS,smeared_qvals                                // 
    105104//      SetScale d,0,0,"1/cm",smeared_LamellarPS                                                        // 
    106 // 
    107 //      smeared_LamellarPS := LamellarPS_Smeared(smear_coef_LamellarPS,$gQvals)         // SMEARED function name 
    108 //      Display smeared_LamellarPS vs $gQvals                                                                   // 
     105//                                       
     106//      Variable/G gs_LamellarPS=0 
     107//      gs_LamellarPS := fLamellarPS_Smeared(smear_coef_LamellarPS,smeared_LamellarPS,smeared_qvals)    //this wrapper fills the STRUCT 
     108//       
     109//      Display smeared_LamellarPS vs smeared_qvals                                                                     // 
    109110//      ModifyGraph log=1,marker=29,msize=2,mode=4 
    110111//      Label bottom "q (\\S-1\\M)" 
    111112//      Label left "I(q) (cm\\S-1\\M)" 
    112 // 
    113 //End     // end macro  
     113//       
     114//      SetDataFolder root: 
     115//End 
     116 
     117 
     118 
     119 
     120 
     121//AAO version, uses XOP if available 
     122// simply calls the original single point calculation with 
     123// a wave assignment (this will behave nicely if given point ranges) 
     124Function LamellarPS(cw,yw,xw) : FitFunc 
     125        Wave cw,yw,xw 
     126         
     127#if exists("LamellarPSX") 
     128        yw = LamellarPSX(cw,xw) 
     129#else 
     130        yw = fLamellarPS(cw,xw) 
     131#endif 
     132        return(0) 
     133End 
    114134 
    115135// instrument resolution IS included here in S(Q) 
    116 Function LamellarPS(w,x) : FitFunc 
     136Function fLamellarPS(w,x) : FitFunc 
    117137        Wave w 
    118138        Variable x 
     
    191211        Return (inten+bkg) 
    192212End 
    193          
     213 
     214//wrapper to calculate the smeared model as an AAO-Struct 
     215// fills the struct and calls the ususal function with the STRUCT parameter 
     216// 
     217// used only for the dependency, not for fitting 
     218// 
     219//Function fLamellarPS_Smeared(coefW,yW,xW) 
     220//      Wave coefW,yW,xW 
     221//       
     222//      String str = getWavesDataFolder(yW,0) 
     223//      String DF="root:"+str+":" 
     224//       
     225//      WAVE resW = $(DF+str+"_res") 
     226//       
     227//      STRUCT ResSmearAAOStruct fs 
     228//      WAVE fs.coefW = coefW    
     229//      WAVE fs.yW = yW 
     230//      WAVE fs.xW = xW 
     231//      WAVE fs.resW = resW 
     232//       
     233//      Variable err 
     234//      err = LamellarPS_Smeared(fs) 
     235//       
     236//      return (0) 
     237//End 
     238 
    194239//the smeared model calculation 
    195 //Function LamellarPS_Smeared(w,x) :FitFunc 
    196 //      Wave w 
    197 //      Variable x 
    198 //       
    199 //      Variable ans 
    200 //      SVAR sq = gSig_Q 
    201 //      SVAR qb = gQ_bar 
    202 //      SVAR sh = gShadow 
    203 //      SVAR gQ = gQVals 
    204 //       
    205 //      ans = Smear_Model_20(LamellarPS,$sq,$qb,$sh,$gQ,w,x)     
    206 // 
    207 //      return(ans) 
     240//Function LamellarPS_Smeared(s) :FitFunc 
     241//      Struct ResSmearAAOStruct &s 
     242// 
     243////    the name of your unsmeared model (AAO) is the first argument 
     244//      s.yW = Smear_Model_20(LamellarPS,s.coefW,s.xW,s.resW) 
     245// 
     246//      return(0) 
    208247//End 
    209 // 
     248//// 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/LamellarPS_HG.ipf

    r127 r128  
    6363        Edit parameters_LamellarPS_HG, coef_LamellarPS_HG 
    6464        ModifyTable width(parameters_LamellarPS_HG)=160 
    65         ywave_LamellarPS_HG  := LamellarPS_HG(coef_LamellarPS_HG, xwave_LamellarPS_HG) 
     65         
     66        Variable/G root:g_LamellarPS_HS 
     67        g_LamellarPS_HG := LamellarPS_HG(coef_LamellarPS_HG, ywave_LamellarPS_HG,xwave_LamellarPS_HG) 
    6668        Display ywave_LamellarPS_HG vs xwave_LamellarPS_HG 
    6769        ModifyGraph marker=29, msize=2, mode=4 
     
    7779End 
    7880 
    79 // 
    80 //this macro sets up all the necessary parameters and waves that are 
    81 //needed to calculate the  smeared model function. 
    82 // 
    83 //no input parameters are necessary, it MUST use the experimental q-values 
    84 // from the experimental data read in from an AVE/QSIG data file 
    85 //////////////////////////////////////////////////// 
    86 //Proc PlotSmeared_LamellarPS_HG()                                                              //Lamellar 
    87 // 
    88 //      // if no gQvals wave, data must not have been loaded => abort 
    89 //      If(ResolutionWavesMissing())            //part of GaussUtils 
     81// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     82//Proc PlotSmeared_LamellarPS_HG(str)                                                            
     83//      String str 
     84//      Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     85//       
     86//      // if any of the resolution waves are missing => abort 
     87//      if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    9088//              Abort 
    9189//      endif 
     90//       
     91//      SetDataFolder $("root:"+str) 
    9292//       
    9393//      // constants 
     
    101101//      // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    102102//      // make extra copy of experimental q-values for easy plotting 
    103 //      Duplicate/O $gQvals smeared_LamellarPS_HG,smeared_qvals                         // 
     103//      Duplicate/O $(str+"_q") smeared_LamellarPS_HG,smeared_qvals                             // 
    104104//      SetScale d,0,0,"1/cm",smeared_LamellarPS_HG                                                     // 
    105 // 
    106 //      smeared_LamellarPS_HG := LamellarPS_HG_Smeared(smear_coef_LamellarPS_HG,$gQvals)                // SMEARED function name 
    107 //      Display smeared_LamellarPS_HG vs $gQvals                                                                        // 
     105//                                       
     106//      Variable/G gs_LamellarPS_HG     =0 
     107//      gs_LamellarPS_HG         := fLamellarPS_HG_Smeared(smear_coef_LamellarPS_HG     ,smeared_LamellarPS_HG  ,smeared_qvals) //this wrapper fills the STRUCT 
     108//       
     109//      Display smeared_LamellarPS_HG vs smeared_qvals                                                          // 
    108110//      ModifyGraph log=1,marker=29,msize=2,mode=4 
    109111//      Label bottom "q (\\S-1\\M)" 
    110112//      Label left "I(q) (cm\\S-1\\M)" 
    111 // 
    112 //End     // end macro  
    113  
    114  
    115 // 
    116 Function LamellarPS_HG(w,x) : FitFunc 
     113//       
     114//      SetDataFolder root: 
     115//End 
     116         
     117 
     118 
     119//AAO version, uses XOP if available 
     120// simply calls the original single point calculation with 
     121// a wave assignment (this will behave nicely if given point ranges) 
     122Function LamellarPS_HG(cw,yw,xw) : FitFunc 
     123        Wave cw,yw,xw 
     124         
     125#if exists("LamellarPS_HGX") 
     126        yw = LamellarPS_HGX(cw,xw) 
     127#else 
     128        yw = fLamellarPS_HG(cw,xw) 
     129#endif 
     130        return(0) 
     131End 
     132 
     133// 
     134Function fLamellarPS_HG(w,x) : FitFunc 
    117135        Wave w 
    118136        Variable x 
     
    202220End 
    203221 
    204 ////the smeared model calculation 
    205 //Function LamellarPS_HG_Smeared(w,x) :FitFunc 
    206 //      Wave w 
    207 //      Variable x 
    208 //       
    209 //      Variable ans 
    210 //      SVAR sq = gSig_Q 
    211 //      SVAR qb = gQ_bar 
    212 //      SVAR sh = gShadow 
    213 //      SVAR gQ = gQVals 
    214 //       
    215 //      ans = Smear_Model_20(LamellarPS_HG,$sq,$qb,$sh,$gQ,w,x)  
    216 // 
    217 //      return(ans) 
    218 //End    
     222//wrapper to calculate the smeared model as an AAO-Struct 
     223// fills the struct and calls the ususal function with the STRUCT parameter 
     224// 
     225// used only for the dependency, not for fitting 
     226// 
     227//Function fLamellarPS_HG_Smeared(coefW,yW,xW) 
     228//      Wave coefW,yW,xW 
     229//       
     230//      String str = getWavesDataFolder(yW,0) 
     231//      String DF="root:"+str+":" 
     232//       
     233//      WAVE resW = $(DF+str+"_res") 
     234//       
     235//      STRUCT ResSmearAAOStruct fs 
     236//      WAVE fs.coefW = coefW    
     237//      WAVE fs.yW = yW 
     238//      WAVE fs.xW = xW 
     239//      WAVE fs.resW = resW 
     240//       
     241//      Variable err 
     242//      err = LamellarPS_HG_Smeared(fs) 
     243//       
     244//      return (0) 
     245//End 
     246 
     247//////the smeared model calculation 
     248//Function LamellarPS_HG_Smeared(s) :FitFunc 
     249//      Struct ResSmearAAOStruct &s 
     250// 
     251////    the name of your unsmeared model (AAO) is the first argument 
     252//      s.yW = Smear_Model_20(LamellarPS_HG,s.coefW,s.xW,s.resW) 
     253// 
     254//      return(0) 
     255//End 
     256         
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/LogNormSpheres_and_Struct.ipf

    r127 r128  
    2323        make/O/T parameters_lns_HS = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","bkg (cm-1 sr-1)"} 
    2424        Edit parameters_lns_HS,coef_lns_HS 
    25         ywave_lns_HS := LogNormalSphere_HS(coef_lns_HS,xwave_lns_HS) 
     25         
     26        Variable/G root:g_lns_HS 
     27        g_lns_HS := LogNormalSphere_HS(coef_lns_HS,ywave_lns_HS,xwave_lns_HS) 
    2628        Display ywave_lns_HS vs xwave_lns_HS 
    2729        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    3133End 
    3234 
    33 Proc PlotSmearedLogNormalSphere_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()) 
     35// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     36Proc PlotSmearedLogNormalSphere_HS(str)                                                          
     37        String str 
     38        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     39         
     40        // if any of the resolution waves are missing => abort 
     41        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    3942                Abort 
    4043        endif 
     44         
     45        SetDataFolder $("root:"+str) 
    4146         
    4247        // Setup parameter table for model function 
     
    4752        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    4853        // make extra copy of experimental q-values for easy plotting 
    49         Duplicate/O $gQvals smeared_lns_HS,smeared_qvals                                 
     54        Duplicate/O $(str+"_q") smeared_lns_HS,smeared_qvals                             
    5055        SetScale d,0,0,"1/cm",smeared_lns_HS                                                     
    51  
    52         smeared_lns_HS := SmearedLogNormalSphere_HS(smear_coef_lns_HS,$gQvals)           
     56                                         
     57        Variable/G gs_lns_HS=0 
     58        gs_lns_HS := fSmearedLogNormalSphere_HS(smear_coef_lns_HS,smeared_lns_HS,smeared_qvals) //this wrapper fills the STRUCT 
     59         
    5360        Display smeared_lns_HS vs smeared_qvals                                                                  
    5461        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    5663        Label left "Intensity (cm\\S-1\\M)" 
    5764        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    58 End 
    59  
    60 Function LogNormalSphere_HS(w,x) : FitFunc 
    61         Wave w 
    62         Variable x 
     65         
     66        SetDataFolder root: 
     67End 
     68         
     69 
     70Function LogNormalSphere_HS(w,yw,xw) : FitFunc 
     71        Wave w,yw,xw 
    6372         
    6473        Variable inten 
     
    8897         
    8998        //calculate each and combine 
    90         inten = LogNormalPolySphere(form_lns_HS,x) 
    91         inten *= HardSphereStruct(struct_lns_HS,x) 
    92         inten *= w[0] 
    93         inten += w[5] 
     99        Duplicate/O xw tmp_lns_HS_PQ,tmp_lns_HS_SQ 
     100        LogNormalPolySphere(form_lns_HS,tmp_lns_HS_PQ,xw) 
     101        HardSphereStruct(struct_lns_HS,tmp_lns_HS_SQ,xw) 
     102        yw = tmp_lns_HS_PQ *tmp_lns_HS_SQ 
     103        yw *= w[0] 
     104        yw += w[5] 
    94105         
    95106        //cleanup waves 
    96107//      Killwaves/Z form_lns_HS,struct_lns_HS 
    97108         
    98         return (inten) 
     109        return (0) 
    99110End 
    100111 
     
    111122        make/O/T parameters_lns_SW = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","well depth (kT)","well width (diam.)","bkg (cm-1 sr-1)"} 
    112123        Edit parameters_lns_SW,coef_lns_SW 
    113         ywave_lns_SW := LogNormalSphere_SW(coef_lns_SW,xwave_lns_SW) 
     124         
     125        Variable/G root:g_lns_SW 
     126        g_lns_SW := LogNormalSphere_SW(coef_lns_SW,ywave_lns_SW,xwave_lns_SW) 
    114127        Display ywave_lns_SW vs xwave_lns_SW 
    115128        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    119132End 
    120133 
    121 Proc PlotSmearedLogNormalSphere_SW()                                                             
    122         //no input parameters necessary, it MUST use the experimental q-values 
    123         // from the experimental data read in from an AVE/QSIG data file 
    124          
    125         // if no gQvals wave, data must not have been loaded => abort 
    126         if(ResolutionWavesMissing()) 
     134// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     135Proc PlotSmearedLogNormalSphere_SW(str)                                                          
     136        String str 
     137        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     138         
     139        // if any of the resolution waves are missing => abort 
     140        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    127141                Abort 
    128142        endif 
     143         
     144        SetDataFolder $("root:"+str) 
    129145         
    130146        // Setup parameter table for model function 
     
    135151        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    136152        // make extra copy of experimental q-values for easy plotting 
    137         Duplicate/O $gQvals smeared_lns_SW,smeared_qvals                                 
     153        Duplicate/O $(str+"_q") smeared_lns_SW,smeared_qvals                             
    138154        SetScale d,0,0,"1/cm",smeared_lns_SW                                                     
    139  
    140         smeared_lns_SW := SmearedLogNormalSphere_SW(smear_coef_lns_SW,$gQvals)           
     155                                         
     156        Variable/G gs_lns_SW=0 
     157        gs_lns_SW := fSmearedLogNormalSphere_SW(smear_coef_lns_SW,smeared_lns_SW,smeared_qvals) //this wrapper fills the STRUCT 
     158         
    141159        Display smeared_lns_SW vs smeared_qvals                                                                  
    142160        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    144162        Label left "Intensity (cm\\S-1\\M)" 
    145163        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    146 End 
    147  
    148 Function LogNormalSphere_SW(w,x) : FitFunc 
    149         Wave w 
    150         Variable x 
     164         
     165        SetDataFolder root: 
     166End 
     167         
     168 
     169Function LogNormalSphere_SW(w,yw,xw) : FitFunc 
     170        Wave w,yw,xw 
    151171         
    152172        Variable inten 
     
    177197         
    178198        //calculate each and combine 
    179         inten = LogNormalPolySphere(form_lns_SW,x) 
    180         inten *= SquareWellStruct(struct_lns_SW,x) 
    181         inten *= w[0] 
    182         inten += w[7] 
     199        Duplicate/O xw tmp_lns_SW_PQ,tmp_lns_SW_SQ 
     200        LogNormalPolySphere(form_lns_SW,tmp_lns_SW_PQ,xw) 
     201        SquareWellStruct(struct_lns_SW,tmp_lns_SW_SQ,xw) 
     202        yw = tmp_lns_SW_PQ * tmp_lns_SW_SQ 
     203        yw *= w[0] 
     204        yw += w[7] 
    183205         
    184206        //cleanup waves 
    185207//      Killwaves/Z form_lns_SW,struct_lns_SW 
    186208         
    187         return (inten) 
     209        return (0) 
    188210End 
    189211 
     
    208230        make/O/T parameters_lns_SC = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","charge","movalent salt(M)","Temperature (K)","dielectric const","bkg (cm-1 sr-1)"} 
    209231        Edit parameters_lns_SC,coef_lns_SC 
    210         ywave_lns_SC := LogNormalSphere_SC(coef_lns_SC,xwave_lns_SC) 
     232         
     233        Variable/G root:g_lns_SC 
     234        g_lns_SC := LogNormalSphere_SC(coef_lns_SC,ywave_lns_SC,xwave_lns_SC) 
    211235        Display ywave_lns_SC vs xwave_lns_SC 
    212236        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    216240End 
    217241 
    218 Proc PlotSmearedLogNormalSphere_SC()                                                             
    219         //no input parameters necessary, it MUST use the experimental q-values 
    220         // from the experimental data read in from an AVE/QSIG data file 
    221          
    222         // if no gQvals wave, data must not have been loaded => abort 
    223         if(ResolutionWavesMissing()) 
     242// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     243Proc PlotSmearedLogNormalSphere_SC(str)                                                          
     244        String str 
     245        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     246         
     247        // if any of the resolution waves are missing => abort 
     248        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    224249                Abort 
    225250        endif 
    226  
     251         
     252        SetDataFolder $("root:"+str) 
     253         
    227254        if (DataFolderExists("root:HayPenMSA")) 
    228255                Make/O/D/N=17 root:HayPenMSA:gMSAWave 
     
    239266        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    240267        // make extra copy of experimental q-values for easy plotting 
    241         Duplicate/O $gQvals smeared_lns_SC,smeared_qvals                                 
     268        Duplicate/O $(str+"_q") smeared_lns_SC,smeared_qvals                             
    242269        SetScale d,0,0,"1/cm",smeared_lns_SC                                                     
    243  
    244         smeared_lns_SC := SmearedLogNormalSphere_SC(smear_coef_lns_SC,$gQvals)           
     270                                         
     271        Variable/G gs_lns_SC=0 
     272        gs_lns_SC := fSmearedLogNormalSphere_SC(smear_coef_lns_SC,smeared_lns_SC,smeared_qvals) //this wrapper fills the STRUCT 
     273         
    245274        Display smeared_lns_SC vs smeared_qvals                                                                  
    246275        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    248277        Label left "Intensity (cm\\S-1\\M)" 
    249278        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    250 End 
    251  
    252 Function LogNormalSphere_SC(w,x) : FitFunc 
    253         Wave w 
    254         Variable x 
     279         
     280        SetDataFolder root: 
     281End 
     282 
     283 
     284 
     285Function LogNormalSphere_SC(w,yw,xw) : FitFunc 
     286        Wave w,yw,xw 
    255287         
    256288        Variable inten 
     
    283315         
    284316        //calculate each and combine 
    285         inten = LogNormalPolySphere(form_lns_SC,x) 
    286         inten *= HayterPenfoldMSA(struct_lns_SC,x) 
    287         inten *= w[0] 
    288         inten += w[9] 
     317        Duplicate/O xw tmp_lns_SC_PQ,tmp_lns_SC_SQ 
     318        LogNormalPolySphere(form_lns_SC,tmp_lns_SC_PQ,xw) 
     319        HayterPenfoldMSA(struct_lns_SC,tmp_lns_SC_SQ,xw) 
     320        yw = tmp_lns_SC_PQ * tmp_lns_SC_SQ 
     321        yw *= w[0] 
     322        yw += w[9] 
    289323         
    290324        //cleanup waves 
    291325//      Killwaves/Z form_lns_SC,struct_lns_SC 
    292326         
    293         return (inten) 
     327        return (0) 
    294328End 
    295329 
     
    306340        make/O/T parameters_lns_SHS = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","perturbation parameter (0.1)","stickiness, tau","bkg (cm-1 sr-1)"} 
    307341        Edit parameters_lns_SHS,coef_lns_SHS 
    308         ywave_lns_SHS := LogNormalSphere_SHS(coef_lns_SHS,xwave_lns_SHS) 
     342         
     343        Variable/G root:g_lns_SHS 
     344        g_lns_SHS := LogNormalSphere_SHS(coef_lns_SHS,ywave_lns_SHS,xwave_lns_SHS) 
    309345        Display ywave_lns_SHS vs xwave_lns_SHS 
    310346        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    314350End 
    315351 
    316 Proc PlotSmearedLogNormalSphere_SHS()                                                            
    317         //no input parameters necessary, it MUST use the experimental q-values 
    318         // from the experimental data read in from an AVE/QSIG data file 
    319          
    320         // if no gQvals wave, data must not have been loaded => abort 
    321         if(ResolutionWavesMissing()) 
     352// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     353Proc PlotSmearedLogNormalSphere_SHS(str)                                                                 
     354        String str 
     355        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     356         
     357        // if any of the resolution waves are missing => abort 
     358        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    322359                Abort 
    323360        endif 
     361         
     362        SetDataFolder $("root:"+str) 
    324363         
    325364        // Setup parameter table for model function 
     
    330369        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    331370        // make extra copy of experimental q-values for easy plotting 
    332         Duplicate/O $gQvals smeared_lns_SHS,smeared_qvals                                
     371        Duplicate/O $(str+"_q") smeared_lns_SHS,smeared_qvals                            
    333372        SetScale d,0,0,"1/cm",smeared_lns_SHS                                                    
    334  
    335         smeared_lns_SHS := SmearedLogNormalSphere_SHS(smear_coef_lns_SHS,$gQvals)                
     373                                         
     374        Variable/G gs_lns_SHS=0 
     375        gs_lns_SHS := fSmearedLogNormalSphere_SHS(smear_coef_lns_SHS,smeared_lns_SHS,smeared_qvals)     //this wrapper fills the STRUCT 
     376         
    336377        Display smeared_lns_SHS vs smeared_qvals                                                                         
    337378        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    339380        Label left "Intensity (cm\\S-1\\M)" 
    340381        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    341 End 
    342  
    343 Function LogNormalSphere_SHS(w,x) : FitFunc 
    344         Wave w 
    345         Variable x 
     382         
     383        SetDataFolder root: 
     384End 
     385         
     386 
     387Function LogNormalSphere_SHS(w,yw,xw) : FitFunc 
     388        Wave w,yw,xw 
    346389         
    347390        Variable inten 
     
    372415         
    373416        //calculate each and combine 
    374         inten = LogNormalPolySphere(form_lns_SHS,x) 
    375         inten *= StickyHS_Struct(struct_lns_SHS,x) 
    376         inten *= w[0] 
    377         inten += w[7] 
     417        Duplicate/O xw tmp_lns_SHS_PQ,tmp_lns_SHS_SQ 
     418        LogNormalPolySphere(form_lns_SHS,tmp_lns_SHS_PQ,xw) 
     419        StickyHS_Struct(struct_lns_SHS,tmp_lns_SHS_SQ,xw) 
     420        yw = tmp_lns_SHS_PQ * tmp_lns_SHS_SQ 
     421        yw *= w[0] 
     422        yw += w[7] 
    378423         
    379424        //cleanup waves 
    380425//      Killwaves/Z form_lns_SHS,struct_lns_SHS 
    381426         
    382         return (inten) 
     427        return (0) 
    383428End 
    384429 
    385430 
    386431// this is all there is to the smeared calculation! 
    387 Function SmearedLogNormalSphere_HS(w,x) :FitFunc 
    388         Wave w 
    389         Variable x 
    390          
    391         Variable ans 
    392         SVAR sq = gSig_Q 
    393         SVAR qb = gQ_bar 
    394         SVAR sh = gShadow 
    395         SVAR gQ = gQVals 
    396          
    397         //the name of your unsmeared model is the first argument 
    398         ans = Smear_Model_20(LogNormalSphere_HS,$sq,$qb,$sh,$gQ,w,x) 
    399  
    400         return(ans) 
     432Function SmearedLogNormalSphere_HS(s) : FitFunc 
     433        Struct ResSmearAAOStruct &s 
     434 
     435//      the name of your unsmeared model (AAO) is the first argument 
     436        s.yW = Smear_Model_20(LogNormalSphere_HS,s.coefW,s.xW,s.resW) 
     437 
     438        return(0) 
    401439End 
    402440 
    403441// this is all there is to the smeared calculation! 
    404 Function SmearedLogNormalSphere_SW(w,x) :FitFunc 
    405         Wave w 
    406         Variable x 
    407          
    408         Variable ans 
    409         SVAR sq = gSig_Q 
    410         SVAR qb = gQ_bar 
    411         SVAR sh = gShadow 
    412         SVAR gQ = gQVals 
    413          
    414         //the name of your unsmeared model is the first argument 
    415         ans = Smear_Model_20(LogNormalSphere_SW,$sq,$qb,$sh,$gQ,w,x) 
    416  
    417         return(ans) 
     442Function SmearedLogNormalSphere_SW(s) : FitFunc 
     443        Struct ResSmearAAOStruct &s 
     444 
     445//      the name of your unsmeared model (AAO) is the first argument 
     446        s.yW = Smear_Model_20(LogNormalSphere_SW,s.coefW,s.xW,s.resW) 
     447 
     448        return(0) 
    418449End 
    419450 
    420451// this is all there is to the smeared calculation! 
    421 Function SmearedLogNormalSphere_SC(w,x) :FitFunc 
    422         Wave w 
    423         Variable x 
    424          
    425         Variable ans 
    426         SVAR sq = gSig_Q 
    427         SVAR qb = gQ_bar 
    428         SVAR sh = gShadow 
    429         SVAR gQ = gQVals 
    430          
    431         //the name of your unsmeared model is the first argument 
    432         ans = Smear_Model_20(LogNormalSphere_SC,$sq,$qb,$sh,$gQ,w,x) 
    433  
    434         return(ans) 
     452Function SmearedLogNormalSphere_SC(s) : FitFunc 
     453        Struct ResSmearAAOStruct &s 
     454 
     455//      the name of your unsmeared model (AAO) is the first argument 
     456        s.yW = Smear_Model_20(LogNormalSphere_SC,s.coefW,s.xW,s.resW) 
     457 
     458        return(0) 
    435459End 
    436460 
    437461// this is all there is to the smeared calculation! 
    438 Function SmearedLogNormalSphere_SHS(w,x) :FitFunc 
    439         Wave w 
    440         Variable x 
    441          
    442         Variable ans 
    443         SVAR sq = gSig_Q 
    444         SVAR qb = gQ_bar 
    445         SVAR sh = gShadow 
    446         SVAR gQ = gQVals 
    447          
    448         //the name of your unsmeared model is the first argument 
    449         ans = Smear_Model_20(LogNormalSphere_SHS,$sq,$qb,$sh,$gQ,w,x) 
    450  
    451         return(ans) 
    452 End 
     462Function SmearedLogNormalSphere_SHS(s) : FitFunc 
     463        Struct ResSmearAAOStruct &s 
     464 
     465//      the name of your unsmeared model (AAO) is the first argument 
     466        s.yW = Smear_Model_20(LogNormalSphere_SHS,s.coefW,s.xW,s.resW) 
     467 
     468        return(0) 
     469End 
     470 
     471//wrapper to calculate the smeared model as an AAO-Struct 
     472// fills the struct and calls the ususal function with the STRUCT parameter 
     473// 
     474// used only for the dependency, not for fitting 
     475// 
     476Function fSmearedLogNormalSphere_HS(coefW,yW,xW) 
     477        Wave coefW,yW,xW 
     478         
     479        String str = getWavesDataFolder(yW,0) 
     480        String DF="root:"+str+":" 
     481         
     482        WAVE resW = $(DF+str+"_res") 
     483         
     484        STRUCT ResSmearAAOStruct fs 
     485        WAVE fs.coefW = coefW    
     486        WAVE fs.yW = yW 
     487        WAVE fs.xW = xW 
     488        WAVE fs.resW = resW 
     489         
     490        Variable err 
     491        err = SmearedLogNormalSphere_HS(fs) 
     492         
     493        return (0) 
     494End 
     495 
     496//wrapper to calculate the smeared model as an AAO-Struct 
     497// fills the struct and calls the ususal function with the STRUCT parameter 
     498// 
     499// used only for the dependency, not for fitting 
     500// 
     501Function fSmearedLogNormalSphere_SW(coefW,yW,xW) 
     502        Wave coefW,yW,xW 
     503         
     504        String str = getWavesDataFolder(yW,0) 
     505        String DF="root:"+str+":" 
     506         
     507        WAVE resW = $(DF+str+"_res") 
     508         
     509        STRUCT ResSmearAAOStruct fs 
     510        WAVE fs.coefW = coefW    
     511        WAVE fs.yW = yW 
     512        WAVE fs.xW = xW 
     513        WAVE fs.resW = resW 
     514         
     515        Variable err 
     516        err = SmearedLogNormalSphere_SW(fs) 
     517         
     518        return (0) 
     519End 
     520 
     521//wrapper to calculate the smeared model as an AAO-Struct 
     522// fills the struct and calls the ususal function with the STRUCT parameter 
     523// 
     524// used only for the dependency, not for fitting 
     525// 
     526Function fSmearedLogNormalSphere_SC(coefW,yW,xW) 
     527        Wave coefW,yW,xW 
     528         
     529        String str = getWavesDataFolder(yW,0) 
     530        String DF="root:"+str+":" 
     531         
     532        WAVE resW = $(DF+str+"_res") 
     533         
     534        STRUCT ResSmearAAOStruct fs 
     535        WAVE fs.coefW = coefW    
     536        WAVE fs.yW = yW 
     537        WAVE fs.xW = xW 
     538        WAVE fs.resW = resW 
     539         
     540        Variable err 
     541        err = SmearedLogNormalSphere_SC(fs) 
     542         
     543        return (0) 
     544End 
     545 
     546//wrapper to calculate the smeared model as an AAO-Struct 
     547// fills the struct and calls the ususal function with the STRUCT parameter 
     548// 
     549// used only for the dependency, not for fitting 
     550// 
     551Function fSmearedLogNormalSphere_SHS(coefW,yW,xW) 
     552        Wave coefW,yW,xW 
     553         
     554        String str = getWavesDataFolder(yW,0) 
     555        String DF="root:"+str+":" 
     556         
     557        WAVE resW = $(DF+str+"_res") 
     558         
     559        STRUCT ResSmearAAOStruct fs 
     560        WAVE fs.coefW = coefW    
     561        WAVE fs.yW = yW 
     562        WAVE fs.xW = xW 
     563        WAVE fs.resW = resW 
     564         
     565        Variable err 
     566        err = SmearedLogNormalSphere_SHS(fs) 
     567         
     568        return (0) 
     569End 
     570 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/LogNormalSphere.ipf

    r127 r128  
    1919        make/O/T parameters_lns = {"Volume Fraction (scale)","exp(mu)=median Radius (A)","sigma","SLD sphere (A-2)","SLD solvent (A-2)","bkg (cm-1 sr-1)"} 
    2020        Edit parameters_lns,coef_lns 
    21         ywave_lns := LogNormalPolySphere(coef_lns,xwave_lns) 
     21         
     22        Variable/G root:g_lns 
     23        g_lns := LogNormalPolySphere(coef_lns,ywave_lns,xwave_lns) 
    2224        Display ywave_lns vs xwave_lns 
    2325        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    2729End 
    2830 
    29 Proc PlotSmearLogNormPolySphere()                                                                
    30         //no input parameters necessary, it MUST use the experimental q-values 
    31         // from the experimental data read in from an AVE/QSIG data file 
    32          
    33         // if no gQvals wave, data must not have been loaded => abort 
    34         if(ResolutionWavesMissing()) 
     31// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     32Proc PlotSmearLogNormPolySphere(str)                                                             
     33        String str 
     34        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     35         
     36        // if any of the resolution waves are missing => abort 
     37        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    3538                Abort 
    3639        endif 
     40         
     41        SetDataFolder $("root:"+str) 
    3742         
    3843        // Setup parameter table for model function 
     
    4348        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    4449        // make extra copy of experimental q-values for easy plotting 
    45         Duplicate/O $gQvals smeared_lns,smeared_qvals                            
     50        Duplicate/O $(str+"_q") smeared_lns,smeared_qvals                                
    4651        SetScale d,0,0,"1/cm",smeared_lns                                                        
    47  
    48         smeared_lns := SmearLogNormSphere(smear_coef_lns,$gQvals)                
     52                                         
     53        Variable/G gs_lns=0 
     54        gs_lns := fSmearLogNormSphere(smear_coef_lns,smeared_lns,smeared_qvals) //this wrapper fills the STRUCT 
     55         
    4956        Display smeared_lns vs smeared_qvals                                                                     
    5057        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    5259        Label left "Intensity (cm\\S-1\\M)" 
    5360        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
     61         
     62        SetDataFolder root: 
     63End 
     64 
     65 
     66 
     67 
     68//AAO version, uses XOP if available 
     69// simply calls the original single point calculation with 
     70// a wave assignment (this will behave nicely if given point ranges) 
     71Function LogNormalPolySphere(cw,yw,xw) : FitFunc 
     72        Wave cw,yw,xw 
     73         
     74#if exists("LogNormalPolySphereX") 
     75        yw = LogNormalPolySphereX(cw,xw) 
     76#else 
     77        yw = fLogNormalPolySphere(cw,xw) 
     78#endif 
     79        return(0) 
    5480End 
    5581 
     
    5985// 76 points is slower, but reccommended to remove high-q oscillations 
    6086// 
    61 Function LogNormalPolySphere(w,x): FitFunc 
     87Function fLogNormalPolySphere(w,x): FitFunc 
    6288        wave w 
    6389        variable x 
     
    127153         
    128154        summ = 0.0              // initialize integral 
     155        Make/O/N=1 tmp_w 
    129156        for(ii=0;ii<nord;ii+=1) 
    130157                // calculate Gauss points on integration interval (r-value for evaluation) 
     
    132159                sphere_temp[1] = zi 
    133160                // calculate sphere scattering 
    134                 yy = gauWt[ii] *  LogNormal_distr(sig,mu,zi) * SphereForm(sphere_temp,x) 
     161                SphereForm(sphere_temp,tmp_w,x)                 //AAO calculation, one point wave 
     162                yy = gauWt[ii] *  LogNormal_distr(sig,mu,zi) * tmp_w[0] 
    135163                yy *= 4*pi/3*zi*zi*zi           //un-normalize by current sphere volume 
    136164                 
     
    151179End 
    152180 
     181//wrapper to calculate the smeared model as an AAO-Struct 
     182// fills the struct and calls the ususal function with the STRUCT parameter 
     183// 
     184// used only for the dependency, not for fitting 
     185// 
     186Function fSmearLogNormSphere(coefW,yW,xW) 
     187        Wave coefW,yW,xW 
     188         
     189        String str = getWavesDataFolder(yW,0) 
     190        String DF="root:"+str+":" 
     191         
     192        WAVE resW = $(DF+str+"_res") 
     193         
     194        STRUCT ResSmearAAOStruct fs 
     195        WAVE fs.coefW = coefW    
     196        WAVE fs.yW = yW 
     197        WAVE fs.xW = xW 
     198        WAVE fs.resW = resW 
     199         
     200        Variable err 
     201        err = SmearLogNormSphere(fs) 
     202         
     203        return (0) 
     204End 
     205 
    153206// this is all there is to the smeared calculation! 
    154 Function SmearLogNormSphere(w,x) :FitFunc 
    155         Wave w 
    156         Variable x 
    157          
    158         Variable ans 
    159         SVAR sq = gSig_Q 
    160         SVAR qb = gQ_bar 
    161         SVAR sh = gShadow 
    162         SVAR gQ = gQVals 
    163          
    164         //the name of your unsmeared model is the first argument 
    165         ans = Smear_Model_20(LogNormalPolySphere,$sq,$qb,$sh,$gQ,w,x) 
    166  
    167         return(ans) 
    168 End 
     207Function SmearLogNormSphere(s) :FitFunc 
     208        Struct ResSmearAAOStruct &s 
     209 
     210//      the name of your unsmeared model (AAO) is the first argument 
     211        s.yW = Smear_Model_20(LogNormalPolySphere,s.coefW,s.xW,s.resW) 
     212 
     213        return(0) 
     214End 
     215         
     216 
    169217 
    170218// normalization is correct, using 3rd moment of lognormal distribution 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/MultiShell.ipf

    r127 r128  
    2222        make/O/T parameters_mss = {"scale","core radius (A)","shell thickness (A)","water thickness","core & solvent SLD (A-2)","Shell SLD (A-2)","number of water/shell pairs","bkg (cm-1)"} 
    2323        Edit/K=1 parameters_mss,coef_mss 
    24         ywave_mss := MultiShellForm(coef_mss,xwave_mss) 
     24         
     25        Variable/G root:g_mss 
     26        g_mss := MultiShellForm(coef_mss,ywave_mss,xwave_mss) 
    2527        Display/K=1 ywave_mss vs xwave_mss 
    2628        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    3032End 
    3133 
    32 Proc PlotSmearedMultiShell()                                                             
    33         //no input parameters necessary, it MUST use the experimental q-values 
    34         // from the experimental data read in from an AVE/QSIG data file 
     34// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     35Proc PlotSmearedMultiShell(str)                                                          
     36        String str 
     37        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
    3538         
    36         // if no gQvals wave, data must not have been loaded => abort 
    37         if(Exists("gQvals") != 2)               // 2 = string or numeric variable exists 
    38                 Abort "6-column QSIG data not loaded. Use LoadQSIGData macro" 
    39         else 
    40                 if(WaveExists($gQvals) ==0)     //wave ref does not exist 
    41                         Abort "6-column QSIG waves are missing. Re-load with LoadQSIGData macro" 
    42                 endif 
     39        // if any of the resolution waves are missing => abort 
     40        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
     41                Abort 
    4342        endif 
     43         
     44        SetDataFolder $("root:"+str) 
    4445         
    4546        // Setup parameter table for model function 
     
    5051        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    5152        // make extra copy of experimental q-values for easy plotting 
    52         Duplicate/O $gQvals smeared_mss,smeared_qvals                            
     53        Duplicate/O $(str+"_q") smeared_mss,smeared_qvals                                
    5354        SetScale d,0,0,"1/cm",smeared_mss                                                        
    54  
    55         smeared_mss := SmearedMultiShell(smear_coef_mss,$gQvals)                 
     55                                         
     56        Variable/G gs_mss=0 
     57        gs_mss := fSmearedMultiShell(smear_coef_mss,smeared_mss,smeared_qvals)  //this wrapper fills the STRUCT 
     58         
    5659        Display/K=1 smeared_mss vs smeared_qvals                                                                         
    5760        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    5962        Label left "Intensity (cm\\S-1\\M)" 
    6063        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
     64         
     65        SetDataFolder root: 
    6166End 
    6267 
    63 Function MultiShellForm(w,x) :FitFunc 
     68 
     69 
     70 
     71//AAO version, uses XOP if available 
     72// simply calls the original single point calculation with 
     73// a wave assignment (this will behave nicely if given point ranges) 
     74Function MultiShellForm(cw,yw,xw) : FitFunc 
     75        Wave cw,yw,xw 
     76         
     77#if exists("MultiShellFormX") 
     78        yw = MultiShellFormX(cw,xw) 
     79#else 
     80        yw = fMultiShellForm(cw,xw) 
     81#endif 
     82        return(0) 
     83End 
     84 
     85Function fMultiShellForm(w,x) :FitFunc 
    6486        Wave w 
    6587        Variable x 
     
    136158//End 
    137159 
     160//wrapper to calculate the smeared model as an AAO-Struct 
     161// fills the struct and calls the ususal function with the STRUCT parameter 
     162// 
     163// used only for the dependency, not for fitting 
     164// 
     165Function fSmearedMultiShell(coefW,yW,xW) 
     166        Wave coefW,yW,xW 
     167         
     168        String str = getWavesDataFolder(yW,0) 
     169        String DF="root:"+str+":" 
     170         
     171        WAVE resW = $(DF+str+"_res") 
     172         
     173        STRUCT ResSmearAAOStruct fs 
     174        WAVE fs.coefW = coefW    
     175        WAVE fs.yW = yW 
     176        WAVE fs.xW = xW 
     177        WAVE fs.resW = resW 
     178         
     179        Variable err 
     180        err = SmearedMultiShell(fs) 
     181         
     182        return (0) 
     183End 
     184 
    138185// this is all there is to the smeared calculation! 
    139 Function SmearedMultiShell(w,x) :FitFunc 
    140         Wave w 
    141         Variable x 
     186Function SmearedMultiShell(s) :FitFunc 
     187        Struct ResSmearAAOStruct &s 
     188 
     189//      the name of your unsmeared model (AAO) is the first argument 
     190        s.yW = Smear_Model_20(MultiShellForm,s.coefW,s.xW,s.resW) 
     191 
     192        return(0) 
     193End 
    142194         
    143         Variable ans 
    144         SVAR sq = gSig_Q 
    145         SVAR qb = gQ_bar 
    146         SVAR sh = gShadow 
    147         SVAR gQ = gQVals 
    148          
    149         //the name of your unsmeared model is the first argument 
    150         ans = Smear_Model_76(MultiShellForm,$sq,$qb,$sh,$gQ,w,x) 
    151  
    152         return(ans) 
    153 End 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/Parallelepiped.ipf

    r127 r128  
    3838        make/o/t parameters_Parallelepiped = {"Scale Factor","Shortest Edge A ()","B ()","Longest Edge C ()","Contrast (^-2)","Incoherent Bgd (cm-1)"}      //CH#3 
    3939        Edit parameters_Parallelepiped, coef_Parallelepiped 
    40         ywave_Parallelepiped  := Parallelepiped(coef_Parallelepiped, xwave_Parallelepiped) 
     40         
     41        Variable/G root:g_Parallelepiped 
     42        g_Parallelepiped := Parallelepiped(coef_Parallelepiped,ywave_Parallelepiped, xwave_Parallelepiped) 
    4143        Display ywave_Parallelepiped vs xwave_Parallelepiped 
    4244        ModifyGraph marker=29, msize=2, mode=4 
     
    4850End 
    4951 
    50 // 
    51 //this macro sets up all the necessary parameters and waves that are 
    52 //needed to calculate the  smeared model function. 
    53 // 
    54 //no input parameters are necessary, it MUST use the experimental q-values 
    55 // from the experimental data read in from an AVE/QSIG data file 
    56 //////////////////////////////////////////////////// 
    57 Proc PlotSmeared_Parallelepiped()                                                               //Parallelepiped 
    58         // if no gQvals wave, data must not have been loaded => abort 
    59         if(ResolutionWavesMissing()) 
     52// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     53Proc PlotSmeared_Parallelepiped(str)                                                             
     54        String str 
     55        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     56         
     57        // if any of the resolution waves are missing => abort 
     58        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    6059                Abort 
    6160        endif 
    6261         
     62        SetDataFolder $("root:"+str) 
    6363         
    6464        // Setup parameter table for model function 
     
    6969        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    7070        // make extra copy of experimental q-values for easy plotting 
    71         Duplicate/O $gQvals smeared_Parallelepiped,smeared_qvals                                // 
     71        Duplicate/O $(str+"_q") smeared_Parallelepiped,smeared_qvals                            // 
    7272        SetScale d,0,0,"1/cm",smeared_Parallelepiped                                                    // 
    73  
    74         smeared_Parallelepiped := Parallelepiped_Smeared(smear_coef_Parallelepiped,$gQvals)             // SMEARED function name 
     73                                         
     74        Variable/G gs_Parallelepiped=0 
     75        gs_Parallelepiped := fParallelepiped_Smeared(smear_coef_Parallelepiped,smeared_Parallelepiped,smeared_qvals)    //this wrapper fills the STRUCT 
     76         
    7577        Display smeared_Parallelepiped vs smeared_qvals                                                                 // 
    7678        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    7880        Label left "I(q) (cm\\S-1\\M)" 
    7981        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    80 End     // end macro  
     82         
     83        SetDataFolder root: 
     84End 
     85 
     86 
     87 
     88//AAO version, uses XOP if available 
     89// simply calls the original single point calculation with 
     90// a wave assignment (this will behave nicely if given point ranges) 
     91Function Parallelepiped(cw,yw,xw) : FitFunc 
     92        Wave cw,yw,xw 
     93         
     94#if exists("ParallelepipedX") 
     95        yw = ParallelepipedX(cw,xw) 
     96#else 
     97        yw = fParallelepiped(cw,xw) 
     98#endif 
     99        return(0) 
     100End 
    81101 
    82102// calculates the form factor of a rectangular solid 
    83103// - a double integral - choose points wisely 
    84104// 
    85 Function Parallelepiped(w,x) : FitFunc 
     105Function fParallelepiped(w,x) : FitFunc 
    86106        Wave w 
    87107        Variable x 
     
    178198End 
    179199 
     200//wrapper to calculate the smeared model as an AAO-Struct 
     201// fills the struct and calls the ususal function with the STRUCT parameter 
     202// 
     203// used only for the dependency, not for fitting 
     204// 
     205Function fParallelepiped_Smeared(coefW,yW,xW) 
     206        Wave coefW,yW,xW 
     207         
     208        String str = getWavesDataFolder(yW,0) 
     209        String DF="root:"+str+":" 
     210         
     211        WAVE resW = $(DF+str+"_res") 
     212         
     213        STRUCT ResSmearAAOStruct fs 
     214        WAVE fs.coefW = coefW    
     215        WAVE fs.yW = yW 
     216        WAVE fs.xW = xW 
     217        WAVE fs.resW = resW 
     218         
     219        Variable err 
     220        err = Parallelepiped_Smeared(fs) 
     221         
     222        return (0) 
     223End 
    180224 
    181225// this is all there is to the smeared calculation! 
    182 Function Parallelepiped_Smeared(w,x) :FitFunc 
    183         Wave w 
    184         Variable x 
    185          
    186         Variable ans 
    187         SVAR sq = gSig_Q 
    188         SVAR qb = gQ_bar 
    189         SVAR sh = gShadow 
    190         SVAR gQ = gQVals 
    191          
    192         //the name of your unsmeared model is the first argument 
    193         ans = Smear_Model_20(Parallelepiped,$sq,$qb,$sh,$gQ,w,x) 
    194  
    195         return(ans) 
    196 End 
     226Function Parallelepiped_Smeared(s) :FitFunc 
     227        Struct ResSmearAAOStruct &s 
     228 
     229//      the name of your unsmeared model (AAO) is the first argument 
     230        s.yW = Smear_Model_20(Parallelepiped,s.coefW,s.xW,s.resW) 
     231 
     232        return(0) 
     233End 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/PolyCoreShellCylinder.ipf

    r127 r128  
    3333        ModifyTable width(parameters_CSCpr)=162 
    3434         
    35         ywave_CSCpr:= PolyCoShCylinder(coef_CSCpr,xwave_CSCpr) 
     35        Variable/G root:g_CSCpr 
     36        g_CSCpr := PolyCoShCylinder(coef_CSCpr,ywave_CSCpr,xwave_CSCpr) 
    3637        Display ywave_CSCpr vs xwave_CSCpr 
    3738        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    4142End 
    4243 
    43  
    44 Proc PlotSmearedPolyCoShCylinder()                                                       
    45         //no input parameters necessary, it MUST use the experimental q-values 
    46         // from the experimental data read in from an AVE/QSIG data file 
    47          
    48         // if no gQvals wave, data must not have been loaded => abort 
    49         if(ResolutionWavesMissing()) 
     44// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     45Proc PlotSmearedPolyCoShCylinder(str)                                                            
     46        String str 
     47        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     48         
     49        // if any of the resolution waves are missing => abort 
     50        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    5051                Abort 
    5152        endif 
     53         
     54        SetDataFolder $("root:"+str) 
    5255         
    5356        // Setup parameter table for model function 
     
    5962        // make extra copy of experimental q-values for easy plotting 
    6063         
    61         Duplicate/O $gQvals smeared_CSCpr,smeared_qvals                          
     64        Duplicate/O $(str+"_q") smeared_CSCpr,smeared_qvals                              
    6265        SetScale d,0,0,"1/cm",smeared_CSCpr                                                      
    63  
    64         smeared_CSCpr := SmearedPolyCoShCylinder(smear_coef_CSCpr,$gQvals)               
     66                                         
     67        Variable/G gs_CSCpr=0 
     68        gs_CSCpr := fSmearedPolyCoShCylinder(smear_coef_CSCpr,smeared_CSCpr,smeared_qvals)      //this wrapper fills the STRUCT 
     69         
    6570        Display smeared_CSCpr vs smeared_qvals                                                                   
    6671        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    6873        Label left "Intensity (cm\\S-1\\M)" 
    6974        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
     75         
     76        SetDataFolder root: 
     77End 
     78         
     79 
     80 
     81//AAO version, uses XOP if available 
     82// simply calls the original single point calculation with 
     83// a wave assignment (this will behave nicely if given point ranges) 
     84Function PolyCoShCylinder(cw,yw,xw) : FitFunc 
     85        Wave cw,yw,xw 
     86         
     87#if exists("PolyCoShCylinderX") 
     88        yw = PolyCoShCylinderX(cw,xw) 
     89#else 
     90        yw = fPolyCoShCylinder(cw,xw) 
     91#endif 
     92        return(0) 
    7093End 
    7194 
     
    7598/////////////////////////////////////////////////////////////////////////////// 
    7699 
    77 Function PolyCoShCylinder(w,x) : FitFunc 
     100Function fPolyCoShCylinder(w,x) : FitFunc 
    78101        Wave w 
    79102        Variable x 
     
    278301End     //Function CScyl() 
    279302 
     303//wrapper to calculate the smeared model as an AAO-Struct 
     304// fills the struct and calls the ususal function with the STRUCT parameter 
     305// 
     306// used only for the dependency, not for fitting 
     307// 
     308Function fSmearedPolyCoShCylinder(coefW,yW,xW) 
     309        Wave coefW,yW,xW 
     310         
     311        String str = getWavesDataFolder(yW,0) 
     312        String DF="root:"+str+":" 
     313         
     314        WAVE resW = $(DF+str+"_res") 
     315         
     316        STRUCT ResSmearAAOStruct fs 
     317        WAVE fs.coefW = coefW    
     318        WAVE fs.yW = yW 
     319        WAVE fs.xW = xW 
     320        WAVE fs.resW = resW 
     321         
     322        Variable err 
     323        err = SmearedPolyCoShCylinder(fs) 
     324         
     325        return (0) 
     326End 
     327 
    280328// this is all there is to the smeared calculation! 
    281 Function SmearedPolyCoShCylinder(w,x) :FitFunc 
    282         Wave w 
    283         Variable x 
    284          
    285         Variable ans 
    286         SVAR sq = gSig_Q 
    287         SVAR qb = gQ_bar 
    288         SVAR sh = gShadow 
    289         SVAR gQ = gQVals 
    290          
    291         //the name of your unsmeared model is the first argument 
    292         ans = Smear_Model_20(PolyCoShCylinder,$sq,$qb,$sh,$gQ,w,x) 
    293  
    294         return(ans) 
    295 End 
    296  
    297  
     329Function SmearedPolyCoShCylinder(s) :FitFunc 
     330        Struct ResSmearAAOStruct &s 
     331 
     332//      the name of your unsmeared model (AAO) is the first argument 
     333        s.yW = Smear_Model_20(PolyCoShCylinder,s.coefW,s.xW,s.resW) 
     334 
     335        return(0) 
     336End 
     337         
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/SchulzSpheres.ipf

    r127 r128  
    2020        make/O/T parameters_sch = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","bkg (cm-1 sr-1)"} 
    2121        Edit parameters_sch,coef_sch 
    22         ywave_sch := SchulzSpheres(coef_sch,xwave_sch) 
     22         
     23        Variable/G root:g_sch 
     24        g_sch := SchulzSpheres(coef_sch,ywave_sch,xwave_sch) 
    2325        Display ywave_sch vs xwave_sch 
    2426        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    2830End 
    2931 
    30 Proc PlotSmearedSchulzPolySpheres()                                                              
    31         //no input parameters necessary, it MUST use the experimental q-values 
    32         // from the experimental data read in from an AVE/QSIG data file 
    33          
    34         // if no gQvals wave, data must not have been loaded => abort 
    35         if(ResolutionWavesMissing()) 
     32 
     33// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     34Proc PlotSmearedSchulzPolySpheres(str)                                                           
     35        String str 
     36        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     37         
     38        // if any of the resolution waves are missing => abort 
     39        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    3640                Abort 
    3741        endif 
     42         
     43        SetDataFolder $("root:"+str) 
    3844         
    3945        // Setup parameter table for model function 
     
    4450        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    4551        // make extra copy of experimental q-values for easy plotting 
    46         Duplicate/O $gQvals smeared_sch,smeared_qvals                            
     52        Duplicate/O $(str+"_q") smeared_sch,smeared_qvals                                
    4753        SetScale d,0,0,"1/cm",smeared_sch                                                        
    48  
    49         smeared_sch := SmearedSchulzSpheres(smear_coef_sch,$gQvals)              
     54                                         
     55        Variable/G gs_sch=0 
     56        gs_sch := fSmearedSchulzSpheres(smear_coef_sch,smeared_sch,smeared_qvals)       //this wrapper fills the STRUCT 
     57         
    5058        Display smeared_sch vs smeared_qvals                                                                     
    5159        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    5361        Label left "Intensity (cm\\S-1\\M)" 
    5462        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    55 End 
     63         
     64        SetDataFolder root: 
     65End 
     66         
    5667 
    5768 
     
    6576End 
    6677 
     78 
     79//AAO version, uses XOP if available 
     80// simply calls the original single point calculation with 
     81// a wave assignment (this will behave nicely if given point ranges) 
     82Function SchulzSpheres(cw,yw,xw) : FitFunc 
     83        Wave cw,yw,xw 
     84         
     85#if exists("SchulzSpheresX") 
     86        yw = SchulzSpheresX(cw,xw) 
     87#else 
     88        yw = fSchulzSpheres(cw,xw) 
     89#endif 
     90        return(0) 
     91End 
     92 
    6793//use the analytic formula from Kotlarchyk & Chen, JCP 79 (1983) 2461 
    6894//equations 23-30 
     
    7096// need to calculate in terms of logarithms to avoid numerical errors 
    7197// 
    72 Function SchulzSpheres(w,x) : FitFunc 
     98Function fSchulzSpheres(w,x) : FitFunc 
    7399        Wave w 
    74100        Variable x 
     
    159185End 
    160186 
    161  
     187//wrapper to calculate the smeared model as an AAO-Struct 
     188// fills the struct and calls the ususal function with the STRUCT parameter 
     189// 
     190// used only for the dependency, not for fitting 
     191// 
     192Function fSmearedSchulzSpheres(coefW,yW,xW) 
     193        Wave coefW,yW,xW 
     194         
     195        String str = getWavesDataFolder(yW,0) 
     196        String DF="root:"+str+":" 
     197         
     198        WAVE resW = $(DF+str+"_res") 
     199         
     200        STRUCT ResSmearAAOStruct fs 
     201        WAVE fs.coefW = coefW    
     202        WAVE fs.yW = yW 
     203        WAVE fs.xW = xW 
     204        WAVE fs.resW = resW 
     205         
     206        Variable err 
     207        err = SmearedSchulzSpheres(fs) 
     208         
     209        return (0) 
     210End 
    162211 
    163212// this is all there is to the smeared calculation! 
    164 Function SmearedSchulzSpheres(w,x) :FitFunc 
    165         Wave w 
    166         Variable x 
    167          
    168         Variable ans 
    169         SVAR sq = gSig_Q 
    170         SVAR qb = gQ_bar 
    171         SVAR sh = gShadow 
    172         SVAR gQ = gQVals 
    173          
    174         //the name of your unsmeared model is the first argument 
    175         ans = Smear_Model_20(SchulzSpheres,$sq,$qb,$sh,$gQ,w,x) 
    176  
    177         return(ans) 
     213Function SmearedSchulzSpheres(s) :FitFunc 
     214        Struct ResSmearAAOStruct &s 
     215 
     216//      the name of your unsmeared model (AAO) is the first argument 
     217        s.yW = Smear_Model_20(SchulzSpheres,s.coefW,s.xW,s.resW) 
     218 
     219        return(0) 
    178220End 
    179221 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/SchulzSpheres_and_Struct.ipf

    r127 r128  
    2323        make/O/T parameters_sch_HS = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","bkg (cm-1 sr-1)"} 
    2424        Edit parameters_sch_HS,coef_sch_HS 
    25         ywave_sch_HS := SchulzSpheres_HS(coef_sch_HS,xwave_sch_HS) 
     25         
     26        Variable/G root:g_sch_HS 
     27        g_sch_HS := SchulzSpheres_HS(coef_sch_HS,ywave_sch_HS,xwave_sch_HS) 
    2628        Display ywave_sch_HS vs xwave_sch_HS 
    2729        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    3133End 
    3234 
    33 Proc PlotSmearedSchulzSpheres_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()) 
     35// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     36Proc PlotSmearedSchulzSpheres_HS(str)                                                            
     37        String str 
     38        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     39         
     40        // if any of the resolution waves are missing => abort 
     41        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    3942                Abort 
    4043        endif 
     44         
     45        SetDataFolder $("root:"+str) 
    4146         
    4247        // Setup parameter table for model function 
     
    4752        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    4853        // make extra copy of experimental q-values for easy plotting 
    49         Duplicate/O $gQvals smeared_sch_HS,smeared_qvals                                 
     54        Duplicate/O $(str+"_q") smeared_sch_HS,smeared_qvals                             
    5055        SetScale d,0,0,"1/cm",smeared_sch_HS                                                     
    51  
    52         smeared_sch_HS := SmearedSchulzSpheres_HS(smear_coef_sch_HS,$gQvals)             
     56                                         
     57        Variable/G gs_sch_HS=0 
     58        gs_sch_HS := fSmearedSchulzSpheres_HS(smear_coef_sch_HS,smeared_sch_HS,smeared_qvals)   //this wrapper fills the STRUCT 
     59         
    5360        Display smeared_sch_HS vs smeared_qvals                                                                  
    5461        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    5663        Label left "Intensity (cm\\S-1\\M)" 
    5764        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    58 End 
    59  
    60 Function SchulzSpheres_HS(w,x) : FitFunc 
    61         Wave w 
    62         Variable x 
     65         
     66        SetDataFolder root: 
     67End 
     68         
     69 
     70 
     71Function SchulzSpheres_HS(w,yw,xw) : FitFunc 
     72        Wave w,yw,xw 
    6373         
    6474        Variable inten 
     
    8999         
    90100        //calculate each and combine 
    91         inten = SchulzSpheres(form_sch_HS,x) 
    92         inten *= HardSphereStruct(struct_sch_HS,x) 
    93         inten *= w[0] 
    94         inten += w[5] 
     101        Duplicate/O xw tmp_sch_HS_PQ,tmp_sch_HS_SQ 
     102        SchulzSpheres(form_sch_HS,tmp_sch_HS_PQ,xw) 
     103        HardSphereStruct(struct_sch_HS,tmp_sch_HS_SQ,xw) 
     104        yw = tmp_sch_HS_PQ * tmp_sch_HS_SQ 
     105        yw *= w[0] 
     106        yw += w[5] 
    95107         
    96108        //cleanup waves 
    97109//      Killwaves/Z form_sch_HS,struct_sch_HS 
    98110         
    99         return (inten) 
     111        return (0) 
    100112End 
    101113 
     
    112124        make/O/T parameters_sch_SW = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","well depth (kT)","well width (diam.)","bkg (cm-1 sr-1)"} 
    113125        Edit parameters_sch_SW,coef_sch_SW 
    114         ywave_sch_SW := SchulzSpheres_SW(coef_sch_SW,xwave_sch_SW) 
     126 
     127        Variable/G root:g_sch_SW 
     128        g_sch_SW := SchulzSpheres_SW(coef_sch_SW,ywave_sch_SW,xwave_sch_SW) 
    115129        Display ywave_sch_SW vs xwave_sch_SW 
    116130        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    120134End 
    121135 
    122 Proc PlotSmearedSchulzSpheres_SW()                                                               
    123         //no input parameters necessary, it MUST use the experimental q-values 
    124         // from the experimental data read in from an AVE/QSIG data file 
    125          
    126         // if no gQvals wave, data must not have been loaded => abort 
    127         if(ResolutionWavesMissing()) 
     136// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     137Proc PlotSmearedSchulzSpheres_SW(str)                                                            
     138        String str 
     139        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     140         
     141        // if any of the resolution waves are missing => abort 
     142        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    128143                Abort 
    129144        endif 
     145         
     146        SetDataFolder $("root:"+str) 
    130147         
    131148        // Setup parameter table for model function 
     
    136153        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    137154        // make extra copy of experimental q-values for easy plotting 
    138         Duplicate/O $gQvals smeared_sch_SW,smeared_qvals                                 
     155        Duplicate/O $(str+"_q") smeared_sch_SW,smeared_qvals                             
    139156        SetScale d,0,0,"1/cm",smeared_sch_SW                                                     
    140  
    141         smeared_sch_SW := SmearedSchulzSpheres_SW(smear_coef_sch_SW,$gQvals)             
     157                                         
     158        Variable/G gs_sch_SW=0 
     159        gs_sch_SW := fSmearedSchulzSpheres_SW(smear_coef_sch_SW,smeared_sch_SW,smeared_qvals)   //this wrapper fills the STRUCT 
     160         
    142161        Display smeared_sch_SW vs smeared_qvals                                                                  
    143162        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    145164        Label left "Intensity (cm\\S-1\\M)" 
    146165        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    147 End 
    148  
    149 Function SchulzSpheres_SW(w,x) : FitFunc 
    150         Wave w 
    151         Variable x 
     166         
     167        SetDataFolder root: 
     168End 
     169 
     170         
     171 
     172Function SchulzSpheres_SW(w,yw,xw) : FitFunc 
     173        Wave w,yw,xw 
    152174         
    153175        Variable inten 
     
    179201         
    180202        //calculate each and combine 
    181         inten = SchulzSpheres(form_sch_SW,x) 
    182         inten *= SquareWellStruct(struct_sch_SW,x) 
    183         inten *= w[0] 
    184         inten += w[7] 
     203        Duplicate/O xw tmp_sch_SW_PQ,tmp_sch_SW_SQ 
     204        SchulzSpheres(form_sch_SW,tmp_sch_SW_PQ,xw) 
     205        SquareWellStruct(struct_sch_SW,tmp_sch_SW_SQ,xw) 
     206        yw = tmp_sch_SW_PQ * tmp_sch_SW_SQ 
     207        yw *= w[0] 
     208        yw += w[7] 
    185209         
    186210        //cleanup waves 
    187211//      Killwaves/Z form_sch_SW,struct_sch_SW 
    188212         
    189         return (inten) 
     213        return (0) 
    190214End 
    191215 
     
    210234        make/O/T parameters_sch_SC = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","charge","movalent salt(M)","Temperature (K)","dielectric const","bkg (cm-1 sr-1)"} 
    211235        Edit parameters_sch_SC,coef_sch_SC 
    212         ywave_sch_SC := SchulzSpheres_SC(coef_sch_SC,xwave_sch_SC) 
     236         
     237        Variable/G root:g_sch_SC 
     238        g_sch_SC := SchulzSpheres_SC(coef_sch_SC,ywave_sch_SC,xwave_sch_SC) 
    213239        Display ywave_sch_SC vs xwave_sch_SC 
    214240        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    218244End 
    219245 
    220 Proc PlotSmearedSchulzSpheres_SC()                                                               
    221         //no input parameters necessary, it MUST use the experimental q-values 
    222         // from the experimental data read in from an AVE/QSIG data file 
    223          
    224         // if no gQvals wave, data must not have been loaded => abort 
    225         if(ResolutionWavesMissing()) 
     246// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     247Proc PlotSmearedSchulzSpheres_SC(str)                                                            
     248        String str 
     249        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     250         
     251        // if any of the resolution waves are missing => abort 
     252        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    226253                Abort 
    227254        endif 
    228  
     255         
     256        SetDataFolder $("root:"+str) 
     257         
    229258        if (DataFolderExists("root:HayPenMSA")) 
    230259                Make/O/D/N=17 root:HayPenMSA:gMSAWave 
     
    241270        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    242271        // make extra copy of experimental q-values for easy plotting 
    243         Duplicate/O $gQvals smeared_sch_SC,smeared_qvals                                 
     272        Duplicate/O $(str+"_q") smeared_sch_SC,smeared_qvals                             
    244273        SetScale d,0,0,"1/cm",smeared_sch_SC                                                     
    245  
    246         smeared_sch_SC := SmearedSchulzSpheres_SC(smear_coef_sch_SC,$gQvals)             
     274                                         
     275        Variable/G gs_sch_SC=0 
     276        gs_sch_SC := fSmearedSchulzSpheres_SC(smear_coef_sch_SC,smeared_sch_SC,smeared_qvals)   //this wrapper fills the STRUCT 
     277         
    247278        Display smeared_sch_SC vs smeared_qvals                                                                  
    248279        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    250281        Label left "Intensity (cm\\S-1\\M)" 
    251282        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    252 End 
    253  
    254 Function SchulzSpheres_SC(w,x) : FitFunc 
    255         Wave w 
    256         Variable x 
     283         
     284        SetDataFolder root: 
     285End 
     286 
     287 
     288Function SchulzSpheres_SC(w,yw,xw) : FitFunc 
     289        Wave w,yw,xw 
    257290         
    258291        Variable inten 
     
    286319         
    287320        //calculate each and combine 
    288         inten = SchulzSpheres(form_sch_SC,x) 
    289         inten *= HayterPenfoldMSA(struct_sch_SC,x) 
    290         inten *= w[0] 
    291         inten += w[9] 
     321        Duplicate/O xw tmp_sch_SC_PQ,tmp_sch_SC_SQ 
     322        SchulzSpheres(form_sch_SC,tmp_sch_SC_PQ,xw) 
     323        HayterPenfoldMSA(struct_sch_SC,tmp_sch_SC_SQ,xw) 
     324        yw = tmp_sch_SC_PQ *tmp_sch_SC_SQ 
     325        yw *= w[0] 
     326        yw += w[9] 
    292327         
    293328        //cleanup waves 
    294329//      Killwaves/Z form_sch_SC,struct_sch_SC 
    295330         
    296         return (inten) 
     331        return (0) 
    297332End 
    298333 
     
    309344        make/O/T parameters_sch_SHS = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","perturbation parameter (0.1)","stickiness, tau","bkg (cm-1 sr-1)"} 
    310345        Edit parameters_sch_SHS,coef_sch_SHS 
    311         ywave_sch_SHS := SchulzSpheres_SHS(coef_sch_SHS,xwave_sch_SHS) 
     346         
     347        Variable/G root:g_sch_SHS 
     348        g_sch_SHS := SchulzSpheres_SHS(coef_sch_SHS,ywave_sch_SHS,xwave_sch_SHS) 
    312349        Display ywave_sch_SHS vs xwave_sch_SHS 
    313350        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    317354End 
    318355 
    319 Proc PlotSmearedSchulzSpheres_SHS()                                                              
    320         //no input parameters necessary, it MUST use the experimental q-values 
    321         // from the experimental data read in from an AVE/QSIG data file 
    322          
    323         // if no gQvals wave, data must not have been loaded => abort 
    324         if(ResolutionWavesMissing()) 
     356// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     357Proc PlotSmearedSchulzSpheres_SHS(str)                                                           
     358        String str 
     359        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     360         
     361        // if any of the resolution waves are missing => abort 
     362        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    325363                Abort 
    326364        endif 
     365         
     366        SetDataFolder $("root:"+str) 
    327367         
    328368        // Setup parameter table for model function 
     
    333373        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    334374        // make extra copy of experimental q-values for easy plotting 
    335         Duplicate/O $gQvals smeared_sch_SHS,smeared_qvals                                
     375        Duplicate/O $(str+"_q") smeared_sch_SHS,smeared_qvals                            
    336376        SetScale d,0,0,"1/cm",smeared_sch_SHS                                                    
    337  
    338         smeared_sch_SHS := SmearedSchulzSpheres_SHS(smear_coef_sch_SHS,$gQvals)          
     377                                         
     378        Variable/G gs_sch_SHS=0 
     379        gs_sch_SHS := fSmearedSchulzSpheres_SHS(smear_coef_sch_SHS,smeared_sch_SHS,smeared_qvals)       //this wrapper fills the STRUCT 
     380         
    339381        Display smeared_sch_SHS vs smeared_qvals                                                                         
    340382        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    342384        Label left "Intensity (cm\\S-1\\M)" 
    343385        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    344 End 
    345  
    346 Function SchulzSpheres_SHS(w,x) : FitFunc 
    347         Wave w 
    348         Variable x 
     386         
     387        SetDataFolder root: 
     388End 
     389 
     390 
     391Function SchulzSpheres_SHS(w,yw,xw) : FitFunc 
     392        Wave w,yw,xw 
    349393         
    350394        Variable inten 
     
    376420         
    377421        //calculate each and combine 
    378         inten = SchulzSpheres(form_sch_SHS,x) 
    379         inten *= StickyHS_Struct(struct_sch_SHS,x) 
    380         inten *= w[0] 
    381         inten += w[7] 
     422        Duplicate/O xw tmp_sch_SHS_PQ,tmp_sch_SHS_SQ 
     423        SchulzSpheres(form_sch_SHS,tmp_sch_SHS_PQ,xw) 
     424        StickyHS_Struct(struct_sch_SHS,tmp_sch_SHS_PQ,xw) 
     425        yw = tmp_sch_SHS_PQ * tmp_sch_SHS_SQ 
     426        yw *= w[0] 
     427        yw += w[7] 
    382428         
    383429        //cleanup waves 
    384430//      Killwaves/Z form_sch_SHS,struct_sch_SHS 
    385431         
    386         return (inten) 
     432        return (0) 
    387433End 
    388434 
     
    390436 
    391437// this is all there is to the smeared calculation! 
    392 Function SmearedSchulzSpheres_HS(w,x) :FitFunc 
    393         Wave w 
    394         Variable x 
    395          
    396         Variable ans 
    397         SVAR sq = gSig_Q 
    398         SVAR qb = gQ_bar 
    399         SVAR sh = gShadow 
    400         SVAR gQ = gQVals 
    401          
    402         //the name of your unsmeared model is the first argument 
    403         ans = Smear_Model_20(SchulzSpheres_HS,$sq,$qb,$sh,$gQ,w,x) 
    404  
    405         return(ans) 
     438Function SmearedSchulzSpheres_HS(s) : FitFunc 
     439        Struct ResSmearAAOStruct &s 
     440 
     441//      the name of your unsmeared model (AAO) is the first argument 
     442        s.yW = Smear_Model_20(SchulzSpheres_HS,s.coefW,s.xW,s.resW) 
     443 
     444        return(0) 
    406445End 
    407446 
    408447// this is all there is to the smeared calculation! 
    409 Function SmearedSchulzSpheres_SW(w,x) :FitFunc 
    410         Wave w 
    411         Variable x 
    412          
    413         Variable ans 
    414         SVAR sq = gSig_Q 
    415         SVAR qb = gQ_bar 
    416         SVAR sh = gShadow 
    417         SVAR gQ = gQVals 
    418          
    419         //the name of your unsmeared model is the first argument 
    420         ans = Smear_Model_20(SchulzSpheres_SW,$sq,$qb,$sh,$gQ,w,x) 
    421  
    422         return(ans) 
     448Function SmearedSchulzSpheres_SW(s) : FitFunc 
     449        Struct ResSmearAAOStruct &s 
     450 
     451//      the name of your unsmeared model (AAO) is the first argument 
     452        s.yW = Smear_Model_20(SchulzSpheres_SW,s.coefW,s.xW,s.resW) 
     453 
     454        return(0) 
    423455End 
    424456 
    425457// this is all there is to the smeared calculation! 
    426 Function SmearedSchulzSpheres_SC(w,x) :FitFunc 
    427         Wave w 
    428         Variable x 
    429          
    430         Variable ans 
    431         SVAR sq = gSig_Q 
    432         SVAR qb = gQ_bar 
    433         SVAR sh = gShadow 
    434         SVAR gQ = gQVals 
    435          
    436         //the name of your unsmeared model is the first argument 
    437         ans = Smear_Model_20(SchulzSpheres_SC,$sq,$qb,$sh,$gQ,w,x) 
    438  
    439         return(ans) 
     458Function SmearedSchulzSpheres_SC(s) : FitFunc 
     459        Struct ResSmearAAOStruct &s 
     460 
     461//      the name of your unsmeared model (AAO) is the first argument 
     462        s.yW = Smear_Model_20(SchulzSpheres_SC,s.coefW,s.xW,s.resW) 
     463 
     464        return(0) 
    440465End 
    441466 
    442467// this is all there is to the smeared calculation! 
    443 Function SmearedSchulzSpheres_SHS(w,x) :FitFunc 
    444         Wave w 
    445         Variable x 
    446          
    447         Variable ans 
    448         SVAR sq = gSig_Q 
    449         SVAR qb = gQ_bar 
    450         SVAR sh = gShadow 
    451         SVAR gQ = gQVals 
    452          
    453         //the name of your unsmeared model is the first argument 
    454         ans = Smear_Model_20(SchulzSpheres_SHS,$sq,$qb,$sh,$gQ,w,x) 
    455  
    456         return(ans) 
    457 End 
     468Function SmearedSchulzSpheres_SHS(s) : FitFunc 
     469        Struct ResSmearAAOStruct &s 
     470 
     471//      the name of your unsmeared model (AAO) is the first argument 
     472        s.yW = Smear_Model_20(SchulzSpheres_SHS,s.coefW,s.xW,s.resW) 
     473 
     474        return(0) 
     475End 
     476 
     477//wrapper to calculate the smeared model as an AAO-Struct 
     478// fills the struct and calls the ususal function with the STRUCT parameter 
     479// 
     480// used only for the dependency, not for fitting 
     481// 
     482Function fSmearedSchulzSpheres_HS(coefW,yW,xW) 
     483        Wave coefW,yW,xW 
     484         
     485        String str = getWavesDataFolder(yW,0) 
     486        String DF="root:"+str+":" 
     487         
     488        WAVE resW = $(DF+str+"_res") 
     489         
     490        STRUCT ResSmearAAOStruct fs 
     491        WAVE fs.coefW = coefW    
     492        WAVE fs.yW = yW 
     493        WAVE fs.xW = xW 
     494        WAVE fs.resW = resW 
     495         
     496        Variable err 
     497        err = SmearedSchulzSpheres_HS(fs) 
     498         
     499        return (0) 
     500End 
     501 
     502//wrapper to calculate the smeared model as an AAO-Struct 
     503// fills the struct and calls the ususal function with the STRUCT parameter 
     504// 
     505// used only for the dependency, not for fitting 
     506// 
     507Function fSmearedSchulzSpheres_SW(coefW,yW,xW) 
     508        Wave coefW,yW,xW 
     509         
     510        String str = getWavesDataFolder(yW,0) 
     511        String DF="root:"+str+":" 
     512         
     513        WAVE resW = $(DF+str+"_res") 
     514         
     515        STRUCT ResSmearAAOStruct fs 
     516        WAVE fs.coefW = coefW    
     517        WAVE fs.yW = yW 
     518        WAVE fs.xW = xW 
     519        WAVE fs.resW = resW 
     520         
     521        Variable err 
     522        err = SmearedSchulzSpheres_SW(fs) 
     523         
     524        return (0) 
     525End 
     526 
     527//wrapper to calculate the smeared model as an AAO-Struct 
     528// fills the struct and calls the ususal function with the STRUCT parameter 
     529// 
     530// used only for the dependency, not for fitting 
     531// 
     532Function fSmearedSchulzSpheres_SC(coefW,yW,xW) 
     533        Wave coefW,yW,xW 
     534         
     535        String str = getWavesDataFolder(yW,0) 
     536        String DF="root:"+str+":" 
     537         
     538        WAVE resW = $(DF+str+"_res") 
     539         
     540        STRUCT ResSmearAAOStruct fs 
     541        WAVE fs.coefW = coefW    
     542        WAVE fs.yW = yW 
     543        WAVE fs.xW = xW 
     544        WAVE fs.resW = resW 
     545         
     546        Variable err 
     547        err = SmearedSchulzSpheres_SC(fs) 
     548         
     549        return (0) 
     550End 
     551 
     552//wrapper to calculate the smeared model as an AAO-Struct 
     553// fills the struct and calls the ususal function with the STRUCT parameter 
     554// 
     555// used only for the dependency, not for fitting 
     556// 
     557Function fSmearedSchulzSpheres_SHS(coefW,yW,xW) 
     558        Wave coefW,yW,xW 
     559         
     560        String str = getWavesDataFolder(yW,0) 
     561        String DF="root:"+str+":" 
     562         
     563        WAVE resW = $(DF+str+"_res") 
     564         
     565        STRUCT ResSmearAAOStruct fs 
     566        WAVE fs.coefW = coefW    
     567        WAVE fs.yW = yW 
     568        WAVE fs.xW = xW 
     569        WAVE fs.resW = resW 
     570         
     571        Variable err 
     572        err = SmearedSchulzSpheres_SHS(fs) 
     573         
     574        return (0) 
     575End 
     576 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/TriaxialEllipsoid.ipf

    r127 r128  
    3434        make/o/t parameters_triax = {"Scale Factor","Semi-axis A [smallest]()","Semi-axis B ()","Semi-axis C [largest]()","Contrast (^-2)","Incoherent Bgd (cm-1)"} //CH#3 
    3535        Edit parameters_triax, coef_triax 
    36         ywave_triax  := TriaxialEllipsoid(coef_triax, xwave_triax) 
     36         
     37        Variable/G root:g_triax 
     38        g_triax := TriaxialEllipsoid(coef_triax, ywave_triax, xwave_triax) 
    3739        Display ywave_triax vs xwave_triax 
    3840        ModifyGraph marker=29, msize=2, mode=4 
     
    4446End 
    4547 
    46 // 
    47 //this Proc sets up all the necessary parameters and waves that are 
    48 //needed to calculate the  smeared model function. 
    49 // 
    50 //no input parameters are necessary, it MUST use the experimental q-values 
    51 // from the experimental data read in from an AVE/QSIG data file 
    52 //////////////////////////////////////////////////// 
    53 Proc PlotSmeared_TriAxEllipsoid()                                                               //triax 
    54         // if no gQvals wave, data must not have been loaded => abort 
    55         if(ResolutionWavesMissing()) 
     48 
     49// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     50Proc PlotSmeared_TriAxEllipsoid(str)                                                             
     51        String str 
     52        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     53         
     54        // if any of the resolution waves are missing => abort 
     55        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    5656                Abort 
    5757        endif 
     58         
     59        SetDataFolder $("root:"+str) 
    5860         
    5961        // Setup parameter table for model function 
     
    6466        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    6567        // make extra copy of experimental q-values for easy plotting 
    66         Duplicate/O $gQvals smeared_triax,smeared_qvals                         // 
     68        Duplicate/O $(str+"_q") smeared_triax,smeared_qvals                             // 
    6769        SetScale d,0,0,"1/cm",smeared_triax                                                     // 
    68  
    69         smeared_triax := Triax_Smeared(smear_coef_triax,$gQvals)                // SMEARED function name 
     70                                         
     71        Variable/G gs_triax=0 
     72        gs_triax := fTriax_Smeared(smear_coef_triax,smeared_triax,smeared_qvals)        //this wrapper fills the STRUCT 
     73         
    7074        Display smeared_triax vs smeared_qvals&