source: sans/Dev/trunk/NCNR_User_Procedures/Analysis/Models/PolyCore_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.7 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 "PolyCore_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 PlotPolyCore_HS(num,qmin,qmax)
16        Variable num=256,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_PCF_HS,ywave_PCF_HS
22        xwave_PCF_HS = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) )
23        Make/O/D coef_PCF_HS = {0.1,60,.2,10,1e-6,2e-6,3e-6,0.0001}
24        make/o/t parameters_PCF_HS = {"volume fraction","avg core rad (A)","core polydisp (0,1)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","bkg (cm-1)"}
25        Edit/K=1 parameters_PCF_HS,coef_PCF_HS
26        Variable/G root:g_PCF_HS
27        g_PCF_HS := PolyCore_HS(coef_PCF_HS,ywave_PCF_HS,xwave_PCF_HS)
28//      ywave_PCF_HS := PolyCore_HS(coef_PCF_HS,xwave_PCF_HS)
29        Display/K=1 ywave_PCF_HS vs xwave_PCF_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("PolyCore_HS","coef_PCF_HS","parameters_PCF_HS","PCF_HS")
37End
38
39// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
40Proc PlotSmearedPolyCore_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_PCF_HS = {0.1,60,.2,10,1e-6,2e-6,3e-6,0.0001}
53        make/o/t smear_parameters_PCF_HS = {"volume fraction","avg core rad (A)","core polydisp (0,1)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","bkg (cm-1)"}
54        Edit smear_parameters_PCF_HS,smear_coef_PCF_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_PCF_HS,smeared_qvals                           
59        SetScale d,0,0,"1/cm",smeared_PCF_HS                                                   
60                                       
61        Variable/G gs_PCF_HS=0
62        gs_PCF_HS := fSmearedPolyCore_HS(smear_coef_PCF_HS,smeared_PCF_HS,smeared_qvals)        //this wrapper fills the STRUCT
63       
64        Display smeared_PCF_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("SmearedPolyCore_HS","smear_coef_PCF_HS","smear_parameters_PCF_HS","PCF_HS")
73End
74       
75
76//AAO function
77Function PolyCore_HS(w,yw,xw) : FitFunc
78        Wave w,yw,xw
79               
80        //setup form factor coefficient wave
81        Make/O/D/N=8 form_PCF_HS
82        form_PCF_HS[0] = 1
83        form_PCF_HS[1] = w[1]
84        form_PCF_HS[2] = w[2]
85        form_PCF_HS[3] = w[3]
86        form_PCF_HS[4] = w[4]
87        form_PCF_HS[5] = w[5]
88        form_PCF_HS[6] = w[6]
89        form_PCF_HS[7] = 0
90       
91        //calculate the diameter of the effective one-component sphere
92        Variable pd,diam,zz,Vpoly,Ravg,thick
93        pd = w[2]
94        zz = (1/pd)^2 - 1
95        Ravg = w[1]
96        thick = w[3]
97       
98        Vpoly = 4*pi/3*(Ravg+thick)^3*(zz+3)*(zz+2)/(zz+1)^2
99        diam = (6*Vpoly/pi)^(1/3)
100       
101       
102        //setup structure factor coefficient wave
103        Make/O/D/N=2 struct_PCF_HS
104        struct_PCF_HS[0] = diam/2
105        struct_PCF_HS[1] = w[0]
106       
107        //calculate each and combine
108        Duplicate/O xw temp_PCF_HS_PQ,temp_PCF_HS_SQ            //make waves for the AAO
109        PolyCoreForm(form_PCF_HS,temp_PCF_HS_PQ,xw)
110        HardSphereStruct(struct_PCF_HS,temp_PCF_HS_SQ,xw)
111        yw = temp_PCF_HS_PQ*temp_PCF_HS_SQ
112        yw *= w[0]
113        yw += w[7]
114       
115        //cleanup waves
116//      Killwaves/Z form_PCF_HS,struct_PCF_HS
117       
118        return (0)
119End
120
121/////////////////////////////////////////
122Proc PlotPolyCore_SW(num,qmin,qmax)
123        Variable num=256,qmin=0.001,qmax=0.7
124        Prompt num "Enter number of data points for model: "
125        Prompt qmin "Enter minimum q-value (A^-1) for model: "
126        Prompt qmax "Enter maximum q-value (A^-1) for model: "
127       
128        Make/O/D/n=(num) xwave_PCF_SW,ywave_PCF_SW
129        xwave_PCF_SW = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) )
130        Make/O/D coef_PCF_SW = {0.1,60,.2,10,1e-6,2e-6,3e-6,1.0,1.2,0.0001}
131        make/o/t parameters_PCF_SW = {"volume fraction","avg core rad (A)","core polydisp (0,1)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","well depth (kT)","well width (diam.)","bkg (cm-1)"}
132        Edit/K=1 parameters_PCF_SW,coef_PCF_SW
133       
134        Variable/G root:g_PCF_SW
135        g_PCF_SW := PolyCore_SW(coef_PCF_SW,ywave_PCF_SW,xwave_PCF_SW)
136        Display/K=1 ywave_PCF_SW vs xwave_PCF_SW
137        ModifyGraph log=1,marker=29,msize=2,mode=4
138        Label bottom "q (A\\S-1\\M)"
139        Label left "Intensity (cm\\S-1\\M)"
140
141        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
142       
143        AddModelToStrings("PolyCore_SW","coef_PCF_SW","parameters_PCF_SW","PCF_SW")
144End
145
146// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
147Proc PlotSmearedPolyCore_SW(str)                                                               
148        String str
149        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
150       
151        // if any of the resolution waves are missing => abort
152        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
153                Abort
154        endif
155       
156        SetDataFolder $("root:"+str)
157       
158        // Setup parameter table for model function
159        Make/O/D smear_coef_PCF_SW = {0.1,60,.2,10,1e-6,2e-6,3e-6,1.0,1.2,0.0001}
160        make/o/t smear_parameters_PCF_SW = {"volume fraction","avg core rad (A)","core polydisp (0,1)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","well depth (kT)","well width (diam.)","bkg (cm-1)"}
161        Edit smear_parameters_PCF_SW,smear_coef_PCF_SW                                 
162       
163        // output smeared intensity wave, dimensions are identical to experimental QSIG values
164        // make extra copy of experimental q-values for easy plotting
165        Duplicate/O $(str+"_q") smeared_PCF_SW,smeared_qvals                           
166        SetScale d,0,0,"1/cm",smeared_PCF_SW                                                   
167                                       
168        Variable/G gs_PCF_SW=0
169        gs_PCF_SW := fSmearedPolyCore_SW(smear_coef_PCF_SW,smeared_PCF_SW,smeared_qvals)        //this wrapper fills the STRUCT
170       
171        Display smeared_PCF_SW vs smeared_qvals                                                                 
172        ModifyGraph log=1,marker=29,msize=2,mode=4
173        Label bottom "q (A\\S-1\\M)"
174        Label left "Intensity (cm\\S-1\\M)"
175
176        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
177       
178        SetDataFolder root:
179        AddModelToStrings("SmearedPolyCore_SW","smear_coef_PCF_SW","smear_parameters_PCF_SW","PCF_SW")
180End
181       
182
183Function PolyCore_SW(w,yw,xw) : FitFunc
184        Wave w,yw,xw
185       
186        Variable inten
187       
188        //setup form factor coefficient wave
189        Make/O/D/N=8 form_PCF_SW
190        form_PCF_SW[0] = 1
191        form_PCF_SW[1] = w[1]
192        form_PCF_SW[2] = w[2]
193        form_PCF_SW[3] = w[3]
194        form_PCF_SW[4] = w[4]
195        form_PCF_SW[5] = w[5]
196        form_PCF_SW[6] = w[6]
197        form_PCF_SW[7] = 0
198       
199        //calculate the diameter of the effective one-component sphere
200        Variable pd,diam,zz,Vpoly,Ravg,thick
201        pd = w[2]
202        zz = (1/pd)^2 - 1
203        Ravg = w[1]
204        thick = w[3]
205       
206        Vpoly = 4*pi/3*(Ravg+thick)^3*(zz+3)*(zz+2)/(zz+1)^2
207        diam = (6*Vpoly/pi)^(1/3)
208       
209        //setup structure factor coefficient wave
210        Make/O/D/N=4 struct_PCF_SW
211        struct_PCF_SW[0] = diam/2
212        struct_PCF_SW[1] = w[0]
213        struct_PCF_SW[2] = w[7]
214        struct_PCF_SW[3] = w[8]
215       
216        //calculate each and combine
217        Duplicate/O xw temp_PCF_SW_PQ,temp_PCF_SW_SQ            //make waves for the AAO
218        PolyCoreForm(form_PCF_SW,temp_PCF_SW_PQ,xw)
219        SquareWellStruct(struct_PCF_SW,temp_PCF_SW_SQ,xw)
220        yw = temp_PCF_SW_PQ * temp_PCF_SW_SQ
221        yw *= w[0]
222        yw += w[9]
223       
224        //cleanup waves
225//      Killwaves/Z form_PCF_SW,struct_PCF_SW
226       
227        return (0)
228End
229
230
231/////////////////////////////////////////
232Proc PlotPolyCore_SC(num,qmin,qmax)
233        Variable num=256,qmin=0.001,qmax=0.7
234        Prompt num "Enter number of data points for model: "
235        Prompt qmin "Enter minimum q-value (A^-1) for model: "
236        Prompt qmax "Enter maximum q-value (A^-1) for model: "
237       
238        if(!DataFolderExists(":HayPenMSA"))
239                NewDataFolder :HayPenMSA
240        endif
241        Make/O/D/N=17 :HayPenMSA:gMSAWave
242       
243        Make/O/D/n=(num) xwave_PCF_SC,ywave_PCF_SC
244        xwave_PCF_SC = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) )
245        Make/O/D coef_PCF_SC = {0.1,60,.2,10,1e-6,2e-6,3e-6,10,0,298,78,0.0001}
246        make/o/t parameters_PCF_SC = {"volume fraction","avg core rad (A)","core polydisp (0,1)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","charge","Monovalent salt (M)","Temperature (K)","dielectric const.","bkg (cm-1)"}
247        Edit/K=1 parameters_PCF_SC,coef_PCF_SC
248       
249        Variable/G root:g_PCF_SC
250        g_PCF_SC := PolyCore_SC(coef_PCF_SC,ywave_PCF_SC,xwave_PCF_SC)
251        Display/K=1 ywave_PCF_SC vs xwave_PCF_SC
252        ModifyGraph log=1,marker=29,msize=2,mode=4
253        Label bottom "q (A\\S-1\\M)"
254        Label left "Intensity (cm\\S-1\\M)"
255
256        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
257       
258        AddModelToStrings("PolyCore_SC","coef_PCF_SC","parameters_PCF_SC","PCF_SC")
259End
260
261// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
262Proc PlotSmearedPolyCore_SC(str)                                                               
263        String str
264        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
265       
266        // if any of the resolution waves are missing => abort
267        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
268                Abort
269        endif
270       
271        SetDataFolder $("root:"+str)
272       
273        if(!DataFolderExists(":HayPenMSA"))
274                NewDataFolder :HayPenMSA
275        endif
276        Make/O/D/N=17 :HayPenMSA:gMSAWave
277       
278        // Setup parameter table for model function
279        Make/O/D smear_coef_PCF_SC = {0.1,60,.2,10,1e-6,2e-6,3e-6,10,0,298,78,0.0001}
280        make/o/t smear_parameters_PCF_SC = {"volume fraction","avg core rad (A)","core polydisp (0,1)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","charge","Monovalent salt (M)","Temperature (K)","dielectric const.","bkg (cm-1)"}
281        Edit smear_parameters_PCF_SC,smear_coef_PCF_SC                                 
282       
283        // output smeared intensity wave, dimensions are identical to experimental QSIG values
284        // make extra copy of experimental q-values for easy plotting
285        Duplicate/O $(str+"_q") smeared_PCF_SC,smeared_qvals                           
286        SetScale d,0,0,"1/cm",smeared_PCF_SC                                                   
287                                       
288        Variable/G gs_PCF_SC=0
289        gs_PCF_SC := fSmearedPolyCore_SC(smear_coef_PCF_SC,smeared_PCF_SC,smeared_qvals)        //this wrapper fills the STRUCT
290       
291        Display smeared_PCF_SC vs smeared_qvals                                                                 
292        ModifyGraph log=1,marker=29,msize=2,mode=4
293        Label bottom "q (A\\S-1\\M)"
294        Label left "Intensity (cm\\S-1\\M)"
295
296        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
297       
298        SetDataFolder root:
299        AddModelToStrings("SmearedPolyCore_SC","smear_coef_PCF_SC","smear_parameters_PCF_SC","PCF_SC")
300End
301
302
303Function PolyCore_SC(w,yw,xw) : FitFunc
304        Wave w,yw,xw
305       
306        Variable inten
307       
308        //setup form factor coefficient wave
309        Make/O/D/N=8 form_PCF_SC
310        form_PCF_SC[0] = 1
311        form_PCF_SC[1] = w[1]
312        form_PCF_SC[2] = w[2]
313        form_PCF_SC[3] = w[3]
314        form_PCF_SC[4] = w[4]
315        form_PCF_SC[5] = w[5]
316        form_PCF_SC[6] = w[6]
317        form_PCF_SC[7] = 0
318       
319        //calculate the diameter of the effective one-component sphere
320        Variable pd,diam,zz,Vpoly,Ravg,thick
321        pd = w[2]
322        zz = (1/pd)^2 - 1
323        Ravg = w[1]
324        thick = w[3]
325       
326        Vpoly = 4*pi/3*(Ravg+thick)^3*(zz+3)*(zz+2)/(zz+1)^2
327        diam = (6*Vpoly/pi)^(1/3)
328       
329        //setup structure factor coefficient wave
330        Make/O/D/N=6 struct_PCF_SC
331        struct_PCF_SC[0] = diam
332        struct_PCF_SC[1] = w[7]
333        struct_PCF_SC[2] = w[0]
334        struct_PCF_SC[3] = w[9]
335        struct_PCF_SC[4] = w[8]
336        struct_PCF_SC[5] = w[10]
337       
338        //calculate each and combine
339        Duplicate/O xw temp_PCF_SC_PQ,temp_PCF_SC_SQ            //make waves for the AAO
340        PolyCoreForm(form_PCF_SC,temp_PCF_SC_PQ,xw)
341        HayterPenfoldMSA(struct_PCF_SC,temp_PCF_SC_SQ,xw)
342        yw = temp_PCF_SC_PQ * temp_PCF_SC_SQ
343        yw *= w[0]
344        yw += w[11]
345       
346        //cleanup waves
347//      Killwaves/Z form_PCF_SC,struct_PCF_SC
348       
349        return (0)
350End
351
352/////////////////////////////////////////
353Proc PlotPolyCore_SHS(num,qmin,qmax)
354        Variable num=256,qmin=0.001,qmax=0.7
355        Prompt num "Enter number of data points for model: "
356        Prompt qmin "Enter minimum q-value (A^-1) for model: "
357        Prompt qmax "Enter maximum q-value (A^-1) for model: "
358       
359        Make/O/D/n=(num) xwave_PCF_SHS,ywave_PCF_SHS
360        xwave_PCF_SHS = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) )
361        Make/O/D coef_PCF_SHS = {0.1,60,.2,10,1e-6,2e-6,3e-6,0.05,0.2,0.0001}
362        make/o/t parameters_PCF_SHS = {"volume fraction","avg core rad (A)","core polydisp (0,1)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","perturbation parameter (0.1)","stickiness, tau","bkg (cm-1)"}
363        Edit/K=1 parameters_PCF_SHS,coef_PCF_SHS
364       
365        Variable/G root:g_PCF_SHS
366        g_PCF_SHS := PolyCore_SHS(coef_PCF_SHS,ywave_PCF_SHS,xwave_PCF_SHS)
367        Display/K=1 ywave_PCF_SHS vs xwave_PCF_SHS
368        ModifyGraph log=1,marker=29,msize=2,mode=4
369        Label bottom "q (A\\S-1\\M)"
370        Label left "Intensity (cm\\S-1\\M)"
371
372        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
373       
374        AddModelToStrings("PolyCore_SHS","coef_PCF_SHS","parameters_PCF_SHS","PCF_SHS")
375End
376
377// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
378Proc PlotSmearedPolyCore_SHS(str)                                                               
379        String str
380        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
381       
382        // if any of the resolution waves are missing => abort
383        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
384                Abort
385        endif
386       
387        SetDataFolder $("root:"+str)
388       
389        // Setup parameter table for model function
390        Make/O/D smear_coef_PCF_SHS = {0.1,60,.2,10,1e-6,2e-6,3e-6,0.05,0.2,0.0001}
391        make/o/t smear_parameters_PCF_SHS = {"volume fraction","avg core rad (A)","core polydisp (0,1)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","perturbation parameter (0.1)","stickiness, tau","bkg (cm-1)"}
392        Edit smear_parameters_PCF_SHS,smear_coef_PCF_SHS                                       
393       
394        // output smeared intensity wave, dimensions are identical to experimental QSIG values
395        // make extra copy of experimental q-values for easy plotting
396        Duplicate/O $(str+"_q") smeared_PCF_SHS,smeared_qvals                           
397        SetScale d,0,0,"1/cm",smeared_PCF_SHS                                                   
398                                       
399        Variable/G gs_PCF_SHS=0
400        gs_PCF_SHS := fSmearedPolyCore_SHS(smear_coef_PCF_SHS,smeared_PCF_SHS,smeared_qvals)    //this wrapper fills the STRUCT
401       
402        Display smeared_PCF_SHS vs smeared_qvals                                                                       
403        ModifyGraph log=1,marker=29,msize=2,mode=4
404        Label bottom "q (A\\S-1\\M)"
405        Label left "Intensity (cm\\S-1\\M)"
406
407        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
408       
409        SetDataFolder root:
410        AddModelToStrings("SmearedPolyCore_SHS","smear_coef_PCF_SHS","smear_parameters_PCF_SHS","PCF_SHS")
411End
412       
413
414Function PolyCore_SHS(w,yw,xw) : FitFunc
415        Wave w,yw,xw
416       
417        Variable inten
418       
419        //setup form factor coefficient wave
420        Make/O/D/N=8 form_PCF_SHS
421        form_PCF_SHS[0] = 1
422        form_PCF_SHS[1] = w[1]
423        form_PCF_SHS[2] = w[2]
424        form_PCF_SHS[3] = w[3]
425        form_PCF_SHS[4] = w[4]
426        form_PCF_SHS[5] = w[5]
427        form_PCF_SHS[6] = w[6]
428        form_PCF_SHS[7] = 0
429       
430        //calculate the diameter of the effective one-component sphere
431        Variable pd,diam,zz,Vpoly,Ravg,thick
432        pd = w[2]
433        zz = (1/pd)^2 - 1
434        Ravg = w[1]
435        thick = w[3]
436       
437        Vpoly = 4*pi/3*(Ravg+thick)^3*(zz+3)*(zz+2)/(zz+1)^2
438        diam = (6*Vpoly/pi)^(1/3)
439       
440        //setup structure factor coefficient wave
441        Make/O/D/N=4 struct_PCF_SHS
442        struct_PCF_SHS[0] = diam/2
443        struct_PCF_SHS[1] = w[0]
444        struct_PCF_SHS[2] = w[7]
445        struct_PCF_SHS[3] = w[8]
446       
447        //calculate each and combine
448        Duplicate/O xw temp_PCF_SHS_PQ,temp_PCF_SHS_SQ          //make waves for the AAO
449        PolyCoreForm(form_PCF_SHS,temp_PCF_SHS_PQ,xw)
450        StickyHS_Struct(struct_PCF_SHS,temp_PCF_SHS_SQ,xw)
451        yw = temp_PCF_SHS_PQ * temp_PCF_SHS_SQ
452        yw *= w[0]
453        yw += w[9]
454       
455        //cleanup waves
456//      Killwaves/Z form_PCF_SW,struct_PCF_SW
457       
458        return (0)
459End
460
461// two yukawa
462Proc PlotPolyCore_2Y(num,qmin,qmax)
463        Variable num=256,qmin=0.001,qmax=0.7
464        Prompt num "Enter number of data points for model: "
465        Prompt qmin "Enter minimum q-value (A^-1) for model: "
466        Prompt qmax "Enter maximum q-value (A^-1) for model: "
467       
468        Make/O/D/n=(num) xwave_PCF_2Y,ywave_PCF_2Y
469        xwave_PCF_2Y = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) )
470        Make/O/D coef_PCF_2Y = {0.1,60,.2,10,1e-6,2e-6,3e-6,6,10,-1,2,0.0001}
471        make/o/t parameters_PCF_2Y = {"volume fraction","avg core rad (A)","core polydisp (0,1)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","scale, K1","charge, Z1","scale, K2","charge, Z2","bkg (cm-1)"}
472        Edit/K=1 parameters_PCF_2Y,coef_PCF_2Y
473        Variable/G root:g_PCF_2Y
474        g_PCF_2Y := PolyCore_2Y(coef_PCF_2Y,ywave_PCF_2Y,xwave_PCF_2Y)
475//      ywave_PCF_2Y := PolyCore_2Y(coef_PCF_2Y,xwave_PCF_2Y)
476        Display/K=1 ywave_PCF_2Y vs xwave_PCF_2Y
477        ModifyGraph log=1,marker=29,msize=2,mode=4
478        Label bottom "q (A\\S-1\\M)"
479        Label left "Intensity (cm\\S-1\\M)"
480
481        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
482       
483        AddModelToStrings("PolyCore_2Y","coef_PCF_2Y","parameters_PCF_2Y","PCF_2Y")
484End
485
486// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
487Proc PlotSmearedPolyCore_2Y(str)                                                               
488        String str
489        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
490       
491        // if any of the resolution waves are missing => abort
492        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
493                Abort
494        endif
495       
496        SetDataFolder $("root:"+str)
497       
498        // Setup parameter table for model function
499        Make/O/D smear_coef_PCF_2Y = {0.1,60,.2,10,1e-6,2e-6,3e-6,6,10,-1,2,0.0001}
500        make/o/t smear_parameters_PCF_2Y = {"volume fraction","avg core rad (A)","core polydisp (0,1)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","scale, K1","charge, Z1","scale, K2","charge, Z2","bkg (cm-1)"}
501        Edit smear_parameters_PCF_2Y,smear_coef_PCF_2Y                                 
502       
503        // output smeared intensity wave, dimensions are identical to experimental QSIG values
504        // make extra copy of experimental q-values for easy plotting
505        Duplicate/O $(str+"_q") smeared_PCF_2Y,smeared_qvals                           
506        SetScale d,0,0,"1/cm",smeared_PCF_2Y                                                   
507                                       
508        Variable/G gs_PCF_2Y=0
509        gs_PCF_2Y := fSmearedPolyCore_2Y(smear_coef_PCF_2Y,smeared_PCF_2Y,smeared_qvals)        //this wrapper fills the STRUCT
510       
511        Display smeared_PCF_2Y vs smeared_qvals                                                                 
512        ModifyGraph log=1,marker=29,msize=2,mode=4
513        Label bottom "q (A\\S-1\\M)"
514        Label left "Intensity (cm\\S-1\\M)"
515
516        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
517       
518        SetDataFolder root:
519        AddModelToStrings("SmearedPolyCore_2Y","smear_coef_PCF_2Y","smear_parameters_PCF_2Y","PCF_2Y")
520End
521       
522
523//AAO function
524Function PolyCore_2Y(w,yw,xw) : FitFunc
525        Wave w,yw,xw
526               
527        //setup form factor coefficient wave
528        Make/O/D/N=8 form_PCF_2Y
529        form_PCF_2Y[0] = 1
530        form_PCF_2Y[1] = w[1]
531        form_PCF_2Y[2] = w[2]
532        form_PCF_2Y[3] = w[3]
533        form_PCF_2Y[4] = w[4]
534        form_PCF_2Y[5] = w[5]
535        form_PCF_2Y[6] = w[6]
536        form_PCF_2Y[7] = 0
537       
538        //calculate the diameter of the effective one-component sphere
539        Variable pd,diam,zz,Vpoly,Ravg,thick
540        pd = w[2]
541        zz = (1/pd)^2 - 1
542        Ravg = w[1]
543        thick = w[3]
544       
545        Vpoly = 4*pi/3*(Ravg+thick)^3*(zz+3)*(zz+2)/(zz+1)^2
546        diam = (6*Vpoly/pi)^(1/3)
547       
548       
549        //setup structure factor coefficient wave
550        Make/O/D/N=6 struct_PCF_2Y
551        struct_PCF_2Y[0] = w[0]
552        struct_PCF_2Y[1] = diam/2
553        struct_PCF_2Y[2] = w[7]
554        struct_PCF_2Y[3] = w[8]
555        struct_PCF_2Y[4] = w[9]
556        struct_PCF_2Y[5] = w[10]
557       
558        //calculate each and combine
559        Duplicate/O xw temp_PCF_2Y_PQ,temp_PCF_2Y_SQ            //make waves for the AAO
560        PolyCoreForm(form_PCF_2Y,temp_PCF_2Y_PQ,xw)
561        TwoYukawa(struct_PCF_2Y,temp_PCF_2Y_SQ,xw)
562        yw = temp_PCF_2Y_PQ*temp_PCF_2Y_SQ
563        yw *= w[0]
564        yw += w[11]
565       
566        //cleanup waves
567//      Killwaves/Z form_PCF_2Y,struct_PCF_2Y
568       
569        return (0)
570End
571
572// this is all there is to the smeared calculation!
573Function SmearedPolyCore_HS(s) :FitFunc
574        Struct ResSmearAAOStruct &s
575
576//      the name of your unsmeared model is the first argument
577        Smear_Model_20(PolyCore_HS,s.coefW,s.xW,s.yW,s.resW)
578
579        return(0)
580End
581
582// this is all there is to the smeared calculation!
583Function SmearedPolyCore_SW(s) :FitFunc
584        Struct ResSmearAAOStruct &s
585
586//      the name of your unsmeared model is the first argument
587        Smear_Model_20(PolyCore_SW,s.coefW,s.xW,s.yW,s.resW)
588
589        return(0)
590End
591
592// this is all there is to the smeared calculation!
593Function SmearedPolyCore_SC(s) :FitFunc
594        Struct ResSmearAAOStruct &s
595
596//      the name of your unsmeared model is the first argument
597        Smear_Model_20(PolyCore_SC,s.coefW,s.xW,s.yW,s.resW)
598
599        return(0)
600End
601
602// this is all there is to the smeared calculation!
603Function SmearedPolyCore_SHS(s) :FitFunc
604        Struct ResSmearAAOStruct &s
605
606//      the name of your unsmeared model is the first argument
607        Smear_Model_20(PolyCore_SHS,s.coefW,s.xW,s.yW,s.resW)
608
609        return(0)
610End
611
612// this is all there is to the smeared calculation!
613Function SmearedPolyCore_2Y(s) :FitFunc
614        Struct ResSmearAAOStruct &s
615
616//      the name of your unsmeared model is the first argument
617        Smear_Model_20(PolyCore_2Y,s.coefW,s.xW,s.yW,s.resW)
618
619        return(0)
620End
621
622//wrapper to calculate the smeared model as an AAO-Struct
623// fills the struct and calls the ususal function with the STRUCT parameter
624//
625// used only for the dependency, not for fitting
626//
627Function fSmearedPolyCore_HS(coefW,yW,xW)
628        Wave coefW,yW,xW
629       
630        String str = getWavesDataFolder(yW,0)
631        String DF="root:"+str+":"
632       
633        WAVE resW = $(DF+str+"_res")
634       
635        STRUCT ResSmearAAOStruct fs
636        WAVE fs.coefW = coefW   
637        WAVE fs.yW = yW
638        WAVE fs.xW = xW
639        WAVE fs.resW = resW
640       
641        Variable err
642        err = SmearedPolyCore_HS(fs)
643       
644        return (0)
645End
646
647//wrapper to calculate the smeared model as an AAO-Struct
648// fills the struct and calls the ususal function with the STRUCT parameter
649//
650// used only for the dependency, not for fitting
651//
652Function fSmearedPolyCore_SW(coefW,yW,xW)
653        Wave coefW,yW,xW
654       
655        String str = getWavesDataFolder(yW,0)
656        String DF="root:"+str+":"
657       
658        WAVE resW = $(DF+str+"_res")
659       
660        STRUCT ResSmearAAOStruct fs
661        WAVE fs.coefW = coefW   
662        WAVE fs.yW = yW
663        WAVE fs.xW = xW
664        WAVE fs.resW = resW
665       
666        Variable err
667        err = SmearedPolyCore_SW(fs)
668       
669        return (0)
670End
671
672//wrapper to calculate the smeared model as an AAO-Struct
673// fills the struct and calls the ususal function with the STRUCT parameter
674//
675// used only for the dependency, not for fitting
676//
677Function fSmearedPolyCore_SC(coefW,yW,xW)
678        Wave coefW,yW,xW
679       
680        String str = getWavesDataFolder(yW,0)
681        String DF="root:"+str+":"
682       
683        WAVE resW = $(DF+str+"_res")
684       
685        STRUCT ResSmearAAOStruct fs
686        WAVE fs.coefW = coefW   
687        WAVE fs.yW = yW
688        WAVE fs.xW = xW
689        WAVE fs.resW = resW
690       
691        Variable err
692        err = SmearedPolyCore_SC(fs)
693       
694        return (0)
695End
696
697//wrapper to calculate the smeared model as an AAO-Struct
698// fills the struct and calls the ususal function with the STRUCT parameter
699//
700// used only for the dependency, not for fitting
701//
702Function fSmearedPolyCore_SHS(coefW,yW,xW)
703        Wave coefW,yW,xW
704       
705        String str = getWavesDataFolder(yW,0)
706        String DF="root:"+str+":"
707       
708        WAVE resW = $(DF+str+"_res")
709       
710        STRUCT ResSmearAAOStruct fs
711        WAVE fs.coefW = coefW   
712        WAVE fs.yW = yW
713        WAVE fs.xW = xW
714        WAVE fs.resW = resW
715       
716        Variable err
717        err = SmearedPolyCore_SHS(fs)
718       
719        return (0)
720End
721
722//wrapper to calculate the smeared model as an AAO-Struct
723// fills the struct and calls the ususal function with the STRUCT parameter
724//
725// used only for the dependency, not for fitting
726//
727Function fSmearedPolyCore_2Y(coefW,yW,xW)
728        Wave coefW,yW,xW
729       
730        String str = getWavesDataFolder(yW,0)
731        String DF="root:"+str+":"
732       
733        WAVE resW = $(DF+str+"_res")
734       
735        STRUCT ResSmearAAOStruct fs
736        WAVE fs.coefW = coefW   
737        WAVE fs.yW = yW
738        WAVE fs.xW = xW
739        WAVE fs.resW = resW
740       
741        Variable err
742        err = SmearedPolyCore_2Y(fs)
743       
744        return (0)
745End
Note: See TracBrowser for help on using the repository browser.