source: sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/FlexCyl_EllipCross.ipf @ 166

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

Modified all procedure files to add to the keyword=value strings to identify the function, coefficients, and suffix once the model is plotted (and the objects will exist)

a one-liner in the Plot and PlotSmeared? macros.

  • necessary for smoother functioning of the wrapper panel.
File size: 5.3 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma IgorVersion = 6.0
3
4#include "FlexibleCylinder"
5
6///////////////////////////
7// plots the scattering from a flexible cylinder with an
8// elliptical cross-section
9//
10// same chain calculation as flexible cylinder,
11// correcting for a different cross-section
12//
13// Bergstrom / Pedersen reference in Langmuir
14//
15// Contains Wei-Ren's corrections for the chain model July 2006
16//
17//
18Proc PlotFlexCyl_Ellip(num,qmin,qmax)
19        Variable num=128,qmin=0.001,qmax=0.7
20        Prompt num "Enter number of data points for model: "
21        Prompt qmin "Enter minimum q-value (^-1) for model: "
22        Prompt qmax "Enter maximum q-value (^-1) for model: "
23       
24        Make/O/D/n=(num) xwave_fleell,ywave_fleell
25        xwave_fleell =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
26        Make/O/D coef_fleell = {1.,1000,100,20,1.5,3.0e-6,0.0001}
27        make/o/t parameters_fleell = {"scale","Contour Length (A)","Kuhn Length, b (A)","Minor Radius (a) (A)","Axis Ratio = major/a","contrast (A^-2)","bkgd (arb)"}
28        Edit parameters_fleell,coef_fleell
29       
30        Variable/G root:g_fleell
31        g_fleell := FlexCyl_Ellip(coef_fleell,ywave_fleell,xwave_fleell)
32        Display ywave_fleell vs xwave_fleell
33        ModifyGraph log=1,marker=29,msize=2,mode=4
34        Label bottom "q (\\S-1\\M)"
35        Label left "Intensity (cm\\S-1\\M)"
36        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
37       
38        AddModelToStrings("FlexCyl_Ellip","coef_fleell","fleell")
39End
40
41// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
42Proc PlotSmearedFlexCyl_Ellip(str)                                                             
43        String str
44        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
45       
46        // if any of the resolution waves are missing => abort
47        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
48                Abort
49        endif
50       
51        SetDataFolder $("root:"+str)
52       
53        // Setup parameter table for model function
54        Make/O/D smear_coef_fleell = {1.,1000,100,20,1.5,3.0e-6,0.0001}
55        make/o/t smear_parameters_fleell = {"scale","ContourLength (A)","KuhnLength, b (A)","Minor Radius (a) (A)","Axis Ratio = major/a","contrast (A^-2)","bkgd (arb)"}
56        Edit smear_parameters_fleell,smear_coef_fleell                                  //display parameters in a table
57       
58        // output smeared intensity wave, dimensions are identical to experimental QSIG values
59        // make extra copy of experimental q-values for easy plotting
60        Duplicate/O $(str+"_q") smeared_fleell,smeared_qvals                            //
61        SetScale d,0,0,"1/cm",smeared_fleell                                                    //
62                                       
63        Variable/G gs_fleell=0
64        gs_fleell := fSmearedFlexCyl_Ellip(smear_coef_fleell,smeared_fleell,smeared_qvals)      //this wrapper fills the STRUCT
65       
66        Display smeared_fleell vs smeared_qvals                                                                 //
67        ModifyGraph log=1,marker=29,msize=2,mode=4
68        Label bottom "q (\\S-1\\M)"
69        Label left "I(q) (cm\\S-1\\M)"
70        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
71       
72        SetDataFolder root:
73        AddModelToStrings("SmearedFlexCyl_Ellip","smear_coef_fleell","fleell")
74End
75       
76
77
78
79//AAO version, uses XOP if available
80// simply calls the original single point calculation with
81// a wave assignment (this will behave nicely if given point ranges)
82Function FlexCyl_Ellip(cw,yw,xw) : FitFunc
83        Wave cw,yw,xw
84       
85#if exists("FlexCyl_EllipX")
86        yw = FlexCyl_EllipX(cw,xw)
87#else
88        yw = fFlexCyl_Ellip(cw,xw)
89#endif
90        return(0)
91End
92
93//
94Function fFlexCyl_Ellip(ww,x) :FitFunc
95        Wave ww
96        Variable x
97
98        //nice names to the input params
99        //ww[0] = scale
100        //ww[1] = L [A]
101        //ww[2] = B [A]
102        //ww[3] = rad [A] cross-sectional radius
103        //ww[4] = ellRatio = major/minor axis (greater than one)
104        //ww[5] = contrast [A^-2]
105        //ww[6] = bkg [cm-1]
106        Variable scale,L,B,bkg,rad,qr,cont,ellRatio
107       
108        scale = ww[0]
109        L = ww[1]
110        B = ww[2]
111        rad = ww[3]
112        ellRatio = ww[4]
113        cont = ww[5]
114        bkg = ww[6]
115        qr = x*rad              //used for cross section contribution only
116       
117        //local variables
118        Variable flex,crossSect
119
120        flex = Sk_WR(x,L,B)                     //Wei-Ren's calculations, do not have cross section
121       
122        //calculate cross section contribution - Eqns.(28) &(29) (approximate)
123        //use elliptical cross-section here
124        crossSect = EllipticalCross_fn(x,rad,(rad*ellRatio))
125       
126        //normalize form factor by multiplying by cylinder volume * cont^2
127        // then convert to cm-1 by multiplying by 10^8
128        // then scale = phi
129
130        flex *= crossSect
131        flex *= Pi*rad*rad*ellRatio*L
132        flex *= cont^2
133        flex *= 1.0e8
134       
135        return (scale*flex + bkg)
136       
137end
138////////////// flex chain - with excluded volume
139
140Function EllipticalCross_fn(qq,a,b)
141        Variable qq,a,b
142       
143        Make/O/D/N=100 ellip
144        SetScale x,0,(pi/2),ellip
145       
146        ellip = bessJ(1,(qq*sqrt(a^2*sin(x)^2+b^2*cos(x)^2))) / (qq*sqrt(a^2*sin(x)^2+b^2*cos(x)^2))
147        ellip *=2
148        ellip = ellip^2
149        Integrate/T ellip
150       
151        return(ellip[99]*2/pi)
152End
153
154//wrapper to calculate the smeared model as an AAO-Struct
155// fills the struct and calls the ususal function with the STRUCT parameter
156//
157// used only for the dependency, not for fitting
158//
159Function fSmearedFlexCyl_Ellip(coefW,yW,xW)
160        Wave coefW,yW,xW
161       
162        String str = getWavesDataFolder(yW,0)
163        String DF="root:"+str+":"
164       
165        WAVE resW = $(DF+str+"_res")
166       
167        STRUCT ResSmearAAOStruct fs
168        WAVE fs.coefW = coefW   
169        WAVE fs.yW = yW
170        WAVE fs.xW = xW
171        WAVE fs.resW = resW
172       
173        Variable err
174        err = SmearedFlexCyl_Ellip(fs)
175       
176        return (0)
177End
178
179// this is all there is to the smeared calculation!
180Function SmearedFlexCyl_Ellip(s) :FitFunc
181        Struct ResSmearAAOStruct &s
182
183//      the name of your unsmeared model (AAO) is the first argument
184        Smear_Model_20(FlexCyl_Ellip,s.coefW,s.xW,s.yW,s.resW)
185
186        return(0)
187End
188
189
Note: See TracBrowser for help on using the repository browser.