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

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

Changed Plot* and PlotSmeared?* naming schemes to be all consistent prefixes for the actual function name, so that the macros can be constructed from the function name, or vice versa.

also some tweaks to the wrapper to make sure that plot and append really work

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