source: sans/Analysis/trunk/Put in User Procedures/SANS_Models_v3.00/Lorentz_model.ipf @ 56

Last change on this file since 56 was 42, checked in by srkline, 16 years ago

initial checkin of Analysis v.3.00 files

File size: 3.1 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2////////////////////////////////////////////////////
3//      J. Barker, 2-10-99
4/////////////////////////////
5Proc Plot_Lorentz(num,qmin,qmax)
6        Variable num=512, qmin=.001, qmax=.7
7        Prompt num "Enter number of data points for model: "
8        Prompt qmin "Enter minimum q-value (^1) for model: "
9         Prompt qmax "Enter maximum q-value (^1) for model: "
10//
11        Make/O/D/n=(num) xwave_Lorentz, ywave_Lorentz
12        xwave_Lorentz =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
13        Make/O/D coef_Lorentz = {100.0, 50.0, 1.0}
14        make/o/t parameters_Lorentz = {"Scale Factor, I0 ", "Screening Length ()","Incoherent Bgd (cm-1)"}
15        Edit parameters_Lorentz, coef_Lorentz
16        ywave_Lorentz  := Lorentz_Model(coef_Lorentz, xwave_Lorentz)
17        Display ywave_Lorentz vs xwave_Lorentz
18        ModifyGraph marker=29, msize=2, mode=4
19        ModifyGraph log(left)=1
20        Label bottom "q (\\S-1\\M) "
21        Label left "Lorentzian (cm\\S-1\\M)"
22        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
23End
24
25////////////////////////////////////////////////////
26Proc PlotSmeared_Lorentz()                                                              //Lorentz
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
29       
30        // if no gQvals wave, data must not have been loaded => abort
31        if(ResolutionWavesMissing())
32                Abort
33        endif
34       
35        // Setup parameter table for model function
36        Make/O/D smear_coef_Lorentz = {100.0, 50.0, 1.0}
37        make/o/t smear_parameters_Lorentz = {"Scale Factor, I0 ", "Screening Length ()","Incoherent Bgd (cm-1)"}
38        Edit smear_parameters_Lorentz,smear_coef_Lorentz                                        //display parameters in a table
39       
40        // output smeared intensity wave, dimensions are identical to experimental QSIG values
41        // make extra copy of experimental q-values for easy plotting
42        Duplicate/O $gQvals smeared_Lorentz,smeared_qvals                               //
43        SetScale d,0,0,"1/cm",smeared_Lorentz                                                   //
44
45        smeared_Lorentz := Smeared_Lorentz_Model(smear_coef_Lorentz,$gQvals)            // SMEARED function name
46        Display smeared_Lorentz vs smeared_qvals                                                                        //
47        ModifyGraph log=1,marker=29,msize=2,mode=4
48        Label bottom "q (\\S-1\\M)"
49        Label left "Lorentz Model (cm\\S-1\\M)"
50        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
51End     // end macro PlotSmearedPeak_Lorentz
52
53Function Lorentz_model(w,x) : FitFunc
54        Wave w
55        Variable x
56//       Input (fitting) variables are:
57        //[0] scale factor
58        //[1] screening length
59        //[2] incoherent background
60//      give them nice names
61        Variable I0, L,bgd
62        I0 = w[0]
63        L = w[1]
64        bgd = w[2]
65       
66//      local variables
67        Variable inten, qval
68//      x is the q-value for the calculation
69        qval = x
70//      do the calculation and return the function value
71       
72        inten = I0/(1 + (qval*L)^2) + bgd
73        Return (inten)
74End
75/////////////////////////////////////////////////////////////////////////////////
76
77
78// this is all there is to the smeared calculation!
79Function Smeared_Lorentz_Model(w,x) :FitFunc
80        Wave w
81        Variable x
82       
83        Variable ans
84        SVAR sq = gSig_Q
85        SVAR qb = gQ_bar
86        SVAR sh = gShadow
87        SVAR gQ = gQVals
88       
89        //the name of your unsmeared model is the first argument
90        ans = Smear_Model_20(Lorentz_model,$sq,$qb,$sh,$gQ,w,x)
91
92        return(ans)
93End
94       
Note: See TracBrowser for help on using the repository browser.