1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
2 | |
---|
3 | |
---|
4 | //////////////////////////////////////////////// |
---|
5 | // this procedure is for the Teubner-Strey Model |
---|
6 | // |
---|
7 | // 06 NOV 98 SRK |
---|
8 | //////////////////////////////////////////////// |
---|
9 | |
---|
10 | Proc PlotTeubnerStreyModel(num,qmin,qmax) |
---|
11 | Variable num=128,qmin=0.001,qmax=0.7 |
---|
12 | Prompt num "Enter number of data points for model: " |
---|
13 | Prompt qmin "Enter minimum q-value (^-1) for model: " |
---|
14 | Prompt qmax "Enter maximum q-value (^-1) for model: " |
---|
15 | |
---|
16 | Make/O/D/n=(num) xwave_ts,ywave_ts |
---|
17 | xwave_ts = alog(log(qmin) + x*((log(qmax)-log(qmin))/num)) |
---|
18 | Make/O/D coef_ts = {0.1,-30,5000,0.1} |
---|
19 | make/o/t parameters_ts = {"scale (a2)","c1","c2","bkg"} |
---|
20 | Edit parameters_ts,coef_ts |
---|
21 | ywave_ts := TeubnerStreyModel(coef_ts,xwave_ts) |
---|
22 | Display ywave_ts vs xwave_ts |
---|
23 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
24 | Label bottom "q (\\S-1\\M)" |
---|
25 | Label left "Intensity (cm\\S-1\\M)" |
---|
26 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
27 | End |
---|
28 | |
---|
29 | /////////////////////////////////////////////////////////// |
---|
30 | |
---|
31 | Proc PlotSmearedTeubnerStreyModel() |
---|
32 | //no input parameters necessary, it MUST use the experimental q-values |
---|
33 | // from the experimental data read in from an AVE/QSIG data file |
---|
34 | |
---|
35 | // if no gQvals wave, data must not have been loaded => abort |
---|
36 | if(ResolutionWavesMissing()) |
---|
37 | Abort |
---|
38 | endif |
---|
39 | |
---|
40 | // Setup parameter table for model function |
---|
41 | Make/O/D smear_coef_ts = {0.1,-30,5000,0.1} |
---|
42 | make/o/t smear_parameters_ts = {"scale (a2)","c1","c2","bkg"} |
---|
43 | Edit smear_parameters_ts,smear_coef_ts |
---|
44 | |
---|
45 | // output smeared intensity wave, dimensions are identical to experimental QSIG values |
---|
46 | // make extra copy of experimental q-values for easy plotting |
---|
47 | Duplicate/O $gQvals smeared_ts,smeared_qvals |
---|
48 | SetScale d,0,0,"1/cm",smeared_ts |
---|
49 | |
---|
50 | smeared_ts := SmearedTeubnerStreyModel(smear_coef_ts,$gQvals) |
---|
51 | Display smeared_ts vs smeared_qvals |
---|
52 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
53 | Label bottom "q (\\S-1\\M)" |
---|
54 | Label left "Intensity (cm\\S-1\\M)" |
---|
55 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
56 | End |
---|
57 | |
---|
58 | /////////////////////////////////////////////////////////////// |
---|
59 | // unsmeared model calculation |
---|
60 | /////////////////////////// |
---|
61 | Function TeubnerStreyModel(w,x) : FitFunc |
---|
62 | Wave w;Variable x |
---|
63 | |
---|
64 | //Varialbes are: |
---|
65 | //[0] scale factor a2 |
---|
66 | //[1] coeff c1 |
---|
67 | //[2] coeff c2 |
---|
68 | //[3] incoh. background |
---|
69 | |
---|
70 | Variable inten,q2,q4 |
---|
71 | |
---|
72 | q2 = x*x |
---|
73 | q4 = q2*q2 |
---|
74 | inten = 1.0/(w[0]+w[1]*q2+w[2]*q4) |
---|
75 | inten += w[3] |
---|
76 | |
---|
77 | return (inten) |
---|
78 | |
---|
79 | End |
---|
80 | |
---|
81 | Macro TeubnerStreyLengths() |
---|
82 | If(exists("coef_ts")!=1) //coefficients don't exist |
---|
83 | Abort "You must plot the Teubner-Strey model before calculating the lengths" |
---|
84 | Endif |
---|
85 | // calculate the correlation length and the repeat distance |
---|
86 | Variable a2,c1,c2,xi,dd |
---|
87 | a2 = coef_ts[0] |
---|
88 | c1 = coef_ts[1] |
---|
89 | c2 = coef_ts[2] |
---|
90 | |
---|
91 | xi = 0.5*sqrt(a2/c2) + c1/4/c2 |
---|
92 | xi = 1/sqrt(xi) |
---|
93 | |
---|
94 | dd = 0.5*sqrt(a2/c2) - c1/4/c2 |
---|
95 | dd = 1/sqrt(dd) |
---|
96 | dd *=2*Pi |
---|
97 | |
---|
98 | Printf "The correlation length (the dispersion of d) xi = %g A\r",xi |
---|
99 | Printf "The quasi-periodic repeat distance, d = %g A\r",dd |
---|
100 | |
---|
101 | End |
---|
102 | // this is all there is to the smeared calculation! |
---|
103 | Function SmearedTeubnerStreyModel(w,x) :FitFunc |
---|
104 | Wave w |
---|
105 | Variable x |
---|
106 | |
---|
107 | Variable ans |
---|
108 | SVAR sq = gSig_Q |
---|
109 | SVAR qb = gQ_bar |
---|
110 | SVAR sh = gShadow |
---|
111 | SVAR gQ = gQVals |
---|
112 | |
---|
113 | //the name of your unsmeared model is the first argument |
---|
114 | ans = Smear_Model_20(TeubnerStreyModel,$sq,$qb,$sh,$gQ,w,x) |
---|
115 | |
---|
116 | return(ans) |
---|
117 | End |
---|