source: sans/Release/trunk/NCNR_User_Procedures/SANS/Analysis/Models_v3.00/NewModels_2006/Debye.ipf @ 381

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

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

File size: 2.4 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2
3// plots the Debye function for polymer scattering
4//
5Proc PlotDebye(num,qmin,qmax)
6        Variable num=256,qmin=0.001,qmax=0.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_deb,ywave_deb
12        xwave_deb = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) )
13        make/O/D coef_deb = {1.,50,0.001}
14        make/O/T parameters_deb = {"scale","Rg (A)","bkg (cm-1)"}
15        Edit parameters_deb,coef_deb
16        ywave_deb := Debye(coef_deb,xwave_deb)
17        Display ywave_deb vs xwave_deb
18        ModifyGraph marker=29,msize=2,mode=4,log=1
19        Label bottom "q (A\\S-1\\M)"
20        Label left "Intensity (cm\\S-1\\M)"
21        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
22End
23
24///////////////////////////////////////////////////////////
25Proc PlotSmearedDebye()
26        //no input parameters necessary, it MUST use the experimental q-values
27        // from the experimental data read in from an AVE/QSIG data file
28       
29        // if no gQvals wave, data must not have been loaded => abort
30        if(ResolutionWavesMissing())
31                Abort
32        endif
33       
34        // Setup parameter table for model function
35        make/O/D smear_coef_deb = {1.,50,0.001}
36        make/O/T smear_parameters_deb = {"scale","Rg (A)","bkg (cm-1)"}
37        Edit smear_parameters_deb,smear_coef_deb
38       
39        // output smeared intensity wave
40        Duplicate/O $gQvals smeared_deb,smeared_qvals
41        SetScale d,0,0,"1/cm",smeared_deb
42
43        smeared_deb := SmearedDebye(smear_coef_deb,$gQvals)
44        Display smeared_deb vs smeared_qvals
45        ModifyGraph log=1,marker=29,msize=2,mode=4
46        Label bottom "q (A\\S-1\\M)"
47        Label left "Intensity (cm\\S-1\\M)"
48        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
49End
50///////////////////////////////////////////////////////////////
51
52
53Function Debye(w,x) : FitFunc
54        Wave w
55        Variable x
56       
57        // variables are:
58        //[0] scale factor
59        //[1] radius of gyration [A]
60        //[2] background        [cm-1]
61       
62        Variable scale,rg,bkg
63        scale = w[0]
64        rg = w[1]
65        bkg = w[2]
66       
67        // calculates (scale*debye)+bkg
68        Variable Pq,qr2
69       
70        qr2=(x*rg)^2
71        Pq = 2*(exp(-(qr2))-1+qr2)/qr2^2
72       
73        //scale
74        Pq *= scale
75        // then add in the background
76        return (Pq+bkg)
77End
78
79// this is all there is to the smeared calculation!
80Function SmearedDebye(w,x) :FitFunc
81        Wave w
82        Variable x
83       
84        Variable ans
85        SVAR sq = gSig_Q
86        SVAR qb = gQ_bar
87        SVAR sh = gShadow
88        SVAR gQ = gQVals
89       
90        //the name of your unsmeared model is the first argument
91        ans = Smear_Model_20(Debye,$sq,$qb,$sh,$gQ,w,x)
92
93        return(ans)
94End
Note: See TracBrowser for help on using the repository browser.