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 | // |
---|
25 | Proc PlotLamellarFF_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 | |
---|
47 | AddModelToStrings("LamellarFF_HG","coef_LamellarFF_HG","LamellarFF_HG") |
---|
48 | // |
---|
49 | End |
---|
50 | |
---|
51 | // - sets up a dependency to a wrapper, not the actual SmearedModelFunction |
---|
52 | Proc PlotSmearedLamellarFF_HG(str) |
---|
53 | String str |
---|
54 | Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4) |
---|
55 | |
---|
56 | // if any of the resolution waves are missing => abort |
---|
57 | if(ResolutionWavesMissingDF(str)) //updated to NOT use global strings (in GaussUtils) |
---|
58 | Abort |
---|
59 | endif |
---|
60 | |
---|
61 | SetDataFolder $("root:"+str) |
---|
62 | |
---|
63 | // Setup parameter table for model function |
---|
64 | Make/O/D smear_coef_LamellarFF_HG = {1,15,10,4e-7,3e-6,6e-6,0} //CH#4 |
---|
65 | 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)"} |
---|
66 | Edit smear_parameters_LamellarFF_HG,smear_coef_LamellarFF_HG //display parameters in a table |
---|
67 | |
---|
68 | // output smeared intensity wave, dimensions are identical to experimental QSIG values |
---|
69 | // make extra copy of experimental q-values for easy plotting |
---|
70 | Duplicate/O $(str+"_q") smeared_LamellarFF_HG,smeared_qvals // |
---|
71 | SetScale d,0,0,"1/cm",smeared_LamellarFF_HG // |
---|
72 | |
---|
73 | Variable/G gs_LamellarFF_HG=0 |
---|
74 | gs_LamellarFF_HG := fSmearedLamellarFF_HG(smear_coef_LamellarFF_HG,smeared_LamellarFF_HG,smeared_qvals) //this wrapper fills the STRUCT |
---|
75 | |
---|
76 | Display smeared_LamellarFF_HG vs smeared_qvals // |
---|
77 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
78 | Label bottom "q (\\S-1\\M)" |
---|
79 | Label left "I(q) (cm\\S-1\\M)" |
---|
80 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
81 | |
---|
82 | SetDataFolder root: |
---|
83 | AddModelToStrings("SmearedLamellarFF_HG","smear_coef_LamellarFF_HG","LamellarFF_HG") |
---|
84 | End |
---|
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) |
---|
91 | Function LamellarFF_HG(cw,yw,xw) : FitFunc |
---|
92 | Wave cw,yw,xw |
---|
93 | |
---|
94 | #if exists("LamellarFF_HGX") |
---|
95 | yw = LamellarFF_HGX(cw,xw) |
---|
96 | #else |
---|
97 | yw = fLamellarFF_HG(cw,xw) |
---|
98 | #endif |
---|
99 | return(0) |
---|
100 | End |
---|
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 | // |
---|
107 | Function fLamellarFF_HG(w,x) : FitFunc |
---|
108 | Wave w |
---|
109 | Variable x |
---|
110 | // Input (fitting) variables are: |
---|
111 | //[0]Scale |
---|
112 | //[1]tail length |
---|
113 | //[2]hg thickness |
---|
114 | //[3]sld tail |
---|
115 | //[4]sld HG |
---|
116 | //[5]sld solvent |
---|
117 | //[6]Incoherent Bgd (cm-1) |
---|
118 | |
---|
119 | // give them nice names |
---|
120 | Variable scale,delT,delH,slds,sldh,sldt,sig,contr,NN,Cp,bkg |
---|
121 | scale = w[0] |
---|
122 | delT = w[1] |
---|
123 | delH = w[2] |
---|
124 | sldt = w[3] |
---|
125 | sldh = w[4] |
---|
126 | slds = w[5] |
---|
127 | bkg = w[6] |
---|
128 | |
---|
129 | // local variables |
---|
130 | Variable inten, qval,Pq,drh,drt |
---|
131 | |
---|
132 | // x is the q-value for the calculation |
---|
133 | qval = x |
---|
134 | drh = sldh - slds |
---|
135 | drt = sldt - slds //correction 13FEB06 by L.Porcar |
---|
136 | |
---|
137 | Pq = drh*(sin(qval*(delH+delT))-sin(qval*delT)) + drt*sin(qval*delT) |
---|
138 | Pq *= Pq |
---|
139 | Pq *= 4/(qval^2) |
---|
140 | |
---|
141 | inten = 2*Pi*scale*Pq/Qval^2 //dimensionless... |
---|
142 | |
---|
143 | inten /= 2*(delT+delH) //normalize by the bilayer thickness |
---|
144 | |
---|
145 | inten *= 1e8 // 1/A to 1/cm |
---|
146 | Return (inten+bkg) |
---|
147 | End |
---|
148 | |
---|
149 | //wrapper to calculate the smeared model as an AAO-Struct |
---|
150 | // fills the struct and calls the ususal function with the STRUCT parameter |
---|
151 | // |
---|
152 | // used only for the dependency, not for fitting |
---|
153 | // |
---|
154 | Function fSmearedLamellarFF_HG(coefW,yW,xW) |
---|
155 | Wave coefW,yW,xW |
---|
156 | |
---|
157 | String str = getWavesDataFolder(yW,0) |
---|
158 | String DF="root:"+str+":" |
---|
159 | |
---|
160 | WAVE resW = $(DF+str+"_res") |
---|
161 | |
---|
162 | STRUCT ResSmearAAOStruct fs |
---|
163 | WAVE fs.coefW = coefW |
---|
164 | WAVE fs.yW = yW |
---|
165 | WAVE fs.xW = xW |
---|
166 | WAVE fs.resW = resW |
---|
167 | |
---|
168 | Variable err |
---|
169 | err = SmearedLamellarFF_HG(fs) |
---|
170 | |
---|
171 | return (0) |
---|
172 | End |
---|
173 | |
---|
174 | //the smeared model calculation |
---|
175 | Function SmearedLamellarFF_HG(s) :FitFunc |
---|
176 | Struct ResSmearAAOStruct &s |
---|
177 | |
---|
178 | // the name of your unsmeared model (AAO) is the first argument |
---|
179 | Smear_Model_20(LamellarFF_HG,s.coefW,s.xW,s.yW,s.resW) |
---|
180 | |
---|
181 | return(0) |
---|
182 | End |
---|