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

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

Typo in dialog in every model...

File size: 5.5 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 from the solvent,
8// surfactant headgroups, and surfactant tails
9//
10// The system is considered to be DILUTE - Interference (S(Q))
11// effects are NOT taken into account.
12// ONLY the form factor is calculated
13//
14// REFERENCE:   Nallet, Laversanne, and Roux, J. Phys. II France, 3, (1993) 487-502.
15//              also in J. Phys. Chem. B, 105, (2001) 11081-11088.
16//
17// 16 JULY 2003 SRK
18// 13 FEB 06 correct normalization (L.Porcar)
19//
20////////////////////////////////////////////////////
21
22//this macro sets up all the necessary parameters and waves that are
23//needed to calculate the model function.
24//
25Proc Plot_LamellarFF_HG(num,qmin,qmax)
26        Variable num=128, qmin=.001, qmax=.5
27        Prompt num "Enter number of data points for model: "
28        Prompt qmin "Enter minimum q-value (^1) for model: "
29        Prompt qmax "Enter maximum q-value (^1) for model: "
30//
31        Make/O/D/n=(num) xwave_LamellarFF_HG, ywave_LamellarFF_HG
32        xwave_LamellarFF_HG =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
33        Make/O/D coef_LamellarFF_HG = {1,15,10,4e-7,3e-6,6e-6,0}                        //CH#2
34        make/o/t parameters_LamellarFF_HG = {"Scale","Tail length (A)","Headgroup thickness (A)","SLD Tails (A^-2)","SLD Headgroup (A^-2)","SLD Solvent (A^-2)","Incoherent Bgd (cm-1)"}        //CH#3
35        Edit parameters_LamellarFF_HG, coef_LamellarFF_HG
36        ModifyTable width(parameters_LamellarFF_HG)=160
37       
38        Variable/G root:g_LamellarFF_HG
39        g_LamellarFF_HG := LamellarFF_HG(coef_LamellarFF_HG, ywave_LamellarFF_HG, xwave_LamellarFF_HG)
40        Display ywave_LamellarFF_HG vs xwave_LamellarFF_HG
41        ModifyGraph marker=29, msize=2, mode=4
42        ModifyGraph log=1
43        Label bottom "q (\\S-1\\M) "
44        Label left "I(q) (cm\\S-1\\M)"
45        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
46//
47End
48
49// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
50Proc PlotSmeared_LamellarFF_HG(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_HG = {1,15,10,4e-7,3e-6,6e-6,0}          //CH#4
63        make/o/t smear_parameters_LamellarFF_HG = {"Scale","Tail length (A)","Headgroup thickness (A)","SLD Tails (A^-2)","SLD Headgroup (A^-2)","SLD Solvent (A^-2)","Incoherent Bgd (cm-1)"}
64        Edit smear_parameters_LamellarFF_HG,smear_coef_LamellarFF_HG                                    //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_HG,smeared_qvals                             //
69        SetScale d,0,0,"1/cm",smeared_LamellarFF_HG                                                     //
70                                       
71        Variable/G gs_LamellarFF_HG=0
72        gs_LamellarFF_HG := fLamellarFF_HG_Smeared(smear_coef_LamellarFF_HG,smeared_LamellarFF_HG,smeared_qvals)        //this wrapper fills the STRUCT
73       
74        Display smeared_LamellarFF_HG 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:
81End
82
83
84
85//AAO version, uses XOP if available
86// simply calls the original single point calculation with
87// a wave assignment (this will behave nicely if given point ranges)
88Function LamellarFF_HG(cw,yw,xw) : FitFunc
89        Wave cw,yw,xw
90       
91#if exists("LamellarFF_HGX")
92        yw = LamellarFF_HGX(cw,xw)
93#else
94        yw = fLamellarFF_HG(cw,xw)
95#endif
96        return(0)
97End
98
99//CH#1
100// you should write your function to calculate the intensity
101// for a single q-value (that's the input parameter x)
102// based on the wave (array) of parameters that you send it (w)
103//
104Function fLamellarFF_HG(w,x) : FitFunc
105        Wave w
106        Variable x
107//       Input (fitting) variables are:
108//[0]Scale
109//[1]tail length
110//[2]hg thickness
111//[3]sld tail
112//[4]sld HG
113//[5]sld solvent
114//[6]Incoherent Bgd (cm-1)
115       
116//      give them nice names
117        Variable scale,delT,delH,slds,sldh,sldt,sig,contr,NN,Cp,bkg
118        scale = w[0]
119        delT = w[1]
120        delH = w[2]
121        sldt = w[3]
122        sldh = w[4]
123        slds = w[5]
124        bkg = w[6]
125       
126//      local variables
127        Variable inten, qval,Pq,drh,drt
128       
129        //      x is the q-value for the calculation
130        qval = x
131        drh = sldh - slds
132        drt = sldt - slds               //correction 13FEB06 by L.Porcar
133       
134        Pq = drh*(sin(qval*(delH+delT))-sin(qval*delT)) + drt*sin(qval*delT)
135        Pq *= Pq
136        Pq *= 4/(qval^2)
137       
138        inten = 2*Pi*scale*Pq/Qval^2            //dimensionless...
139       
140        inten /= 2*(delT+delH)                  //normalize by the bilayer thickness
141       
142        inten *= 1e8            // 1/A to 1/cm
143        Return (inten+bkg)
144End
145
146//wrapper to calculate the smeared model as an AAO-Struct
147// fills the struct and calls the ususal function with the STRUCT parameter
148//
149// used only for the dependency, not for fitting
150//
151Function fLamellarFF_HG_Smeared(coefW,yW,xW)
152        Wave coefW,yW,xW
153       
154        String str = getWavesDataFolder(yW,0)
155        String DF="root:"+str+":"
156       
157        WAVE resW = $(DF+str+"_res")
158       
159        STRUCT ResSmearAAOStruct fs
160        WAVE fs.coefW = coefW   
161        WAVE fs.yW = yW
162        WAVE fs.xW = xW
163        WAVE fs.resW = resW
164       
165        Variable err
166        err = LamellarFF_HG_Smeared(fs)
167       
168        return (0)
169End
170
171//the smeared model calculation
172Function LamellarFF_HG_Smeared(s) :FitFunc
173        Struct ResSmearAAOStruct &s
174
175//      the name of your unsmeared model (AAO) is the first argument
176        s.yW = Smear_Model_20(LamellarFF_HG,s.coefW,s.xW,s.resW)
177
178        return(0)
179End
Note: See TracBrowser for help on using the repository browser.