1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
2 | #pragma IgorVersion=6.0 |
---|
3 | |
---|
4 | //////////////////////////////////////////////// |
---|
5 | // |
---|
6 | // this function is for the form factor of a with some |
---|
7 | // number of shells around a central core (currently 1-2-3) |
---|
8 | // |
---|
9 | // monodisperse and polydisperse (and smeared) versions are included |
---|
10 | // - for the polydisperse models, only polydispersity of the core is taken |
---|
11 | // into account, and done numerically. for a Schulz distribution, this |
---|
12 | // should be possible to do analytically, whith a great savings in computation |
---|
13 | // time. |
---|
14 | // |
---|
15 | // It may also be useful to think of scenarios where the layers as well are |
---|
16 | // polydisperse - to break up the very regular spacing of the layers, which |
---|
17 | // is not a very natural structure. |
---|
18 | // |
---|
19 | // 03 MAR 04 SRK |
---|
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 PlotOneShell(num,qmin,qmax) |
---|
26 | Variable num=200, qmin=0.001, qmax=0.7 |
---|
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_OneShell, ywave_OneShell |
---|
32 | xwave_OneShell = alog(log(qmin) + x*((log(qmax)-log(qmin))/num)) |
---|
33 | Make/O/D coef_OneShell = {1.,60,6.4e-6,10,1e-6,6.4e-6,0.001} |
---|
34 | make/o/t parameters_OneShell = {"scale","core radius (A)","Core SLD (A-2)","Shell thickness (A)","Shell SLD (A-2)","Solvent SLD (A-2)","bkg (cm-1)"} |
---|
35 | Edit parameters_OneShell, coef_OneShell |
---|
36 | |
---|
37 | Variable/G root:g_OneShell |
---|
38 | g_OneShell := OneShell(coef_OneShell, ywave_OneShell, xwave_OneShell) |
---|
39 | Display ywave_OneShell vs xwave_OneShell |
---|
40 | ModifyGraph marker=29, msize=2, mode=4 |
---|
41 | ModifyGraph log=1,grid=1,mirror=2 |
---|
42 | Label bottom "q (\\S-1\\M) " |
---|
43 | Label left "I(q) (cm\\S-1\\M)" |
---|
44 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
45 | |
---|
46 | AddModelToStrings("OneShell","coef_OneShell","OneShell") |
---|
47 | // |
---|
48 | End |
---|
49 | |
---|
50 | Proc PlotTwoShell(num,qmin,qmax) |
---|
51 | Variable num=200, qmin=0.001, qmax=0.7 |
---|
52 | Prompt num "Enter number of data points for model: " |
---|
53 | Prompt qmin "Enter minimum q-value (^-1) for model: " |
---|
54 | Prompt qmax "Enter maximum q-value (^-1) for model: " |
---|
55 | // |
---|
56 | Make/O/D/n=(num) xwave_TwoShell, ywave_TwoShell |
---|
57 | xwave_TwoShell = alog(log(qmin) + x*((log(qmax)-log(qmin))/num)) |
---|
58 | Make/O/D coef_TwoShell = {1.,60,6.4e-6,10,1e-6,10,2e-6,6.4e-6,0.001} |
---|
59 | make/o/t parameters_TwoShell = {"scale","core radius (A)","Core SLD (A-2)","Shell 1 thickness","Shell 1 SLD (A-2)","Shell 2 thickness","Shell 2 SLD (A-2)","Solvent SLD (A-2)","bkg (cm-1)"} |
---|
60 | Edit parameters_TwoShell, coef_TwoShell |
---|
61 | |
---|
62 | Variable/G root:g_TwoShell |
---|
63 | g_TwoShell := TwoShell(coef_TwoShell, ywave_TwoShell, xwave_TwoShell) |
---|
64 | Display ywave_TwoShell vs xwave_TwoShell |
---|
65 | ModifyGraph marker=29, msize=2, mode=4 |
---|
66 | ModifyGraph log=1,grid=1,mirror=2 |
---|
67 | Label bottom "q (\\S-1\\M) " |
---|
68 | Label left "I(q) (cm\\S-1\\M)" |
---|
69 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
70 | |
---|
71 | AddModelToStrings("TwoShell","coef_TwoShell","TwoShell") |
---|
72 | // |
---|
73 | End |
---|
74 | |
---|
75 | Proc PlotThreeShell(num,qmin,qmax) |
---|
76 | Variable num=200, qmin=0.001, qmax=0.7 |
---|
77 | Prompt num "Enter number of data points for model: " |
---|
78 | Prompt qmin "Enter minimum q-value (^-1) for model: " |
---|
79 | Prompt qmax "Enter maximum q-value (^-1) for model: " |
---|
80 | // |
---|
81 | Make/O/D/n=(num) xwave_ThreeShell, ywave_ThreeShell |
---|
82 | xwave_ThreeShell = alog(log(qmin) + x*((log(qmax)-log(qmin))/num)) |
---|
83 | Make/O/D coef_ThreeShell ={1.,60,6.4e-6,10,1e-6,10,2e-6,10,3e-6,6.4e-6,0.001} |
---|
84 | make/o/t parameters_ThreeShell = {"scale","core radius (A)","Core SLD (A-2)","Shell 1 thickness","Shell 1 SLD (A-2)","Shell 2 thickness","Shell 2 SLD (A-2)","Shell 3 thickness","Shell 3 SLD (A-2)","Solvent SLD (A-2)","bkg (cm-1)"} |
---|
85 | Edit parameters_ThreeShell, coef_ThreeShell |
---|
86 | |
---|
87 | Variable/G root:g_ThreeShell |
---|
88 | g_ThreeShell := ThreeShell(coef_ThreeShell, ywave_ThreeShell, xwave_ThreeShell) |
---|
89 | Display ywave_ThreeShell vs xwave_ThreeShell |
---|
90 | ModifyGraph marker=29, msize=2, mode=4 |
---|
91 | ModifyGraph log=1,grid=1,mirror=2 |
---|
92 | Label bottom "q (\\S-1\\M) " |
---|
93 | Label left "I(q) (cm\\S-1\\M)" |
---|
94 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
95 | |
---|
96 | AddModelToStrings("ThreeShell","coef_ThreeShell","ThreeShell") |
---|
97 | // |
---|
98 | End |
---|
99 | |
---|
100 | Proc PlotFourShell(num,qmin,qmax) |
---|
101 | Variable num=200, qmin=0.001, qmax=0.7 |
---|
102 | Prompt num "Enter number of data points for model: " |
---|
103 | Prompt qmin "Enter minimum q-value (^-1) for model: " |
---|
104 | Prompt qmax "Enter maximum q-value (^-1) for model: " |
---|
105 | // |
---|
106 | Make/O/D/n=(num) xwave_FourShell, ywave_FourShell |
---|
107 | xwave_FourShell = alog(log(qmin) + x*((log(qmax)-log(qmin))/num)) |
---|
108 | Make/O/D coef_FourShell ={1.,60,6.4e-6,10,1e-6,10,2e-6,5,3e-6,10,4e-6,6.4e-6,0.001} |
---|
109 | make/o/t parameters_FourShell = {"scale","core radius (A)","Core SLD (A-2)","Shell 1 thickness","Shell 1 SLD (A-2)","Shell 2 thickness","Shell 2 SLD (A-2)","Shell 3 thickness","Shell 3 SLD (A-2)","Shell 4 thickness","Shell 4 SLD (A-2)","Solvent SLD (A-2)","bkg (cm-1)"} |
---|
110 | Edit parameters_FourShell, coef_FourShell |
---|
111 | |
---|
112 | Variable/G root:g_FourShell |
---|
113 | g_FourShell := FourShell(coef_FourShell, ywave_FourShell, xwave_FourShell) |
---|
114 | Display ywave_FourShell vs xwave_FourShell |
---|
115 | ModifyGraph marker=29, msize=2, mode=4 |
---|
116 | ModifyGraph log=1,grid=1,mirror=2 |
---|
117 | Label bottom "q (\\S-1\\M) " |
---|
118 | Label left "I(q) (cm\\S-1\\M)" |
---|
119 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
120 | |
---|
121 | AddModelToStrings("FourShell","coef_FourShell","FourShell") |
---|
122 | // |
---|
123 | End |
---|
124 | |
---|
125 | |
---|
126 | |
---|
127 | |
---|
128 | // |
---|
129 | //this macro sets up all the necessary parameters and waves that are |
---|
130 | //needed to calculate the smeared model function. |
---|
131 | // |
---|
132 | //no input parameters are necessary, it MUST use the experimental q-values |
---|
133 | // from the experimental data read in from an AVE/QSIG data file |
---|
134 | //////////////////////////////////////////////////// |
---|
135 | // - sets up a dependency to a wrapper, not the actual SmearedModelFunction |
---|
136 | Proc PlotSmearedOneShell(str) |
---|
137 | String str |
---|
138 | Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4) |
---|
139 | |
---|
140 | // if any of the resolution waves are missing => abort |
---|
141 | if(ResolutionWavesMissingDF(str)) //updated to NOT use global strings (in GaussUtils) |
---|
142 | Abort |
---|
143 | endif |
---|
144 | |
---|
145 | SetDataFolder $("root:"+str) |
---|
146 | |
---|
147 | // Setup parameter table for model function |
---|
148 | Make/O/D smear_coef_OneShell = {1.,60,6.4e-6,10,1e-6,6.4e-6,0.001} |
---|
149 | make/o/t smear_parameters_OneShell = {"scale","core radius (A)","Core SLD (A-2)","Shell thickness (A)","Shell SLD (A-2)","Solvent SLD (A-2)","bkg (cm-1)"} |
---|
150 | Edit smear_parameters_OneShell,smear_coef_OneShell //display parameters in a table |
---|
151 | |
---|
152 | // output smeared intensity wave, dimensions are identical to experimental QSIG values |
---|
153 | // make extra copy of experimental q-values for easy plotting |
---|
154 | Duplicate/O $(str+"_q") smeared_OneShell,smeared_qvals |
---|
155 | SetScale d,0,0,"1/cm",smeared_OneShell |
---|
156 | |
---|
157 | Variable/G gs_OneShell=0 |
---|
158 | gs_OneShell := fSmearedOneShell(smear_coef_OneShell,smeared_OneShell,smeared_qvals) //this wrapper fills the STRUCT |
---|
159 | |
---|
160 | Display smeared_OneShell vs smeared_qvals |
---|
161 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
162 | Label bottom "q (\\S-1\\M)" |
---|
163 | Label left "I(q) (cm\\S-1\\M)" |
---|
164 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
165 | |
---|
166 | SetDataFolder root: |
---|
167 | AddModelToStrings("SmearedOneShell","smear_coef_OneShell","OneShell") |
---|
168 | End |
---|
169 | |
---|
170 | Proc PlotSmearedTwoShell(str) |
---|
171 | String str |
---|
172 | Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4) |
---|
173 | |
---|
174 | // if any of the resolution waves are missing => abort |
---|
175 | if(ResolutionWavesMissingDF(str)) //updated to NOT use global strings (in GaussUtils) |
---|
176 | Abort |
---|
177 | endif |
---|
178 | |
---|
179 | SetDataFolder $("root:"+str) |
---|
180 | |
---|
181 | // Setup parameter table for model function |
---|
182 | Make/O/D smear_coef_TwoShell = {1.,60,6.4e-6,10,1e-6,10,2e-6,6.4e-6,0.001} |
---|
183 | make/o/t smear_parameters_TwoShell = {"scale","core radius (A)","Core SLD (A-2)","Shell 1 thickness","Shell 1 SLD (A-2)","Shell 2 thickness","Shell 2 SLD (A-2)","Solvent SLD (A-2)","bkg (cm-1)"} |
---|
184 | Edit smear_parameters_TwoShell,smear_coef_TwoShell //display parameters in a table |
---|
185 | |
---|
186 | // output smeared intensity wave, dimensions are identical to experimental QSIG values |
---|
187 | // make extra copy of experimental q-values for easy plotting |
---|
188 | Duplicate/O $(str+"_q") smeared_TwoShell,smeared_qvals |
---|
189 | SetScale d,0,0,"1/cm",smeared_TwoShell |
---|
190 | |
---|
191 | Variable/G gs_TwoShell=0 |
---|
192 | gs_TwoShell := fSmearedTwoShell(smear_coef_TwoShell,smeared_TwoShell,smeared_qvals) //this wrapper fills the STRUCT |
---|
193 | |
---|
194 | Display smeared_TwoShell vs smeared_qvals |
---|
195 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
196 | Label bottom "q (\\S-1\\M)" |
---|
197 | Label left "I(q) (cm\\S-1\\M)" |
---|
198 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
199 | |
---|
200 | SetDataFolder root: |
---|
201 | AddModelToStrings("SmearedTwoShell","smear_coef_TwoShell","TwoShell") |
---|
202 | End |
---|
203 | |
---|
204 | |
---|
205 | Proc PlotSmearedThreeShell(str) |
---|
206 | String str |
---|
207 | Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4) |
---|
208 | |
---|
209 | // if any of the resolution waves are missing => abort |
---|
210 | if(ResolutionWavesMissingDF(str)) //updated to NOT use global strings (in GaussUtils) |
---|
211 | Abort |
---|
212 | endif |
---|
213 | |
---|
214 | SetDataFolder $("root:"+str) |
---|
215 | |
---|
216 | // Setup parameter table for model function |
---|
217 | Make/O/D smear_coef_ThreeShell = {1.,60,6.4e-6,10,1e-6,10,2e-6,5,3e-6,6.4e-6,0.001} |
---|
218 | make/o/t smear_parameters_ThreeShell = {"scale","core radius (A)","Core SLD (A-2)","Shell 1 thickness","Shell 1 SLD (A-2)","Shell 2 thickness","Shell 2 SLD (A-2)","Shell 3 thickness","Shell 3 SLD (A-2)","Solvent SLD (A-2)","bkg (cm-1)"} |
---|
219 | Edit smear_parameters_ThreeShell,smear_coef_ThreeShell //display parameters in a table |
---|
220 | |
---|
221 | // output smeared intensity wave, dimensions are identical to experimental QSIG values |
---|
222 | // make extra copy of experimental q-values for easy plotting |
---|
223 | Duplicate/O $(str+"_q") smeared_ThreeShell,smeared_qvals |
---|
224 | SetScale d,0,0,"1/cm",smeared_ThreeShell |
---|
225 | |
---|
226 | Variable/G gs_ThreeShell=0 |
---|
227 | gs_ThreeShell := fSmearedThreeShell(smear_coef_ThreeShell,smeared_ThreeShell,smeared_qvals) //this wrapper fills the STRUCT |
---|
228 | |
---|
229 | Display smeared_ThreeShell vs smeared_qvals |
---|
230 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
231 | Label bottom "q (\\S-1\\M)" |
---|
232 | Label left "I(q) (cm\\S-1\\M)" |
---|
233 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
234 | |
---|
235 | SetDataFolder root: |
---|
236 | AddModelToStrings("SmearedThreeShell","smear_coef_ThreeShell","ThreeShell") |
---|
237 | End |
---|
238 | |
---|
239 | Proc PlotSmearedFourShell(str) |
---|
240 | String str |
---|
241 | Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4) |
---|
242 | |
---|
243 | // if any of the resolution waves are missing => abort |
---|
244 | if(ResolutionWavesMissingDF(str)) //updated to NOT use global strings (in GaussUtils) |
---|
245 | Abort |
---|
246 | endif |
---|
247 | |
---|
248 | SetDataFolder $("root:"+str) |
---|
249 | |
---|
250 | // Setup parameter table for model function |
---|
251 | Make/O/D smear_coef_FourShell = {1.,60,6.4e-6,10,1e-6,10,2e-6,5,3e-6,10,4e-6,6.4e-6,0.001} |
---|
252 | make/o/t smear_parameters_FourShell = {"scale","core radius (A)","Core SLD (A-2)","Shell 1 thickness","Shell 1 SLD (A-2)","Shell 2 thickness","Shell 2 SLD (A-2)","Shell 3 thickness","Shell 3 SLD (A-2)","Shell 4 thickness","Shell 4 SLD (A-2)","Solvent SLD (A-2)","bkg (cm-1)"} |
---|
253 | Edit smear_parameters_FourShell,smear_coef_FourShell //display parameters in a table |
---|
254 | |
---|
255 | // output smeared intensity wave, dimensions are identical to experimental QSIG values |
---|
256 | // make extra copy of experimental q-values for easy plotting |
---|
257 | Duplicate/O $(str+"_q") smeared_FourShell,smeared_qvals |
---|
258 | SetScale d,0,0,"1/cm",smeared_FourShell |
---|
259 | |
---|
260 | Variable/G gs_FourShell=0 |
---|
261 | gs_FourShell := fSmearedFourShell(smear_coef_FourShell,smeared_FourShell,smeared_qvals) //this wrapper fills the STRUCT |
---|
262 | |
---|
263 | Display smeared_FourShell vs smeared_qvals |
---|
264 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
265 | Label bottom "q (\\S-1\\M)" |
---|
266 | Label left "I(q) (cm\\S-1\\M)" |
---|
267 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
268 | |
---|
269 | SetDataFolder root: |
---|
270 | AddModelToStrings("SmearedFourShell","smear_coef_FourShell","FourShell") |
---|
271 | End |
---|
272 | |
---|
273 | |
---|
274 | // nothing to change here |
---|
275 | // |
---|
276 | //AAO version, uses XOP if available |
---|
277 | // simply calls the original single point calculation with |
---|
278 | // a wave assignment (this will behave nicely if given point ranges) |
---|
279 | Function OneShell(cw,yw,xw) : FitFunc |
---|
280 | Wave cw,yw,xw |
---|
281 | |
---|
282 | #if exists("OneShellX") |
---|
283 | yw = OneShellX(cw,xw) |
---|
284 | #else |
---|
285 | yw = fOneShell(cw,xw) |
---|
286 | #endif |
---|
287 | return(0) |
---|
288 | End |
---|
289 | |
---|
290 | Function TwoShell(cw,yw,xw) : FitFunc |
---|
291 | Wave cw,yw,xw |
---|
292 | |
---|
293 | #if exists("TwoShellX") |
---|
294 | yw = TwoShellX(cw,xw) |
---|
295 | #else |
---|
296 | yw = fTwoShell(cw,xw) |
---|
297 | #endif |
---|
298 | return(0) |
---|
299 | End |
---|
300 | |
---|
301 | Function ThreeShell(cw,yw,xw) : FitFunc |
---|
302 | Wave cw,yw,xw |
---|
303 | |
---|
304 | #if exists("ThreeShellX") |
---|
305 | yw =ThreeShellX(cw,xw) |
---|
306 | #else |
---|
307 | yw = fThreeShell(cw,xw) |
---|
308 | #endif |
---|
309 | return(0) |
---|
310 | End |
---|
311 | |
---|
312 | Function FourShell(cw,yw,xw) : FitFunc |
---|
313 | Wave cw,yw,xw |
---|
314 | |
---|
315 | #if exists("FourShellX") |
---|
316 | yw = FourShellX(cw,xw) |
---|
317 | #else |
---|
318 | yw = fFourShell(cw,xw) |
---|
319 | #endif |
---|
320 | return(0) |
---|
321 | End |
---|
322 | |
---|
323 | |
---|
324 | // |
---|
325 | // unsmeared model calculation |
---|
326 | // |
---|
327 | Function fOneShell(w,x) : FitFunc |
---|
328 | Wave w |
---|
329 | Variable x |
---|
330 | |
---|
331 | // variables are: |
---|
332 | //[0] scale factor |
---|
333 | //[1] radius of core [] |
---|
334 | //[2] SLD of the core [-2] |
---|
335 | //[3] thickness of the shell [] |
---|
336 | //[4] SLD of the shell |
---|
337 | //[5] SLD of the solvent |
---|
338 | //[6] background [cm-1] |
---|
339 | |
---|
340 | // All inputs are in ANGSTROMS |
---|
341 | //OUTPUT is normalized by the particle volume, and converted to [cm-1] |
---|
342 | |
---|
343 | |
---|
344 | Variable scale,rcore,thick,rhocore,rhoshel,rhosolv,bkg |
---|
345 | scale = w[0] |
---|
346 | rcore = w[1] |
---|
347 | rhocore = w[2] |
---|
348 | thick = w[3] |
---|
349 | rhoshel = w[4] |
---|
350 | rhosolv = w[5] |
---|
351 | bkg = w[6] |
---|
352 | |
---|
353 | // calculates scale *( f^2 + bkg) |
---|
354 | Variable bes,f,vol,qr,contr,f2 |
---|
355 | |
---|
356 | // core first, then add in shell |
---|
357 | qr=x*rcore |
---|
358 | contr = rhocore-rhoshel |
---|
359 | bes = 3*(sin(qr)-qr*cos(qr))/qr^3 |
---|
360 | vol = 4*pi/3*rcore^3 |
---|
361 | f = vol*bes*contr |
---|
362 | //now the shell |
---|
363 | qr=x*(rcore+thick) |
---|
364 | contr = rhoshel-rhosolv |
---|
365 | bes = 3*(sin(qr)-qr*cos(qr))/qr^3 |
---|
366 | vol = 4*pi/3*(rcore+thick)^3 |
---|
367 | f += vol*bes*contr |
---|
368 | |
---|
369 | // normalize to particle volume and rescale from [-1] to [cm-1] |
---|
370 | f2 = f*f/vol*1.0e8 |
---|
371 | |
---|
372 | //scale if desired |
---|
373 | f2 *= scale |
---|
374 | // then add in the background |
---|
375 | f2 += bkg |
---|
376 | |
---|
377 | return (f2) |
---|
378 | End |
---|
379 | |
---|
380 | |
---|
381 | Function fTwoShell(w,x) : FitFunc |
---|
382 | Wave w |
---|
383 | Variable x |
---|
384 | |
---|
385 | // variables are: |
---|
386 | //[0] scale factor |
---|
387 | //[1] radius of core [] |
---|
388 | //[2] SLD of the core [-2] |
---|
389 | //[3] thickness of shell 1 [] |
---|
390 | //[4] SLD of shell 1 |
---|
391 | //[5] thickness of shell 2 [] |
---|
392 | //[6] SLD of shell 2 |
---|
393 | //[7] SLD of the solvent |
---|
394 | //[8] background [cm-1] |
---|
395 | |
---|
396 | // All inputs are in ANGSTROMS |
---|
397 | //OUTPUT is normalized by the particle volume, and converted to [cm-1] |
---|
398 | |
---|
399 | |
---|
400 | Variable scale,rcore,thick1,thick2,rhocore,rhoshel1,rhoshel2,rhosolv,bkg |
---|
401 | scale = w[0] |
---|
402 | rcore = w[1] |
---|
403 | rhocore = w[2] |
---|
404 | thick1 = w[3] |
---|
405 | rhoshel1 = w[4] |
---|
406 | thick2 = w[5] |
---|
407 | rhoshel2 = w[6] |
---|
408 | rhosolv = w[7] |
---|
409 | bkg = w[8] |
---|
410 | |
---|
411 | // calculates scale *( f^2 + bkg) |
---|
412 | Variable bes,f,vol,qr,contr,f2 |
---|
413 | |
---|
414 | // core first, then add in shells |
---|
415 | qr=x*rcore |
---|
416 | contr = rhocore-rhoshel1 |
---|
417 | bes = 3*(sin(qr)-qr*cos(qr))/qr^3 |
---|
418 | vol = 4*pi/3*rcore^3 |
---|
419 | f = vol*bes*contr |
---|
420 | //now the shell (1) |
---|
421 | qr=x*(rcore+thick1) |
---|
422 | contr = rhoshel1-rhoshel2 |
---|
423 | bes = 3*(sin(qr)-qr*cos(qr))/qr^3 |
---|
424 | vol = 4*pi/3*(rcore+thick1)^3 |
---|
425 | f += vol*bes*contr |
---|
426 | //now the shell (2) |
---|
427 | qr=x*(rcore+thick1+thick2) |
---|
428 | contr = rhoshel2-rhosolv |
---|
429 | bes = 3*(sin(qr)-qr*cos(qr))/qr^3 |
---|
430 | vol = 4*pi/3*(rcore+thick1+thick2)^3 |
---|
431 | f += vol*bes*contr |
---|
432 | |
---|
433 | // normalize to particle volume and rescale from [-1] to [cm-1] |
---|
434 | f2 = f*f/vol*1.0e8 |
---|
435 | |
---|
436 | //scale if desired |
---|
437 | f2 *= scale |
---|
438 | // then add in the background |
---|
439 | f2 += bkg |
---|
440 | |
---|
441 | return (f2) |
---|
442 | |
---|
443 | End |
---|
444 | |
---|
445 | Function fThreeShell(w,x) : FitFunc |
---|
446 | Wave w |
---|
447 | Variable x |
---|
448 | |
---|
449 | // variables are: |
---|
450 | //[0] scale factor |
---|
451 | //[1] radius of core [] |
---|
452 | //[2] SLD of the core [-2] |
---|
453 | //[3] thickness of shell 1 [] |
---|
454 | //[4] SLD of shell 1 |
---|
455 | //[5] thickness of shell 2 [] |
---|
456 | //[6] SLD of shell 2 |
---|
457 | //[7] SLD of the solvent |
---|
458 | //[8] background [cm-1] |
---|
459 | |
---|
460 | // All inputs are in ANGSTROMS |
---|
461 | //OUTPUT is normalized by the particle volume, and converted to [cm-1] |
---|
462 | |
---|
463 | |
---|
464 | Variable scale,rcore,thick1,thick2,thick3,rhoshel1,rhoshel2,rhoshel3 |
---|
465 | Variable rhocore,rhosolv,bkg |
---|
466 | scale = w[0] |
---|
467 | rcore = w[1] |
---|
468 | rhocore = w[2] |
---|
469 | thick1 = w[3] |
---|
470 | rhoshel1 = w[4] |
---|
471 | thick2 = w[5] |
---|
472 | rhoshel2 = w[6] |
---|
473 | thick3 = w[7] |
---|
474 | rhoshel3 = w[8] |
---|
475 | rhosolv = w[9] |
---|
476 | bkg = w[10] |
---|
477 | |
---|
478 | // calculates scale *( f^2 + bkg) |
---|
479 | Variable bes,f,vol,qr,contr,f2 |
---|
480 | |
---|
481 | // core first, then add in shells |
---|
482 | qr=x*rcore |
---|
483 | contr = rhocore-rhoshel1 |
---|
484 | bes = 3*(sin(qr)-qr*cos(qr))/qr^3 |
---|
485 | vol = 4*pi/3*rcore^3 |
---|
486 | f = vol*bes*contr |
---|
487 | //now the shell (1) |
---|
488 | qr=x*(rcore+thick1) |
---|
489 | contr = rhoshel1-rhoshel2 |
---|
490 | bes = 3*(sin(qr)-qr*cos(qr))/qr^3 |
---|
491 | vol = 4*pi/3*(rcore+thick1)^3 |
---|
492 | f += vol*bes*contr |
---|
493 | //now the shell (2) |
---|
494 | qr=x*(rcore+thick1+thick2) |
---|
495 | contr = rhoshel2-rhoshel3 |
---|
496 | bes = 3*(sin(qr)-qr*cos(qr))/qr^3 |
---|
497 | vol = 4*pi/3*(rcore+thick1+thick2)^3 |
---|
498 | f += vol*bes*contr |
---|
499 | //now the shell (3) |
---|
500 | qr=x*(rcore+thick1+thick2+thick3) |
---|
501 | contr = rhoshel3-rhosolv |
---|
502 | bes = 3*(sin(qr)-qr*cos(qr))/qr^3 |
---|
503 | vol = 4*pi/3*(rcore+thick1+thick2+thick3)^3 |
---|
504 | f += vol*bes*contr |
---|
505 | |
---|
506 | // normalize to particle volume and rescale from [-1] to [cm-1] |
---|
507 | f2 = f*f/vol*1.0e8 |
---|
508 | |
---|
509 | //scale if desired |
---|
510 | f2 *= scale |
---|
511 | // then add in the background |
---|
512 | f2 += bkg |
---|
513 | |
---|
514 | return (f2) |
---|
515 | End |
---|
516 | |
---|
517 | |
---|
518 | Function fFourShell(w,x) : FitFunc |
---|
519 | Wave w |
---|
520 | Variable x |
---|
521 | |
---|
522 | // variables are: |
---|
523 | //[0] scale factor |
---|
524 | //[1] radius of core [] |
---|
525 | //[2] SLD of the core [-2] |
---|
526 | //[3] thickness of shell 1 [] |
---|
527 | //[4] SLD of shell 1 |
---|
528 | //[5] thickness of shell 2 [] |
---|
529 | //[6] SLD of shell 2 |
---|
530 | //[7] SLD of the solvent |
---|
531 | //[8] background [cm-1] |
---|
532 | |
---|
533 | // All inputs are in ANGSTROMS |
---|
534 | //OUTPUT is normalized by the particle volume, and converted to [cm-1] |
---|
535 | |
---|
536 | |
---|
537 | Variable scale,rcore,thick1,thick2,thick3,thick4 |
---|
538 | Variable rhoshel1,rhoshel2,rhoshel3,rhoshel4 |
---|
539 | Variable rhocore,rhosolv,bkg |
---|
540 | scale = w[0] |
---|
541 | rcore = w[1] |
---|
542 | rhocore = w[2] |
---|
543 | thick1 = w[3] |
---|
544 | rhoshel1 = w[4] |
---|
545 | thick2 = w[5] |
---|
546 | rhoshel2 = w[6] |
---|
547 | thick3 = w[7] |
---|
548 | rhoshel3 = w[8] |
---|
549 | thick4 = w[9] |
---|
550 | rhoshel4 = w[10] |
---|
551 | rhosolv = w[11] |
---|
552 | bkg = w[12] |
---|
553 | |
---|
554 | // calculates scale *( f^2 + bkg) |
---|
555 | Variable bes,f,vol,qr,contr,f2 |
---|
556 | |
---|
557 | // core first, then add in shells |
---|
558 | qr=x*rcore |
---|
559 | contr = rhocore-rhoshel1 |
---|
560 | bes = 3*(sin(qr)-qr*cos(qr))/qr^3 |
---|
561 | vol = 4*pi/3*rcore^3 |
---|
562 | f = vol*bes*contr |
---|
563 | //now the shell (1) |
---|
564 | qr=x*(rcore+thick1) |
---|
565 | contr = rhoshel1-rhoshel2 |
---|
566 | bes = 3*(sin(qr)-qr*cos(qr))/qr^3 |
---|
567 | vol = 4*pi/3*(rcore+thick1)^3 |
---|
568 | f += vol*bes*contr |
---|
569 | //now the shell (2) |
---|
570 | qr=x*(rcore+thick1+thick2) |
---|
571 | contr = rhoshel2-rhoshel3 |
---|
572 | bes = 3*(sin(qr)-qr*cos(qr))/qr^3 |
---|
573 | vol = 4*pi/3*(rcore+thick1+thick2)^3 |
---|
574 | f += vol*bes*contr |
---|
575 | //now the shell (3) |
---|
576 | qr=x*(rcore+thick1+thick2+thick3) |
---|
577 | contr = rhoshel3-rhoshel4 |
---|
578 | bes = 3*(sin(qr)-qr*cos(qr))/qr^3 |
---|
579 | vol = 4*pi/3*(rcore+thick1+thick2+thick3)^3 |
---|
580 | f += vol*bes*contr |
---|
581 | //now the shell (4) |
---|
582 | qr=x*(rcore+thick1+thick2+thick3+thick4) |
---|
583 | contr = rhoshel4-rhosolv |
---|
584 | bes = 3*(sin(qr)-qr*cos(qr))/qr^3 |
---|
585 | vol = 4*pi/3*(rcore+thick1+thick2+thick3+thick4)^3 |
---|
586 | f += vol*bes*contr |
---|
587 | |
---|
588 | |
---|
589 | // normalize to particle volume and rescale from [-1] to [cm-1] |
---|
590 | f2 = f*f/vol*1.0e8 |
---|
591 | |
---|
592 | //scale if desired |
---|
593 | f2 *= scale |
---|
594 | // then add in the background |
---|
595 | f2 += bkg |
---|
596 | |
---|
597 | return (f2) |
---|
598 | End |
---|
599 | |
---|
600 | |
---|
601 | |
---|
602 | |
---|
603 | /////////////////////////////////////////////////////////////// |
---|
604 | // smeared model calculation |
---|
605 | // |
---|
606 | // you don't need to do anything with this function, as long as |
---|
607 | // your OneShell works correctly, you get the resolution-smeared |
---|
608 | // version for free. |
---|
609 | // |
---|
610 | // this is all there is to the smeared model calculation! |
---|
611 | Function SmearedOneShell(s) : FitFunc |
---|
612 | Struct ResSmearAAOStruct &s |
---|
613 | |
---|
614 | // the name of your unsmeared model (AAO) is the first argument |
---|
615 | Smear_Model_20(OneShell,s.coefW,s.xW,s.yW,s.resW) |
---|
616 | |
---|
617 | return(0) |
---|
618 | End |
---|
619 | |
---|
620 | Function SmearedTwoShell(s) : FitFunc |
---|
621 | Struct ResSmearAAOStruct &s |
---|
622 | |
---|
623 | // the name of your unsmeared model (AAO) is the first argument |
---|
624 | Smear_Model_20(TwoShell,s.coefW,s.xW,s.yW,s.resW) |
---|
625 | |
---|
626 | return(0) |
---|
627 | End |
---|
628 | |
---|
629 | Function SmearedThreeShell(s) : FitFunc |
---|
630 | Struct ResSmearAAOStruct &s |
---|
631 | |
---|
632 | // the name of your unsmeared model (AAO) is the first argument |
---|
633 | Smear_Model_20(ThreeShell,s.coefW,s.xW,s.yW,s.resW) |
---|
634 | |
---|
635 | return(0) |
---|
636 | End |
---|
637 | |
---|
638 | Function SmearedFourShell(s) : FitFunc |
---|
639 | Struct ResSmearAAOStruct &s |
---|
640 | |
---|
641 | // the name of your unsmeared model (AAO) is the first argument |
---|
642 | Smear_Model_20(FourShell,s.coefW,s.xW,s.yW,s.resW) |
---|
643 | |
---|
644 | return(0) |
---|
645 | End |
---|
646 | |
---|
647 | |
---|
648 | |
---|
649 | /////////////////////////////////////////////////////////////// |
---|
650 | |
---|
651 | |
---|
652 | // nothing to change here |
---|
653 | // |
---|
654 | //wrapper to calculate the smeared model as an AAO-Struct |
---|
655 | // fills the struct and calls the ususal function with the STRUCT parameter |
---|
656 | // |
---|
657 | // used only for the dependency, not for fitting |
---|
658 | // |
---|
659 | Function fSmearedOneShell(coefW,yW,xW) |
---|
660 | Wave coefW,yW,xW |
---|
661 | |
---|
662 | String str = getWavesDataFolder(yW,0) |
---|
663 | String DF="root:"+str+":" |
---|
664 | |
---|
665 | WAVE resW = $(DF+str+"_res") |
---|
666 | |
---|
667 | STRUCT ResSmearAAOStruct fs |
---|
668 | WAVE fs.coefW = coefW |
---|
669 | WAVE fs.yW = yW |
---|
670 | WAVE fs.xW = xW |
---|
671 | WAVE fs.resW = resW |
---|
672 | |
---|
673 | Variable err |
---|
674 | err = SmearedOneShell(fs) |
---|
675 | |
---|
676 | return (0) |
---|
677 | End |
---|
678 | |
---|
679 | //wrapper to calculate the smeared model as an AAO-Struct |
---|
680 | // fills the struct and calls the ususal function with the STRUCT parameter |
---|
681 | // |
---|
682 | // used only for the dependency, not for fitting |
---|
683 | // |
---|
684 | Function fSmearedTwoShell(coefW,yW,xW) |
---|
685 | Wave coefW,yW,xW |
---|
686 | |
---|
687 | String str = getWavesDataFolder(yW,0) |
---|
688 | String DF="root:"+str+":" |
---|
689 | |
---|
690 | WAVE resW = $(DF+str+"_res") |
---|
691 | |
---|
692 | STRUCT ResSmearAAOStruct fs |
---|
693 | WAVE fs.coefW = coefW |
---|
694 | WAVE fs.yW = yW |
---|
695 | WAVE fs.xW = xW |
---|
696 | WAVE fs.resW = resW |
---|
697 | |
---|
698 | Variable err |
---|
699 | err = SmearedTwoShell(fs) |
---|
700 | |
---|
701 | return (0) |
---|
702 | End |
---|
703 | |
---|
704 | //wrapper to calculate the smeared model as an AAO-Struct |
---|
705 | // fills the struct and calls the ususal function with the STRUCT parameter |
---|
706 | // |
---|
707 | // used only for the dependency, not for fitting |
---|
708 | // |
---|
709 | Function fSmearedThreeShell(coefW,yW,xW) |
---|
710 | Wave coefW,yW,xW |
---|
711 | |
---|
712 | String str = getWavesDataFolder(yW,0) |
---|
713 | String DF="root:"+str+":" |
---|
714 | |
---|
715 | WAVE resW = $(DF+str+"_res") |
---|
716 | |
---|
717 | STRUCT ResSmearAAOStruct fs |
---|
718 | WAVE fs.coefW = coefW |
---|
719 | WAVE fs.yW = yW |
---|
720 | WAVE fs.xW = xW |
---|
721 | WAVE fs.resW = resW |
---|
722 | |
---|
723 | Variable err |
---|
724 | err = SmearedThreeShell(fs) |
---|
725 | |
---|
726 | return (0) |
---|
727 | End |
---|
728 | |
---|
729 | //wrapper to calculate the smeared model as an AAO-Struct |
---|
730 | // fills the struct and calls the ususal function with the STRUCT parameter |
---|
731 | // |
---|
732 | // used only for the dependency, not for fitting |
---|
733 | // |
---|
734 | Function fSmearedFourShell(coefW,yW,xW) |
---|
735 | Wave coefW,yW,xW |
---|
736 | |
---|
737 | String str = getWavesDataFolder(yW,0) |
---|
738 | String DF="root:"+str+":" |
---|
739 | |
---|
740 | WAVE resW = $(DF+str+"_res") |
---|
741 | |
---|
742 | STRUCT ResSmearAAOStruct fs |
---|
743 | WAVE fs.coefW = coefW |
---|
744 | WAVE fs.yW = yW |
---|
745 | WAVE fs.xW = xW |
---|
746 | WAVE fs.resW = resW |
---|
747 | |
---|
748 | Variable err |
---|
749 | err = SmearedFourShell(fs) |
---|
750 | |
---|
751 | return (0) |
---|
752 | End |
---|