source: sans/Dev/trunk/NCNR_User_Procedures/Analysis/Models/Sphere_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: 20.3 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma IgorVersion=6.1
3
4// be sure to include all the necessary files...
5
6#include "Sphere_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 PlotSphere_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 the normal model waves
21        Make/O/D/n=(num) xwave_S_HS,ywave_S_HS                                 
22        xwave_S_HS =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))                                   
23        Make/O/D coef_S_HS = {0.1,60,1e-6,6.3e-6,0.01}                                         
24        make/o/t parameters_S_HS = {"volume fraction","Radius (A)","SLD sphere (A-2)","SLD solvent (A-2)","bkgd (cm-1)"}               
25        Edit/K=1 parameters_S_HS,coef_S_HS
26        Variable/G root:g_S_HS                                         
27        g_S_HS := Sphere_HS(coef_S_HS,ywave_S_HS,xwave_S_HS)                   
28//      ywave_S_HS := Sphere_HS(coef_S_HS,xwave_S_HS)                   
29        Display/K=1 ywave_S_HS vs xwave_S_HS                                                   
30        ModifyGraph log=1,marker=29,msize=2,mode=4                     
31        Label bottom "q (A\\S-1\\M)"
32        Label left "Intensity (cm\\S-1\\M)"                                     
33
34        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
35       
36        AddModelToStrings("Sphere_HS","coef_S_HS","parameters_S_HS","S_HS")
37End
38
39// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
40Proc PlotSmearedSphere_HS(str)                                                         
41        String str
42        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
43       
44        // if any of the resolution waves are missing => abort
45        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
46                Abort
47        endif
48       
49        SetDataFolder $("root:"+str)
50       
51        // Setup parameter table for model function
52        Make/O/D smear_coef_S_HS = {0.1,60,1e-6,6.3e-6,0.01}                                           
53        make/o/t smear_parameters_S_HS = {"volume fraction","Radius (A)","SLD sphere (A-2)","SLD solvent (A-2)","bkgd (cm-1)"}         
54        Edit smear_parameters_S_HS,smear_coef_S_HS                                     
55       
56        // output smeared intensity wave, dimensions are identical to experimental QSIG values
57        // make extra copy of experimental q-values for easy plotting
58        Duplicate/O $(str+"_q") smeared_S_HS,smeared_qvals                             
59        SetScale d,0,0,"1/cm",smeared_S_HS                                                     
60                                       
61        Variable/G gs_S_HS=0
62        gs_S_HS := fSmearedSphere_HS(smear_coef_S_HS,smeared_S_HS,smeared_qvals)        //this wrapper fills the STRUCT
63       
64        Display smeared_S_HS vs smeared_qvals                                                                   
65        ModifyGraph log=1,marker=29,msize=2,mode=4
66        Label bottom "q (A\\S-1\\M)"
67        Label left "Intensity (cm\\S-1\\M)"
68
69        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
70       
71        SetDataFolder root:
72        AddModelToStrings("SmearedSphere_HS","smear_coef_S_HS","smear_parameters_S_HS","S_HS")
73End
74
75
76//AAO function
77Function Sphere_HS(w,yw,xw) : FitFunc
78        Wave w,yw,xw
79               
80        //setup form factor coefficient wave
81        Make/O/D/N=5 form_S_HS
82        form_S_HS[0] = 1
83        form_S_HS[1] = w[1]
84        form_S_HS[2] = w[2]
85        form_S_HS[3] = w[3]
86        form_S_HS[4] = 0
87       
88        //setup structure factor coefficient wave
89        Make/O/D/N=2 struct_S_HS
90        struct_S_HS[0] = w[1]
91        struct_S_HS[1] = w[0]
92       
93        //calculate each and combine
94        Duplicate/O xw temp_S_HS_PQ,temp_S_HS_SQ                //make waves for the AAO
95        SphereForm(form_S_HS,temp_S_HS_PQ,xw)
96        HardSphereStruct(struct_S_HS,temp_S_HS_SQ,xw)
97        yw = temp_S_HS_PQ * temp_S_HS_SQ
98        yw *= w[0]
99        yw += w[4]
100       
101        //cleanup waves
102        //Killwaves/Z form_S_HS,struct_S_HS
103       
104        return (0)
105End
106
107/////////////////////////////////
108Proc PlotSphere_SW(num,qmin,qmax)                                               
109        Variable num=256,qmin=0.001,qmax=0.7
110        Prompt num "Enter number of data points for model: "
111        Prompt qmin "Enter minimum q-value (A^-1) for model: "
112        Prompt qmax "Enter maximum q-value (A^-1) for model: "
113       
114        ///
115        Make/O/D/N=4 form_S_SW
116        Make/O/D/N=4 struct_S_SW
117        ///
118        Make/O/D/n=(num) xwave_S_SW,ywave_S_SW                                 
119        xwave_S_SW =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))                                   
120        Make/O/D coef_S_SW = {0.1,60,1e-6,6.3e-6,1.0,1.2,0.01}                                         
121        make/o/t parameters_S_SW = {"volume fraction","Radius (A)","SLD sphere (A-2)","SLD solvent (A-2)","well depth (kT)","well width (diam.)","bkgd (cm-1)"}         
122        Edit/K=1 parameters_S_SW,coef_S_SW     
123        Variable/G root:g_S_SW                                                 
124        g_S_SW := Sphere_SW(coef_S_SW,ywave_S_SW,xwave_S_SW)                   
125//      ywave_S_SW := Sphere_SW(coef_S_SW,xwave_S_SW)                   
126        Display/K=1 ywave_S_SW vs xwave_S_SW                                                   
127        ModifyGraph log=1,marker=29,msize=2,mode=4                     
128        Label bottom "q (A\\S-1\\M)"
129        Label left "Intensity (cm\\S-1\\M)"                                     
130
131        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
132        AddModelToStrings("Sphere_SW","coef_S_SW","parameters_S_SW","S_SW")
133End
134
135// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
136Proc PlotSmearedSphere_SW(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_S_SW = {0.1,60,1e-6,6.3e-6,1.0,1.2,0.01}                                           
149        make/o/t smear_parameters_S_SW = {"volume fraction","Radius (A)","SLD sphere (A-2)","SLD solvent (A-2)","well depth (kT)","well width (diam.)","bkgd (cm-1)"}           
150        Edit smear_parameters_S_SW,smear_coef_S_SW                                     
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_S_SW,smeared_qvals                             
155        SetScale d,0,0,"1/cm",smeared_S_SW                                                     
156                                       
157        Variable/G gs_S_SW=0
158        gs_S_SW := fSmearedSphere_SW(smear_coef_S_SW,smeared_S_SW,smeared_qvals)        //this wrapper fills the STRUCT
159       
160        Display smeared_S_SW vs smeared_qvals                                                                   
161        ModifyGraph log=1,marker=29,msize=2,mode=4
162        Label bottom "q (A\\S-1\\M)"
163        Label left "Intensity (cm\\S-1\\M)"
164
165        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
166       
167        SetDataFolder root:
168        AddModelToStrings("SmearedSphere_SW","smear_coef_S_SW","smear_parameters_S_SW","S_SW")
169End
170       
171
172//AAO function
173Function Sphere_SW(w,yw,xw) : FitFunc
174        Wave w,yw,xw
175               
176        //setup form factor coefficient wave
177        Make/O/D/N=5 form_S_SW
178        form_S_SW[0] = 1
179        form_S_SW[1] = w[1]
180        form_S_SW[2] = w[2]
181        form_S_SW[3] = w[3]
182        form_S_SW[4] = 0
183       
184        //setup structure factor coefficient wave
185        Make/O/D/N=4 struct_S_SW
186        struct_S_SW[0] = w[1]
187        struct_S_SW[1] = w[0]
188        struct_S_SW[2] = w[4]
189        struct_S_SW[3] = w[5]
190       
191        //calculate each and combine
192        Duplicate/O xw temp_S_SW_PQ,temp_S_SW_SQ
193        SphereForm(form_S_SW,temp_S_SW_PQ,xw)
194        SquareWellStruct(struct_S_SW,temp_S_SW_SQ,xw)
195        yw = temp_S_SW_PQ * temp_S_SW_SQ
196        yw *= w[0]
197        yw += w[6]
198       
199        //cleanup waves
200        //Killwaves/Z form_S_SW,struct_S_SW
201       
202        return (0)
203End
204
205/////////////////////////////////
206Proc PlotSphere_SC(num,qmin,qmax)                                               
207        Variable num=256,qmin=0.001,qmax=0.7
208        Prompt num "Enter number of data points for model: "
209        Prompt qmin "Enter minimum q-value (A^-1) for model: "
210        Prompt qmax "Enter maximum q-value (A^-1) for model: "
211       
212        if(!DataFolderExists(":HayPenMSA"))
213                NewDataFolder :HayPenMSA
214        endif
215        Make/O/D/N=17 :HayPenMSA:gMSAWave
216       
217        ///
218        Make/O/D/n=(num) xwave_S_SC,ywave_S_SC                                 
219        xwave_S_SC =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))                           
220        Make/O/D coef_S_SC = {0.2,50,1e-6,6.3e-6,20,0,298,78,0.0001}                                           
221        make/o/t parameters_S_SC = {"volume fraction","Radius (A)","SLD sphere (A-2)","SLD solvent (A-2)","charge","movalent salt(M)","Temperature (K)","dielectric const","bkgd (cm-1)"}               
222        Edit/K=1 parameters_S_SC,coef_S_SC
223        Variable/G root:g_S_SC                                                 
224        g_S_SC := Sphere_SC(coef_S_SC,ywave_S_SC,xwave_S_SC)                   
225//      ywave_S_SC := Sphere_SC(coef_S_SC,xwave_S_SC)                   
226        Display/K=1 ywave_S_SC vs xwave_S_SC                                                   
227        ModifyGraph log=1,marker=29,msize=2,mode=4                     
228        Label bottom "q (A\\S-1\\M)"
229        Label left "Intensity (cm\\S-1\\M)"                                     
230
231        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
232       
233        AddModelToStrings("Sphere_SC","coef_S_SC","parameters_S_SC","S_SC")
234End
235
236// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
237Proc PlotSmearedSphere_SC(str)                                                         
238        String str
239        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
240       
241        // if any of the resolution waves are missing => abort
242        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
243                Abort
244        endif
245       
246        SetDataFolder $("root:"+str)
247       
248        if(!DataFolderExists(":HayPenMSA"))
249                NewDataFolder :HayPenMSA
250        endif
251        Make/O/D/N=17 :HayPenMSA:gMSAWave
252       
253        // Setup parameter table for model function
254        Make/O/D smear_coef_S_SC = {0.2,50,1e-6,6.3e-6,20,0,298,78,0.0001}                                             
255        make/o/t smear_parameters_S_SC = {"volume fraction","Radius (A)","SLD sphere (A-2)","SLD solvent (A-2)","charge","movalent salt(M)","Temperature (K)","dielectric const","bkgd (cm-1)"}         
256        Edit smear_parameters_S_SC,smear_coef_S_SC                                     
257       
258        // output smeared intensity wave, dimensions are identical to experimental QSIG values
259        // make extra copy of experimental q-values for easy plotting
260        Duplicate/O $(str+"_q") smeared_S_SC,smeared_qvals                             
261        SetScale d,0,0,"1/cm",smeared_S_SC                                                     
262                                       
263        Variable/G gs_S_SC=0
264        gs_S_SC := fSmearedSphere_SC(smear_coef_S_SC,smeared_S_SC,smeared_qvals)        //this wrapper fills the STRUCT
265       
266        Display smeared_S_SC vs smeared_qvals                                                                   
267        ModifyGraph log=1,marker=29,msize=2,mode=4
268        Label bottom "q (A\\S-1\\M)"
269        Label left "Intensity (cm\\S-1\\M)"
270
271        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
272       
273        SetDataFolder root:
274        AddModelToStrings("SmearedSphere_SC","smear_coef_S_SC","smear_parameters_S_SC","S_SC")
275End
276       
277
278//AAO function
279Function Sphere_SC(w,yw,xw) : FitFunc
280        Wave w,yw,xw
281
282        //setup form factor coefficient wave
283        Make/O/D/N=5 form_S_SC
284        form_S_SC[0] = 1
285        form_S_SC[1] = w[1]
286        form_S_SC[2] = w[2]
287        form_S_SC[3] = w[3]
288        form_S_SC[4] = 0
289       
290        //setup structure factor coefficient wave
291        Make/O/D/N=6 struct_S_SC
292        struct_S_SC[0] = 2*w[1]         //diameter
293        struct_S_SC[1] = w[4]
294        struct_S_SC[2] = w[0]
295        struct_S_SC[3] = w[6]
296        struct_S_SC[4] = w[5]
297        struct_S_SC[5] = w[7]
298       
299        //calculate each and combine
300        Duplicate/O xw temp_S_SC_PQ,temp_S_SC_SQ
301        SphereForm(form_S_SC,temp_S_SC_PQ,xw)
302        HayterPenfoldMSA(struct_S_SC,temp_S_SC_SQ,xw)
303        yw = temp_S_SC_PQ * temp_S_SC_SQ
304        yw *= w[0]
305        yw += w[8]
306       
307        //cleanup waves
308        //Killwaves/Z form_S_SC,struct_S_SC
309        return (0)
310End
311
312/////////////////////////////////
313Proc PlotSphere_SHS(num,qmin,qmax)                                             
314        Variable num=256,qmin=0.001,qmax=0.7
315        Prompt num "Enter number of data points for model: "
316        Prompt qmin "Enter minimum q-value (A^-1) for model: "
317        Prompt qmax "Enter maximum q-value (A^-1) for model: "
318       
319        ///
320        Make/O/D/N=4 form_S_SHS
321        Make/O/D/N=4 struct_S_SHS
322        ///
323        Make/O/D/n=(num) xwave_S_SHS,ywave_S_SHS                                       
324        xwave_S_SHS =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))                                 
325        Make/O/D coef_S_SHS = {0.1,60,1e-6,6.3e-6,0.05,0.2,0.01}                                               
326        make/o/t parameters_S_SHS = {"volume fraction","Radius (A)","SLD sphere (A-2)","SLD solvent (A-2)","perturbation parameter (0.1)","stickiness, tau","bkgd (cm-1)"}             
327        Edit/K=1 parameters_S_SHS,coef_S_SHS
328        Variable/G root:g_S_SHS                                         
329        g_S_SHS := Sphere_SHS(coef_S_SHS,ywave_S_SHS,xwave_S_SHS)                       
330//      ywave_S_SHS := Sphere_SHS(coef_S_SHS,xwave_S_SHS)                       
331        Display/K=1 ywave_S_SHS vs xwave_S_SHS                                                 
332        ModifyGraph log=1,marker=29,msize=2,mode=4                     
333        Label bottom "q (A\\S-1\\M)"
334        Label left "Intensity (cm\\S-1\\M)"                                     
335
336        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
337       
338        AddModelToStrings("Sphere_SHS","coef_S_SHS","parameters_S_SHS","S_SHS")
339End
340
341// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
342Proc PlotSmearedSphere_SHS(str)                                                         
343        String str
344        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
345       
346        // if any of the resolution waves are missing => abort
347        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
348                Abort
349        endif
350       
351        SetDataFolder $("root:"+str)
352       
353        // Setup parameter table for model function
354        Make/O/D smear_coef_S_SHS = {0.1,60,1e-6,6.3e-6,0.05,0.2,0.01}                                         
355        make/o/t smear_parameters_S_SHS = {"volume fraction","Radius (A)","SLD sphere (A-2)","SLD solvent (A-2)","perturbation parameter (0.1)","stickiness, tau","bkgd (cm-1)"}               
356        Edit smear_parameters_S_SHS,smear_coef_S_SHS                                   
357       
358        // output smeared intensity wave, dimensions are identical to experimental QSIG values
359        // make extra copy of experimental q-values for easy plotting
360        Duplicate/O $(str+"_q") smeared_S_SHS,smeared_qvals                             
361        SetScale d,0,0,"1/cm",smeared_S_SHS                                                     
362                                       
363        Variable/G gs_S_SHS=0
364        gs_S_SHS := fSmearedSphere_SHS(smear_coef_S_SHS,smeared_S_SHS,smeared_qvals)    //this wrapper fills the STRUCT
365       
366        Display smeared_S_SHS vs smeared_qvals                                                                 
367        ModifyGraph log=1,marker=29,msize=2,mode=4
368        Label bottom "q (A\\S-1\\M)"
369        Label left "Intensity (cm\\S-1\\M)"
370
371        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
372       
373        SetDataFolder root:
374        AddModelToStrings("SmearedSphere_SHS","smear_coef_S_SHS","smear_parameters_S_SHS","S_SHS")
375End
376
377
378//AAO function
379Function Sphere_SHS(w,yw,xw) : FitFunc
380        Wave w,yw,xw
381       
382        //setup form factor coefficient wave
383        Make/O/D/N=5 form_S_SHS
384        form_S_SHS[0] = 1
385        form_S_SHS[1] = w[1]
386        form_S_SHS[2] = w[2]
387        form_S_SHS[3] = w[3]
388        form_S_SHS[4] = 0
389       
390        //setup structure factor coefficient wave
391        Make/O/D/N=4 struct_S_SHS
392        struct_S_SHS[0] = w[1]
393        struct_S_SHS[1] = w[0]
394        struct_S_SHS[2] = w[4]
395        struct_S_SHS[3] = w[5]
396       
397        //calculate each and combine
398        Duplicate/O xw temp_S_SHS_PQ,temp_S_SHS_SQ
399        SphereForm(form_S_SHS,temp_S_SHS_PQ,xw)
400        StickyHS_Struct(struct_S_SHS,temp_S_SHS_SQ,xw)
401        yw = temp_S_SHS_PQ * temp_S_SHS_SQ
402        yw *= w[0]
403        yw += w[6]
404       
405        //cleanup waves
406        //Killwaves/Z form_S_SHS,struct_S_SHS
407       
408        return (0)
409End
410
411// two yukawa
412Proc PlotSphere_2Y(num,qmin,qmax)                                               
413        Variable num=256,qmin=0.001,qmax=0.7
414        Prompt num "Enter number of data points for model: "
415        Prompt qmin "Enter minimum q-value (A^-1) for model: "
416        Prompt qmax "Enter maximum q-value (A^-1) for model: "
417       
418        //make the normal model waves
419        Make/O/D/n=(num) xwave_S_2Y,ywave_S_2Y                                 
420        xwave_S_2Y =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))                                   
421        Make/O/D coef_S_2Y = {0.1,60,1e-6,6.3e-6,6,10,-1,2,0.01}                                               
422        make/o/t parameters_S_2Y = {"volume fraction","Radius (A)","SLD sphere (A-2)","SLD solvent (A-2)","scale, K1","charge, Z1","scale, K2","charge, Z2","bkgd (cm-1)"}             
423        Edit/K=1 parameters_S_2Y,coef_S_2Y
424        Variable/G root:g_S_2Y                                         
425        g_S_2Y := Sphere_2Y(coef_S_2Y,ywave_S_2Y,xwave_S_2Y)                   
426//      ywave_S_2Y := Sphere_2Y(coef_S_2Y,xwave_S_2Y)                   
427        Display/K=1 ywave_S_2Y vs xwave_S_2Y                                                   
428        ModifyGraph log=1,marker=29,msize=2,mode=4                     
429        Label bottom "q (A\\S-1\\M)"
430        Label left "Intensity (cm\\S-1\\M)"                                     
431
432        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
433       
434        AddModelToStrings("Sphere_2Y","coef_S_2Y","parameters_S_2Y","S_2Y")
435End
436
437// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
438Proc PlotSmearedSphere_2Y(str)                                                         
439        String str
440        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
441       
442        // if any of the resolution waves are missing => abort
443        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
444                Abort
445        endif
446       
447        SetDataFolder $("root:"+str)
448       
449        // Setup parameter table for model function
450        Make/O/D smear_coef_S_2Y = {0.1,60,1e-6,6.3e-6,6,10,-1,2,0.01}                                         
451        make/o/t smear_parameters_S_2Y = {"volume fraction","Radius (A)","SLD sphere (A-2)","SLD solvent (A-2)","scale, K1","charge, Z1","scale, K2","charge, Z2","bkgd (cm-1)"}               
452        Edit smear_parameters_S_2Y,smear_coef_S_2Y                                     
453       
454        // output smeared intensity wave, dimensions are identical to experimental QSIG values
455        // make extra copy of experimental q-values for easy plotting
456        Duplicate/O $(str+"_q") smeared_S_2Y,smeared_qvals                             
457        SetScale d,0,0,"1/cm",smeared_S_2Y                                                     
458                                       
459        Variable/G gs_S_2Y=0
460        gs_S_2Y := fSmearedSphere_2Y(smear_coef_S_2Y,smeared_S_2Y,smeared_qvals)        //this wrapper fills the STRUCT
461       
462        Display smeared_S_2Y vs smeared_qvals                                                                   
463        ModifyGraph log=1,marker=29,msize=2,mode=4
464        Label bottom "q (A\\S-1\\M)"
465        Label left "Intensity (cm\\S-1\\M)"
466
467        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
468       
469        SetDataFolder root:
470        AddModelToStrings("SmearedSphere_2Y","smear_coef_S_2Y","smear_parameters_S_2Y","S_2Y")
471End
472
473
474//AAO function
475Function Sphere_2Y(w,yw,xw) : FitFunc
476        Wave w,yw,xw
477               
478        //setup form factor coefficient wave
479        Make/O/D/N=5 form_S_2Y
480        form_S_2Y[0] = 1
481        form_S_2Y[1] = w[1]
482        form_S_2Y[2] = w[2]
483        form_S_2Y[3] = w[3]
484        form_S_2Y[4] = 0
485       
486        //setup structure factor coefficient wave
487        Make/O/D/N=6 struct_S_2Y
488        struct_S_2Y[0] = w[0]   //phi
489        struct_S_2Y[1] = w[1]   //rad
490        struct_S_2Y[2] = w[4]   //K1
491        struct_S_2Y[3] = w[5]   //Z1
492        struct_S_2Y[4] = w[6]   //K2
493        struct_S_2Y[5] = w[7]   //Z2
494       
495        //calculate each and combine
496        Duplicate/O xw temp_S_2Y_PQ,temp_S_2Y_SQ                //make waves for the AAO
497        SphereForm(form_S_2Y,temp_S_2Y_PQ,xw)
498        TwoYukawa(struct_S_2Y,temp_S_2Y_SQ,xw)
499        yw = temp_S_2Y_PQ * temp_S_2Y_SQ
500        yw *= w[0]
501        yw += w[8]
502       
503        //cleanup waves
504        //Killwaves/Z form_S_2Y,struct_S_2Y
505       
506        return (0)
507End
508
509
510
511
512// this is all there is to the smeared calculation!
513Function SmearedSphere_HS(s) :FitFunc
514        Struct ResSmearAAOStruct &s
515
516//      the name of your unsmeared model is the first argument
517        Smear_Model_20(Sphere_HS,s.coefW,s.xW,s.yW,s.resW)
518
519        return(0)
520End
521 
522// this is all there is to the smeared calculation!
523Function SmearedSphere_SW(s) :FitFunc
524        Struct ResSmearAAOStruct &s
525
526//      the name of your unsmeared model is the first argument
527        Smear_Model_20(Sphere_SW,s.coefW,s.xW,s.yW,s.resW)
528
529        return(0)
530End
531
532// this is all there is to the smeared calculation!
533Function SmearedSphere_SC(s) :FitFunc
534        Struct ResSmearAAOStruct &s
535
536//      the name of your unsmeared model is the first argument
537        Smear_Model_20(Sphere_SC,s.coefW,s.xW,s.yW,s.resW)
538
539        return(0)
540End
541
542// this is all there is to the smeared calculation!
543Function SmearedSphere_SHS(s) :FitFunc
544        Struct ResSmearAAOStruct &s
545
546//      the name of your unsmeared model is the first argument
547        Smear_Model_20(Sphere_SHS,s.coefW,s.xW,s.yW,s.resW)
548
549        return(0)
550End
551
552// this is all there is to the smeared calculation!
553Function SmearedSphere_2Y(s) :FitFunc
554        Struct ResSmearAAOStruct &s
555
556//      the name of your unsmeared model is the first argument
557        Smear_Model_20(Sphere_2Y,s.coefW,s.xW,s.yW,s.resW)
558
559        return(0)
560End
561
562
563//wrapper to calculate the smeared model as an AAO-Struct
564// fills the struct and calls the ususal function with the STRUCT parameter
565//
566// used only for the dependency, not for fitting
567//
568Function fSmearedSphere_HS(coefW,yW,xW)
569        Wave coefW,yW,xW
570       
571        String str = getWavesDataFolder(yW,0)
572        String DF="root:"+str+":"
573       
574        WAVE resW = $(DF+str+"_res")
575       
576        STRUCT ResSmearAAOStruct fs
577        WAVE fs.coefW = coefW   
578        WAVE fs.yW = yW
579        WAVE fs.xW = xW
580        WAVE fs.resW = resW
581       
582        Variable err
583        err = SmearedSphere_HS(fs)
584       
585        return (0)
586End
587
588//wrapper to calculate the smeared model as an AAO-Struct
589// fills the struct and calls the ususal function with the STRUCT parameter
590//
591// used only for the dependency, not for fitting
592//
593Function fSmearedSphere_SW(coefW,yW,xW)
594        Wave coefW,yW,xW
595       
596        String str = getWavesDataFolder(yW,0)
597        String DF="root:"+str+":"
598       
599        WAVE resW = $(DF+str+"_res")
600       
601        STRUCT ResSmearAAOStruct fs
602        WAVE fs.coefW = coefW   
603        WAVE fs.yW = yW
604        WAVE fs.xW = xW
605        WAVE fs.resW = resW
606       
607        Variable err
608        err = SmearedSphere_SW(fs)
609       
610        return (0)
611End
612
613//wrapper to calculate the smeared model as an AAO-Struct
614// fills the struct and calls the ususal function with the STRUCT parameter
615//
616// used only for the dependency, not for fitting
617//
618Function fSmearedSphere_SC(coefW,yW,xW)
619        Wave coefW,yW,xW
620       
621        String str = getWavesDataFolder(yW,0)
622        String DF="root:"+str+":"
623       
624        WAVE resW = $(DF+str+"_res")
625       
626        STRUCT ResSmearAAOStruct fs
627        WAVE fs.coefW = coefW   
628        WAVE fs.yW = yW
629        WAVE fs.xW = xW
630        WAVE fs.resW = resW
631       
632        Variable err
633        err = SmearedSphere_SC(fs)
634       
635        return (0)
636End
637
638//wrapper to calculate the smeared model as an AAO-Struct
639// fills the struct and calls the ususal function with the STRUCT parameter
640//
641// used only for the dependency, not for fitting
642//
643Function fSmearedSphere_SHS(coefW,yW,xW)
644        Wave coefW,yW,xW
645       
646        String str = getWavesDataFolder(yW,0)
647        String DF="root:"+str+":"
648       
649        WAVE resW = $(DF+str+"_res")
650       
651        STRUCT ResSmearAAOStruct fs
652        WAVE fs.coefW = coefW   
653        WAVE fs.yW = yW
654        WAVE fs.xW = xW
655        WAVE fs.resW = resW
656       
657        Variable err
658        err = SmearedSphere_SHS(fs)
659       
660        return (0)
661End
662
663//wrapper to calculate the smeared model as an AAO-Struct
664// fills the struct and calls the ususal function with the STRUCT parameter
665//
666// used only for the dependency, not for fitting
667//
668Function fSmearedSphere_2Y(coefW,yW,xW)
669        Wave coefW,yW,xW
670       
671        String str = getWavesDataFolder(yW,0)
672        String DF="root:"+str+":"
673       
674        WAVE resW = $(DF+str+"_res")
675       
676        STRUCT ResSmearAAOStruct fs
677        WAVE fs.coefW = coefW   
678        WAVE fs.yW = yW
679        WAVE fs.xW = xW
680        WAVE fs.resW = resW
681       
682        Variable err
683        err = SmearedSphere_2Y(fs)
684       
685        return (0)
686End
Note: See TracBrowser for help on using the repository browser.