# source:sans/Release/trunk/NCNR_User_Procedures/SANS/Analysis/Models_v3.00/Lorentz_model.ipf@381

Last change on this file since 381 was 381, checked in by srkline, 15 years ago

Merging Dev/trunk revision 374+ into Release/trunk for version 6.004

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 (A^1) for model: "
9         Prompt qmax "Enter maximum q-value (A^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 (A)","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 (A\\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 (A)","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 (A\\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