1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
2 | //////////////////////////////////////////////////// |
---|
3 | // C. Glinka, 11-22-98 |
---|
4 | //////////////// |
---|
5 | |
---|
6 | Proc PlotDAB(num,qmin,qmax) |
---|
7 | Variable num=512, qmin=.001, qmax=.7 |
---|
8 | Prompt num "Enter number of data points for model: " |
---|
9 | Prompt qmin "Enter minimum q-value (^1) for model: " |
---|
10 | Prompt qmax "Enter maximum q-value (^1) for model: " |
---|
11 | // |
---|
12 | Make/O/D/n=(num) xwave_DAB, ywave_DAB |
---|
13 | xwave_DAB = alog(log(qmin) + x*((log(qmax)-log(qmin))/num)) |
---|
14 | Make/O/D coef_DAB = {10.0, 40, 1.0} |
---|
15 | make/o/t parameters_DAB = {"Scale Factor, A ", "Correlation Length ()", "Incoherent Bgd (cm-1)"} |
---|
16 | Edit parameters_DAB, coef_DAB |
---|
17 | ywave_DAB := DAB_Model(coef_DAB, xwave_DAB) |
---|
18 | Display ywave_DAB vs xwave_DAB |
---|
19 | ModifyGraph marker=29, msize=2, mode=4 |
---|
20 | ModifyGraph log(left)=1 |
---|
21 | Label bottom "q (\\S-1\\M) " |
---|
22 | Label left "Debye-Anderson-Brumberger Model (cm\\S-1\\M)" |
---|
23 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
24 | End |
---|
25 | //////////////////////////////////////////////////// |
---|
26 | Proc PlotSmearedDAB() //Debye-Anderson-Brumberger |
---|
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_DAB = {10.0, 40, 1.0} //model coef values to match unsmeared model above |
---|
37 | make/o/t smear_parameters_DAB = {"Scale Factor, A ", "Correlation Length ()", "Incoherent Bgd (cm-1)"}// parameter names |
---|
38 | Edit smear_parameters_DAB,smear_coef_DAB //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_DAB,smeared_qvals // |
---|
43 | SetScale d,0,0,"1/cm",smeared_DAB // |
---|
44 | |
---|
45 | smeared_DAB := SmearedDAB_Model(smear_coef_DAB,$gQvals) // SMEARED function name |
---|
46 | Display smeared_DAB vs smeared_qvals // |
---|
47 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
48 | Label bottom "q (\\S-1\\M)" |
---|
49 | Label left "Debye-Anderson-Brumberger Model (cm\\S-1\\M)" |
---|
50 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
51 | End // end macro PlotSmearedDAB |
---|
52 | |
---|
53 | Function DAB_model(w,x) : FitFunc |
---|
54 | Wave w |
---|
55 | Variable x |
---|
56 | // Input (fitting) variables are: |
---|
57 | //[0] scale factor |
---|
58 | //[1] correlation range |
---|
59 | //[2] incoherent background |
---|
60 | // give them nice names |
---|
61 | Variable Izero, range, incoh |
---|
62 | Izero = w[0] |
---|
63 | range = w[1] |
---|
64 | incoh = w[2] |
---|
65 | // local variables |
---|
66 | Variable inten, qval |
---|
67 | // x is the q-value for the calculation |
---|
68 | qval = x |
---|
69 | // do the calculation and return the function value |
---|
70 | |
---|
71 | inten = Izero/(1 + (qval*range)^2)^2 + incoh |
---|
72 | Return (inten) |
---|
73 | End |
---|
74 | ///////////////////////////////////////////////////////////////////////////////// |
---|
75 | |
---|
76 | // this is all there is to the smeared calculation! |
---|
77 | Function SmearedDAB_Model(w,x) :FitFunc |
---|
78 | Wave w |
---|
79 | Variable x |
---|
80 | |
---|
81 | Variable ans |
---|
82 | SVAR sq = gSig_Q |
---|
83 | SVAR qb = gQ_bar |
---|
84 | SVAR sh = gShadow |
---|
85 | SVAR gQ = gQVals |
---|
86 | |
---|
87 | //the name of your unsmeared model is the first argument |
---|
88 | ans = Smear_Model_20(DAB_Model,$sq,$qb,$sh,$gQ,w,x) |
---|
89 | |
---|
90 | return(ans) |
---|
91 | End |
---|