source: sans/Dev/trunk/NCNR_User_Procedures/Analysis/Models/PolyCoreShellRatio_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.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
6#include "PolyCoreShellRatio_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 PlotPolyCSRatio_HS(num,qmin,qmax)
15        Variable num=256,qmin=0.001,qmax=0.7
16        Prompt num "Enter number of data points for model: "
17        Prompt qmin "Enter minimum q-value (A^-1) for model: "
18        Prompt qmax "Enter maximum q-value (A^-1) for model: "
19       
20        Make/O/D/n=(num) xwave_PCR_HS,ywave_PCR_HS
21        xwave_PCR_HS =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
22        Make/O/D coef_PCR_HS = {0.1,60,10,0.1,1e-6,2e-6,6e-6,0.0001}
23        make/o/t parameters_PCR_HS = {"volume fraction","avg radius (A)","avg shell thickness (A)","overall polydispersity","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","bkg (cm-1)"}
24        Edit/K=1 parameters_PCR_HS,coef_PCR_HS
25       
26        Variable/G root:g_PCR_HS
27        g_PCR_HS := PolyCSRatio_HS(coef_PCR_HS,ywave_PCR_HS,xwave_PCR_HS)
28        Display/K=1 ywave_PCR_HS vs xwave_PCR_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("PolyCSRatio_HS","coef_PCR_HS","parameters_PCR_HS","PCR_HS")
36End
37
38// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
39Proc PlotSmearedPolyCSRatio_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_PCR_HS = {0.1,60,10,0.1,1e-6,2e-6,6e-6,0.0001}
52        make/o/t smear_parameters_PCR_HS = {"volume fraction","avg radius (A)","avg shell thickness (A)","overall polydispersity","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","bkg (cm-1)"}
53        Edit smear_parameters_PCR_HS,smear_coef_PCR_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_PCR_HS,smeared_qvals                           
58        SetScale d,0,0,"1/cm",smeared_PCR_HS                                                   
59                                       
60        Variable/G gs_PCR_HS=0
61        gs_PCR_HS := fSmearedPolyCSRatio_HS(smear_coef_PCR_HS,smeared_PCR_HS,smeared_qvals)     //this wrapper fills the STRUCT
62       
63        Display smeared_PCR_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("SmearedPolyCSRatio_HS","smear_coef_PCR_HS","smear_parameters_PCR_HS","PCR_HS")
72End
73       
74
75Function PolyCSRatio_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=8 form_PCR_HS
82        form_PCR_HS[0] = 1
83        form_PCR_HS[1] = w[1]
84        form_PCR_HS[2] = w[2]
85        form_PCR_HS[3] = w[3]
86        form_PCR_HS[4] = w[4]
87        form_PCR_HS[5] = w[5]
88        form_PCR_HS[6] = w[6]
89        form_PCR_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[3]
94        zz = (1/pd)^2 - 1
95        Ravg = w[1]
96        thick = w[2]
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        //setup structure factor coefficient wave
102        Make/O/D/N=2 struct_PCR_HS
103        struct_PCR_HS[0] = diam/2
104        struct_PCR_HS[1] = w[0]
105       
106        //calculate each and combine
107        Duplicate/O xw temp_PCR_HS_PQ,temp_PCR_HS_SQ            //make waves for the AAO
108        PolyCoreShellRatio(form_PCR_HS,temp_PCR_HS_PQ,xw)
109        HardSphereStruct(struct_PCR_HS,temp_PCR_HS_SQ,xw)
110        yw = temp_PCR_HS_PQ * temp_PCR_HS_SQ
111        yw *= w[0]
112        yw += w[7]
113       
114        //cleanup waves
115//      Killwaves/Z form_PCR_HS,struct_PCR_HS
116       
117        return (0)
118End
119
120/////////////////////////////////////////
121Proc PlotPolyCSRatio_SW(num,qmin,qmax)
122        Variable num=256,qmin=0.001,qmax=0.7
123        Prompt num "Enter number of data points for model: "
124        Prompt qmin "Enter minimum q-value (A^-1) for model: "
125        Prompt qmax "Enter maximum q-value (A^-1) for model: "
126       
127        Make/O/D/n=(num) xwave_PCR_SW,ywave_PCR_SW
128        xwave_PCR_SW =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
129        Make/O/D coef_PCR_SW = {0.1,60,10,0.1,1e-6,2e-6,3e-6,1,1.2,0.0001}
130        make/o/t parameters_PCR_SW = {"volume fraction","avg radius(A)","avg shell thickness (A)","overall polydispersity","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","well depth (kT)","well width (diam.)","bkg (cm-1)"}
131        Edit/K=1 parameters_PCR_SW,coef_PCR_SW
132       
133        Variable/G root:g_PCR_SW
134        g_PCR_SW := PolyCSRatio_SW(coef_PCR_SW,ywave_PCR_SW,xwave_PCR_SW)
135        Display/K=1 ywave_PCR_SW vs xwave_PCR_SW
136        ModifyGraph log=1,marker=29,msize=2,mode=4
137        Label bottom "q (A\\S-1\\M)"
138        Label left "Intensity (cm\\S-1\\M)"
139
140        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
141       
142        AddModelToStrings("PolyCSRatio_SW","coef_PCR_SW","parameters_PCR_SW","PCR_SW")
143End
144
145// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
146Proc PlotSmearedPolyCSRatio_SW(str)                                                             
147        String str
148        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
149       
150        // if any of the resolution waves are missing => abort
151        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
152                Abort
153        endif
154       
155        SetDataFolder $("root:"+str)
156       
157        // Setup parameter table for model function
158        Make/O/D smear_coef_PCR_SW = {0.1,60,10,0.1,1e-6,2e-6,3e-6,1,1.2,0.0001}
159        make/o/t smear_parameters_PCR_SW = {"volume fraction","avg radius(A)","avg shell thickness (A)","overall polydispersity","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","well depth (kT)","well width (diam.)","bkg (cm-1)"}
160        Edit smear_parameters_PCR_SW,smear_coef_PCR_SW                                 
161       
162        // output smeared intensity wave, dimensions are identical to experimental QSIG values
163        // make extra copy of experimental q-values for easy plotting
164        Duplicate/O $(str+"_q") smeared_PCR_SW,smeared_qvals                           
165        SetScale d,0,0,"1/cm",smeared_PCR_SW                                                   
166                                       
167        Variable/G gs_PCR_SW=0
168        gs_PCR_SW := fSmearedPolyCSRatio_SW(smear_coef_PCR_SW,smeared_PCR_SW,smeared_qvals)     //this wrapper fills the STRUCT
169       
170        Display smeared_PCR_SW vs smeared_qvals                                                                 
171        ModifyGraph log=1,marker=29,msize=2,mode=4
172        Label bottom "q (A\\S-1\\M)"
173        Label left "Intensity (cm\\S-1\\M)"
174
175        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
176       
177        SetDataFolder root:
178        AddModelToStrings("SmearedPolyCSRatio_SW","smear_coef_PCR_SW","smear_parameters_PCR_SW","PCR_SW")
179End
180       
181
182Function PolyCSRatio_SW(w,yw,xw) : FitFunc
183        Wave w,yw,xw
184       
185        Variable inten
186       
187        //setup form factor coefficient wave
188        Make/O/D/N=8 form_PCR_SW
189        form_PCR_SW[0] = 1
190        form_PCR_SW[1] = w[1]
191        form_PCR_SW[2] = w[2]
192        form_PCR_SW[3] = w[3]
193        form_PCR_SW[4] = w[4]
194        form_PCR_SW[5] = w[5]
195        form_PCR_SW[6] = w[6]
196        form_PCR_SW[7] = 0
197       
198        //calculate the diameter of the effective one-component sphere
199        Variable pd,diam,zz,Vpoly,Ravg,thick
200        pd = w[3]
201        zz = (1/pd)^2 - 1
202        Ravg = w[1]
203        thick = w[2]
204       
205        Vpoly = 4*pi/3*(Ravg+thick)^3*(zz+3)*(zz+2)/(zz+1)^2
206        diam = (6*Vpoly/pi)^(1/3)
207       
208        //setup structure factor coefficient wave
209        Make/O/D/N=4 struct_PCR_SW
210        struct_PCR_SW[0] = diam/2
211        struct_PCR_SW[1] = w[0]
212        struct_PCR_SW[2] = w[7]
213        struct_PCR_SW[3] = w[8]
214       
215        //calculate each and combine
216        Duplicate/O xw temp_PCR_SW_PQ,temp_PCR_SW_SQ            //make waves for the AAO
217        PolyCoreShellRatio(form_PCR_SW,temp_PCR_SW_PQ,xw)
218        SquareWellStruct(struct_PCR_SW,temp_PCR_SW_SQ,xw)
219        yw = temp_PCR_SW_PQ * temp_PCR_SW_SQ
220        yw *= w[0]
221        yw += w[9]
222       
223        //cleanup waves
224//      Killwaves/Z form_PCR_SW,struct_PCR_SW
225       
226        return (0)
227End
228
229
230/////////////////////////////////////////
231Proc PlotPolyCSRatio_SC(num,qmin,qmax)
232        Variable num=256,qmin=0.001,qmax=0.7
233        Prompt num "Enter number of data points for model: "
234        Prompt qmin "Enter minimum q-value (A^-1) for model: "
235        Prompt qmax "Enter maximum q-value (A^-1) for model: "
236       
237        if(!DataFolderExists(":HayPenMSA"))
238                NewDataFolder :HayPenMSA
239        endif
240        Make/O/D/N=17 :HayPenMSA:gMSAWave
241       
242        Make/O/D/n=(num) xwave_PCR_SC,ywave_PCR_SC
243        xwave_PCR_SC =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
244        Make/O/D coef_PCR_SC = {0.1,60,10,0.1,1e-6,2e-6,6e-6,10,0,298,78,0.0001}
245        make/o/t parameters_PCR_SC = {"volume fraction","avg radius(A)","avg shell thickness (A)","overall polydispersity","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","charge","Monovalent salt (M)","Temperature (K)","dielectric const.","bkg (cm-1)"}
246        Edit/K=1 parameters_PCR_SC,coef_PCR_SC
247       
248        Variable/G root:g_PCR_SC
249        g_PCR_SC := PolyCSRatio_SC(coef_PCR_SC,ywave_PCR_SC,xwave_PCR_SC)
250        Display/K=1 ywave_PCR_SC vs xwave_PCR_SC
251        ModifyGraph log=1,marker=29,msize=2,mode=4
252        Label bottom "q (A\\S-1\\M)"
253        Label left "Intensity (cm\\S-1\\M)"
254
255        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
256       
257        AddModelToStrings("PolyCSRatio_SC","coef_PCR_SC","parameters_PCR_SC","PCR_SC")
258End
259
260// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
261Proc PlotSmearedPolyCSRatio_SC(str)                                                             
262        String str
263        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
264       
265        // if any of the resolution waves are missing => abort
266        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
267                Abort
268        endif
269       
270        SetDataFolder $("root:"+str)
271       
272        if(!DataFolderExists(":HayPenMSA"))
273                NewDataFolder :HayPenMSA
274        endif
275        Make/O/D/N=17 :HayPenMSA:gMSAWave
276       
277        // Setup parameter table for model function
278        Make/O/D smear_coef_PCR_SC = {0.1,60,10,0.1,1e-6,2e-6,6e-6,10,0,298,78,0.0001}
279        make/o/t smear_parameters_PCR_SC = {"volume fraction","avg radius(A)","avg shell thickness (A)","overall polydispersity","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","charge","Monovalent salt (M)","Temperature (K)","dielectric const.","bkg (cm-1)"}
280        Edit smear_parameters_PCR_SC,smear_coef_PCR_SC                                 
281       
282        // output smeared intensity wave, dimensions are identical to experimental QSIG values
283        // make extra copy of experimental q-values for easy plotting
284        Duplicate/O $(str+"_q") smeared_PCR_SC,smeared_qvals                           
285        SetScale d,0,0,"1/cm",smeared_PCR_SC                                                   
286                                       
287        Variable/G gs_PCR_SC=0
288        gs_PCR_SC := fSmearedPolyCSRatio_SC(smear_coef_PCR_SC,smeared_PCR_SC,smeared_qvals)     //this wrapper fills the STRUCT
289       
290        Display smeared_PCR_SC vs smeared_qvals                                                                 
291        ModifyGraph log=1,marker=29,msize=2,mode=4
292        Label bottom "q (A\\S-1\\M)"
293        Label left "Intensity (cm\\S-1\\M)"
294
295        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
296       
297        SetDataFolder root:
298        AddModelToStrings("SmearedPolyCSRatio_SC","smear_coef_PCR_SC","smear_parameters_PCR_SC","PCR_SC")
299End
300
301
302Function PolyCSRatio_SC(w,yw,xw) : FitFunc
303        Wave w,yw,xw
304       
305        Variable inten
306       
307        //setup form factor coefficient wave
308        Make/O/D/N=8 form_PCR_SC
309        form_PCR_SC[0] = 1
310        form_PCR_SC[1] = w[1]
311        form_PCR_SC[2] = w[2]
312        form_PCR_SC[3] = w[3]
313        form_PCR_SC[4] = w[4]
314        form_PCR_SC[5] = w[5]
315        form_PCR_SC[6] = w[6]
316        form_PCR_SC[7] = 0
317       
318        //calculate the diameter of the effective one-component sphere
319        Variable pd,diam,zz,Vpoly,Ravg,thick
320        pd = w[3]
321        zz = (1/pd)^2 - 1
322        Ravg = w[1]
323        thick = w[2]
324       
325        Vpoly = 4*pi/3*(Ravg+thick)^3*(zz+3)*(zz+2)/(zz+1)^2
326        diam = (6*Vpoly/pi)^(1/3)
327       
328        //setup structure factor coefficient wave
329        Make/O/D/N=6 struct_PCR_SC
330        struct_PCR_SC[0] = diam
331        struct_PCR_SC[1] = w[7]
332        struct_PCR_SC[2] = w[0]
333        struct_PCR_SC[3] = w[9]
334        struct_PCR_SC[4] = w[8]
335        struct_PCR_SC[5] = w[10]
336       
337        //calculate each and combine
338        Duplicate/O xw temp_PCR_SC_PQ,temp_PCR_SC_SQ            //make waves for the AAO
339        PolyCoreShellRatio(form_PCR_SC,temp_PCR_SC_PQ,xw)
340        HayterPenfoldMSA(struct_PCR_SC,temp_PCR_SC_SQ,xw)
341        yw = temp_PCR_SC_PQ * temp_PCR_SC_SQ
342        yw *= w[0]
343        yw += w[11]
344       
345        //cleanup waves
346//      Killwaves/Z form_PCR_SC,struct_PCR_SC
347       
348        return (0)
349End
350
351/////////////////////////////////////////
352Proc PlotPolyCSRatio_SHS(num,qmin,qmax)
353        Variable num=256,qmin=0.001,qmax=0.7
354        Prompt num "Enter number of data points for model: "
355        Prompt qmin "Enter minimum q-value (A^-1) for model: "
356        Prompt qmax "Enter maximum q-value (A^-1) for model: "
357       
358        Make/O/D/n=(num) xwave_PCR_SHS,ywave_PCR_SHS
359        xwave_PCR_SHS =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
360        Make/O/D coef_PCR_SHS = {0.1,60,10,0.1,1e-6,2e-6,3e-6,0.05,0.2,0.0001}
361        make/o/t parameters_PCR_SHS = {"volume fraction","avg radius(A)","avg shell thickness (A)","overall polydispersity","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","perturbation parameter (0.1)","stickiness, tau","bkg (cm-1)"}
362        Edit/K=1 parameters_PCR_SHS,coef_PCR_SHS
363       
364        Variable/G root:g_PCR_SHS
365        g_PCR_SHS := PolyCSRatio_SHS(coef_PCR_SHS,ywave_PCR_SHS,xwave_PCR_SHS)
366        Display/K=1 ywave_PCR_SHS vs xwave_PCR_SHS
367        ModifyGraph log=1,marker=29,msize=2,mode=4
368        Label bottom "q (A\\S-1\\M)"
369        Label left "Intensity (cm\\S-1\\M)"
370
371        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
372       
373        AddModelToStrings("PolyCSRatio_SHS","coef_PCR_SHS","parameters_PCR_SHS","PCR_SHS")
374End
375
376// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
377Proc PlotSmearedPolyCSRatio_SHS(str)                                                           
378        String str
379        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
380       
381        // if any of the resolution waves are missing => abort
382        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
383                Abort
384        endif
385       
386        SetDataFolder $("root:"+str)
387       
388        // Setup parameter table for model function
389        Make/O/D smear_coef_PCR_SHS = {0.1,60,10,0.1,1e-6,2e-6,3e-6,0.05,0.2,0.0001}
390        make/o/t smear_parameters_PCR_SHS = {"volume fraction","avg radius(A)","avg shell thickness (A)","overall polydispersity","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","perturbation parameter (0.1)","stickiness, tau","bkg (cm-1)"}
391        Edit smear_parameters_PCR_SHS,smear_coef_PCR_SHS                                       
392       
393        // output smeared intensity wave, dimensions are identical to experimental QSIG values
394        // make extra copy of experimental q-values for easy plotting
395        Duplicate/O $(str+"_q") smeared_PCR_SHS,smeared_qvals                           
396        SetScale d,0,0,"1/cm",smeared_PCR_SHS                                                   
397                                       
398        Variable/G gs_PCR_SHS=0
399        gs_PCR_SHS := fSmearedPolyCSRatio_SHS(smear_coef_PCR_SHS,smeared_PCR_SHS,smeared_qvals) //this wrapper fills the STRUCT
400       
401        Display smeared_PCR_SHS vs smeared_qvals                                                                       
402        ModifyGraph log=1,marker=29,msize=2,mode=4
403        Label bottom "q (A\\S-1\\M)"
404        Label left "Intensity (cm\\S-1\\M)"
405
406        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
407       
408        SetDataFolder root:
409        AddModelToStrings("SmearedPolyCSRatio_SHS","smear_coef_PCR_SHS","smear_parameters_PCR_SHS","PCR_SHS")
410End
411
412
413Function PolyCSRatio_SHS(w,yw,xw) : FitFunc
414        Wave w,yw,xw
415       
416        Variable inten
417       
418        //setup form factor coefficient wave
419        Make/O/D/N=8 form_PCR_SHS
420        form_PCR_SHS[0] = 1
421        form_PCR_SHS[1] = w[1]
422        form_PCR_SHS[2] = w[2]
423        form_PCR_SHS[3] = w[3]
424        form_PCR_SHS[4] = w[4]
425        form_PCR_SHS[5] = w[5]
426        form_PCR_SHS[6] = w[6]
427        form_PCR_SHS[7] = 0
428       
429        //calculate the diameter of the effective one-component sphere
430        Variable pd,diam,zz,Vpoly,Ravg,thick
431        pd = w[3]
432        zz = (1/pd)^2 - 1
433        Ravg = w[1]
434        thick = w[2]
435       
436        Vpoly = 4*pi/3*(Ravg+thick)^3*(zz+3)*(zz+2)/(zz+1)^2
437        diam = (6*Vpoly/pi)^(1/3)
438       
439        //setup structure factor coefficient wave
440        Make/O/D/N=4 struct_PCR_SHS
441        struct_PCR_SHS[0] = diam/2
442        struct_PCR_SHS[1] = w[0]
443        struct_PCR_SHS[2] = w[7]
444        struct_PCR_SHS[3] = w[8]
445       
446        //calculate each and combine
447        Duplicate/O xw temp_PCR_SHS_PQ,temp_PCR_SHS_SQ          //make waves for the AAO
448        PolyCoreShellRatio(form_PCR_SHS,temp_PCR_SHS_PQ,xw)
449        StickyHS_Struct(struct_PCR_SHS,temp_PCR_SHS_SQ,xw)
450        yw = temp_PCR_SHS_PQ * temp_PCR_SHS_SQ
451        yw *= w[0]
452        yw += w[9]
453       
454        //cleanup waves
455//      Killwaves/Z form_PCR_SHS,struct_PCR_SHS
456       
457        return (0)
458End
459
460// two yukawa
461Proc PlotPolyCSRatio_2Y(num,qmin,qmax)
462        Variable num=256,qmin=0.001,qmax=0.7
463        Prompt num "Enter number of data points for model: "
464        Prompt qmin "Enter minimum q-value (A^-1) for model: "
465        Prompt qmax "Enter maximum q-value (A^-1) for model: "
466       
467        Make/O/D/n=(num) xwave_PCR_2Y,ywave_PCR_2Y
468        xwave_PCR_2Y =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
469        Make/O/D coef_PCR_2Y = {0.1,60,10,0.1,1e-6,2e-6,6e-6,6,10,-1,2,0.0001}
470        make/o/t parameters_PCR_2Y = {"volume fraction","avg radius (A)","avg shell thickness (A)","overall polydispersity","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","scale, K1","charge, Z1","scale, K2","charge, Z2","bkg (cm-1)"}
471        Edit/K=1 parameters_PCR_2Y,coef_PCR_2Y
472       
473        Variable/G root:g_PCR_2Y
474        g_PCR_2Y := PolyCSRatio_2Y(coef_PCR_2Y,ywave_PCR_2Y,xwave_PCR_2Y)
475        Display/K=1 ywave_PCR_2Y vs xwave_PCR_2Y
476        ModifyGraph log=1,marker=29,msize=2,mode=4
477        Label bottom "q (A\\S-1\\M)"
478        Label left "Intensity (cm\\S-1\\M)"
479
480        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
481       
482        AddModelToStrings("PolyCSRatio_2Y","coef_PCR_2Y","parameters_PCR_2Y","PCR_2Y")
483End
484
485// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
486Proc PlotSmearedPolyCSRatio_2Y(str)                                                             
487        String str
488        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
489       
490        // if any of the resolution waves are missing => abort
491        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
492                Abort
493        endif
494       
495        SetDataFolder $("root:"+str)
496       
497        // Setup parameter table for model function
498        Make/O/D smear_coef_PCR_2Y = {0.1,60,10,0.1,1e-6,2e-6,6e-6,6,10,-1,2,0.0001}
499        make/o/t smear_parameters_PCR_2Y = {"volume fraction","avg radius (A)","avg shell thickness (A)","overall polydispersity","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","scale, K1","charge, Z1","scale, K2","charge, Z2","bkg (cm-1)"}
500        Edit smear_parameters_PCR_2Y,smear_coef_PCR_2Y                                 
501       
502        // output smeared intensity wave, dimensions are identical to experimental QSIG values
503        // make extra copy of experimental q-values for easy plotting
504        Duplicate/O $(str+"_q") smeared_PCR_2Y,smeared_qvals                           
505        SetScale d,0,0,"1/cm",smeared_PCR_2Y                                                   
506                                       
507        Variable/G gs_PCR_2Y=0
508        gs_PCR_2Y := fSmearedPolyCSRatio_2Y(smear_coef_PCR_2Y,smeared_PCR_2Y,smeared_qvals)     //this wrapper fills the STRUCT
509       
510        Display smeared_PCR_2Y vs smeared_qvals                                                                 
511        ModifyGraph log=1,marker=29,msize=2,mode=4
512        Label bottom "q (A\\S-1\\M)"
513        Label left "Intensity (cm\\S-1\\M)"
514
515        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
516       
517        SetDataFolder root:
518        AddModelToStrings("SmearedPolyCSRatio_2Y","smear_coef_PCR_2Y","smear_parameters_PCR_2Y","PCR_2Y")
519End
520       
521
522Function PolyCSRatio_2Y(w,yw,xw) : FitFunc
523        Wave w,yw,xw
524       
525        Variable inten
526       
527        //setup form factor coefficient wave
528        Make/O/D/N=8 form_PCR_2Y
529        form_PCR_2Y[0] = 1
530        form_PCR_2Y[1] = w[1]
531        form_PCR_2Y[2] = w[2]
532        form_PCR_2Y[3] = w[3]
533        form_PCR_2Y[4] = w[4]
534        form_PCR_2Y[5] = w[5]
535        form_PCR_2Y[6] = w[6]
536        form_PCR_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[3]
541        zz = (1/pd)^2 - 1
542        Ravg = w[1]
543        thick = w[2]
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        //setup structure factor coefficient wave
549        Make/O/D/N=6 struct_PCR_2Y
550        struct_PCR_2Y[0] = w[0]
551        struct_PCR_2Y[1] = diam/2
552        struct_PCR_2Y[2] = w[7]
553        struct_PCR_2Y[3] = w[8]
554        struct_PCR_2Y[4] = w[9]
555        struct_PCR_2Y[5] = w[10]
556       
557        //calculate each and combine
558        Duplicate/O xw temp_PCR_2Y_PQ,temp_PCR_2Y_SQ            //make waves for the AAO
559        PolyCoreShellRatio(form_PCR_2Y,temp_PCR_2Y_PQ,xw)
560        TwoYukawa(struct_PCR_2Y,temp_PCR_2Y_SQ,xw)
561        yw = temp_PCR_2Y_PQ * temp_PCR_2Y_SQ
562        yw *= w[0]
563        yw += w[11]
564       
565        //cleanup waves
566//      Killwaves/Z form_PCR_2Y,struct_PCR_2Y
567       
568        return (0)
569End
570
571
572// this is all there is to the smeared calculation!
573Function SmearedPolyCSRatio_HS(s) :FitFunc
574        Struct ResSmearAAOStruct &s
575
576//      the name of your unsmeared model is the first argument
577        Smear_Model_20(PolyCSRatio_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 SmearedPolyCSRatio_SW(s) :FitFunc
584        Struct ResSmearAAOStruct &s
585
586//      the name of your unsmeared model is the first argument
587        Smear_Model_20(PolyCSRatio_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 SmearedPolyCSRatio_SC(s) :FitFunc
594        Struct ResSmearAAOStruct &s
595
596//      the name of your unsmeared model is the first argument
597        Smear_Model_20(PolyCSRatio_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 SmearedPolyCSRatio_SHS(s) :FitFunc
604        Struct ResSmearAAOStruct &s
605
606//      the name of your unsmeared model is the first argument
607        Smear_Model_20(PolyCSRatio_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 SmearedPolyCSRatio_2Y(s) :FitFunc
614        Struct ResSmearAAOStruct &s
615
616//      the name of your unsmeared model is the first argument
617        Smear_Model_20(PolyCSRatio_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 fSmearedPolyCSRatio_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 = SmearedPolyCSRatio_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 fSmearedPolyCSRatio_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 = SmearedPolyCSRatio_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 fSmearedPolyCSRatio_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 = SmearedPolyCSRatio_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 fSmearedPolyCSRatio_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 = SmearedPolyCSRatio_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 fSmearedPolyCSRatio_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 = SmearedPolyCSRatio_2Y(fs)
743       
744        return (0)
745End
Note: See TracBrowser for help on using the repository browser.