1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
2 | #pragma IgorVersion=6.0 |
---|
3 | |
---|
4 | //////////////////////////////////////////////////// |
---|
5 | // Raspberry model |
---|
6 | // |
---|
7 | // Larson-Smith et al. Small angle scattering model for Pickering emulsions and raspberry particles. |
---|
8 | // Journal of colloid and interface science (2010) vol. 343 (1) pp. 36-41 |
---|
9 | // |
---|
10 | // Default parameters are for a 5000A hexadecane drop stabilized by 100A silica particles |
---|
11 | // in D2O. The particles are 50% inserted into the interface (delta = 0) and surface coverage is 50% |
---|
12 | //////////////////////////////////////////////////// |
---|
13 | |
---|
14 | //this macro sets up all the necessary parameters and waves that are |
---|
15 | //needed to calculate the model function. |
---|
16 | // |
---|
17 | Proc PlotRaspberry(num,qmin,qmax) |
---|
18 | Variable num=500, qmin=1e-5, qmax=0.7 |
---|
19 | Prompt num "Enter number of data points for model: " |
---|
20 | Prompt qmin "Enter minimum q-value (^-1) for model: " |
---|
21 | Prompt qmax "Enter maximum q-value (^-1) for model: " |
---|
22 | // |
---|
23 | Make/O/D/n=(num) xwave_Raspberry, ywave_Raspberry |
---|
24 | xwave_Raspberry = alog(log(qmin) + x*((log(qmax)-log(qmin))/num)) |
---|
25 | Make/O/D coef_Raspberry = {0.05,5000,-4e-7,0.005,100,0.4,3.5e-6,0,6.3e-6,0.0} |
---|
26 | make/o/t parameters_Raspberry = {"vol fract Large","Radius Large (A)","SLD Large sphere (A-2)","vol fract Small", "Radius Small (A)","surface coverage","SLD Small sphere (A-2)","delta","SLD solvent (A-2)","bkgd (cm-1)"} |
---|
27 | Edit parameters_Raspberry, coef_Raspberry |
---|
28 | |
---|
29 | Variable/G root:g_Raspberry |
---|
30 | g_Raspberry := Raspberry(coef_Raspberry, ywave_Raspberry, xwave_Raspberry) |
---|
31 | Display ywave_Raspberry vs xwave_Raspberry |
---|
32 | ModifyGraph marker=29, msize=2, mode=4 |
---|
33 | ModifyGraph log=1,grid=1,mirror=2 |
---|
34 | Label bottom "q (\\S-1\\M) " |
---|
35 | Label left "I(q) (cm\\S-1\\M)" |
---|
36 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
37 | |
---|
38 | AddModelToStrings("Raspberry","coef_Raspberry","parameters_Raspberry","Raspberry") |
---|
39 | // |
---|
40 | End |
---|
41 | |
---|
42 | |
---|
43 | // |
---|
44 | //this macro sets up all the necessary parameters and waves that are |
---|
45 | //needed to calculate the smeared model function. |
---|
46 | // |
---|
47 | //no input parameters are necessary, it MUST use the experimental q-values |
---|
48 | // from the experimental data read in from an AVE/QSIG data file |
---|
49 | //////////////////////////////////////////////////// |
---|
50 | // - sets up a dependency to a wrapper, not the actual SmearedModelFunction |
---|
51 | Proc PlotSmearedRaspberry(str) |
---|
52 | String str |
---|
53 | Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4) |
---|
54 | |
---|
55 | // if any of the resolution waves are missing => abort |
---|
56 | if(ResolutionWavesMissingDF(str)) //updated to NOT use global strings (in GaussUtils) |
---|
57 | Abort |
---|
58 | endif |
---|
59 | |
---|
60 | SetDataFolder $("root:"+str) |
---|
61 | |
---|
62 | // Setup parameter table for model function |
---|
63 | Make/O/D smear_coef_Raspberry = {0.05,5000,-4e-7,0.005,100,0.4,3.5e-6,0,6.3e-6,0.0} |
---|
64 | make/o/t smear_parameters_Raspberry = {"vol fract Large","Radius Large (A)","SLD Large sphere (A-2)","vol fract Small", "Radius Small (A)","surface coverage","SLD Small sphere (A-2)","delta","SLD solvent (A-2)","bkgd (cm-1)"} |
---|
65 | Edit smear_parameters_Raspberry,smear_coef_Raspberry //display parameters in a table |
---|
66 | |
---|
67 | // output smeared intensity wave, dimensions are identical to experimental QSIG values |
---|
68 | // make extra copy of experimental q-values for easy plotting |
---|
69 | Duplicate/O $(str+"_q") smeared_Raspberry,smeared_qvals |
---|
70 | SetScale d,0,0,"1/cm",smeared_Raspberry |
---|
71 | |
---|
72 | Variable/G gs_Raspberry=0 |
---|
73 | gs_Raspberry := fSmearedRaspberry(smear_coef_Raspberry,smeared_Raspberry,smeared_qvals) //this wrapper fills the STRUCT |
---|
74 | |
---|
75 | Display smeared_Raspberry vs smeared_qvals |
---|
76 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
77 | Label bottom "q (\\S-1\\M)" |
---|
78 | Label left "I(q) (cm\\S-1\\M)" |
---|
79 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
80 | |
---|
81 | SetDataFolder root: |
---|
82 | AddModelToStrings("SmearedRaspberry","smear_coef_Raspberry","smear_parameters_Raspberry","Raspberry") |
---|
83 | End |
---|
84 | |
---|
85 | |
---|
86 | Macro CalcRaspberryStats() |
---|
87 | |
---|
88 | Variable vfL,rL,sldL,vfS,rS,sldS,deltaS,delrhoL,delrhoS,bkg,sldSolv,qval ,aSs |
---|
89 | vfL = coef_Raspberry[0] |
---|
90 | rL = coef_Raspberry[1] |
---|
91 | sldL = coef_Raspberry[2] |
---|
92 | vfS = coef_Raspberry[3] |
---|
93 | rS = coef_Raspberry[4] |
---|
94 | aSs = coef_Raspberry[5] |
---|
95 | sldS = coef_Raspberry[6] |
---|
96 | deltaS = coef_Raspberry[7] |
---|
97 | sldSolv = coef_Raspberry[8] |
---|
98 | bkg = coef_Raspberry[9] |
---|
99 | |
---|
100 | Variable fractionsmall,Np,VL,VS |
---|
101 | |
---|
102 | VL = 4*pi/3*rL^3 |
---|
103 | VS = 4*pi/3*rS^3 |
---|
104 | |
---|
105 | //Np = aSs*0.04*(rS/(rL+deltaS))*(VL/VS) |
---|
106 | Np = aSs*4*((rL+deltaS)/rS)^2 |
---|
107 | fractionsmall = Np*vfL*VS/vfS/VL |
---|
108 | |
---|
109 | print "Fraction small on large = "+num2str(fractionsmall)+"\r" |
---|
110 | print "Number of small particles on large = "+num2str(Np)+"\r" |
---|
111 | |
---|
112 | End |
---|
113 | |
---|
114 | Proc PlotRaspberrySq() |
---|
115 | |
---|
116 | setdatafolder root: |
---|
117 | |
---|
118 | Variable vfL,rL,sldL,vfS,rS,sldS,deltaS,delrhoL,delrhoS,bkg,sldSolv,qval ,aSs |
---|
119 | vfL = coef_Raspberry[0] |
---|
120 | rL = coef_Raspberry[1] |
---|
121 | delrhoL = coef_Raspberry[2] |
---|
122 | vfS = coef_Raspberry[3] |
---|
123 | rS = coef_Raspberry[4] |
---|
124 | aSs = coef_Raspberry[5] |
---|
125 | delrhoS = coef_Raspberry[6] |
---|
126 | deltaS = coef_Raspberry[7] |
---|
127 | |
---|
128 | Duplicate/O xwave_Raspberry ywave_sfLS_Rasp |
---|
129 | Duplicate/O xwave_Raspberry ywave_sfSS_Rasp |
---|
130 | |
---|
131 | Variable psiL,psiS,vol,f2 |
---|
132 | Variable VL,VS,slT,Np,fSs |
---|
133 | |
---|
134 | VL = 4*pi/3*rL^3 |
---|
135 | VS = 4*pi/3*rS^3 |
---|
136 | Np = aSs*4*((rL+deltaS)/rS)^2 |
---|
137 | |
---|
138 | ywave_sfLS_Rasp = fRaspBes(xwave_Raspberry,rL)*fRaspBes(xwave_Raspberry,rS)*(sin(xwave_Raspberry*(rL+deltaS*rS))/xwave_Raspberry/(rL+deltaS*rS)) |
---|
139 | ywave_sfSS_Rasp = fRaspBes(xwave_Raspberry,rS)*fRaspBes(xwave_Raspberry,rS)*(sin(xwave_Raspberry*(rL+deltaS*rS))/xwave_Raspberry/(rL+deltaS*rS))^2 |
---|
140 | |
---|
141 | Display ywave_sfLS_Rasp vs xwave_Raspberry |
---|
142 | AppendToGraph ywave_sfSS_Rasp vs xwave_Raspberry |
---|
143 | ModifyGraph log(bottom)=1 |
---|
144 | |
---|
145 | End |
---|
146 | |
---|
147 | // nothing to change here |
---|
148 | // |
---|
149 | //AAO version, uses XOP if available |
---|
150 | // simply calls the original single point calculation with |
---|
151 | // a wave assignment (this will behave nicely if given point ranges) |
---|
152 | Function Raspberry(cw,yw,xw) : FitFunc |
---|
153 | Wave cw,yw,xw |
---|
154 | |
---|
155 | #if exists("RaspberryX") |
---|
156 | yw = RaspberryX(cw,xw) |
---|
157 | #else |
---|
158 | yw = fRaspberry(cw,xw) |
---|
159 | #endif |
---|
160 | return(0) |
---|
161 | End |
---|
162 | |
---|
163 | |
---|
164 | // you should write your function to calculate the intensity |
---|
165 | // for a single q-value (that's the input parameter x) |
---|
166 | // based on the wave (array) of parameters that you send it (w) |
---|
167 | // |
---|
168 | // unsmeared model calculation |
---|
169 | // |
---|
170 | Function fRaspberry(w,x) : FitFunc |
---|
171 | Wave w |
---|
172 | Variable x |
---|
173 | |
---|
174 | // variables are: |
---|
175 | //[0] volume fraction large spheres |
---|
176 | //[1] radius large sphere () |
---|
177 | //[2] sld large sphere (-2) |
---|
178 | //[3] volume fraction small spheres |
---|
179 | //[4] fraction of small spheres at surface |
---|
180 | //[5] radius small sphere (A) |
---|
181 | //[6] sld small sphere |
---|
182 | //[7] small sphere penetration (A) |
---|
183 | //[8] sld solvent |
---|
184 | //[9] background (cm-1) |
---|
185 | |
---|
186 | Variable vfL,rL,sldL,vfS,rS,sldS,deltaS,delrhoL,delrhoS,bkg,sldSolv,qval ,aSs |
---|
187 | vfL = w[0] |
---|
188 | rL = w[1] |
---|
189 | sldL = w[2] |
---|
190 | vfS = w[3] |
---|
191 | rS = w[4] |
---|
192 | aSs = w[5] |
---|
193 | sldS = w[6] |
---|
194 | deltaS = w[7] |
---|
195 | sldSolv = w[8] |
---|
196 | bkg = w[9] |
---|
197 | |
---|
198 | delrhoL = abs(sldL - sldSolv) |
---|
199 | delrhoS = abs(sldS - sldSolv) |
---|
200 | |
---|
201 | Variable VL,VS,Np,f2,fSs |
---|
202 | |
---|
203 | VL = 4*pi/3*rL^3 |
---|
204 | VS = 4*pi/3*rS^3 |
---|
205 | |
---|
206 | //Np = vfS*fSs*VL/vfL/VS |
---|
207 | //Np = aSs*4*(rS/(rL+deltaS))*(VL/VS) |
---|
208 | Np = aSs*4*((rL+deltaS)/rS)^2 |
---|
209 | |
---|
210 | fSs = Np*vfL*VS/vfS/VL |
---|
211 | |
---|
212 | Make/O/N=9 rasp_temp |
---|
213 | rasp_temp[0] = w[0] |
---|
214 | rasp_temp[1] = w[1] |
---|
215 | rasp_temp[2] = delrhoL |
---|
216 | rasp_temp[3] = w[3] |
---|
217 | rasp_temp[4] = w[4] |
---|
218 | rasp_temp[5] = w[5] |
---|
219 | rasp_temp[6] = delrhoS |
---|
220 | rasp_temp[7] = w[7] |
---|
221 | |
---|
222 | //f2 = (vfL*delrhoL^2*VL + vfS*fSs*Np*delrhoS^2*VS)*fRaspberryKernel(rasp_temp,x) |
---|
223 | f2 = fRaspberryKernel(rasp_temp,x) |
---|
224 | f2+= vfS*(1-fSs)*delrhoS^2*VS*fRaspBes(x,rS)*fRaspBes(x,rS) |
---|
225 | |
---|
226 | // normalize to single particle volume and convert to 1/cm |
---|
227 | f2 *= 1e8 // [=] 1/cm |
---|
228 | |
---|
229 | return (f2+bkg) // Scale, then add in the background |
---|
230 | |
---|
231 | End |
---|
232 | |
---|
233 | Function fRaspberryKernel(w,x) |
---|
234 | Wave w |
---|
235 | Variable x |
---|
236 | |
---|
237 | // variables are: |
---|
238 | //[0] volume fraction large spheres |
---|
239 | //[1] radius large sphere () |
---|
240 | //[2] sld large sphere (-2) |
---|
241 | //[3] volume fraction small spheres |
---|
242 | //[4] fraction of small spheres at surface |
---|
243 | //[5] radius small sphere (A) |
---|
244 | //[6] sld small sphere |
---|
245 | //[7] small sphere penetration (A) |
---|
246 | //[8] sld solvent |
---|
247 | |
---|
248 | Variable vfL,rL,sldL,vfS,rS,sldS,deltaS,delrhoL,delrhoS,bkg,sldSolv,qval ,aSs |
---|
249 | vfL = w[0] |
---|
250 | rL = w[1] |
---|
251 | delrhoL = w[2] |
---|
252 | vfS = w[3] |
---|
253 | rS = w[4] |
---|
254 | aSs = w[5] |
---|
255 | delrhoS = w[6] |
---|
256 | deltaS = w[7] |
---|
257 | |
---|
258 | qval = x //rename the input q-value, purely for readability |
---|
259 | |
---|
260 | Variable psiL,psiS,vol,f2 |
---|
261 | Variable sfLS,sfSS |
---|
262 | Variable VL,VS,slT,Np,fSs |
---|
263 | |
---|
264 | VL = 4*pi/3*rL^3 |
---|
265 | VS = 4*pi/3*rS^3 |
---|
266 | |
---|
267 | Np = aSs*4*(rS/(rL+deltaS))*VL/VS |
---|
268 | //Np = aSs*4*((rL+deltaS)/rS)^2 |
---|
269 | |
---|
270 | fSs = Np*vfL*VS/vfS/VL |
---|
271 | |
---|
272 | slT = delrhoL*VL + Np*delrhoS*VS |
---|
273 | |
---|
274 | psiL = fRaspBes(qval,rL) |
---|
275 | psiS = fRaspBes(qval,rS) |
---|
276 | |
---|
277 | sfLS = psiL*psiS*(sin(qval*(rL+deltaS*rS))/qval/(rL+deltaS*rS)) |
---|
278 | sfSS = psiS*psiS*(sin(qval*(rL+deltaS*rS))/qval/(rL+deltaS*rS))^2 |
---|
279 | |
---|
280 | f2 = delrhoL^2*VL^2*psiL^2 |
---|
281 | f2 += Np*delrhoS^2*VS^2*psiS^2 |
---|
282 | f2 += Np*(Np-1)*delrhoS^2*VS^2*sfSS |
---|
283 | f2 += 2*Np*delrhoL*delrhoS*VL*VS*sfLS |
---|
284 | if (f2 != 0) |
---|
285 | f2 = f2/slT/slT |
---|
286 | endif |
---|
287 | |
---|
288 | f2 = f2*(vfL*delrhoL^2*VL + vfS*fSs*Np*delrhoS^2*VS) |
---|
289 | |
---|
290 | return f2 |
---|
291 | End |
---|
292 | |
---|
293 | Function fRaspBes(Qval,Rad) |
---|
294 | Variable Qval,Rad |
---|
295 | |
---|
296 | Variable retval |
---|
297 | |
---|
298 | retval = 3*(sin(qval*rad)-qval*rad*cos(qval*rad))/qval^3/rad^3 |
---|
299 | |
---|
300 | return retval |
---|
301 | End |
---|
302 | |
---|
303 | /////////////////////////////////////////////////////////////// |
---|
304 | // smeared model calculation |
---|
305 | // |
---|
306 | // you don't need to do anything with this function, as long as |
---|
307 | // your Raspberry works correctly, you get the resolution-smeared |
---|
308 | // version for free. |
---|
309 | // |
---|
310 | // this is all there is to the smeared model calculation! |
---|
311 | Function SmearedRaspberry(s) : FitFunc |
---|
312 | Struct ResSmearAAOStruct &s |
---|
313 | |
---|
314 | // the name of your unsmeared model (AAO) is the first argument |
---|
315 | Smear_Model_20(Raspberry,s.coefW,s.xW,s.yW,s.resW) |
---|
316 | |
---|
317 | return(0) |
---|
318 | End |
---|
319 | |
---|
320 | |
---|
321 | /////////////////////////////////////////////////////////////// |
---|
322 | |
---|
323 | |
---|
324 | // nothing to change here |
---|
325 | // |
---|
326 | //wrapper to calculate the smeared model as an AAO-Struct |
---|
327 | // fills the struct and calls the ususal function with the STRUCT parameter |
---|
328 | // |
---|
329 | // used only for the dependency, not for fitting |
---|
330 | // |
---|
331 | Function fSmearedRaspberry(coefW,yW,xW) |
---|
332 | Wave coefW,yW,xW |
---|
333 | |
---|
334 | String str = getWavesDataFolder(yW,0) |
---|
335 | String DF="root:"+str+":" |
---|
336 | |
---|
337 | WAVE resW = $(DF+str+"_res") |
---|
338 | |
---|
339 | STRUCT ResSmearAAOStruct fs |
---|
340 | WAVE fs.coefW = coefW |
---|
341 | WAVE fs.yW = yW |
---|
342 | WAVE fs.xW = xW |
---|
343 | WAVE fs.resW = resW |
---|
344 | |
---|
345 | Variable err |
---|
346 | err = SmearedRaspberry(fs) |
---|
347 | |
---|
348 | return (0) |
---|
349 | End |
---|