Ignore:
Timestamp:
Oct 15, 2008 5:13:05 PM (14 years ago)
Author:
srkline
Message:

Lots of little changes:

changed debye function to a limiting value at low qRg to avoid numerical errors. There is no XOP, so no changes needed there.

Added MonteCarlo? simulation routine (1st draft) to the SANS Reduction, including changes to SASCALC to implement. Still very alpha with lots of bits to add. See the top of the monte carlo file for the list.

added MonteCarlo? file to SANS includes
added SAS folder to 2D display list to view MonteCarlo? results
removed more "non-functions" from the function popup in analysis. these were a result of motofit/genFit, and simultaneous loading of SANS/USANS reduction. More will follow.

Location:
sans/Dev/trunk/NCNR_User_Procedures
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Analysis/Models/NewModels_2006/Debye_v40.ipf

    r379 r429  
    9797        Variable Pq,qr2 
    9898         
     99        if(x*Rg < 1e-3)         //added Oct 2008 to avoid numerical errors at low arg values 
     100                return(scale+bkg) 
     101        endif 
     102         
    99103        qr2=(x*rg)^2 
    100104        Pq = 2*(exp(-(qr2))-1+qr2)/qr2^2 
  • sans/Dev/trunk/NCNR_User_Procedures/Analysis/Packages/Wrapper_v40.ipf

    r427 r429  
    191191 
    192192        //now start to remove everything the user doesn't need to see... 
    193                  
     193 
    194194        tmp = FunctionList("*_proto",";","KIND:10")             //prototypes 
    195195        list = RemoveFromList(tmp, list  ,";") 
     
    212212        list = RemoveFromList("MakeBSMask", list) 
    213213         
    214  
     214        // MOTOFIT/GenFit bits 
     215        tmp = "GEN_allatoncefitfunc;GEN_fitfunc;GetCheckBoxesState;MOTO_GFFitAllAtOnceTemplate;MOTO_GFFitFuncTemplate;MOTO_NewGF_SetXWaveInList;MOTO_NewGlblFitFunc;MOTO_NewGlblFitFuncAllAtOnce;" 
     216        list = RemoveFromList(tmp, list  ,";") 
     217 
     218        // SANS Reduction bits 
     219        tmp = "ASStandardFunction;Ann_1D_Graph;Avg_1D_Graph;BStandardFunction;CStandardFunction;Draw_Plot1D;MyMat2XYZ;NewDirection;SANSModelAAO_MCproto;" 
     220        list = RemoveFromList(tmp, list  ,";") 
     221         
    215222        tmp = FunctionList("f*",";","NPARAMS:2")                //point calculations 
    216223        list = RemoveFromList(tmp, list  ,";") 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/DisplayUtils.ipf

    r418 r429  
    196196Proc ChangeDisplay(type) 
    197197        String type 
    198         Prompt type,"Display WORK data type",popup,"SAM;EMP;BGD;DIV;COR;CAL;RAW;ABS;STO;SUB;DRK;" 
     198        Prompt type,"Display WORK data type",popup,"SAM;EMP;BGD;DIV;COR;CAL;RAW;ABS;STO;SUB;DRK;SAS;" 
    199199         
    200200        //macro will take whatever is in "type" folder 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/Includes_v510.ipf

    r417 r429  
    5454 
    5555#include "TISANE" 
     56#include "MultScatter_MonteCarlo_2D"                    //Oct 2008 SRK for SASCALC simulation 
    5657 
    5758// to include the analysis packages, uncomment the following 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/SASCALC.ipf

    r428 r429  
    7373        // data 
    7474        Make/O/D/N=(128,128) root:Packages:NIST:SAS:data,root:Packages:NIST:SAS:linear_data 
    75         Make/O/D/N=2 root:Packages:NIST:SAS:aveint,root:Packages:NIST:SAS:qval 
     75        Make/O/D/N=2 root:Packages:NIST:SAS:aveint,root:Packages:NIST:SAS:qval,root:Packages:NIST:SAS:sigave 
    7676        root:Packages:NIST:SAS:data = 1 
    7777        root:Packages:NIST:SAS:linear_data = 1 
     
    8282        // -(hard coded right now - look for NVAR declarations) 
    8383        Variable/G root:Packages:NIST:SAS:gBinWidth=1 
     84        Variable/G root:Packages:NIST:SAS:gisLogScale=0 
     85        String/G root:Packages:NIST:SAS:FileList = "SASCALC" 
    8486         
    8587        // for the panel 
     
    99101        Variable/G root:Packages:NIST:SAS:gUsingLenses = 0              //0=no lenses, 1=lenses(or prisms) 
    100102        Variable/G root:Packages:NIST:SAS:gModelOffsetFactor = 1 
     103         
     104        // for the MC simulation 
     105        Variable/G root:Packages:NIST:SAS:gImon = 10000 
     106        Variable/G root:Packages:NIST:SAS:gThick = 0.1 
     107        Variable/G root:Packages:NIST:SAS:gSig_incoh = 0.1 
     108        String/G root:Packages:NIST:SAS:gFuncStr = "SphereForm" 
     109        Variable/G root:Packages:NIST:SAS:gR2 = 2.54/2   
     110        Variable/G root:Packages:NIST:SAS:gDoMonteCarlo = 0      
     111        Make/O/D/N=10 root:Packages:NIST:SAS:results = 0 
     112        Make/O/T/N=10 root:Packages:NIST:SAS:results_desc = {"total X-section (1/cm)","SAS X-section (1/cm)","# reaching detector","fraction reaching detector","# that interact","fraction singly scattered","fraction transmitted","","",""} 
    101113         
    102114        //tick labels for SDD slider 
     
    239251        rw[17] = 64             // beamcenter Y 
    240252         
    241         rw[10]  = 5                     //detector resolution (5mm) and calibration constants (linearity) 
     253        rw[10]  = 5.08                  //detector resolution (5mm) and calibration constants (linearity) 
    242254        rw[11] = 10000 
    243         rw[13] = 5 
     255        rw[12] = 0 
     256        rw[13] = 5.08 
    244257        rw[14] = 10000 
     258        rw[15] = 0 
    245259         
    246260        rw[20] = 65             // det size in cm 
     
    267281        Display /W=(5,44,463,570)/K=1 aveint vs qval as "SASCALC" 
    268282        DoWindow/C SASCALC 
    269         SetDataFolder fldrSav0 
    270283        ModifyGraph cbRGB=(49151,53155,65535) 
    271284        ModifyGraph mode=3 
     
    275288        Modifygraph grid=1 
    276289        Modifygraph mirror=2 
     290        ModifyGraph msize(aveint)=2 
     291        ErrorBars/T=0 aveint Y,wave=(sigave,sigave) 
    277292        Label bottom, "Q (1/A)" 
    278293        Label left, "Relative Intensity" 
    279294        legend 
    280          
     295        SetDataFolder fldrSav0 
     296 
     297 
    281298        ControlBar 200 
    282299         
     
    316333         
    317334        SetVariable setvar0_3,pos={140,94},size={110,15},title="Diam (mm)",disable=1 
    318         SetVariable setvar0_3,limits={0,100,0.1},value= root:Packages:NIST:SAS:gSamApOther,proc=SourceApOtherSetVarProc 
     335        SetVariable setvar0_3,limits={0,100,0.1},value= root:Packages:NIST:SAS:gSamApOther,proc=SampleApOtherSetVarProc 
    319336         
    320337        CheckBox checkLens,pos={6,155},size={44,14},proc=LensCheckProc,title="Lenses?" 
     
    628645        endif 
    629646         
     647        // do the simulation here 
     648        Variable r1,xCtr,yCtr,sdd,pixSize,wavelength 
     649        String coefStr 
     650         
     651//      Variable imon,thick,r2,sig_incoh 
     652//      String funcStr 
     653//      imon = 10000 
     654//      thick = 0.1 
     655//      sig_incoh = 0.1 
     656//      funcStr = "SphereForm" 
     657//      r2 = 2.54/2                     //typical 1" diameter sample, convert to radius in cm 
     658 
     659        NVAR doMonteCarlo = root:Packages:NIST:SAS:gDoMonteCarlo                // == 1 if MC, 0 if other 
     660        SVAR funcStr = root:Packages:NIST:SAS:gFuncStr 
     661 
     662        if(doMonteCarlo == 1) 
     663                WAVE rw=root:Packages:NIST:SAS:realsRead 
     664                 
     665                NVAR imon = root:Packages:NIST:SAS:gImon 
     666                NVAR thick = root:Packages:NIST:SAS:gThick 
     667                NVAR sig_incoh = root:Packages:NIST:SAS:gSig_incoh 
     668                NVAR r2 = root:Packages:NIST:SAS:gR2 
     669         
     670                r1 = rw[24]/2/10                // sample diameter convert diam in [mm] to radius in cm 
     671                xCtr = rw[16] 
     672                yCtr = rw[17] 
     673                sdd = rw[18]*100                //conver header of [m] to [cm] 
     674                pixSize = rw[10]/10             // convert pix size in mm to cm 
     675                wavelength = rw[26] 
     676                coefStr = MC_getFunctionCoef(funcStr) 
     677                 
     678                if(!MC_CheckFunctionAndCoef(funcStr,coefStr)) 
     679                        Abort "The coefficients and function type do not match. Please correct the selections in the popup menus." 
     680                endif 
     681                 
     682                FUNCREF SANSModelAAO_MCproto func=$funcStr 
     683                WAVE results = root:Packages:NIST:SAS:results 
     684                results = 0 
     685                 
     686                Monte_SANS(imon,r1,r2,xCtr,yCtr,sdd,pixSize,thick,wavelength,sig_incoh,func,$coefStr,results) 
     687                 
     688                // convert to absolute scale 
     689                Variable kappa,beaminten = beamIntensity() 
     690                // results[6] is the fraction transmitted 
     691//              kappa = beamInten*pi*r1*r1*thick*(pixSize/sdd)^2*results[6]*(iMon/beaminten) 
     692                kappa = thick*(pixSize/sdd)^2*results[6]*iMon *2        //why the factor of 2? 
     693                 
     694                WAVE linear_data = root:Packages:NIST:SAS:linear_data 
     695                WAVE data = root:Packages:NIST:SAS:data 
     696                linear_data = linear_data / kappa 
     697                data = linear_data 
     698         
     699        endif 
     700         
    630701        // update the wave with the beamstop diameter here, since I don't know what 
    631702        // combinations of parameters will change the BS - but anytime the curve is  
     
    642713         
    643714        //aveint = S_SphereForm(1,80,1e-6,0,qval) 
    644         aveint = S_Debye(1000,100,0.0,qval) 
    645  
    646         // multiply by beamstop shadowing 
     715        if(doMonteCarlo != 1) 
     716                if(exists(funcStr) != 0) 
     717                        FUNCREF SANSModelAAO_MCproto func=$funcStr 
     718                        coefStr = MC_getFunctionCoef(funcStr) 
     719                         
     720                        if(!MC_CheckFunctionAndCoef(funcStr,coefStr)) 
     721                                Abort "The coefficients and function type do not match. Please correct the selections in the popup menus." 
     722                        endif 
     723                        func($coefStr,aveint,qval) 
     724                else 
     725                        aveint = S_Debye(1000,100,0.0,qval) 
     726                endif 
     727        endif 
     728         
     729        // multiply either estimate by beamstop shadowing 
    647730        aveint *= fSubS 
    648731         
     
    13671450 
    13681451// change the sample aperture to a non-standard value 
    1369 Function SourceApOtherSetVarProc(ctrlName,varNum,varStr,varName) : SetVariableControl 
     1452Function SampleApOtherSetVarProc(ctrlName,varNum,varStr,varName) : SetVariableControl 
    13701453        String ctrlName 
    13711454        Variable varNum 
Note: See TracChangeset for help on using the changeset viewer.