source: sans/Dev/trunk/NCNR_User_Procedures/Analysis/Models/NewModels_2006/GaussSpheres_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: 22.0 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma IgorVersion=6.1
3
4//
5// be sure to include all of the necessary files
6//
7#include "GaussSpheres_v40"
8
9#include "HardSphereStruct_v40"
10#include "HPMSA_v40"
11#include "SquareWellStruct_v40"
12#include "StickyHardSphereStruct_v40"
13#include "Two_Yukawa_v40"
14
15Proc PlotGaussPolySphere_HS(num,qmin,qmax)
16        Variable num=128,qmin=0.001,qmax=0.7
17        Prompt num "Enter number of data points for model: "
18        Prompt qmin "Enter minimum q-value (A^-1) for model: "
19        Prompt qmax "Enter maximum q-value (A^-1) for model: "
20       
21        Make/O/D/N=(num) xwave_pgs_HS,ywave_pgs_HS
22        xwave_pgs_HS = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) )
23        Make/O/D coef_pgs_HS = {0.01,60,0.2,1e-6,3e-6,0.001}
24        make/O/T parameters_pgs_HS = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","bkg (cm-1 sr-1)"}
25        Edit parameters_pgs_HS,coef_pgs_HS
26       
27        Variable/G root:g_pgs_HS
28        g_pgs_HS := GaussPolySphere_HS(coef_pgs_HS,ywave_pgs_HS,xwave_pgs_HS)
29        Display ywave_pgs_HS vs xwave_pgs_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        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
34       
35        AddModelToStrings("GaussPolySphere_HS","coef_pgs_HS","parameters_pgs_HS","pgs_HS")
36End
37
38// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
39Proc PlotSmearedGaussPolySphere_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_pgs_HS = {0.01,60,0.2,1e-6,3e-6,0.001}                                     
52        make/o/t smear_parameters_pgs_HS = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","bkg (cm-1 sr-1)"} 
53        Edit smear_parameters_pgs_HS,smear_coef_pgs_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_pgs_HS,smeared_qvals                           
58        SetScale d,0,0,"1/cm",smeared_pgs_HS                                                   
59                                       
60        Variable/G gs_pgs_HS=0
61        gs_pgs_HS := fSmearedGaussPolySphere_HS(smear_coef_pgs_HS,smeared_pgs_HS,smeared_qvals) //this wrapper fills the STRUCT
62       
63        Display smeared_pgs_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        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
68       
69        SetDataFolder root:
70        AddModelToStrings("SmearedGaussPolySphere_HS","smear_coef_pgs_HS","smear_parameters_pgs_HS","pgs_HS")
71End
72
73
74
75Function GaussPolySphere_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=6 form_pgs_HS
82        form_pgs_HS[0] = 1
83        form_pgs_HS[1] = w[1]
84        form_pgs_HS[2] = w[2]
85        form_pgs_HS[3] = w[3]
86        form_pgs_HS[4] = w[4]
87        form_pgs_HS[5] = 0
88       
89        //calculate the diameter of the effective one-component sphere
90        Variable pd,diam,Vpoly,Ravg
91        pd = w[2]
92        Ravg = w[1]
93       
94        Vpoly = (4*pi/3*Ravg^3)*(1+3*pd^2)
95        diam = (6*Vpoly/pi)^(1/3)
96       
97       
98        //setup structure factor coefficient wave
99        Make/O/D/N=2 struct_pgs_HS
100        struct_pgs_HS[0] = diam/2
101        struct_pgs_HS[1] = w[0]
102       
103        //calculate each and combine
104        Duplicate/O xw tmp_pgs_HS_PQ,tmp_pgs_HS_SQ
105        GaussSpheres(form_pgs_HS,tmp_pgs_HS_PQ,xw)
106        HardSphereStruct(struct_pgs_HS,tmp_pgs_HS_SQ,xw)
107        yw = tmp_pgs_HS_PQ * tmp_pgs_HS_SQ
108        yw *= w[0]
109        yw += w[5]
110       
111        //cleanup waves
112//      Killwaves/Z form_pgs_HS,struct_pgs_HS
113       
114        return (0)
115End
116
117/////////////////////////////////////////
118Proc PlotGaussPolySphere_SW(num,qmin,qmax)
119        Variable num=128,qmin=0.001,qmax=0.7
120        Prompt num "Enter number of data points for model: "
121        Prompt qmin "Enter minimum q-value (A^-1) for model: "
122        Prompt qmax "Enter maximum q-value (A^-1) for model: "
123       
124        Make/O/D/N=(num) xwave_pgs_SW,ywave_pgs_SW
125        xwave_pgs_SW = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) )
126        Make/O/D coef_pgs_SW = {0.01,60,0.2,1e-6,3e-6,1.0,1.2,0.001}
127        make/O/T parameters_pgs_SW = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","well depth (kT)","well width (diam.)","bkg (cm-1 sr-1)"}
128        Edit parameters_pgs_SW,coef_pgs_SW
129       
130        Variable/G root:g_pgs_SW
131        g_pgs_SW := GaussPolySphere_SW(coef_pgs_SW,ywave_pgs_SW,xwave_pgs_SW)
132        Display ywave_pgs_SW vs xwave_pgs_SW
133        ModifyGraph log=1,marker=29,msize=2,mode=4
134        Label bottom "q (A\\S-1\\M)"
135        Label left "Intensity (cm\\S-1\\M)"
136        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
137       
138        AddModelToStrings("GaussPolySphere_SW","coef_pgs_SW","parameters_pgs_SW","pgs_SW")
139End
140
141// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
142Proc PlotSmearedGaussPolySphere_SW(str)                                                         
143        String str
144        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
145       
146        // if any of the resolution waves are missing => abort
147        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
148                Abort
149        endif
150       
151        SetDataFolder $("root:"+str)
152       
153        // Setup parameter table for model function
154        Make/O/D smear_coef_pgs_SW = {0.01,60,0.2,1e-6,3e-6,1.0,1.2,0.001}                                     
155        make/o/t smear_parameters_pgs_SW = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","well depth (kT)","well width (diam.)","bkg (cm-1 sr-1)"}   
156        Edit smear_parameters_pgs_SW,smear_coef_pgs_SW                                 
157       
158        // output smeared intensity wave, dimensions are identical to experimental QSIG values
159        // make extra copy of experimental q-values for easy plotting
160        Duplicate/O $(str+"_q") smeared_pgs_SW,smeared_qvals                           
161        SetScale d,0,0,"1/cm",smeared_pgs_SW                                                   
162                                       
163        Variable/G gs_pgs_SW=0
164        gs_pgs_SW := fSmearedGaussPolySphere_SW(smear_coef_pgs_SW,smeared_pgs_SW,smeared_qvals) //this wrapper fills the STRUCT
165       
166        Display smeared_pgs_SW vs smeared_qvals                                                                 
167        ModifyGraph log=1,marker=29,msize=2,mode=4
168        Label bottom "q (A\\S-1\\M)"
169        Label left "Intensity (cm\\S-1\\M)"
170        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
171       
172        SetDataFolder root:
173        AddModelToStrings("SmearedGaussPolySphere_SW","smear_coef_pgs_SW","smear_parameters_pgs_SW","pgs_SW")
174End
175       
176
177Function GaussPolySphere_SW(w,yw,xw) : FitFunc
178        Wave w,yw,xw
179       
180        Variable inten
181       
182        //setup form factor coefficient wave
183        Make/O/D/N=6 form_pgs_SW
184        form_pgs_SW[0] = 1
185        form_pgs_SW[1] = w[1]
186        form_pgs_SW[2] = w[2]
187        form_pgs_SW[3] = w[3]
188        form_pgs_SW[4] = w[4]
189        form_pgs_SW[5] = 0
190       
191        //calculate the diameter of the effective one-component sphere
192        Variable pd,diam,Vpoly,Ravg
193        pd = w[2]
194        Ravg = w[1]
195       
196        Vpoly = (4*pi/3*Ravg^3)*(1+3*pd^2)
197        diam = (6*Vpoly/pi)^(1/3)
198       
199        //setup structure factor coefficient wave
200        Make/O/D/N=4 struct_pgs_SW
201        struct_pgs_SW[0] = diam/2
202        struct_pgs_SW[1] = w[0]
203        struct_pgs_SW[2] = w[5]
204        struct_pgs_SW[3] = w[6]
205       
206        //calculate each and combine
207        Duplicate/O xw tmp_pgs_SW_PQ,tmp_pgs_SW_SQ
208        GaussSpheres(form_pgs_SW,tmp_pgs_SW_PQ,xw)
209        SquareWellStruct(struct_pgs_SW,tmp_pgs_SW_SQ,xw)
210        yw = tmp_pgs_SW_PQ * tmp_pgs_SW_SQ
211        yw *= w[0]
212        yw += w[7]
213       
214        //cleanup waves
215//      Killwaves/Z form_pgs_SW,struct_pgs_SW
216       
217        return (0)
218End
219
220
221/////////////////////////////////////////
222Proc PlotGaussPolySphere_SC(num,qmin,qmax)
223        Variable num=256,qmin=0.001,qmax=0.7
224        Prompt num "Enter number of data points for model: "
225        Prompt qmin "Enter minimum q-value (A^-1) for model: "
226        Prompt qmax "Enter maximum q-value (A^-1) for model: "
227       
228        if(!DataFolderExists(":HayPenMSA"))
229                NewDataFolder :HayPenMSA
230        endif
231        Make/O/D/N=17 :HayPenMSA:gMSAWave
232
233        Make/O/D/N=(num) xwave_pgs_SC,ywave_pgs_SC
234        xwave_pgs_SC = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) )
235        Make/O/D coef_pgs_SC = {0.01,60,0.2,1e-6,3e-6,20,0,298,78,0.001}
236        make/O/T parameters_pgs_SC = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","charge","movalent salt(M)","Temperature (K)","dielectric const","bkg (cm-1 sr-1)"}
237        Edit parameters_pgs_SC,coef_pgs_SC
238       
239        Variable/G root:g_pgs_SC
240        g_pgs_SC := GaussPolySphere_SC(coef_pgs_SC,ywave_pgs_SC,xwave_pgs_SC)
241        Display ywave_pgs_SC vs xwave_pgs_SC
242        ModifyGraph log=1,marker=29,msize=2,mode=4
243        Label bottom "q (A\\S-1\\M)"
244        Label left "Intensity (cm\\S-1\\M)"
245        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
246       
247        AddModelToStrings("GaussPolySphere_SC","coef_pgs_SC","parameters_pgs_SC","pgs_SC")
248End
249
250// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
251Proc PlotSmearedGaussPolySphere_SC(str)                                                         
252        String str
253        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
254       
255        // if any of the resolution waves are missing => abort
256        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
257                Abort
258        endif
259       
260        SetDataFolder $("root:"+str)
261       
262        if(!DataFolderExists(":HayPenMSA"))
263                NewDataFolder :HayPenMSA
264        endif
265        Make/O/D/N=17 :HayPenMSA:gMSAWave
266       
267        // Setup parameter table for model function
268        Make/O/D smear_coef_pgs_SC = {0.01,60,0.2,1e-6,3e-6,20,0,298,78,0.001}                                 
269        make/o/t smear_parameters_pgs_SC = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","charge","movalent salt(M)","Temperature (K)","dielectric const","bkg (cm-1 sr-1)"}
270        Edit smear_parameters_pgs_SC,smear_coef_pgs_SC                                 
271       
272        // output smeared intensity wave, dimensions are identical to experimental QSIG values
273        // make extra copy of experimental q-values for easy plotting
274        Duplicate/O $(str+"_q") smeared_pgs_SC,smeared_qvals                           
275        SetScale d,0,0,"1/cm",smeared_pgs_SC                                                   
276                                       
277        Variable/G gs_pgs_SC=0
278        gs_pgs_SC := fSmearedGaussPolySphere_SC(smear_coef_pgs_SC,smeared_pgs_SC,smeared_qvals) //this wrapper fills the STRUCT
279       
280        Display smeared_pgs_SC vs smeared_qvals                                                                 
281        ModifyGraph log=1,marker=29,msize=2,mode=4
282        Label bottom "q (A\\S-1\\M)"
283        Label left "Intensity (cm\\S-1\\M)"
284        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
285       
286        SetDataFolder root:
287        AddModelToStrings("SmearedGaussPolySphere_SC","smear_coef_pgs_SC","smear_parameters_pgs_SC","pgs_SC")
288End
289
290
291Function GaussPolySphere_SC(w,yw,xw) : FitFunc
292        Wave w,yw,xw
293       
294        Variable inten
295       
296        //setup form factor coefficient wave
297        Make/O/D/N=6 form_pgs_SC
298        form_pgs_SC[0] = 1
299        form_pgs_SC[1] = w[1]
300        form_pgs_SC[2] = w[2]
301        form_pgs_SC[3] = w[3]
302        form_pgs_SC[4] = w[4]
303        form_pgs_SC[5] = 0
304       
305        //calculate the diameter of the effective one-component sphere
306        Variable pd,diam,Vpoly,Ravg
307        pd = w[2]
308        Ravg = w[1]
309       
310        Vpoly = (4*pi/3*Ravg^3)*(1+3*pd^2)
311        diam = (6*Vpoly/pi)^(1/3)
312       
313        //setup structure factor coefficient wave
314        Make/O/D/N=6 struct_pgs_SC
315        struct_pgs_SC[0] = diam
316        struct_pgs_SC[1] = w[5]
317        struct_pgs_SC[2] = w[0]
318        struct_pgs_SC[3] = w[7]
319        struct_pgs_SC[4] = w[6]
320        struct_pgs_SC[5] = w[8]
321       
322        //calculate each and combine
323        Duplicate/O xw tmp_pgs_SC_PQ,tmp_pgs_SC_SQ
324        GaussSpheres(form_pgs_SC,tmp_pgs_SC_PQ,xw)
325        HayterPenfoldMSA(struct_pgs_SC,tmp_pgs_SC_SQ,xw)
326        yw = tmp_pgs_SC_PQ * tmp_pgs_SC_SQ
327        yw *= w[0]
328        yw += w[9]
329       
330        //cleanup waves
331//      Killwaves/Z form_pgs_SC,struct_pgs_SC
332       
333        return (0)
334End
335
336/////////////////////////////////////////
337Proc PlotGaussPolySphere_SHS(num,qmin,qmax)
338        Variable num=256,qmin=0.001,qmax=0.7
339        Prompt num "Enter number of data points for model: "
340        Prompt qmin "Enter minimum q-value (A^-1) for model: "
341        Prompt qmax "Enter maximum q-value (A^-1) for model: "
342       
343        Make/O/D/N=(num) xwave_pgs_SHS,ywave_pgs_SHS
344        xwave_pgs_SHS = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) )
345        Make/O/D coef_pgs_SHS = {0.01,60,0.2,1e-6,3e-6,0.05,0.2,0.001}
346        make/O/T parameters_pgs_SHS = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","perturbation parameter (0.1)","stickiness, tau","bkg (cm-1 sr-1)"}
347        Edit parameters_pgs_SHS,coef_pgs_SHS
348       
349        Variable/G root:g_pgs_SHS
350        g_pgs_SHS := GaussPolySphere_SHS(coef_pgs_SHS,ywave_pgs_SHS,xwave_pgs_SHS)
351        Display ywave_pgs_SHS vs xwave_pgs_SHS
352        ModifyGraph log=1,marker=29,msize=2,mode=4
353        Label bottom "q (A\\S-1\\M)"
354        Label left "Intensity (cm\\S-1\\M)"
355        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
356       
357        AddModelToStrings("GaussPolySphere_SHS","coef_pgs_SHS","parameters_pgs_SHS","pgs_SHS")
358End
359
360// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
361Proc PlotSmearedGaussPolySphere_SHS(str)                                                               
362        String str
363        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
364       
365        // if any of the resolution waves are missing => abort
366        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
367                Abort
368        endif
369       
370        SetDataFolder $("root:"+str)
371       
372        // Setup parameter table for model function
373        Make/O/D smear_coef_pgs_SHS = {0.01,60,0.2,1e-6,3e-6,0.05,0.2,0.001}                                   
374        make/o/t smear_parameters_pgs_SHS = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","perturbation parameter (0.1)","stickiness, tau","bkg (cm-1 sr-1)"}       
375        Edit smear_parameters_pgs_SHS,smear_coef_pgs_SHS                                       
376       
377        // output smeared intensity wave, dimensions are identical to experimental QSIG values
378        // make extra copy of experimental q-values for easy plotting
379        Duplicate/O $(str+"_q") smeared_pgs_SHS,smeared_qvals                           
380        SetScale d,0,0,"1/cm",smeared_pgs_SHS                                                   
381                                       
382        Variable/G gs_pgs_SHS=0
383        gs_pgs_SHS := fSmearedGaussPolySphere_SHS(smear_coef_pgs_SHS,smeared_pgs_SHS,smeared_qvals)     //this wrapper fills the STRUCT
384       
385        Display smeared_pgs_SHS vs smeared_qvals                                                                       
386        ModifyGraph log=1,marker=29,msize=2,mode=4
387        Label bottom "q (A\\S-1\\M)"
388        Label left "Intensity (cm\\S-1\\M)"
389        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
390       
391        SetDataFolder root:
392        AddModelToStrings("SmearedGaussPolySphere_SHS","smear_coef_pgs_SHS","smear_parameters_pgs_SHS","pgs_SHS")
393End
394       
395
396Function GaussPolySphere_SHS(w,yw,xw) : FitFunc
397        Wave w,yw,xw
398       
399        Variable inten
400       
401        //setup form factor coefficient wave
402        Make/O/D/N=6 form_pgs_SHS
403        form_pgs_SHS[0] = 1
404        form_pgs_SHS[1] = w[1]
405        form_pgs_SHS[2] = w[2]
406        form_pgs_SHS[3] = w[3]
407        form_pgs_SHS[4] = w[4]
408        form_pgs_SHS[5] = 0
409       
410        //calculate the diameter of the effective one-component sphere
411        Variable pd,diam,Vpoly,Ravg
412        pd = w[2]
413        Ravg = w[1]
414       
415        Vpoly = (4*pi/3*Ravg^3)*(1+3*pd^2)
416        diam = (6*Vpoly/pi)^(1/3)
417       
418        //setup structure factor coefficient wave
419        Make/O/D/N=4 struct_pgs_SHS
420        struct_pgs_SHS[0] = diam/2
421        struct_pgs_SHS[1] = w[0]
422        struct_pgs_SHS[2] = w[5]
423        struct_pgs_SHS[3] = w[6]
424       
425        //calculate each and combine
426        Duplicate/O xw tmp_pgs_SHS_PQ,tmp_pgs_SHS_SQ
427        GaussSpheres(form_pgs_SHS,tmp_pgs_SHS_PQ,xw)
428        StickyHS_Struct(struct_pgs_SHS,tmp_pgs_SHS_SQ,xw)
429        yw = tmp_pgs_SHS_PQ * tmp_pgs_SHS_SQ
430        yw *= w[0]
431        yw += w[7]
432       
433        //cleanup waves
434//      Killwaves/Z form_pgs_SHS,struct_pgs_SHS
435       
436        return (0)
437End
438
439//two yukawa
440Proc PlotGaussPolySphere_2Y(num,qmin,qmax)
441        Variable num=128,qmin=0.001,qmax=0.7
442        Prompt num "Enter number of data points for model: "
443        Prompt qmin "Enter minimum q-value (A^-1) for model: "
444        Prompt qmax "Enter maximum q-value (A^-1) for model: "
445       
446        Make/O/D/N=(num) xwave_pgs_2Y,ywave_pgs_2Y
447        xwave_pgs_2Y = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) )
448        Make/O/D coef_pgs_2Y = {0.01,60,0.2,1e-6,3e-6,6,10,-1,2,0.001}
449        make/O/T parameters_pgs_2Y = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","scale, K1","charge, Z1","scale, K2","charge, Z2","bkg (cm-1 sr-1)"}
450        Edit parameters_pgs_2Y,coef_pgs_2Y
451       
452        Variable/G root:g_pgs_2Y
453        g_pgs_2Y := GaussPolySphere_2Y(coef_pgs_2Y,ywave_pgs_2Y,xwave_pgs_2Y)
454        Display ywave_pgs_2Y vs xwave_pgs_2Y
455        ModifyGraph log=1,marker=29,msize=2,mode=4
456        Label bottom "q (A\\S-1\\M)"
457        Label left "Intensity (cm\\S-1\\M)"
458        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
459       
460        AddModelToStrings("GaussPolySphere_2Y","coef_pgs_2Y","parameters_pgs_2Y","pgs_2Y")
461End
462
463// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
464Proc PlotSmearedGaussPolySphere_2Y(str)                                                         
465        String str
466        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
467       
468        // if any of the resolution waves are missing => abort
469        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
470                Abort
471        endif
472       
473        SetDataFolder $("root:"+str)
474       
475        // Setup parameter table for model function
476        Make/O/D smear_coef_pgs_2Y = {0.01,60,0.2,1e-6,3e-6,6,10,-1,2,0.001}                                   
477        make/o/t smear_parameters_pgs_2Y = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","scale, K1","charge, Z1","scale, K2","charge, Z2","bkg (cm-1 sr-1)"}       
478        Edit smear_parameters_pgs_2Y,smear_coef_pgs_2Y                                 
479       
480        // output smeared intensity wave, dimensions are identical to experimental QSIG values
481        // make extra copy of experimental q-values for easy plotting
482        Duplicate/O $(str+"_q") smeared_pgs_2Y,smeared_qvals                           
483        SetScale d,0,0,"1/cm",smeared_pgs_2Y                                                   
484                                       
485        Variable/G gs_pgs_2Y=0
486        gs_pgs_2Y := fSmearedGaussPolySphere_2Y(smear_coef_pgs_2Y,smeared_pgs_2Y,smeared_qvals) //this wrapper fills the STRUCT
487       
488        Display smeared_pgs_2Y vs smeared_qvals                                                                 
489        ModifyGraph log=1,marker=29,msize=2,mode=4
490        Label bottom "q (A\\S-1\\M)"
491        Label left "Intensity (cm\\S-1\\M)"
492        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
493       
494        SetDataFolder root:
495        AddModelToStrings("SmearedGaussPolySphere_2Y","smear_coef_pgs_2Y","smear_parameters_pgs_2Y","pgs_2Y")
496End
497
498
499
500Function GaussPolySphere_2Y(w,yw,xw) : FitFunc
501        Wave w,yw,xw
502       
503        Variable inten
504       
505        //setup form factor coefficient wave
506        Make/O/D/N=6 form_pgs_2Y
507        form_pgs_2Y[0] = 1
508        form_pgs_2Y[1] = w[1]
509        form_pgs_2Y[2] = w[2]
510        form_pgs_2Y[3] = w[3]
511        form_pgs_2Y[4] = w[4]
512        form_pgs_2Y[5] = 0
513       
514        //calculate the diameter of the effective one-component sphere
515        Variable pd,diam,Vpoly,Ravg
516        pd = w[2]
517        Ravg = w[1]
518       
519        Vpoly = (4*pi/3*Ravg^3)*(1+3*pd^2)
520        diam = (6*Vpoly/pi)^(1/3)
521       
522       
523        //setup structure factor coefficient wave
524        Make/O/D/N=6 struct_pgs_2Y
525        struct_pgs_2Y[0] = w[0]
526        struct_pgs_2Y[1] = diam/2
527        struct_pgs_2Y[2] = w[5]
528        struct_pgs_2Y[3] = w[6]
529        struct_pgs_2Y[4] = w[7]
530        struct_pgs_2Y[5] = w[8]
531       
532        //calculate each and combine
533        Duplicate/O xw tmp_pgs_2Y_PQ,tmp_pgs_2Y_SQ
534        GaussSpheres(form_pgs_2Y,tmp_pgs_2Y_PQ,xw)
535        TwoYukawa(struct_pgs_2Y,tmp_pgs_2Y_SQ,xw)
536        yw = tmp_pgs_2Y_PQ * tmp_pgs_2Y_SQ
537        yw *= w[0]
538        yw += w[9]
539       
540        //cleanup waves
541//      Killwaves/Z form_pgs_2Y,struct_pgs_2Y
542       
543        return (0)
544End
545
546// this is all there is to the smeared calculation!
547Function SmearedGaussPolySphere_HS(s) : FitFunc
548        Struct ResSmearAAOStruct &s
549
550//      the name of your unsmeared model (AAO) is the first argument
551        Smear_Model_20(GaussPolySphere_HS,s.coefW,s.xW,s.yW,s.resW)
552
553        return(0)
554End
555
556// this is all there is to the smeared calculation!
557Function SmearedGaussPolySphere_SW(s) : FitFunc
558        Struct ResSmearAAOStruct &s
559
560//      the name of your unsmeared model (AAO) is the first argument
561        Smear_Model_20(GaussPolySphere_SW,s.coefW,s.xW,s.yW,s.resW)
562
563        return(0)
564End
565
566// this is all there is to the smeared calculation!
567Function SmearedGaussPolySphere_SC(s) : FitFunc
568        Struct ResSmearAAOStruct &s
569
570//      the name of your unsmeared model (AAO) is the first argument
571        Smear_Model_20(GaussPolySphere_SC,s.coefW,s.xW,s.yW,s.resW)
572
573        return(0)
574End
575
576// this is all there is to the smeared calculation!
577Function SmearedGaussPolySphere_SHS(s) : FitFunc
578        Struct ResSmearAAOStruct &s
579
580//      the name of your unsmeared model (AAO) is the first argument
581        Smear_Model_20(GaussPolySphere_SHS,s.coefW,s.xW,s.yW,s.resW)
582
583        return(0)
584End
585
586// this is all there is to the smeared calculation!
587Function SmearedGaussPolySphere_2Y(s) : FitFunc
588        Struct ResSmearAAOStruct &s
589
590//      the name of your unsmeared model (AAO) is the first argument
591        Smear_Model_20(GaussPolySphere_2Y,s.coefW,s.xW,s.yW,s.resW)
592
593        return(0)
594End
595
596//wrapper to calculate the smeared model as an AAO-Struct
597// fills the struct and calls the ususal function with the STRUCT parameter
598//
599// used only for the dependency, not for fitting
600//
601Function fSmearedGaussPolySphere_HS(coefW,yW,xW)
602        Wave coefW,yW,xW
603       
604        String str = getWavesDataFolder(yW,0)
605        String DF="root:"+str+":"
606       
607        WAVE resW = $(DF+str+"_res")
608       
609        STRUCT ResSmearAAOStruct fs
610        WAVE fs.coefW = coefW   
611        WAVE fs.yW = yW
612        WAVE fs.xW = xW
613        WAVE fs.resW = resW
614       
615        Variable err
616        err = SmearedGaussPolySphere_HS(fs)
617       
618        return (0)
619End
620
621//wrapper to calculate the smeared model as an AAO-Struct
622// fills the struct and calls the ususal function with the STRUCT parameter
623//
624// used only for the dependency, not for fitting
625//
626Function fSmearedGaussPolySphere_SW(coefW,yW,xW)
627        Wave coefW,yW,xW
628       
629        String str = getWavesDataFolder(yW,0)
630        String DF="root:"+str+":"
631       
632        WAVE resW = $(DF+str+"_res")
633       
634        STRUCT ResSmearAAOStruct fs
635        WAVE fs.coefW = coefW   
636        WAVE fs.yW = yW
637        WAVE fs.xW = xW
638        WAVE fs.resW = resW
639       
640        Variable err
641        err = SmearedGaussPolySphere_SW(fs)
642       
643        return (0)
644End
645
646//wrapper to calculate the smeared model as an AAO-Struct
647// fills the struct and calls the ususal function with the STRUCT parameter
648//
649// used only for the dependency, not for fitting
650//
651Function fSmearedGaussPolySphere_SC(coefW,yW,xW)
652        Wave coefW,yW,xW
653       
654        String str = getWavesDataFolder(yW,0)
655        String DF="root:"+str+":"
656       
657        WAVE resW = $(DF+str+"_res")
658       
659        STRUCT ResSmearAAOStruct fs
660        WAVE fs.coefW = coefW   
661        WAVE fs.yW = yW
662        WAVE fs.xW = xW
663        WAVE fs.resW = resW
664       
665        Variable err
666        err = SmearedGaussPolySphere_SC(fs)
667       
668        return (0)
669End
670
671//wrapper to calculate the smeared model as an AAO-Struct
672// fills the struct and calls the ususal function with the STRUCT parameter
673//
674// used only for the dependency, not for fitting
675//
676Function fSmearedGaussPolySphere_SHS(coefW,yW,xW)
677        Wave coefW,yW,xW
678       
679        String str = getWavesDataFolder(yW,0)
680        String DF="root:"+str+":"
681       
682        WAVE resW = $(DF+str+"_res")
683       
684        STRUCT ResSmearAAOStruct fs
685        WAVE fs.coefW = coefW   
686        WAVE fs.yW = yW
687        WAVE fs.xW = xW
688        WAVE fs.resW = resW
689       
690        Variable err
691        err = SmearedGaussPolySphere_SHS(fs)
692       
693        return (0)
694End
695
696//wrapper to calculate the smeared model as an AAO-Struct
697// fills the struct and calls the ususal function with the STRUCT parameter
698//
699// used only for the dependency, not for fitting
700//
701Function fSmearedGaussPolySphere_2Y(coefW,yW,xW)
702        Wave coefW,yW,xW
703       
704        String str = getWavesDataFolder(yW,0)
705        String DF="root:"+str+":"
706       
707        WAVE resW = $(DF+str+"_res")
708       
709        STRUCT ResSmearAAOStruct fs
710        WAVE fs.coefW = coefW   
711        WAVE fs.yW = yW
712        WAVE fs.xW = xW
713        WAVE fs.resW = resW
714       
715        Variable err
716        err = SmearedGaussPolySphere_2Y(fs)
717       
718        return (0)
719End
Note: See TracBrowser for help on using the repository browser.