1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
2 | |
---|
3 | //////////////////////////////////////////////// |
---|
4 | // GaussUtils.proc and PlotUtils.proc MUST be included for the smearing calculation to compile |
---|
5 | // Adopting these into the experiment will insure that they are always present |
---|
6 | //////////////////////////////////////////////// |
---|
7 | // this procedure is for the form factor of a sphere |
---|
8 | // |
---|
9 | // 06 NOV 98 SRK |
---|
10 | //////////////////////////////////////////////// |
---|
11 | |
---|
12 | Proc PlotSphereForm(num,qmin,qmax) |
---|
13 | Variable num=128,qmin=0.001,qmax=0.7 |
---|
14 | Prompt num "Enter number of data points for model: " |
---|
15 | Prompt qmin "Enter minimum q-value (^-1) for model: " |
---|
16 | Prompt qmax "Enter maximum q-value (^-1) for model: " |
---|
17 | |
---|
18 | Make/O/D/n=(num) xwave_sf,ywave_sf |
---|
19 | xwave_sf = alog(log(qmin) + x*((log(qmax)-log(qmin))/num)) |
---|
20 | Make/O/D coef_sf = {1.,60,1e-6,0.01} |
---|
21 | make/o/t parameters_sf = {"scale","Radius (A)","contrast (-2)","bkgd (cm-1)"} |
---|
22 | Edit parameters_sf,coef_sf |
---|
23 | ywave_sf := SphereForm(coef_sf,xwave_sf) |
---|
24 | Display ywave_sf vs xwave_sf |
---|
25 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
26 | Label bottom "q (\\S-1\\M)" |
---|
27 | Label left "Intensity (cm\\S-1\\M)" |
---|
28 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
29 | End |
---|
30 | |
---|
31 | /////////////////////////////////////////////////////////// |
---|
32 | |
---|
33 | Proc PlotSmearedSphereForm() |
---|
34 | //no input parameters necessary, it MUST use the experimental q-values |
---|
35 | // from the experimental data read in from an AVE/QSIG data file |
---|
36 | |
---|
37 | // if no gQvals wave, data must not have been loaded => abort |
---|
38 | if(ResolutionWavesMissing()) |
---|
39 | Abort |
---|
40 | endif |
---|
41 | |
---|
42 | // Setup parameter table for model function |
---|
43 | Make/O/D smear_coef_sf = {1.,60,1e-6,0.0} |
---|
44 | make/o/t smear_parameters_sf = {"scale","Radius (A)","contrast (-2)","bkgd (cm-1)"} |
---|
45 | Edit smear_parameters_sf,smear_coef_sf |
---|
46 | |
---|
47 | // output smeared intensity wave, dimensions are identical to experimental QSIG values |
---|
48 | // make extra copy of experimental q-values for easy plotting |
---|
49 | Duplicate/O $gQvals smeared_sf,smeared_qvals |
---|
50 | SetScale d,0,0,"1/cm",smeared_sf |
---|
51 | |
---|
52 | smeared_sf := SmearedSphereForm(smear_coef_sf,$gQvals) |
---|
53 | Display smeared_sf vs smeared_qvals |
---|
54 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
55 | Label bottom "q (\\S-1\\M)" |
---|
56 | Label left "Intensity (cm\\S-1\\M)" |
---|
57 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
58 | End |
---|
59 | |
---|
60 | /////////////////////////////////////////////////////////////// |
---|
61 | // unsmeared model calculation |
---|
62 | /////////////////////////// |
---|
63 | Function SphereForm(w,x) : FitFunc |
---|
64 | Wave w |
---|
65 | Variable x |
---|
66 | |
---|
67 | // variables are: |
---|
68 | //[0] scale |
---|
69 | //[1] radius () |
---|
70 | //[2] delrho (-2) |
---|
71 | //[3] background (cm-1) |
---|
72 | |
---|
73 | Variable scale,radius,delrho,bkg |
---|
74 | scale = w[0] |
---|
75 | radius = w[1] |
---|
76 | delrho = w[2] |
---|
77 | bkg = w[3] |
---|
78 | |
---|
79 | |
---|
80 | // calculates scale * f^2/Vol where f=Vol*3*delrho*((sin(qr)-qrcos(qr))/qr^3 |
---|
81 | // and is rescaled to give [=] cm^-1 |
---|
82 | |
---|
83 | Variable bes,f,vol,f2 |
---|
84 | // |
---|
85 | //handle q==0 separately |
---|
86 | If(x==0) |
---|
87 | f = 4/3*pi*radius^3*delrho*delrho*scale*1e8 + bkg |
---|
88 | return(f) |
---|
89 | Endif |
---|
90 | |
---|
91 | bes = 3*(sin(x*radius)-x*radius*cos(x*radius))/x^3/radius^3 |
---|
92 | vol = 4*pi/3*radius^3 |
---|
93 | f = vol*bes*delrho // [=] |
---|
94 | // normalize to single particle volume, convert to 1/cm |
---|
95 | f2 = f * f / vol * 1.0e8 // [=] 1/cm |
---|
96 | |
---|
97 | return (scale*f2+bkg) // Scale, then add in the background |
---|
98 | |
---|
99 | End |
---|
100 | |
---|
101 | // this is all there is to the smeared calculation! |
---|
102 | Function SmearedSphereForm(w,x) :FitFunc |
---|
103 | Wave w |
---|
104 | Variable x |
---|
105 | |
---|
106 | Variable ans |
---|
107 | SVAR sq = gSig_Q |
---|
108 | SVAR qb = gQ_bar |
---|
109 | SVAR sh = gShadow |
---|
110 | SVAR gQ = gQVals |
---|
111 | |
---|
112 | //the name of your unsmeared model is the first argument |
---|
113 | ans = Smear_Model_20(SphereForm,$sq,$qb,$sh,$gQ,w,x) |
---|
114 | |
---|
115 | return(ans) |
---|
116 | End |
---|