source: sans/Dev/trunk/NCNR_User_Procedures/Analysis/Models/CoreShell_Sq_v40.ipf @ 774

Last change on this file since 774 was 774, checked in by srkline, 12 years ago

Added the Two-Yukawa structure factor calculations to those model functions with S(Q).

Fixed the name of Vesicle_UL_Sq.ipf to be consistent.

File size: 21.1 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma IgorVersion=6.1
3
4//// include everything that is necessary
5//
6#include "CoreShell_v40"
7
8#include "HardSphereStruct_v40"
9#include "HPMSA_v40"
10#include "SquareWellStruct_v40"
11#include "StickyHardSphereStruct_v40"
12#include "Two_Yukawa_v40"
13
14Proc PlotCoreShell_HS(num,qmin,qmax)
15        Variable num=256,qmin=0.001,qmax=0.7
16        Prompt num "Enter number of data points for model: "
17        Prompt qmin "Enter minimum q-value (A^-1) for model: "
18        Prompt qmax "Enter maximum q-value (A^-1) for model: "
19       
20        Make/O/D/n=(num) xwave_CSS_HS,ywave_CSS_HS
21        xwave_CSS_HS =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
22        Make/O/D coef_CSS_HS = {0.1,60,10,1e-6,2e-6,3e-6,0.0001}
23        make/o/t parameters_CSS_HS = {"volume fraction","core rad (A)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","bkg (cm-1)"}
24        Edit/K=1 parameters_CSS_HS,coef_CSS_HS
25       
26        Variable/G root:g_CSS_HS
27        g_CSS_HS := CoreShell_HS(coef_CSS_HS,ywave_CSS_HS,xwave_CSS_HS)
28        Display/K=1 ywave_CSS_HS vs xwave_CSS_HS
29        ModifyGraph log=1,marker=29,msize=2,mode=4
30        Label bottom "q (A\\S-1\\M)"
31        Label left "Intensity (cm\\S-1\\M)"
32
33        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
34       
35        AddModelToStrings("CoreShell_HS","coef_CSS_HS","parameters_CSS_HS","CSS_HS")
36End
37
38// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
39Proc PlotSmearedCoreShell_HS(str)                                                               
40        String str
41        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
42       
43        // if any of the resolution waves are missing => abort
44        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
45                Abort
46        endif
47       
48        SetDataFolder $("root:"+str)
49       
50        // Setup parameter table for model function
51        Make/O/D smear_coef_CSS_HS = {0.1,60,10,1e-6,2e-6,3e-6,0.0001}
52        make/o/t smear_parameters_CSS_HS = {"volume fraction","core rad (A)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","bkg (cm-1)"}
53        Edit smear_parameters_CSS_HS,smear_coef_CSS_HS                                 
54       
55        // output smeared intensity wave, dimensions are identical to experimental QSIG values
56        // make extra copy of experimental q-values for easy plotting
57        Duplicate/O $(str+"_q") smeared_CSS_HS,smeared_qvals                           
58        SetScale d,0,0,"1/cm",smeared_CSS_HS                                                   
59                                       
60        Variable/G gs_CSS_HS=0
61        gs_CSS_HS := fSmearedCoreShell_HS(smear_coef_CSS_HS,smeared_CSS_HS,smeared_qvals)       //this wrapper fills the STRUCT
62       
63        Display smeared_CSS_HS vs smeared_qvals                                                                 
64        ModifyGraph log=1,marker=29,msize=2,mode=4
65        Label bottom "q (A\\S-1\\M)"
66        Label left "Intensity (cm\\S-1\\M)"
67
68        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
69       
70        SetDataFolder root:
71        AddModelToStrings("SmearedCoreShell_HS","smear_coef_CSS_HS","smear_parameters_CSS_HS","CSS_HS")
72End
73       
74
75Function CoreShell_HS(w,yw,xw) : FitFunc
76        Wave w,yw,xw
77       
78        Variable inten
79       
80        //setup form factor coefficient wave
81        Make/O/D/N=7 form_CSS_HS
82        form_CSS_HS[0] = 1
83        form_CSS_HS[1] = w[1]
84        form_CSS_HS[2] = w[2]
85        form_CSS_HS[3] = w[3]
86        form_CSS_HS[4] = w[4]
87        form_CSS_HS[5] = w[5]
88        form_CSS_HS[6] = 0
89       
90        //setup structure factor coefficient wave
91        Make/O/D/N=2 struct_CSS_HS
92        struct_CSS_HS[0] = w[1] + w[2]
93        struct_CSS_HS[1] = w[0]
94       
95        //calculate each and combine
96        Duplicate/O xw temp_CSS_HS_PQ,temp_CSS_HS_SQ            //make waves for the AAO
97        CoreShellSphere(form_CSS_HS,temp_CSS_HS_PQ,xw)
98        HardSphereStruct(struct_CSS_HS,temp_CSS_HS_SQ,xw)
99        yw = temp_CSS_HS_PQ * temp_CSS_HS_SQ
100        yw *= w[0]
101        yw += w[6]
102       
103        //cleanup waves
104//      Killwaves/Z form_CSS_HS,struct_CSS_HS
105       
106        return (0)
107End
108
109/////////////////////////////////////////
110Proc PlotCoreShell_SW(num,qmin,qmax)
111        Variable num=256,qmin=0.001,qmax=0.7
112        Prompt num "Enter number of data points for model: "
113        Prompt qmin "Enter minimum q-value (A^-1) for model: "
114        Prompt qmax "Enter maximum q-value (A^-1) for model: "
115       
116        Make/O/D/n=(num) xwave_CSS_SW,ywave_CSS_SW
117        xwave_CSS_SW =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
118        Make/O/D coef_CSS_SW = {0.1,60,10,1e-6,2e-6,3e-6,1.0,1.2,0.0001}
119        make/o/t parameters_CSS_SW = {"volume fraction","core rad (A)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","well depth (kT)","well width (diam.)","bkg (cm-1)"}
120        Edit/K=1 parameters_CSS_SW,coef_CSS_SW
121       
122        Variable/G root:g_CSS_SW
123        g_CSS_SW := CoreShell_SW(coef_CSS_SW,ywave_CSS_SW,xwave_CSS_SW)
124        Display/K=1 ywave_CSS_SW vs xwave_CSS_SW
125        ModifyGraph log=1,marker=29,msize=2,mode=4
126        Label bottom "q (A\\S-1\\M)"
127        Label left "Intensity (cm\\S-1\\M)"
128
129        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
130       
131        AddModelToStrings("CoreShell_SW","coef_CSS_SW","parameters_CSS_SW","CSS_SW")
132End
133
134// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
135Proc PlotSmearedCoreShell_SW(str)                                                               
136        String str
137        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
138       
139        // if any of the resolution waves are missing => abort
140        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
141                Abort
142        endif
143       
144        SetDataFolder $("root:"+str)
145       
146        // Setup parameter table for model function
147        Make/O/D smear_coef_CSS_SW = {0.1,60,10,1e-6,2e-6,3e-6,1.0,1.2,0.0001}
148        make/o/t smear_parameters_CSS_SW = {"volume fraction","core rad (A)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","well depth (kT)","well width (diam.)","bkg (cm-1)"}
149        Edit smear_parameters_CSS_SW,smear_coef_CSS_SW                                 
150       
151        // output smeared intensity wave, dimensions are identical to experimental QSIG values
152        // make extra copy of experimental q-values for easy plotting
153        Duplicate/O $(str+"_q") smeared_CSS_SW,smeared_qvals                           
154        SetScale d,0,0,"1/cm",smeared_CSS_SW                                                   
155                                       
156        Variable/G gs_CSS_SW=0
157        gs_CSS_SW := fSmearedCoreShell_SW(smear_coef_CSS_SW,smeared_CSS_SW,smeared_qvals)       //this wrapper fills the STRUCT
158       
159        Display smeared_CSS_SW vs smeared_qvals                                                                 
160        ModifyGraph log=1,marker=29,msize=2,mode=4
161        Label bottom "q (A\\S-1\\M)"
162        Label left "Intensity (cm\\S-1\\M)"
163
164        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
165       
166        SetDataFolder root:
167        AddModelToStrings("SmearedCoreShell_SW","smear_coef_CSS_SW","smear_parameters_CSS_SW","CSS_SW")
168End
169       
170
171Function CoreShell_SW(w,yw,xw) : FitFunc
172        Wave w,yw,xw
173       
174        Variable inten
175       
176        //setup form factor coefficient wave
177        Make/O/D/N=7 form_CSS_SW
178        form_CSS_SW[0] = 1
179        form_CSS_SW[1] = w[1]
180        form_CSS_SW[2] = w[2]
181        form_CSS_SW[3] = w[3]
182        form_CSS_SW[4] = w[4]
183        form_CSS_SW[5] = w[5]
184        form_CSS_SW[6] = 0
185       
186        //setup structure factor coefficient wave
187        Make/O/D/N=4 struct_CSS_SW
188        struct_CSS_SW[0] = w[1] + w[2]
189        struct_CSS_SW[1] = w[0]
190        struct_CSS_SW[2] = w[6]
191        struct_CSS_SW[3] = w[7]
192       
193        //calculate each and combine
194        Duplicate/O xw temp_CSS_SW_PQ,temp_CSS_SW_SQ            //make waves for the AAO
195        CoreShellSphere(form_CSS_SW,temp_CSS_SW_PQ,xw)
196        SquareWellStruct(struct_CSS_SW,temp_CSS_SW_SQ,xw)
197        yw = temp_CSS_SW_PQ * temp_CSS_SW_SQ
198        yw *= w[0]
199        yw += w[8]
200       
201        //cleanup waves
202//      Killwaves/Z form_CSS_SW,struct_CSS_SW
203       
204        return (0)
205End
206
207
208/////////////////////////////////////////
209Proc PlotCoreShell_SC(num,qmin,qmax)
210        Variable num=256,qmin=0.001,qmax=0.7
211        Prompt num "Enter number of data points for model: "
212        Prompt qmin "Enter minimum q-value (A^-1) for model: "
213        Prompt qmax "Enter maximum q-value (A^-1) for model: "
214       
215        if(!DataFolderExists(":HayPenMSA"))
216                NewDataFolder :HayPenMSA
217        endif
218        Make/O/D/N=17 :HayPenMSA:gMSAWave
219       
220        Make/O/D/n=(num) xwave_CSS_SC,ywave_CSS_SC
221        xwave_CSS_SC = alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
222        Make/O/D coef_CSS_SC = {0.1,60,10,1e-6,2e-6,3e-6,10,0,298,78,0.0001}
223        make/o/t parameters_CSS_SC = {"volume fraction","core rad (A)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","charge","Monovalent salt (M)","Temperature (K)","dielectric const.","bkg (cm-1)"}
224        Edit/K=1 parameters_CSS_SC,coef_CSS_SC
225       
226        Variable/G root:g_CSS_SC
227        g_CSS_SC := CoreShell_SC(coef_CSS_SC,ywave_CSS_SC,xwave_CSS_SC)
228        Display/K=1 ywave_CSS_SC vs xwave_CSS_SC
229        ModifyGraph log=1,marker=29,msize=2,mode=4
230        Label bottom "q (A\\S-1\\M)"
231        Label left "Intensity (cm\\S-1\\M)"
232
233        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
234       
235        AddModelToStrings("CoreShell_SC","coef_CSS_SC","parameters_CSS_SC","CSS_SC")
236End
237
238// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
239Proc PlotSmearedCoreShell_SC(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        if(!DataFolderExists(":HayPenMSA"))
251                NewDataFolder :HayPenMSA
252        endif
253        Make/O/D/N=17 :HayPenMSA:gMSAWave
254       
255        // Setup parameter table for model function
256        Make/O/D smear_coef_CSS_SC = {0.1,60,10,1e-6,2e-6,3e-6,10,0,298,78,0.0001}
257        make/o/t smear_parameters_CSS_SC = {"volume fraction","core rad (A)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","charge","Monovalent salt (M)","Temperature (K)","dielectric const.","bkg (cm-1)"}
258        Edit smear_parameters_CSS_SC,smear_coef_CSS_SC                                 
259       
260        // output smeared intensity wave, dimensions are identical to experimental QSIG values
261        // make extra copy of experimental q-values for easy plotting
262        Duplicate/O $(str+"_q") smeared_CSS_SC,smeared_qvals                           
263        SetScale d,0,0,"1/cm",smeared_CSS_SC                                                   
264                                       
265        Variable/G gs_CSS_SC=0
266        gs_CSS_SC := fSmearedCoreShell_SC(smear_coef_CSS_SC,smeared_CSS_SC,smeared_qvals)       //this wrapper fills the STRUCT
267       
268        Display smeared_CSS_SC vs smeared_qvals                                                                 
269        ModifyGraph log=1,marker=29,msize=2,mode=4
270        Label bottom "q (A\\S-1\\M)"
271        Label left "Intensity (cm\\S-1\\M)"
272
273        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
274       
275        SetDataFolder root:
276        AddModelToStrings("SmearedCoreShell_SC","smear_coef_CSS_SC","smear_parameters_CSS_SC","CSS_SC")
277End
278       
279
280Function CoreShell_SC(w,yw,xw) : FitFunc
281        Wave w,yw,xw
282       
283        Variable inten
284       
285        //setup form factor coefficient wave
286        Make/O/D/N=7 form_CSS_SC
287        form_CSS_SC[0] = 1
288        form_CSS_SC[1] = w[1]
289        form_CSS_SC[2] = w[2]
290        form_CSS_SC[3] = w[3]
291        form_CSS_SC[4] = w[4]
292        form_CSS_SC[5] = w[5]
293        form_CSS_SC[6] = 0
294       
295        //setup structure factor coefficient wave
296        Make/O/D/N=6 struct_CSS_SC
297        struct_CSS_SC[0] = 2*(w[1]+w[2])
298        struct_CSS_SC[1] = w[6]
299        struct_CSS_SC[2] = w[0]
300        struct_CSS_SC[3] = w[8]
301        struct_CSS_SC[4] = w[7]
302        struct_CSS_SC[5] = w[9]
303       
304        //calculate each and combine
305        Duplicate/O xw temp_CSS_SC_PQ,temp_CSS_SC_SQ            //make waves for the AAO
306        CoreShellSphere(form_CSS_SC,temp_CSS_SC_PQ,xw)
307        HayterPenfoldMSA(struct_CSS_SC,temp_CSS_SC_SQ,xw)
308        yw = temp_CSS_SC_PQ * temp_CSS_SC_SQ
309        yw *= w[0]
310        yw += w[10]
311       
312        //cleanup waves
313//      Killwaves/Z form_CSS_SC,struct_CSS_SC
314       
315        return (0)
316End
317
318/////////////////////////////////////////
319Proc PlotCoreShell_SHS(num,qmin,qmax)
320        Variable num=256,qmin=0.001,qmax=0.7
321        Prompt num "Enter number of data points for model: "
322        Prompt qmin "Enter minimum q-value (A^-1) for model: "
323        Prompt qmax "Enter maximum q-value (A^-1) for model: "
324       
325        Make/O/D/n=(num) xwave_CSS_SHS,ywave_CSS_SHS
326        xwave_CSS_SHS =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
327        Make/O/D coef_CSS_SHS = {0.1,60,10,1e-6,2e-6,3e-6,0.05,0.2,0.0001}
328        make/o/t parameters_CSS_SHS = {"volume fraction","core rad (A)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","perturbation parameter (0.1)","stickiness, tau","bkg (cm-1)"}
329        Edit/K=1 parameters_CSS_SHS,coef_CSS_SHS
330       
331        Variable/G root:g_CSS_SHS
332        g_CSS_SHS := CoreShell_SHS(coef_CSS_SHS,ywave_CSS_SHS,xwave_CSS_SHS)
333        Display/K=1 ywave_CSS_SHS vs xwave_CSS_SHS
334        ModifyGraph log=1,marker=29,msize=2,mode=4
335        Label bottom "q (A\\S-1\\M)"
336        Label left "Intensity (cm\\S-1\\M)"
337
338        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
339       
340        AddModelToStrings("CoreShell_SHS","coef_CSS_SHS","parameters_CSS_SHS","CSS_SHS")
341End
342
343// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
344Proc PlotSmearedCoreShell_SHS(str)                                                             
345        String str
346        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
347       
348        // if any of the resolution waves are missing => abort
349        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
350                Abort
351        endif
352       
353        SetDataFolder $("root:"+str)
354       
355        // Setup parameter table for model function
356        Make/O/D smear_coef_CSS_SHS = {0.1,60,10,1e-6,2e-6,3e-6,0.05,0.2,0.0001}
357        make/o/t smear_parameters_CSS_SHS = {"volume fraction","core rad (A)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","perturbation parameter (0.1)","stickiness, tau","bkg (cm-1)"}
358        Edit smear_parameters_CSS_SHS,smear_coef_CSS_SHS                                       
359       
360        // output smeared intensity wave, dimensions are identical to experimental QSIG values
361        // make extra copy of experimental q-values for easy plotting
362        Duplicate/O $(str+"_q") smeared_CSS_SHS,smeared_qvals                           
363        SetScale d,0,0,"1/cm",smeared_CSS_SHS                                                   
364                                       
365        Variable/G gs_CSS_SHS=0
366        gs_CSS_SHS := fSmearedCoreShell_SHS(smear_coef_CSS_SHS,smeared_CSS_SHS,smeared_qvals)   //this wrapper fills the STRUCT
367       
368        Display smeared_CSS_SHS vs smeared_qvals                                                                       
369        ModifyGraph log=1,marker=29,msize=2,mode=4
370        Label bottom "q (A\\S-1\\M)"
371        Label left "Intensity (cm\\S-1\\M)"
372
373        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
374       
375        SetDataFolder root:
376        AddModelToStrings("SmearedCoreShell_SHS","smear_coef_CSS_SHS","smear_parameters_CSS_SHS","CSS_SHS")
377End
378       
379
380Function CoreShell_SHS(w,yw,xw) : FitFunc
381        Wave w,yw,xw
382       
383        Variable inten
384       
385        //setup form factor coefficient wave
386        Make/O/D/N=7 form_CSS_SHS
387        form_CSS_SHS[0] = 1
388        form_CSS_SHS[1] = w[1]
389        form_CSS_SHS[2] = w[2]
390        form_CSS_SHS[3] = w[3]
391        form_CSS_SHS[4] = w[4]
392        form_CSS_SHS[5] = w[5]
393        form_CSS_SHS[6] = 0
394       
395        //setup structure factor coefficient wave
396        Make/O/D/N=4 struct_CSS_SHS
397        struct_CSS_SHS[0] = w[1] + w[2]
398        struct_CSS_SHS[1] = w[0]
399        struct_CSS_SHS[2] = w[6]
400        struct_CSS_SHS[3] = w[7]
401       
402        //calculate each and combine
403        Duplicate/O xw temp_CSS_SHS_PQ,temp_CSS_SHS_SQ          //make waves for the AAO
404        CoreShellSphere(form_CSS_SHS,temp_CSS_SHS_PQ,xw)
405        StickyHS_Struct(struct_CSS_SHS,temp_CSS_SHS_SQ,xw)
406        yw = temp_CSS_SHS_PQ * temp_CSS_SHS_SQ
407        yw *= w[0]
408        yw += w[8]
409       
410        //cleanup waves
411//      Killwaves/Z form_CSS_SHS,struct_CSS_SHS
412       
413        return (0)
414End
415
416//two yukawa
417Proc PlotCoreShell_2Y(num,qmin,qmax)
418        Variable num=256,qmin=0.001,qmax=0.7
419        Prompt num "Enter number of data points for model: "
420        Prompt qmin "Enter minimum q-value (A^-1) for model: "
421        Prompt qmax "Enter maximum q-value (A^-1) for model: "
422       
423        Make/O/D/n=(num) xwave_CSS_2Y,ywave_CSS_2Y
424        xwave_CSS_2Y =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
425        Make/O/D coef_CSS_2Y = {0.1,60,10,1e-6,2e-6,3e-6,6,10,-1,2,0.0001}
426        make/o/t parameters_CSS_2Y = {"volume fraction","core rad (A)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","scale, K1","charge, Z1","scale, K2","charge, Z2","bkg (cm-1)"}
427        Edit/K=1 parameters_CSS_2Y,coef_CSS_2Y
428       
429        Variable/G root:g_CSS_2Y
430        g_CSS_2Y := CoreShell_2Y(coef_CSS_2Y,ywave_CSS_2Y,xwave_CSS_2Y)
431        Display/K=1 ywave_CSS_2Y vs xwave_CSS_2Y
432        ModifyGraph log=1,marker=29,msize=2,mode=4
433        Label bottom "q (A\\S-1\\M)"
434        Label left "Intensity (cm\\S-1\\M)"
435
436        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
437       
438        AddModelToStrings("CoreShell_2Y","coef_CSS_2Y","parameters_CSS_2Y","CSS_2Y")
439End
440
441// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
442Proc PlotSmearedCoreShell_2Y(str)                                                               
443        String str
444        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
445       
446        // if any of the resolution waves are missing => abort
447        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
448                Abort
449        endif
450       
451        SetDataFolder $("root:"+str)
452       
453        // Setup parameter table for model function
454        Make/O/D smear_coef_CSS_2Y = {0.1,60,10,1e-6,2e-6,3e-6,6,10,-1,2,0.0001}
455        make/o/t smear_parameters_CSS_2Y = {"volume fraction","core rad (A)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","scale, K1","charge, Z1","scale, K2","charge, Z2","bkg (cm-1)"}
456        Edit smear_parameters_CSS_2Y,smear_coef_CSS_2Y                                 
457       
458        // output smeared intensity wave, dimensions are identical to experimental QSIG values
459        // make extra copy of experimental q-values for easy plotting
460        Duplicate/O $(str+"_q") smeared_CSS_2Y,smeared_qvals                           
461        SetScale d,0,0,"1/cm",smeared_CSS_2Y                                                   
462                                       
463        Variable/G gs_CSS_2Y=0
464        gs_CSS_2Y := fSmearedCoreShell_2Y(smear_coef_CSS_2Y,smeared_CSS_2Y,smeared_qvals)       //this wrapper fills the STRUCT
465       
466        Display smeared_CSS_2Y vs smeared_qvals                                                                 
467        ModifyGraph log=1,marker=29,msize=2,mode=4
468        Label bottom "q (A\\S-1\\M)"
469        Label left "Intensity (cm\\S-1\\M)"
470
471        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
472       
473        SetDataFolder root:
474        AddModelToStrings("SmearedCoreShell_2Y","smear_coef_CSS_2Y","smear_parameters_CSS_2Y","CSS_2Y")
475End
476       
477
478Function CoreShell_2Y(w,yw,xw) : FitFunc
479        Wave w,yw,xw
480       
481        Variable inten
482       
483        //setup form factor coefficient wave
484        Make/O/D/N=7 form_CSS_2Y
485        form_CSS_2Y[0] = 1
486        form_CSS_2Y[1] = w[1]
487        form_CSS_2Y[2] = w[2]
488        form_CSS_2Y[3] = w[3]
489        form_CSS_2Y[4] = w[4]
490        form_CSS_2Y[5] = w[5]
491        form_CSS_2Y[6] = 0
492       
493        //setup structure factor coefficient wave
494        Make/O/D/N=6 struct_CSS_2Y
495        struct_CSS_2Y[0] = w[0]
496        struct_CSS_2Y[1] = w[1] + w[2]
497        struct_CSS_2Y[2] = w[6]
498        struct_CSS_2Y[3] = w[7]
499        struct_CSS_2Y[4] = w[8]
500        struct_CSS_2Y[5] = w[9]
501       
502        //calculate each and combine
503        Duplicate/O xw temp_CSS_2Y_PQ,temp_CSS_2Y_SQ            //make waves for the AAO
504        CoreShellSphere(form_CSS_2Y,temp_CSS_2Y_PQ,xw)
505        TwoYukawa(struct_CSS_2Y,temp_CSS_2Y_SQ,xw)
506        yw = temp_CSS_2Y_PQ * temp_CSS_2Y_SQ
507        yw *= w[0]
508        yw += w[10]
509       
510        //cleanup waves
511//      Killwaves/Z form_CSS_2Y,struct_CSS_2Y
512       
513        return (0)
514End
515
516
517
518// this is all there is to the smeared calculation!
519Function SmearedCoreShell_HS(s) :FitFunc
520        Struct ResSmearAAOStruct &s
521
522//      the name of your unsmeared model is the first argument
523        Smear_Model_20(CoreShell_HS,s.coefW,s.xW,s.yW,s.resW)
524
525        return(0)
526End
527
528// this is all there is to the smeared calculation!
529Function SmearedCoreShell_SW(s) :FitFunc
530        Struct ResSmearAAOStruct &s
531
532//      the name of your unsmeared model is the first argument
533        Smear_Model_20(CoreShell_SW,s.coefW,s.xW,s.yW,s.resW)
534
535        return(0)
536End
537
538// this is all there is to the smeared calculation!
539Function SmearedCoreShell_SC(s) :FitFunc
540        Struct ResSmearAAOStruct &s
541
542//      the name of your unsmeared model is the first argument
543        Smear_Model_20(CoreShell_SC,s.coefW,s.xW,s.yW,s.resW)
544
545        return(0)
546End
547
548// this is all there is to the smeared calculation!
549Function SmearedCoreShell_SHS(s) :FitFunc
550        Struct ResSmearAAOStruct &s
551
552//      the name of your unsmeared model is the first argument
553        Smear_Model_20(CoreShell_SHS,s.coefW,s.xW,s.yW,s.resW)
554
555        return(0)
556End
557
558// this is all there is to the smeared calculation!
559Function SmearedCoreShell_2Y(s) :FitFunc
560        Struct ResSmearAAOStruct &s
561
562//      the name of your unsmeared model is the first argument
563        Smear_Model_20(CoreShell_2Y,s.coefW,s.xW,s.yW,s.resW)
564
565        return(0)
566End
567
568//wrapper to calculate the smeared model as an AAO-Struct
569// fills the struct and calls the ususal function with the STRUCT parameter
570//
571// used only for the dependency, not for fitting
572//
573Function fSmearedCoreShell_HS(coefW,yW,xW)
574        Wave coefW,yW,xW
575       
576        String str = getWavesDataFolder(yW,0)
577        String DF="root:"+str+":"
578       
579        WAVE resW = $(DF+str+"_res")
580       
581        STRUCT ResSmearAAOStruct fs
582        WAVE fs.coefW = coefW   
583        WAVE fs.yW = yW
584        WAVE fs.xW = xW
585        WAVE fs.resW = resW
586       
587        Variable err
588        err = SmearedCoreShell_HS(fs)
589       
590        return (0)
591End
592
593//wrapper to calculate the smeared model as an AAO-Struct
594// fills the struct and calls the ususal function with the STRUCT parameter
595//
596// used only for the dependency, not for fitting
597//
598Function fSmearedCoreShell_SW(coefW,yW,xW)
599        Wave coefW,yW,xW
600       
601        String str = getWavesDataFolder(yW,0)
602        String DF="root:"+str+":"
603       
604        WAVE resW = $(DF+str+"_res")
605       
606        STRUCT ResSmearAAOStruct fs
607        WAVE fs.coefW = coefW   
608        WAVE fs.yW = yW
609        WAVE fs.xW = xW
610        WAVE fs.resW = resW
611       
612        Variable err
613        err = SmearedCoreShell_SW(fs)
614       
615        return (0)
616End
617
618//wrapper to calculate the smeared model as an AAO-Struct
619// fills the struct and calls the ususal function with the STRUCT parameter
620//
621// used only for the dependency, not for fitting
622//
623Function fSmearedCoreShell_SC(coefW,yW,xW)
624        Wave coefW,yW,xW
625       
626        String str = getWavesDataFolder(yW,0)
627        String DF="root:"+str+":"
628       
629        WAVE resW = $(DF+str+"_res")
630       
631        STRUCT ResSmearAAOStruct fs
632        WAVE fs.coefW = coefW   
633        WAVE fs.yW = yW
634        WAVE fs.xW = xW
635        WAVE fs.resW = resW
636       
637        Variable err
638        err = SmearedCoreShell_SC(fs)
639       
640        return (0)
641End
642
643//wrapper to calculate the smeared model as an AAO-Struct
644// fills the struct and calls the ususal function with the STRUCT parameter
645//
646// used only for the dependency, not for fitting
647//
648Function fSmearedCoreShell_SHS(coefW,yW,xW)
649        Wave coefW,yW,xW
650       
651        String str = getWavesDataFolder(yW,0)
652        String DF="root:"+str+":"
653       
654        WAVE resW = $(DF+str+"_res")
655       
656        STRUCT ResSmearAAOStruct fs
657        WAVE fs.coefW = coefW   
658        WAVE fs.yW = yW
659        WAVE fs.xW = xW
660        WAVE fs.resW = resW
661       
662        Variable err
663        err = SmearedCoreShell_SHS(fs)
664       
665        return (0)
666End
667
668//wrapper to calculate the smeared model as an AAO-Struct
669// fills the struct and calls the ususal function with the STRUCT parameter
670//
671// used only for the dependency, not for fitting
672//
673Function fSmearedCoreShell_2Y(coefW,yW,xW)
674        Wave coefW,yW,xW
675       
676        String str = getWavesDataFolder(yW,0)
677        String DF="root:"+str+":"
678       
679        WAVE resW = $(DF+str+"_res")
680       
681        STRUCT ResSmearAAOStruct fs
682        WAVE fs.coefW = coefW   
683        WAVE fs.yW = yW
684        WAVE fs.xW = xW
685        WAVE fs.resW = resW
686       
687        Variable err
688        err = SmearedCoreShell_2Y(fs)
689       
690        return (0)
691End
Note: See TracBrowser for help on using the repository browser.