source: sans/Dev/trunk/NCNR_User_Procedures/Analysis/Models/Cylinder_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.9 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#include "EffectiveDiameter_v40"
6#include "Cylinder_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 PlotCylinder_HS(num,qmin,qmax)
15        Variable num=128,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_CYL_HS,ywave_CYL_HS
21        xwave_CYL_HS =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
22        Make/O/D coef_CYL_HS = {0.01,20.,400,1e-6,6.3e-6,0.01}
23        make/o/t parameters_CYL_HS = {"volume fraction","radius (A)","length (A)","SLD cylinder (A^-2)","SLD solvent (A^-2)","incoh. bkg (cm^-1)"}
24        Edit parameters_CYL_HS,coef_CYL_HS
25       
26        Variable/G root:g_CYL_HS
27        g_CYL_HS := Cylinder_HS(coef_CYL_HS,ywave_CYL_HS,xwave_CYL_HS)
28        Display ywave_CYL_HS vs xwave_CYL_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("Cylinder_HS","coef_CYL_HS","parameters_CYL_HS","CYL_HS")
36End
37
38// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
39Proc PlotSmearedCylinder_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_CYL_HS = {0.01,20.,400,1e-6,6.3e-6,0.01}
52        make/o/t smear_parameters_CYL_HS = {"volume fraction","radius (A)","length (A)","SLD cylinder (A^-2)","SLD solvent (A^-2)","incoh. bkg (cm^-1)"}
53        Edit smear_parameters_CYL_HS,smear_coef_CYL_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_CYL_HS,smeared_qvals                           
58        SetScale d,0,0,"1/cm",smeared_CYL_HS                                                   
59                                       
60        Variable/G gs_CYL_HS=0
61        gs_CYL_HS := fSmearedCylinder_HS(smear_coef_CYL_HS,smeared_CYL_HS,smeared_qvals)        //this wrapper fills the STRUCT
62       
63        Display smeared_CYL_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("SmearedCylinder_HS","smear_coef_CYL_HS","smear_parameters_CYL_HS","CYL_HS")
72End
73               
74
75Function Cylinder_HS(w,yw,xw) : FitFunc
76        Wave w,yw,xw
77       
78        Variable inten,rad,len
79        rad=w[1]
80        len=w[2]
81       
82        //setup form factor coefficient wave
83        Make/O/D/N=6 form_CYL_HS
84        form_CYL_HS[0] = 1
85        form_CYL_HS[1] = w[1]
86        form_CYL_HS[2] = w[2]
87        form_CYL_HS[3] = w[3]
88        form_CYL_HS[4] = w[4]   
89        form_CYL_HS[5] = 0
90       
91        //setup structure factor coefficient wave
92        Make/O/D/N=2 struct_CYL_HS
93        struct_CYL_HS[0] = 0.5*DiamCyl(len,rad)
94        struct_CYL_HS[1] = w[0]
95       
96        //calculate each and combine
97        Duplicate/O xw temp_CYL_HS_PQ,temp_CYL_HS_SQ            //make waves for the AAO
98        CylinderForm(form_CYL_HS,temp_CYL_HS_PQ,xw)
99        HardSphereStruct(struct_CYL_HS,temp_CYL_HS_SQ,xw)
100        yw = temp_CYL_HS_PQ * temp_CYL_HS_SQ
101        yw *= w[0]
102        yw += w[5]
103       
104        //cleanup waves (don't do this - it takes a lot of time...)
105//      Killwaves/Z form_CYL_HS,struct_CYL_HS
106       
107        return (0)
108End
109
110Proc PlotCylinder_SW(num,qmin,qmax)
111        Variable num=128,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_CYL_SW,ywave_CYL_SW
117        xwave_CYL_SW =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
118        Make/O/D coef_CYL_SW = {0.01,20.,400,1e-6,6.3e-6,1.0,1.2,0.01}
119        make/o/t parameters_CYL_SW = {"volume fraction","radius (A)","length (A)","SLD cylinder (A^-2)","SLD solvent (A^-2)","well depth (kT)","well width (diam.)","incoh. bkg (cm^-1)"}
120        Edit parameters_CYL_SW,coef_CYL_SW
121       
122        Variable/G root:g_CYL_SW
123        g_CYL_SW := Cylinder_SW(coef_CYL_SW,ywave_CYL_SW,xwave_CYL_SW)
124        Display ywave_CYL_SW vs xwave_CYL_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("Cylinder_SW","coef_CYL_SW","parameters_CYL_SW","CYL_SW")
132End
133
134// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
135Proc PlotSmearedCylinder_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_CYL_SW = {0.01,20.,400,1e-6,6.3e-6,1.0,1.2,0.01}
148        make/o/t smear_parameters_CYL_SW = {"volume fraction","radius (A)","length (A)","SLD cylinder (A^-2)","SLD solvent (A^-2)","well depth (kT)","well width (diam.)","incoh. bkg (cm^-1)"}
149        Edit smear_parameters_CYL_SW,smear_coef_CYL_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_CYL_SW,smeared_qvals                           
154        SetScale d,0,0,"1/cm",smeared_CYL_SW                                                   
155                                       
156        Variable/G gs_CYL_SW=0
157        gs_CYL_SW := fSmearedCylinder_SW(smear_coef_CYL_SW,smeared_CYL_SW,smeared_qvals)        //this wrapper fills the STRUCT
158       
159        Display smeared_CYL_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("SmearedCylinder_SW","smear_coef_CYL_SW","smear_parameters_CYL_SW","CYL_SW")
168End
169       
170
171Function Cylinder_SW(w,yw,xw) : FitFunc
172        Wave w,yw,xw
173       
174        Variable inten,rad,len
175        rad=w[1]
176        len=w[2]
177       
178        //setup form factor coefficient wave
179        Make/O/D/N=6 form_CYL_SW
180        form_CYL_SW[0] = 1
181        form_CYL_SW[1] = w[1]
182        form_CYL_SW[2] = w[2]
183        form_CYL_SW[3] = w[3]
184        form_CYL_SW[4] = w[4]
185        form_CYL_SW[5] = 0
186       
187        //setup structure factor coefficient wave
188        Make/O/D/N=4 struct_CYL_SW
189        struct_CYL_SW[0] = 0.5*DiamCyl(len,rad)
190        struct_CYL_SW[1] = w[0]
191        struct_CYL_SW[2] = w[5]
192        struct_CYL_SW[3] = w[6]
193       
194        //calculate each and combine
195        Duplicate/O xw temp_CYL_SW_PQ,temp_CYL_SW_SQ            //make waves for the AAO
196        CylinderForm(form_CYL_SW,temp_CYL_SW_PQ,xw)
197        SquareWellStruct(struct_CYL_SW,temp_CYL_SW_SQ,xw)
198        yw = temp_CYL_SW_PQ * temp_CYL_SW_SQ
199        yw *= w[0]
200        yw += w[7]
201       
202        //cleanup waves
203//      Killwaves/Z form_CYL_SW,struct_CYL_SW
204       
205        return (0)
206End
207
208Proc PlotCylinder_SC(num,qmin,qmax)
209        Variable num=128,qmin=0.001,qmax=0.7
210        Prompt num "Enter number of data points for model: "
211        Prompt qmin "Enter minimum q-value (A^-1) for model: "
212        Prompt qmax "Enter maximum q-value (A^-1) for model: "
213       
214        if(!DataFolderExists(":HayPenMSA"))
215                NewDataFolder :HayPenMSA
216        endif
217        Make/O/D/N=17 :HayPenMSA:gMSAWave
218       
219        Make/O/D/n=(num) xwave_CYL_SC,ywave_CYL_SC
220        xwave_CYL_SC =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
221        Make/O/D coef_CYL_SC = {0.01,20.,400,1e-6,6.3e-6,20,0,298,78,0.01}
222        make/o/t parameters_CYL_SC = {"volume fraction","radius (A)","length (A)","SLD cylinder (A^-2)","SLD solvent (A^-2)","charge","movalent salt(M)","Temperature (K)","dielectric const","incoh. bkg (cm^-1)"}
223        Edit parameters_CYL_SC,coef_CYL_SC
224       
225        Variable/G root:g_CYL_SC
226        g_CYL_SC := Cylinder_SC(coef_CYL_SC,ywave_CYL_SC,xwave_CYL_SC)
227        Display ywave_CYL_SC vs xwave_CYL_SC
228        ModifyGraph log=1,marker=29,msize=2,mode=4
229        Label bottom "q (A\\S-1\\M)"
230        Label left "Intensity (cm\\S-1\\M)"
231
232        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
233       
234        AddModelToStrings("Cylinder_SC","coef_CYL_SC","parameters_CYL_SC","CYL_SC")
235End
236
237// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
238Proc PlotSmearedCylinder_SC(str)                                                               
239        String str
240        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
241       
242        // if any of the resolution waves are missing => abort
243        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
244                Abort
245        endif
246       
247        SetDataFolder $("root:"+str)
248       
249        if(!DataFolderExists(":HayPenMSA"))
250                NewDataFolder :HayPenMSA
251        endif
252        Make/O/D/N=17 :HayPenMSA:gMSAWave
253       
254        // Setup parameter table for model function
255        Make/O/D smear_coef_CYL_SC = {0.01,20.,400,1e-6,6.3e-6,20,0,298,78,0.01}
256        make/o/t smear_parameters_CYL_SC = {"volume fraction","radius (A)","length (A)","SLD cylinder (A^-2)","SLD solvent (A^-2)","charge","movalent salt(M)","Temperature (K)","dielectric const","incoh. bkg (cm^-1)"}
257        Edit smear_parameters_CYL_SC,smear_coef_CYL_SC                                 
258       
259        // output smeared intensity wave, dimensions are identical to experimental QSIG values
260        // make extra copy of experimental q-values for easy plotting
261        Duplicate/O $(str+"_q") smeared_CYL_SC,smeared_qvals                           
262        SetScale d,0,0,"1/cm",smeared_CYL_SC                                                   
263                                       
264        Variable/G gs_CYL_SC=0
265        gs_CYL_SC := fSmearedCylinder_SC(smear_coef_CYL_SC,smeared_CYL_SC,smeared_qvals)        //this wrapper fills the STRUCT
266       
267        Display smeared_CYL_SC vs smeared_qvals                                                                 
268        ModifyGraph log=1,marker=29,msize=2,mode=4
269        Label bottom "q (A\\S-1\\M)"
270        Label left "Intensity (cm\\S-1\\M)"
271
272        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
273       
274        SetDataFolder root:
275        AddModelToStrings("SmearedCylinder_SC","smear_coef_CYL_SC","smear_parameters_CYL_SC","CYL_SC")
276End
277
278
279Function Cylinder_SC(w,yw,xw) : FitFunc
280        Wave w,yw,xw
281       
282        Variable inten,rad,len
283        rad=w[1]
284        len=w[2]
285       
286        //setup form factor coefficient wave
287        Make/O/D/N=6 form_CYL_SC
288        form_CYL_SC[0] = 1
289        form_CYL_SC[1] = w[1]
290        form_CYL_SC[2] = w[2]
291        form_CYL_SC[3] = w[3]
292        form_CYL_SC[4] = w[4]
293        form_CYL_SC[5] = 0
294       
295        //setup structure factor coefficient wave
296        Make/O/D/N=6 struct_CYL_SC
297        struct_CYL_SC[0] = DiamCyl(len,rad)
298        struct_CYL_SC[1] = w[5]
299        struct_CYL_SC[2] = w[0]
300        struct_CYL_SC[3] = w[7]
301        struct_CYL_SC[4] = w[6]
302        struct_CYL_SC[5] = w[8]
303       
304        //calculate each and combine
305        Duplicate/O xw temp_CYL_SC_PQ,temp_CYL_SC_SQ            //make waves for the AAO
306        CylinderForm(form_CYL_SC,temp_CYL_SC_PQ,xw)
307        HayterPenfoldMSA(struct_CYL_SC,temp_CYL_SC_SQ,xw)
308        yw = temp_CYL_SC_PQ * temp_CYL_SC_SQ
309        yw *= w[0]
310        yw += w[9]
311       
312        //cleanup waves
313//      Killwaves/Z form_CYL_SC,struct_CYL_SC
314       
315        return (0)
316End
317
318
319Proc PlotCylinder_SHS(num,qmin,qmax)
320        Variable num=128,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_CYL_SHS,ywave_CYL_SHS
326        xwave_CYL_SHS =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
327        Make/O/D coef_CYL_SHS = {0.01,20.0,400,1e-6,6.3e-6,0.05,0.2,0.01}
328        make/o/t parameters_CYL_SHS = {"volume fraction","radius (A)","length (A)","SLD cylinder (A^-2)","SLD solvent (A^-2)","perturbation parameter (0.1)","stickiness, tau","incoh. bkg (cm^-1)"}
329        Edit parameters_CYL_SHS,coef_CYL_SHS
330       
331        Variable/G root:g_CYL_SHS
332        g_CYL_SHS := Cylinder_SHS(coef_CYL_SHS,ywave_CYL_SHS,xwave_CYL_SHS)
333        Display ywave_CYL_SHS vs xwave_CYL_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("Cylinder_SHS","coef_CYL_SHS","parameters_CYL_SHS","CYL_SHS")
341End
342
343// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
344Proc PlotSmearedCylinder_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_CYL_SHS = {0.01,20.0,400,1e-6,6.3e-6,0.05,0.2,0.01}
357        make/o/t smear_parameters_CYL_SHS = {"volume fraction","radius (A)","length (A)","SLD cylinder (A^-2)","SLD solvent (A^-2)","perturbation parameter (0.1)","stickiness, tau","incoh. bkg (cm^-1)"}
358        Edit smear_parameters_CYL_SHS,smear_coef_CYL_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_CYL_SHS,smeared_qvals                           
363        SetScale d,0,0,"1/cm",smeared_CYL_SHS                                                   
364                                       
365        Variable/G gs_CYL_SHS=0
366        gs_CYL_SHS := fSmearedCylinder_SHS(smear_coef_CYL_SHS,smeared_CYL_SHS,smeared_qvals)    //this wrapper fills the STRUCT
367       
368        Display smeared_CYL_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("SmearedCylinder_SHS","smear_coef_CYL_SHS","smear_parameters_CYL_SHS","CYL_SHS")
377End
378       
379
380Function Cylinder_SHS(w,yw,xw) : FitFunc
381        Wave w,yw,xw
382       
383        Variable inten,rad,len
384        rad=w[1]
385        len=w[2]
386       
387        //setup form factor coefficient wave
388        Make/O/D/N=6 form_CYL_SHS
389        form_CYL_SHS[0] = 1
390        form_CYL_SHS[1] = w[1]
391        form_CYL_SHS[2] = w[2]
392        form_CYL_SHS[3] = w[3]
393        form_CYL_SHS[4] = w[4]
394        form_CYL_SHS[5] = 0
395       
396        //setup structure factor coefficient wave
397        Make/O/D/N=4 struct_CYL_SHS
398        struct_CYL_SHS[0] = 0.5*DiamCyl(len,rad)
399        struct_CYL_SHS[1] = w[0]
400        struct_CYL_SHS[2] = w[5]
401        struct_CYL_SHS[3] = w[6]
402       
403        //calculate each and combine
404        Duplicate/O xw temp_CYL_SHS_PQ,temp_CYL_SHS_SQ          //make waves for the AAO
405        CylinderForm(form_CYL_SHS,temp_CYL_SHS_PQ,xw)
406        StickyHS_Struct(struct_CYL_SHS,temp_CYL_SHS_SQ,xw)
407        yw = temp_CYL_SHS_PQ * temp_CYL_SHS_SQ
408        yw *= w[0]
409        yw += w[7]
410       
411        //cleanup waves
412//      Killwaves/Z form_CYL_SHS,struct_CYL_SHS
413       
414        return (0)
415End
416
417// two yukawa
418Proc PlotCylinder_2Y(num,qmin,qmax)
419        Variable num=128,qmin=0.001,qmax=0.7
420        Prompt num "Enter number of data points for model: "
421        Prompt qmin "Enter minimum q-value (A^-1) for model: "
422        Prompt qmax "Enter maximum q-value (A^-1) for model: "
423       
424        Make/O/D/n=(num) xwave_CYL_2Y,ywave_CYL_2Y
425        xwave_CYL_2Y =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
426        Make/O/D coef_CYL_2Y = {0.01,20.,400,1e-6,6.3e-6,6,10,-1,2,0.01}
427        make/o/t parameters_CYL_2Y = {"volume fraction","radius (A)","length (A)","SLD cylinder (A^-2)","SLD solvent (A^-2)","scale, K1","charge, Z1","scale, K2","charge, Z2","incoh. bkg (cm^-1)"}
428        Edit parameters_CYL_2Y,coef_CYL_2Y
429       
430        Variable/G root:g_CYL_2Y
431        g_CYL_2Y := Cylinder_2Y(coef_CYL_2Y,ywave_CYL_2Y,xwave_CYL_2Y)
432        Display ywave_CYL_2Y vs xwave_CYL_2Y
433        ModifyGraph log=1,marker=29,msize=2,mode=4
434        Label bottom "q (A\\S-1\\M)"
435        Label left "Intensity (cm\\S-1\\M)"
436
437        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
438       
439        AddModelToStrings("Cylinder_2Y","coef_CYL_2Y","parameters_CYL_2Y","CYL_2Y")
440End
441
442// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
443Proc PlotSmearedCylinder_2Y(str)                                                               
444        String str
445        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
446       
447        // if any of the resolution waves are missing => abort
448        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
449                Abort
450        endif
451       
452        SetDataFolder $("root:"+str)
453       
454        // Setup parameter table for model function
455        Make/O/D smear_coef_CYL_2Y = {0.01,20.,400,1e-6,6.3e-6,6,10,-1,2,0.01}
456        make/o/t smear_parameters_CYL_2Y = {"volume fraction","radius (A)","length (A)","SLD cylinder (A^-2)","SLD solvent (A^-2)","scale, K1","charge, Z1","scale, K2","charge, Z2","incoh. bkg (cm^-1)"}
457        Edit smear_parameters_CYL_2Y,smear_coef_CYL_2Y                                 
458       
459        // output smeared intensity wave, dimensions are identical to experimental QSIG values
460        // make extra copy of experimental q-values for easy plotting
461        Duplicate/O $(str+"_q") smeared_CYL_2Y,smeared_qvals                           
462        SetScale d,0,0,"1/cm",smeared_CYL_2Y                                                   
463                                       
464        Variable/G gs_CYL_2Y=0
465        gs_CYL_2Y := fSmearedCylinder_2Y(smear_coef_CYL_2Y,smeared_CYL_2Y,smeared_qvals)        //this wrapper fills the STRUCT
466       
467        Display smeared_CYL_2Y vs smeared_qvals                                                                 
468        ModifyGraph log=1,marker=29,msize=2,mode=4
469        Label bottom "q (A\\S-1\\M)"
470        Label left "Intensity (cm\\S-1\\M)"
471
472        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
473       
474        SetDataFolder root:
475        AddModelToStrings("SmearedCylinder_2Y","smear_coef_CYL_2Y","smear_parameters_CYL_2Y","CYL_2Y")
476End
477               
478
479Function Cylinder_2Y(w,yw,xw) : FitFunc
480        Wave w,yw,xw
481       
482        Variable inten,rad,len
483        rad=w[1]
484        len=w[2]
485       
486        //setup form factor coefficient wave
487        Make/O/D/N=6 form_CYL_2Y
488        form_CYL_2Y[0] = 1
489        form_CYL_2Y[1] = w[1]
490        form_CYL_2Y[2] = w[2]
491        form_CYL_2Y[3] = w[3]
492        form_CYL_2Y[4] = w[4]   
493        form_CYL_2Y[5] = 0
494       
495        //setup structure factor coefficient wave
496        Make/O/D/N=6 struct_CYL_2Y
497        struct_CYL_2Y[0] = w[0]
498        struct_CYL_2Y[1] = 0.5*DiamCyl(len,rad)
499        struct_CYL_2Y[2] = w[5]
500        struct_CYL_2Y[3] = w[6]
501        struct_CYL_2Y[4] = w[7]
502        struct_CYL_2Y[5] = w[8]
503       
504        //calculate each and combine
505        Duplicate/O xw temp_CYL_2Y_PQ,temp_CYL_2Y_SQ            //make waves for the AAO
506        CylinderForm(form_CYL_2Y,temp_CYL_2Y_PQ,xw)
507        TwoYukawa(struct_CYL_2Y,temp_CYL_2Y_SQ,xw)
508        yw = temp_CYL_2Y_PQ * temp_CYL_2Y_SQ
509        yw *= w[0]
510        yw += w[9]
511       
512        //cleanup waves (don't do this - it takes a lot of time...)
513//      Killwaves/Z form_CYL_2Y,struct_CYL_2Y
514       
515        return (0)
516End
517
518// this is all there is to the smeared calculation!
519Function SmearedCylinder_HS(s) :FitFunc
520        Struct ResSmearAAOStruct &s
521
522//      the name of your unsmeared model is the first argument
523        Smear_Model_20(Cylinder_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 SmearedCylinder_SW(s) :FitFunc
530        Struct ResSmearAAOStruct &s
531
532//      the name of your unsmeared model is the first argument
533        Smear_Model_20(Cylinder_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 SmearedCylinder_SC(s) :FitFunc
540        Struct ResSmearAAOStruct &s
541
542//      the name of your unsmeared model is the first argument
543        Smear_Model_20(Cylinder_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 SmearedCylinder_SHS(s) :FitFunc
550        Struct ResSmearAAOStruct &s
551
552//      the name of your unsmeared model is the first argument
553        Smear_Model_20(Cylinder_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 SmearedCylinder_2Y(s) :FitFunc
560        Struct ResSmearAAOStruct &s
561
562//      the name of your unsmeared model is the first argument
563        Smear_Model_20(Cylinder_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 fSmearedCylinder_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 = SmearedCylinder_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 fSmearedCylinder_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 = SmearedCylinder_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 fSmearedCylinder_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 = SmearedCylinder_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 fSmearedCylinder_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 = SmearedCylinder_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 fSmearedCylinder_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 = SmearedCylinder_2Y(fs)
689       
690        return (0)
691End
Note: See TracBrowser for help on using the repository browser.