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

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

Second round of changes to ipf files to (hopefully) complete the changes to bring all of the model functions to be:

  • this set of changes is for the "2006" set of models
  • AAO
  • new dependencies
  • smearing using structures
  • #if conditional compile for XOPS

-this needs to be FULLY tested for correctness and bugs
-packages are certainly still broken (data folders)

SRK 25 JUL 07

File size: 5.1 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 Plot_LamellarFF(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//
45End
46
47// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
48Proc PlotSmeared_LamellarFF(str)                                                               
49        String str
50        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4)
51       
52        // if any of the resolution waves are missing => abort
53        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
54                Abort
55        endif
56       
57        SetDataFolder $("root:"+str)
58       
59        // Setup parameter table for model function
60        Make/O/D smear_coef_LamellarFF = {1,50,0.15,6e-6,0}             //CH#4
61        make/o/t smear_parameters_LamellarFF = {"Scale","Bilayer Thick (delta) (A)","polydisp of thickness","contrast (A^-2)","Incoherent Bgd (cm-1)"}
62        Edit smear_parameters_LamellarFF,smear_coef_LamellarFF                                  //display parameters in a table
63       
64        // output smeared intensity wave, dimensions are identical to experimental QSIG values
65        // make extra copy of experimental q-values for easy plotting
66        Duplicate/O $(str+"_q") smeared_LamellarFF,smeared_qvals                                //
67        SetScale d,0,0,"1/cm",smeared_LamellarFF                                                        //
68                                       
69        Variable/G gs_LamellarFF=0
70        gs_LamellarFF := fLamellarFF_Smeared(smear_coef_LamellarFF,smeared_LamellarFF,smeared_qvals)    //this wrapper fills the STRUCT
71       
72        Display smeared_LamellarFF vs smeared_qvals                                                                     //
73        ModifyGraph log=1,marker=29,msize=2,mode=4
74        Label bottom "q (\\S-1\\M)"
75        Label left "I(q) (cm\\S-1\\M)"
76        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
77       
78        SetDataFolder root:
79End
80////////////////////////////////////////////////////
81       
82
83
84//AAO version, uses XOP if available
85// simply calls the original single point calculation with
86// a wave assignment (this will behave nicely if given point ranges)
87Function LamellarFF(cw,yw,xw) : FitFunc
88        Wave cw,yw,xw
89       
90#if exists("LamellarFFX")
91        yw = LamellarFFX(cw,xw)
92#else
93        yw = fLamellarFF(cw,xw)
94#endif
95        return(0)
96End
97
98//CH#1
99// you should write your function to calculate the intensity
100// for a single q-value (that's the input parameter x)
101// based on the wave (array) of parameters that you send it (w)
102//
103Function fLamellarFF(w,x) : FitFunc
104        Wave w
105        Variable x
106//       Input (fitting) variables are:
107//[0]Scale
108//[1]Bilay Thick (delta)
109//[2] polydispersity of thickness
110//[3]contrast
111//[4]Incoherent Bgd (cm-1)
112       
113//      give them nice names
114        Variable scale,dd,del,sig,contr,NN,Cp,bkg
115        scale = w[0]
116        del = w[1]
117        sig = w[2]*del
118        contr = w[3]
119        bkg = w[4]
120       
121//      local variables
122        Variable inten, qval,Pq,Sq,ii,alpha,temp,t1,t2,t3,dQ
123       
124        //      x is the q-value for the calculation
125        qval = x
126       
127        Pq = 2*contr^2/qval/qval*(1-cos(qval*del)*exp(-0.5*qval^2*sig^2))
128       
129        inten = 2*Pi*scale*Pq/Qval^2            //this is now dimensionless...
130       
131        inten /= del                    //normalize by the thickness (in A)
132       
133        inten *= 1e8            // 1/A to 1/cm
134       
135        Return (inten+bkg)
136End
137
138//wrapper to calculate the smeared model as an AAO-Struct
139// fills the struct and calls the ususal function with the STRUCT parameter
140//
141// used only for the dependency, not for fitting
142//
143Function fLamellarFF_Smeared(coefW,yW,xW)
144        Wave coefW,yW,xW
145       
146        String str = getWavesDataFolder(yW,0)
147        String DF="root:"+str+":"
148       
149        WAVE resW = $(DF+str+"_res")
150       
151        STRUCT ResSmearAAOStruct fs
152        WAVE fs.coefW = coefW   
153        WAVE fs.yW = yW
154        WAVE fs.xW = xW
155        WAVE fs.resW = resW
156       
157        Variable err
158        err = LamellarFF_Smeared(fs)
159       
160        return (0)
161End
162
163//the smeared model calculation
164Function LamellarFF_Smeared(s) :FitFunc
165        Struct ResSmearAAOStruct &s
166
167//      the name of your unsmeared model (AAO) is the first argument
168        s.yW = Smear_Model_20(LamellarFF,s.coefW,s.xW,s.resW)
169
170        return(0)
171End
Note: See TracBrowser for help on using the repository browser.