source: sans/Dev/trunk/NCNR_User_Procedures/Analysis/Models/NewModels_2006/SchulzSpheres_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.1 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 "SchulzSpheres_v40"
8
9#include "HardSphereStruct_v40"
10#include "HPMSA_v40"
11#include "SquareWellStruct_v40"
12#include "StickyHardSphereStruct_v40"
13#include "Two_Yukawa_v40"
14
15
16Proc PlotSchulzSpheres_HS(num,qmin,qmax)
17        Variable num=128,qmin=0.001,qmax=0.7
18        Prompt num "Enter number of data points for model: "
19        Prompt qmin "Enter minimum q-value (A^-1) for model: "
20        Prompt qmax "Enter maximum q-value (A^-1) for model: "
21       
22        Make/O/D/N=(num) xwave_sch_HS,ywave_sch_HS
23        xwave_sch_HS = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) )
24        Make/O/D coef_sch_HS = {0.01,60,0.2,1e-6,3e-6,0.001}
25        make/O/T parameters_sch_HS = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","bkg (cm-1 sr-1)"}
26        Edit parameters_sch_HS,coef_sch_HS
27       
28        Variable/G root:g_sch_HS
29        g_sch_HS := SchulzSpheres_HS(coef_sch_HS,ywave_sch_HS,xwave_sch_HS)
30        Display ywave_sch_HS vs xwave_sch_HS
31        ModifyGraph log=1,marker=29,msize=2,mode=4
32        Label bottom "q (A\\S-1\\M)"
33        Label left "Intensity (cm\\S-1\\M)"
34        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
35       
36        AddModelToStrings("SchulzSpheres_HS","coef_sch_HS","parameters_sch_HS","sch_HS")
37End
38
39// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
40Proc PlotSmearedSchulzSpheres_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_sch_HS = {0.01,60,0.2,1e-6,3e-6,0.001}                                     
53        make/o/t smear_parameters_sch_HS = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","bkg (cm-1 sr-1)"} 
54        Edit smear_parameters_sch_HS,smear_coef_sch_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_sch_HS,smeared_qvals                           
59        SetScale d,0,0,"1/cm",smeared_sch_HS                                                   
60                                       
61        Variable/G gs_sch_HS=0
62        gs_sch_HS := fSmearedSchulzSpheres_HS(smear_coef_sch_HS,smeared_sch_HS,smeared_qvals)   //this wrapper fills the STRUCT
63       
64        Display smeared_sch_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        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
69       
70        SetDataFolder root:
71        AddModelToStrings("SmearedSchulzSpheres_HS","smear_coef_sch_HS","smear_parameters_sch_HS","sch_HS")
72End
73       
74
75
76Function SchulzSpheres_HS(w,yw,xw) : FitFunc
77        Wave w,yw,xw
78       
79        Variable inten
80       
81        //setup form factor coefficient wave
82        Make/O/D/N=6 form_sch_HS
83        form_sch_HS[0] = 1
84        form_sch_HS[1] = w[1]
85        form_sch_HS[2] = w[2]
86        form_sch_HS[3] = w[3]
87        form_sch_HS[4] = w[4]
88        form_sch_HS[5] = 0
89       
90        //calculate the diameter of the effective one-component sphere
91        Variable pd,diam,zz,Vpoly,Ravg
92        pd = w[2]
93        zz = (1/pd)^2 - 1
94        Ravg = w[1]
95       
96        Vpoly = 4*pi/3*(Ravg)^3*(zz+3)*(zz+2)/(zz+1)^2
97        diam = (6*Vpoly/pi)^(1/3)
98       
99       
100        //setup structure factor coefficient wave
101        Make/O/D/N=2 struct_sch_HS
102        struct_sch_HS[0] = diam/2
103        struct_sch_HS[1] = w[0]
104       
105        //calculate each and combine
106        Duplicate/O xw tmp_sch_HS_PQ,tmp_sch_HS_SQ
107        SchulzSpheres(form_sch_HS,tmp_sch_HS_PQ,xw)
108        HardSphereStruct(struct_sch_HS,tmp_sch_HS_SQ,xw)
109        yw = tmp_sch_HS_PQ * tmp_sch_HS_SQ
110        yw *= w[0]
111        yw += w[5]
112       
113        //cleanup waves
114//      Killwaves/Z form_sch_HS,struct_sch_HS
115       
116        return (0)
117End
118
119/////////////////////////////////////////
120Proc PlotSchulzSpheres_SW(num,qmin,qmax)
121        Variable num=128,qmin=0.001,qmax=0.7
122        Prompt num "Enter number of data points for model: "
123        Prompt qmin "Enter minimum q-value (A^-1) for model: "
124        Prompt qmax "Enter maximum q-value (A^-1) for model: "
125       
126        Make/O/D/N=(num) xwave_sch_SW,ywave_sch_SW
127        xwave_sch_SW = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) )
128        Make/O/D coef_sch_SW = {0.01,60,0.2,1e-6,3e-6,1.0,1.2,0.001}
129        make/O/T parameters_sch_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)"}
130        Edit parameters_sch_SW,coef_sch_SW
131
132        Variable/G root:g_sch_SW
133        g_sch_SW := SchulzSpheres_SW(coef_sch_SW,ywave_sch_SW,xwave_sch_SW)
134        Display ywave_sch_SW vs xwave_sch_SW
135        ModifyGraph log=1,marker=29,msize=2,mode=4
136        Label bottom "q (A\\S-1\\M)"
137        Label left "Intensity (cm\\S-1\\M)"
138        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
139       
140        AddModelToStrings("SchulzSpheres_SW","coef_sch_SW","parameters_sch_SW","sch_SW")
141End
142
143// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
144Proc PlotSmearedSchulzSpheres_SW(str)                                                           
145        String str
146        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
147       
148        // if any of the resolution waves are missing => abort
149        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
150                Abort
151        endif
152       
153        SetDataFolder $("root:"+str)
154       
155        // Setup parameter table for model function
156        Make/O/D smear_coef_sch_SW = {0.01,60,0.2,1e-6,3e-6,1.0,1.2,0.001}                                     
157        make/o/t smear_parameters_sch_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)"}   
158        Edit smear_parameters_sch_SW,smear_coef_sch_SW                                 
159       
160        // output smeared intensity wave, dimensions are identical to experimental QSIG values
161        // make extra copy of experimental q-values for easy plotting
162        Duplicate/O $(str+"_q") smeared_sch_SW,smeared_qvals                           
163        SetScale d,0,0,"1/cm",smeared_sch_SW                                                   
164                                       
165        Variable/G gs_sch_SW=0
166        gs_sch_SW := fSmearedSchulzSpheres_SW(smear_coef_sch_SW,smeared_sch_SW,smeared_qvals)   //this wrapper fills the STRUCT
167       
168        Display smeared_sch_SW vs smeared_qvals                                                                 
169        ModifyGraph log=1,marker=29,msize=2,mode=4
170        Label bottom "q (A\\S-1\\M)"
171        Label left "Intensity (cm\\S-1\\M)"
172        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
173       
174        SetDataFolder root:
175        AddModelToStrings("SmearedSchulzSpheres_SW","smear_coef_sch_SW","smear_parameters_sch_SW","sch_SW")
176End
177
178       
179
180Function SchulzSpheres_SW(w,yw,xw) : FitFunc
181        Wave w,yw,xw
182       
183        Variable inten
184       
185        //setup form factor coefficient wave
186        Make/O/D/N=6 form_sch_SW
187        form_sch_SW[0] = 1
188        form_sch_SW[1] = w[1]
189        form_sch_SW[2] = w[2]
190        form_sch_SW[3] = w[3]
191        form_sch_SW[4] = w[4]
192        form_sch_SW[5] = 0
193       
194        //calculate the diameter of the effective one-component sphere
195        Variable pd,diam,zz,Vpoly,Ravg
196        pd = w[2]
197        zz = (1/pd)^2 - 1
198        Ravg = w[1]
199       
200        Vpoly = 4*pi/3*(Ravg)^3*(zz+3)*(zz+2)/(zz+1)^2
201        diam = (6*Vpoly/pi)^(1/3)
202       
203        //setup structure factor coefficient wave
204        Make/O/D/N=4 struct_sch_SW
205        struct_sch_SW[0] = diam/2
206        struct_sch_SW[1] = w[0]
207        struct_sch_SW[2] = w[5]
208        struct_sch_SW[3] = w[6]
209       
210        //calculate each and combine
211        Duplicate/O xw tmp_sch_SW_PQ,tmp_sch_SW_SQ
212        SchulzSpheres(form_sch_SW,tmp_sch_SW_PQ,xw)
213        SquareWellStruct(struct_sch_SW,tmp_sch_SW_SQ,xw)
214        yw = tmp_sch_SW_PQ * tmp_sch_SW_SQ
215        yw *= w[0]
216        yw += w[7]
217       
218        //cleanup waves
219//      Killwaves/Z form_sch_SW,struct_sch_SW
220       
221        return (0)
222End
223
224
225/////////////////////////////////////////
226Proc PlotSchulzSpheres_SC(num,qmin,qmax)
227        Variable num=256,qmin=0.001,qmax=0.7
228        Prompt num "Enter number of data points for model: "
229        Prompt qmin "Enter minimum q-value (A^-1) for model: "
230        Prompt qmax "Enter maximum q-value (A^-1) for model: "
231       
232        if(!DataFolderExists(":HayPenMSA"))
233                NewDataFolder :HayPenMSA
234        endif
235        Make/O/D/N=17 :HayPenMSA:gMSAWave
236
237        Make/O/D/N=(num) xwave_sch_SC,ywave_sch_SC
238        xwave_sch_SC = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) )
239        Make/O/D coef_sch_SC = {0.01,60,0.2,1e-6,3e-6,20,0,298,78,0.001}
240        make/O/T parameters_sch_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)"}
241        Edit parameters_sch_SC,coef_sch_SC
242       
243        Variable/G root:g_sch_SC
244        g_sch_SC := SchulzSpheres_SC(coef_sch_SC,ywave_sch_SC,xwave_sch_SC)
245        Display ywave_sch_SC vs xwave_sch_SC
246        ModifyGraph log=1,marker=29,msize=2,mode=4
247        Label bottom "q (A\\S-1\\M)"
248        Label left "Intensity (cm\\S-1\\M)"
249        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
250       
251        AddModelToStrings("SchulzSpheres_SC","coef_sch_SC","parameters_sch_SC","sch_SC")
252End
253
254// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
255Proc PlotSmearedSchulzSpheres_SC(str)                                                           
256        String str
257        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
258       
259        // if any of the resolution waves are missing => abort
260        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
261                Abort
262        endif
263       
264        SetDataFolder $("root:"+str)
265       
266        if(!DataFolderExists(":HayPenMSA"))
267                NewDataFolder :HayPenMSA
268        endif
269        Make/O/D/N=17 :HayPenMSA:gMSAWave
270       
271        // Setup parameter table for model function
272        Make/O/D smear_coef_sch_SC = {0.01,60,0.2,1e-6,3e-6,20,0,298,78,0.001}                                 
273        make/o/t smear_parameters_sch_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)"}
274        Edit smear_parameters_sch_SC,smear_coef_sch_SC                                 
275       
276        // output smeared intensity wave, dimensions are identical to experimental QSIG values
277        // make extra copy of experimental q-values for easy plotting
278        Duplicate/O $(str+"_q") smeared_sch_SC,smeared_qvals                           
279        SetScale d,0,0,"1/cm",smeared_sch_SC                                                   
280                                       
281        Variable/G gs_sch_SC=0
282        gs_sch_SC := fSmearedSchulzSpheres_SC(smear_coef_sch_SC,smeared_sch_SC,smeared_qvals)   //this wrapper fills the STRUCT
283       
284        Display smeared_sch_SC vs smeared_qvals                                                                 
285        ModifyGraph log=1,marker=29,msize=2,mode=4
286        Label bottom "q (A\\S-1\\M)"
287        Label left "Intensity (cm\\S-1\\M)"
288        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
289       
290        SetDataFolder root:
291        AddModelToStrings("SmearedSchulzSpheres_SC","smear_coef_sch_SC","smear_parameters_sch_SC","sch_SC")
292End
293
294
295Function SchulzSpheres_SC(w,yw,xw) : FitFunc
296        Wave w,yw,xw
297       
298        Variable inten
299       
300        //setup form factor coefficient wave
301        Make/O/D/N=6 form_sch_SC
302        form_sch_SC[0] = 1
303        form_sch_SC[1] = w[1]
304        form_sch_SC[2] = w[2]
305        form_sch_SC[3] = w[3]
306        form_sch_SC[4] = w[4]
307        form_sch_SC[5] = 0
308       
309        //calculate the diameter of the effective one-component sphere
310        Variable pd,diam,zz,Vpoly,Ravg
311        pd = w[2]
312        zz = (1/pd)^2 - 1
313        Ravg = w[1]
314       
315        Vpoly = 4*pi/3*(Ravg)^3*(zz+3)*(zz+2)/(zz+1)^2
316        diam = (6*Vpoly/pi)^(1/3)
317       
318        //setup structure factor coefficient wave
319        Make/O/D/N=6 struct_sch_SC
320        struct_sch_SC[0] = diam
321        struct_sch_SC[1] = w[5]
322        struct_sch_SC[2] = w[0]
323        struct_sch_SC[3] = w[7]
324        struct_sch_SC[4] = w[6]
325        struct_sch_SC[5] = w[8]
326       
327        //calculate each and combine
328        Duplicate/O xw tmp_sch_SC_PQ,tmp_sch_SC_SQ
329        SchulzSpheres(form_sch_SC,tmp_sch_SC_PQ,xw)
330        HayterPenfoldMSA(struct_sch_SC,tmp_sch_SC_SQ,xw)
331        yw = tmp_sch_SC_PQ *tmp_sch_SC_SQ
332        yw *= w[0]
333        yw += w[9]
334       
335        //cleanup waves
336//      Killwaves/Z form_sch_SC,struct_sch_SC
337       
338        return (0)
339End
340
341/////////////////////////////////////////
342Proc PlotSchulzSpheres_SHS(num,qmin,qmax)
343        Variable num=256,qmin=0.001,qmax=0.7
344        Prompt num "Enter number of data points for model: "
345        Prompt qmin "Enter minimum q-value (A^-1) for model: "
346        Prompt qmax "Enter maximum q-value (A^-1) for model: "
347       
348        Make/O/D/N=(num) xwave_sch_SHS,ywave_sch_SHS
349        xwave_sch_SHS = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) )
350        Make/O/D coef_sch_SHS = {0.01,60,0.2,1e-6,3e-6,0.05,0.2,0.001}
351        make/O/T parameters_sch_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)"}
352        Edit parameters_sch_SHS,coef_sch_SHS
353       
354        Variable/G root:g_sch_SHS
355        g_sch_SHS := SchulzSpheres_SHS(coef_sch_SHS,ywave_sch_SHS,xwave_sch_SHS)
356        Display ywave_sch_SHS vs xwave_sch_SHS
357        ModifyGraph log=1,marker=29,msize=2,mode=4
358        Label bottom "q (A\\S-1\\M)"
359        Label left "Intensity (cm\\S-1\\M)"
360        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
361       
362        AddModelToStrings("SchulzSpheres_SHS","coef_sch_SHS","parameters_sch_SHS","sch_SHS")
363End
364
365// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
366Proc PlotSmearedSchulzSpheres_SHS(str)                                                         
367        String str
368        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
369       
370        // if any of the resolution waves are missing => abort
371        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
372                Abort
373        endif
374       
375        SetDataFolder $("root:"+str)
376       
377        // Setup parameter table for model function
378        Make/O/D smear_coef_sch_SHS = {0.01,60,0.2,1e-6,3e-6,0.05,0.2,0.001}                                   
379        make/o/t smear_parameters_sch_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)"}       
380        Edit smear_parameters_sch_SHS,smear_coef_sch_SHS                                       
381       
382        // output smeared intensity wave, dimensions are identical to experimental QSIG values
383        // make extra copy of experimental q-values for easy plotting
384        Duplicate/O $(str+"_q") smeared_sch_SHS,smeared_qvals                           
385        SetScale d,0,0,"1/cm",smeared_sch_SHS                                                   
386                                       
387        Variable/G gs_sch_SHS=0
388        gs_sch_SHS := fSmearedSchulzSpheres_SHS(smear_coef_sch_SHS,smeared_sch_SHS,smeared_qvals)       //this wrapper fills the STRUCT
389       
390        Display smeared_sch_SHS vs smeared_qvals                                                                       
391        ModifyGraph log=1,marker=29,msize=2,mode=4
392        Label bottom "q (A\\S-1\\M)"
393        Label left "Intensity (cm\\S-1\\M)"
394        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
395       
396        SetDataFolder root:
397        AddModelToStrings("SmearedSchulzSpheres_SHS","smear_coef_sch_SHS","smear_parameters_sch_SHS","sch_SHS")
398End
399
400
401Function SchulzSpheres_SHS(w,yw,xw) : FitFunc
402        Wave w,yw,xw
403       
404        Variable inten
405       
406        //setup form factor coefficient wave
407        Make/O/D/N=6 form_sch_SHS
408        form_sch_SHS[0] = 1
409        form_sch_SHS[1] = w[1]
410        form_sch_SHS[2] = w[2]
411        form_sch_SHS[3] = w[3]
412        form_sch_SHS[4] = w[4]
413        form_sch_SHS[5] = 0
414       
415        //calculate the diameter of the effective one-component sphere
416        Variable pd,diam,zz,Vpoly,Ravg
417        pd = w[2]
418        zz = (1/pd)^2 - 1
419        Ravg = w[1]
420       
421        Vpoly = 4*pi/3*(Ravg)^3*(zz+3)*(zz+2)/(zz+1)^2
422        diam = (6*Vpoly/pi)^(1/3)
423       
424        //setup structure factor coefficient wave
425        Make/O/D/N=4 struct_sch_SHS
426        struct_sch_SHS[0] = diam/2
427        struct_sch_SHS[1] = w[0]
428        struct_sch_SHS[2] = w[5]
429        struct_sch_SHS[3] = w[6]
430       
431        //calculate each and combine
432        Duplicate/O xw tmp_sch_SHS_PQ,tmp_sch_SHS_SQ
433        SchulzSpheres(form_sch_SHS,tmp_sch_SHS_PQ,xw)
434        StickyHS_Struct(struct_sch_SHS,tmp_sch_SHS_SQ,xw)
435        yw = tmp_sch_SHS_PQ * tmp_sch_SHS_SQ
436        yw *= w[0]
437        yw += w[7]
438       
439        //cleanup waves
440//      Killwaves/Z form_sch_SHS,struct_sch_SHS
441       
442        return (0)
443End
444
445//two yukawa
446Proc PlotSchulzSpheres_2Y(num,qmin,qmax)
447        Variable num=128,qmin=0.001,qmax=0.7
448        Prompt num "Enter number of data points for model: "
449        Prompt qmin "Enter minimum q-value (A^-1) for model: "
450        Prompt qmax "Enter maximum q-value (A^-1) for model: "
451       
452        Make/O/D/N=(num) xwave_sch_2Y,ywave_sch_2Y
453        xwave_sch_2Y = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) )
454        Make/O/D coef_sch_2Y = {0.01,60,0.2,1e-6,3e-6,6,10,-1,2,0.001}
455        make/O/T parameters_sch_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)"}
456        Edit parameters_sch_2Y,coef_sch_2Y
457       
458        Variable/G root:g_sch_2Y
459        g_sch_2Y := SchulzSpheres_2Y(coef_sch_2Y,ywave_sch_2Y,xwave_sch_2Y)
460        Display ywave_sch_2Y vs xwave_sch_2Y
461        ModifyGraph log=1,marker=29,msize=2,mode=4
462        Label bottom "q (A\\S-1\\M)"
463        Label left "Intensity (cm\\S-1\\M)"
464        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
465       
466        AddModelToStrings("SchulzSpheres_2Y","coef_sch_2Y","parameters_sch_2Y","sch_2Y")
467End
468
469// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
470Proc PlotSmearedSchulzSpheres_2Y(str)                                                           
471        String str
472        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
473       
474        // if any of the resolution waves are missing => abort
475        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
476                Abort
477        endif
478       
479        SetDataFolder $("root:"+str)
480       
481        // Setup parameter table for model function
482        Make/O/D smear_coef_sch_2Y = {0.01,60,0.2,1e-6,3e-6,6,10,-1,2,0.001}                                   
483        make/o/t smear_parameters_sch_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)"}       
484        Edit smear_parameters_sch_2Y,smear_coef_sch_2Y                                 
485       
486        // output smeared intensity wave, dimensions are identical to experimental QSIG values
487        // make extra copy of experimental q-values for easy plotting
488        Duplicate/O $(str+"_q") smeared_sch_2Y,smeared_qvals                           
489        SetScale d,0,0,"1/cm",smeared_sch_2Y                                                   
490                                       
491        Variable/G gs_sch_2Y=0
492        gs_sch_2Y := fSmearedSchulzSpheres_2Y(smear_coef_sch_2Y,smeared_sch_2Y,smeared_qvals)   //this wrapper fills the STRUCT
493       
494        Display smeared_sch_2Y vs smeared_qvals                                                                 
495        ModifyGraph log=1,marker=29,msize=2,mode=4
496        Label bottom "q (A\\S-1\\M)"
497        Label left "Intensity (cm\\S-1\\M)"
498        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
499       
500        SetDataFolder root:
501        AddModelToStrings("SmearedSchulzSpheres_2Y","smear_coef_sch_2Y","smear_parameters_sch_2Y","sch_2Y")
502End
503       
504
505
506Function SchulzSpheres_2Y(w,yw,xw) : FitFunc
507        Wave w,yw,xw
508       
509        Variable inten
510       
511        //setup form factor coefficient wave
512        Make/O/D/N=6 form_sch_2Y
513        form_sch_2Y[0] = 1
514        form_sch_2Y[1] = w[1]
515        form_sch_2Y[2] = w[2]
516        form_sch_2Y[3] = w[3]
517        form_sch_2Y[4] = w[4]
518        form_sch_2Y[5] = 0
519       
520        //calculate the diameter of the effective one-component sphere
521        Variable pd,diam,zz,Vpoly,Ravg
522        pd = w[2]
523        zz = (1/pd)^2 - 1
524        Ravg = w[1]
525       
526        Vpoly = 4*pi/3*(Ravg)^3*(zz+3)*(zz+2)/(zz+1)^2
527        diam = (6*Vpoly/pi)^(1/3)
528       
529       
530        //setup structure factor coefficient wave
531        Make/O/D/N=6 struct_sch_2Y
532        struct_sch_2Y[0] = w[0]
533        struct_sch_2Y[1] = diam/2
534        struct_sch_2Y[2] = w[5]
535        struct_sch_2Y[3] = w[6]
536        struct_sch_2Y[4] = w[7]
537        struct_sch_2Y[5] = w[8]
538       
539        //calculate each and combine
540        Duplicate/O xw tmp_sch_2Y_PQ,tmp_sch_2Y_SQ
541        SchulzSpheres(form_sch_2Y,tmp_sch_2Y_PQ,xw)
542        TwoYukawa(struct_sch_2Y,tmp_sch_2Y_SQ,xw)
543        yw = tmp_sch_2Y_PQ * tmp_sch_2Y_SQ
544        yw *= w[0]
545        yw += w[9]
546       
547        //cleanup waves
548//      Killwaves/Z form_sch_2Y,struct_sch_2Y
549       
550        return (0)
551End
552
553
554
555// this is all there is to the smeared calculation!
556Function SmearedSchulzSpheres_HS(s) : FitFunc
557        Struct ResSmearAAOStruct &s
558
559//      the name of your unsmeared model (AAO) is the first argument
560        Smear_Model_20(SchulzSpheres_HS,s.coefW,s.xW,s.yW,s.resW)
561
562        return(0)
563End
564
565// this is all there is to the smeared calculation!
566Function SmearedSchulzSpheres_SW(s) : FitFunc
567        Struct ResSmearAAOStruct &s
568
569//      the name of your unsmeared model (AAO) is the first argument
570        Smear_Model_20(SchulzSpheres_SW,s.coefW,s.xW,s.yW,s.resW)
571
572        return(0)
573End
574
575// this is all there is to the smeared calculation!
576Function SmearedSchulzSpheres_SC(s) : FitFunc
577        Struct ResSmearAAOStruct &s
578
579//      the name of your unsmeared model (AAO) is the first argument
580        Smear_Model_20(SchulzSpheres_SC,s.coefW,s.xW,s.yW,s.resW)
581
582        return(0)
583End
584
585// this is all there is to the smeared calculation!
586Function SmearedSchulzSpheres_SHS(s) : FitFunc
587        Struct ResSmearAAOStruct &s
588
589//      the name of your unsmeared model (AAO) is the first argument
590        Smear_Model_20(SchulzSpheres_SHS,s.coefW,s.xW,s.yW,s.resW)
591
592        return(0)
593End
594
595// this is all there is to the smeared calculation!
596Function SmearedSchulzSpheres_2Y(s) : FitFunc
597        Struct ResSmearAAOStruct &s
598
599//      the name of your unsmeared model (AAO) is the first argument
600        Smear_Model_20(SchulzSpheres_2Y,s.coefW,s.xW,s.yW,s.resW)
601
602        return(0)
603End
604
605//wrapper to calculate the smeared model as an AAO-Struct
606// fills the struct and calls the ususal function with the STRUCT parameter
607//
608// used only for the dependency, not for fitting
609//
610Function fSmearedSchulzSpheres_HS(coefW,yW,xW)
611        Wave coefW,yW,xW
612       
613        String str = getWavesDataFolder(yW,0)
614        String DF="root:"+str+":"
615       
616        WAVE resW = $(DF+str+"_res")
617       
618        STRUCT ResSmearAAOStruct fs
619        WAVE fs.coefW = coefW   
620        WAVE fs.yW = yW
621        WAVE fs.xW = xW
622        WAVE fs.resW = resW
623       
624        Variable err
625        err = SmearedSchulzSpheres_HS(fs)
626       
627        return (0)
628End
629
630//wrapper to calculate the smeared model as an AAO-Struct
631// fills the struct and calls the ususal function with the STRUCT parameter
632//
633// used only for the dependency, not for fitting
634//
635Function fSmearedSchulzSpheres_SW(coefW,yW,xW)
636        Wave coefW,yW,xW
637       
638        String str = getWavesDataFolder(yW,0)
639        String DF="root:"+str+":"
640       
641        WAVE resW = $(DF+str+"_res")
642       
643        STRUCT ResSmearAAOStruct fs
644        WAVE fs.coefW = coefW   
645        WAVE fs.yW = yW
646        WAVE fs.xW = xW
647        WAVE fs.resW = resW
648       
649        Variable err
650        err = SmearedSchulzSpheres_SW(fs)
651       
652        return (0)
653End
654
655//wrapper to calculate the smeared model as an AAO-Struct
656// fills the struct and calls the ususal function with the STRUCT parameter
657//
658// used only for the dependency, not for fitting
659//
660Function fSmearedSchulzSpheres_SC(coefW,yW,xW)
661        Wave coefW,yW,xW
662       
663        String str = getWavesDataFolder(yW,0)
664        String DF="root:"+str+":"
665       
666        WAVE resW = $(DF+str+"_res")
667       
668        STRUCT ResSmearAAOStruct fs
669        WAVE fs.coefW = coefW   
670        WAVE fs.yW = yW
671        WAVE fs.xW = xW
672        WAVE fs.resW = resW
673       
674        Variable err
675        err = SmearedSchulzSpheres_SC(fs)
676       
677        return (0)
678End
679
680//wrapper to calculate the smeared model as an AAO-Struct
681// fills the struct and calls the ususal function with the STRUCT parameter
682//
683// used only for the dependency, not for fitting
684//
685Function fSmearedSchulzSpheres_SHS(coefW,yW,xW)
686        Wave coefW,yW,xW
687       
688        String str = getWavesDataFolder(yW,0)
689        String DF="root:"+str+":"
690       
691        WAVE resW = $(DF+str+"_res")
692       
693        STRUCT ResSmearAAOStruct fs
694        WAVE fs.coefW = coefW   
695        WAVE fs.yW = yW
696        WAVE fs.xW = xW
697        WAVE fs.resW = resW
698       
699        Variable err
700        err = SmearedSchulzSpheres_SHS(fs)
701       
702        return (0)
703End
704
705//wrapper to calculate the smeared model as an AAO-Struct
706// fills the struct and calls the ususal function with the STRUCT parameter
707//
708// used only for the dependency, not for fitting
709//
710Function fSmearedSchulzSpheres_2Y(coefW,yW,xW)
711        Wave coefW,yW,xW
712       
713        String str = getWavesDataFolder(yW,0)
714        String DF="root:"+str+":"
715       
716        WAVE resW = $(DF+str+"_res")
717       
718        STRUCT ResSmearAAOStruct fs
719        WAVE fs.coefW = coefW   
720        WAVE fs.yW = yW
721        WAVE fs.xW = xW
722        WAVE fs.resW = resW
723       
724        Variable err
725        err = SmearedSchulzSpheres_2Y(fs)
726       
727        return (0)
728End
Note: See TracBrowser for help on using the repository browser.