source: sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/LamellarFF.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////////////////////////////////////////////////////
5//
6// model function that calculates the scattering from
7// lamellar surfactant structures. contrast is two-phase,
8// from the solvent and uniform bilayer. The system is
9// considered to be DILUTE - Interference (S(Q)) effects
10// are NOT taken into account. ONLY the form factor is calculated
11//
12//
13// REFERENCE:   Nallet, Laversanne, and Roux, J. Phys. II France, 3, (1993) 487-502.
14//              also in J. Phys. Chem. B, 105, (2001) 11081-11088.
15//
16// 16 JULY 2003 SRK
17//
18////////////////////////////////////////////////////
19
20//this macro sets up all the necessary parameters and waves that are
21//needed to calculate the model function.
22//
23Proc PlotLamellarFF(num,qmin,qmax)
24        Variable num=128, qmin=.001, qmax=.5
25        Prompt num "Enter number of data points for model: "
26        Prompt qmin "Enter minimum q-value (^1) for model: "
27        Prompt qmax "Enter maximum q-value (^1) for model: "
28//
29        Make/O/D/n=(num) xwave_LamellarFF, ywave_LamellarFF
30        xwave_LamellarFF =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
31        Make/O/D coef_LamellarFF = {1,50,0.15,6e-6,0}                   //CH#2
32        make/o/t parameters_LamellarFF = {"Scale","Bilayer Thick (delta) (A)","polydisp of thickness","contrast (A^-2)","Incoherent Bgd (cm-1)"}        //CH#3
33        Edit parameters_LamellarFF, coef_LamellarFF
34        ModifyTable width(parameters_LamellarFF)=160
35       
36        Variable/G root:g_LamellarFF
37        g_LamellarFF := LamellarFF(coef_LamellarFF, ywave_LamellarFF,xwave_LamellarFF)
38        Display ywave_LamellarFF vs xwave_LamellarFF
39        ModifyGraph marker=29, msize=2, mode=4
40        ModifyGraph log=1
41        Label bottom "q (\\S-1\\M) "
42        Label left "I(q) (cm\\S-1\\M)"
43        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
44       
45        AddModelToStrings("LamellarFF","coef_LamellarFF","LamellarFF")
46//
47End
48
49// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
50Proc PlotSmearedLamellarFF(str)                                                         
51        String str
52        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
53       
54        // if any of the resolution waves are missing => abort
55        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
56                Abort
57        endif
58       
59        SetDataFolder $("root:"+str)
60       
61        // Setup parameter table for model function
62        Make/O/D smear_coef_LamellarFF = {1,50,0.15,6e-6,0}             //CH#4
63        make/o/t smear_parameters_LamellarFF = {"Scale","Bilayer Thick (delta) (A)","polydisp of thickness","contrast (A^-2)","Incoherent Bgd (cm-1)"}
64        Edit smear_parameters_LamellarFF,smear_coef_LamellarFF                                  //display parameters in a table
65       
66        // output smeared intensity wave, dimensions are identical to experimental QSIG values
67        // make extra copy of experimental q-values for easy plotting
68        Duplicate/O $(str+"_q") smeared_LamellarFF,smeared_qvals                                //
69        SetScale d,0,0,"1/cm",smeared_LamellarFF                                                        //
70                                       
71        Variable/G gs_LamellarFF=0
72        gs_LamellarFF := fSmearedLamellarFF(smear_coef_LamellarFF,smeared_LamellarFF,smeared_qvals)     //this wrapper fills the STRUCT
73       
74        Display smeared_LamellarFF vs smeared_qvals                                                                     //
75        ModifyGraph log=1,marker=29,msize=2,mode=4
76        Label bottom "q (\\S-1\\M)"
77        Label left "I(q) (cm\\S-1\\M)"
78        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
79       
80        SetDataFolder root:
81       
82        AddModelToStrings("SmearedLamellarPS","smear_coef_LamellarFF","LamellarFF")
83End
84////////////////////////////////////////////////////
85       
86
87
88//AAO version, uses XOP if available
89// simply calls the original single point calculation with
90// a wave assignment (this will behave nicely if given point ranges)
91Function LamellarFF(cw,yw,xw) : FitFunc
92        Wave cw,yw,xw
93       
94#if exists("LamellarFFX")
95        yw = LamellarFFX(cw,xw)
96#else
97        yw = fLamellarFF(cw,xw)
98#endif
99        return(0)
100End
101
102//CH#1
103// you should write your function to calculate the intensity
104// for a single q-value (that's the input parameter x)
105// based on the wave (array) of parameters that you send it (w)
106//
107Function fLamellarFF(w,x) : FitFunc
108        Wave w
109        Variable x
110//       Input (fitting) variables are:
111//[0]Scale
112//[1]Bilay Thick (delta)
113//[2] polydispersity of thickness
114//[3]contrast
115//[4]Incoherent Bgd (cm-1)
116       
117//      give them nice names
118        Variable scale,dd,del,sig,contr,NN,Cp,bkg
119        scale = w[0]
120        del = w[1]
121        sig = w[2]*del
122        contr = w[3]
123        bkg = w[4]
124       
125//      local variables
126        Variable inten, qval,Pq,Sq,ii,alpha,temp,t1,t2,t3,dQ
127       
128        //      x is the q-value for the calculation
129        qval = x
130       
131        Pq = 2*contr^2/qval/qval*(1-cos(qval*del)*exp(-0.5*qval^2*sig^2))
132       
133        inten = 2*Pi*scale*Pq/Qval^2            //this is now dimensionless...
134       
135        inten /= del                    //normalize by the thickness (in A)
136       
137        inten *= 1e8            // 1/A to 1/cm
138       
139        Return (inten+bkg)
140End
141
142//wrapper to calculate the smeared model as an AAO-Struct
143// fills the struct and calls the ususal function with the STRUCT parameter
144//
145// used only for the dependency, not for fitting
146//
147Function fSmearedLamellarFF(coefW,yW,xW)
148        Wave coefW,yW,xW
149       
150        String str = getWavesDataFolder(yW,0)
151        String DF="root:"+str+":"
152       
153        WAVE resW = $(DF+str+"_res")
154       
155        STRUCT ResSmearAAOStruct fs
156        WAVE fs.coefW = coefW   
157        WAVE fs.yW = yW
158        WAVE fs.xW = xW
159        WAVE fs.resW = resW
160       
161        Variable err
162        err = SmearedLamellarFF(fs)
163       
164        return (0)
165End
166
167//the smeared model calculation
168Function SmearedLamellarFF(s) :FitFunc
169        Struct ResSmearAAOStruct &s
170
171//      the name of your unsmeared model (AAO) is the first argument
172        Smear_Model_20(LamellarFF,s.coefW,s.xW,s.yW,s.resW)
173
174        return(0)
175End
Note: See TracBrowser for help on using the repository browser.