source: sans/Analysis/trunk/Put in User Procedures/SANS_Models_v3.00/PolyCSRatio_and_Struct.ipf @ 56

Last change on this file since 56 was 42, checked in by srkline, 16 years ago

initial checkin of Analysis v.3.00 files

File size: 14.5 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2
3// be sure to include all the necessary files...
4
5#include "PolyCoreShellRatio"
6
7#include "HardSphereStruct"
8#include "HPMSA"
9#include "SquareWellStruct"
10#include "StickyHardSphereStruct"
11
12Proc PlotPolyCSRatio_HS(num,qmin,qmax)
13        Variable num=256,qmin=0.001,qmax=0.7
14        Prompt num "Enter number of data points for model: "
15        Prompt qmin "Enter minimum q-value (^-1) for model: "
16        Prompt qmax "Enter maximum q-value (^-1) for model: "
17       
18        Make/O/D/n=(num) xwave_PCR_HS,ywave_PCR_HS
19        xwave_PCR_HS =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
20        Make/O/D coef_PCR_HS = {0.1,60,10,0.1,1e-6,2e-6,6e-6,0.0001}
21        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)"}
22        Edit/K=1 parameters_PCR_HS,coef_PCR_HS
23        ywave_PCR_HS := PolyCSRatio_HS(coef_PCR_HS,xwave_PCR_HS)
24        Display/K=1 ywave_PCR_HS vs xwave_PCR_HS
25        ModifyGraph log=1,marker=29,msize=2,mode=4
26        Label bottom "q (\\S-1\\M)"
27        Label left "Intensity (cm\\S-1\\M)"
28
29        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
30End
31
32Proc PlotSmearedPolyCSRatio_HS()                                                               
33        //no input parameters necessary, it MUST use the experimental q-values
34        // from the experimental data read in from an AVE/QSIG data file
35       
36        // if no gQvals wave, data must not have been loaded => abort
37        if(ResolutionWavesMissing())
38                Abort
39        endif
40       
41        // Setup parameter table for model function
42        Make/O/D smear_coef_PCR_HS = {0.1,60,10,0.1,1e-6,2e-6,6e-6,0.0001}
43        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)"}
44        Edit smear_parameters_PCR_HS,smear_coef_PCR_HS                                 
45       
46        // output smeared intensity wave, dimensions are identical to experimental QSIG values
47        // make extra copy of experimental q-values for easy plotting
48        Duplicate/O $gQvals smeared_PCR_HS,smeared_qvals                               
49        SetScale d,0,0,"1/cm",smeared_PCR_HS                                                   
50
51        smeared_PCR_HS := SmearedPolyCSRatio_HS(smear_coef_PCR_HS,$gQvals)             
52        Display smeared_PCR_HS vs smeared_qvals                                                                 
53        ModifyGraph log=1,marker=29,msize=2,mode=4
54        Label bottom "q (\\S-1\\M)"
55        Label left "Intensity (cm\\S-1\\M)"
56
57        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
58End
59
60Function PolyCSRatio_HS(w,x) : FitFunc
61        Wave w
62        Variable x
63       
64        Variable inten
65       
66        //setup form factor coefficient wave
67        Make/O/D/N=8 form_PCR_HS
68        form_PCR_HS[0] = 1
69        form_PCR_HS[1] = w[1]
70        form_PCR_HS[2] = w[2]
71        form_PCR_HS[3] = w[3]
72        form_PCR_HS[4] = w[4]
73        form_PCR_HS[5] = w[5]
74        form_PCR_HS[6] = w[6]
75        form_PCR_HS[7] = 0
76       
77        //calculate the diameter of the effective one-component sphere
78        Variable pd,diam,zz,Vpoly,Ravg,thick
79        pd = w[3]
80        zz = (1/pd)^2 - 1
81        Ravg = w[1]
82        thick = w[2]
83       
84        Vpoly = 4*pi/3*(Ravg+thick)^3*(zz+3)*(zz+2)/(zz+1)^2
85        diam = (6*Vpoly/pi)^(1/3)
86       
87        //setup structure factor coefficient wave
88        Make/O/D/N=2 struct_PCR_HS
89        struct_PCR_HS[0] = diam/2
90        struct_PCR_HS[1] = w[0]
91       
92        //calculate each and combine
93        inten = PolyCoreShellRatio(form_PCR_HS,x)
94        inten *= HardSphereStruct(struct_PCR_HS,x)
95        inten *= w[0]
96        inten += w[7]
97       
98        //cleanup waves
99//      Killwaves/Z form_PCR_HS,struct_PCR_HS
100       
101        return (inten)
102End
103
104/////////////////////////////////////////
105Proc PlotPolyCSRatio_SW(num,qmin,qmax)
106        Variable num=256,qmin=0.001,qmax=0.7
107        Prompt num "Enter number of data points for model: "
108        Prompt qmin "Enter minimum q-value (^-1) for model: "
109        Prompt qmax "Enter maximum q-value (^-1) for model: "
110       
111        Make/O/D/n=(num) xwave_PCR_SW,ywave_PCR_SW
112        xwave_PCR_SW =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
113        Make/O/D coef_PCR_SW = {0.1,60,10,0.1,1e-6,2e-6,3e-6,1,1.2,0.0001}
114        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)"}
115        Edit/K=1 parameters_PCR_SW,coef_PCR_SW
116        ywave_PCR_SW := PolyCSRatio_SW(coef_PCR_SW,xwave_PCR_SW)
117        Display/K=1 ywave_PCR_SW vs xwave_PCR_SW
118        ModifyGraph log=1,marker=29,msize=2,mode=4
119        Label bottom "q (\\S-1\\M)"
120        Label left "Intensity (cm\\S-1\\M)"
121
122        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
123End
124
125Proc PlotSmearedPolyCSRatio_SW()                                                               
126        //no input parameters necessary, it MUST use the experimental q-values
127        // from the experimental data read in from an AVE/QSIG data file
128       
129        // if no gQvals wave, data must not have been loaded => abort
130        if(ResolutionWavesMissing())
131                Abort
132        endif
133       
134        // Setup parameter table for model function
135        Make/O/D smear_coef_PCR_SW = {0.1,60,10,0.1,1e-6,2e-6,3e-6,1,1.2,0.0001}
136        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)"}
137        Edit smear_parameters_PCR_SW,smear_coef_PCR_SW                                 
138       
139        // output smeared intensity wave, dimensions are identical to experimental QSIG values
140        // make extra copy of experimental q-values for easy plotting
141        Duplicate/O $gQvals smeared_PCR_SW,smeared_qvals                               
142        SetScale d,0,0,"1/cm",smeared_PCR_SW                                                   
143
144        smeared_PCR_SW := SmearedPolyCSRatio_SW(smear_coef_PCR_SW,$gQvals)             
145        Display smeared_PCR_SW vs smeared_qvals                                                                 
146        ModifyGraph log=1,marker=29,msize=2,mode=4
147        Label bottom "q (\\S-1\\M)"
148        Label left "Intensity (cm\\S-1\\M)"
149
150        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
151End
152
153Function PolyCSRatio_SW(w,x) : FitFunc
154        Wave w
155        Variable x
156       
157        Variable inten
158       
159        //setup form factor coefficient wave
160        Make/O/D/N=8 form_PCR_SW
161        form_PCR_SW[0] = 1
162        form_PCR_SW[1] = w[1]
163        form_PCR_SW[2] = w[2]
164        form_PCR_SW[3] = w[3]
165        form_PCR_SW[4] = w[4]
166        form_PCR_SW[5] = w[5]
167        form_PCR_SW[6] = w[6]
168        form_PCR_SW[7] = 0
169       
170        //calculate the diameter of the effective one-component sphere
171        Variable pd,diam,zz,Vpoly,Ravg,thick
172        pd = w[3]
173        zz = (1/pd)^2 - 1
174        Ravg = w[1]
175        thick = w[2]
176       
177        Vpoly = 4*pi/3*(Ravg+thick)^3*(zz+3)*(zz+2)/(zz+1)^2
178        diam = (6*Vpoly/pi)^(1/3)
179       
180        //setup structure factor coefficient wave
181        Make/O/D/N=4 struct_PCR_SW
182        struct_PCR_SW[0] = diam/2
183        struct_PCR_SW[1] = w[0]
184        struct_PCR_SW[2] = w[7]
185        struct_PCR_SW[3] = w[8]
186       
187        //calculate each and combine
188        inten = PolyCoreShellRatio(form_PCR_SW,x)
189        inten *= SquareWellStruct(struct_PCR_SW,x)
190        inten *= w[0]
191        inten += w[9]
192       
193        //cleanup waves
194//      Killwaves/Z form_PCR_SW,struct_PCR_SW
195       
196        return (inten)
197End
198
199
200/////////////////////////////////////////
201Proc PlotPolyCSRatio_SC(num,qmin,qmax)
202        Variable num=256,qmin=0.001,qmax=0.7
203        Prompt num "Enter number of data points for model: "
204        Prompt qmin "Enter minimum q-value (^-1) for model: "
205        Prompt qmax "Enter maximum q-value (^-1) for model: "
206       
207        if (DataFolderExists("root:HayPenMSA"))
208                Make/O/D/N=17 root:HayPenMSA:gMSAWave
209        else
210                NewDataFolder root:HayPenMSA
211                Make/O/D/N=17 root:HayPenMSA:gMSAWave
212        endif
213       
214        Make/O/D/n=(num) xwave_PCR_SC,ywave_PCR_SC
215        xwave_PCR_SC =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
216        Make/O/D coef_PCR_SC = {0.1,60,10,0.1,1e-6,2e-6,6e-6,10,0,298,78,0.0001}
217        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)"}
218        Edit/K=1 parameters_PCR_SC,coef_PCR_SC
219        ywave_PCR_SC := PolyCSRatio_SC(coef_PCR_SC,xwave_PCR_SC)
220        Display/K=1 ywave_PCR_SC vs xwave_PCR_SC
221        ModifyGraph log=1,marker=29,msize=2,mode=4
222        Label bottom "q (\\S-1\\M)"
223        Label left "Intensity (cm\\S-1\\M)"
224
225        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
226End
227
228Proc PlotSmearedPolyCSRatio_SC()                                                               
229        //no input parameters necessary, it MUST use the experimental q-values
230        // from the experimental data read in from an AVE/QSIG data file
231       
232        // if no gQvals wave, data must not have been loaded => abort
233        if(ResolutionWavesMissing())
234                Abort
235        endif
236
237        if (DataFolderExists("root:HayPenMSA"))
238                Make/O/D/N=17 root:HayPenMSA:gMSAWave
239        else
240                NewDataFolder root:HayPenMSA
241                Make/O/D/N=17 root:HayPenMSA:gMSAWave
242        endif
243       
244        // Setup parameter table for model function
245        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}
246        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)"}
247        Edit smear_parameters_PCR_SC,smear_coef_PCR_SC                                 
248       
249        // output smeared intensity wave, dimensions are identical to experimental QSIG values
250        // make extra copy of experimental q-values for easy plotting
251        Duplicate/O $gQvals smeared_PCR_SC,smeared_qvals                               
252        SetScale d,0,0,"1/cm",smeared_PCR_SC                                                   
253
254        smeared_PCR_SC := SmearedPolyCSRatio_SC(smear_coef_PCR_SC,$gQvals)             
255        Display smeared_PCR_SC vs smeared_qvals                                                                 
256        ModifyGraph log=1,marker=29,msize=2,mode=4
257        Label bottom "q (\\S-1\\M)"
258        Label left "Intensity (cm\\S-1\\M)"
259
260        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
261End
262
263Function PolyCSRatio_SC(w,x) : FitFunc
264        Wave w
265        Variable x
266       
267        Variable inten
268       
269        //setup form factor coefficient wave
270        Make/O/D/N=8 form_PCR_SC
271        form_PCR_SC[0] = 1
272        form_PCR_SC[1] = w[1]
273        form_PCR_SC[2] = w[2]
274        form_PCR_SC[3] = w[3]
275        form_PCR_SC[4] = w[4]
276        form_PCR_SC[5] = w[5]
277        form_PCR_SC[6] = w[6]
278        form_PCR_SC[7] = 0
279       
280        //calculate the diameter of the effective one-component sphere
281        Variable pd,diam,zz,Vpoly,Ravg,thick
282        pd = w[3]
283        zz = (1/pd)^2 - 1
284        Ravg = w[1]
285        thick = w[2]
286       
287        Vpoly = 4*pi/3*(Ravg+thick)^3*(zz+3)*(zz+2)/(zz+1)^2
288        diam = (6*Vpoly/pi)^(1/3)
289       
290        //setup structure factor coefficient wave
291        Make/O/D/N=6 struct_PCR_SC
292        struct_PCR_SC[0] = diam
293        struct_PCR_SC[1] = w[7]
294        struct_PCR_SC[2] = w[0]
295        struct_PCR_SC[3] = w[9]
296        struct_PCR_SC[4] = w[8]
297        struct_PCR_SC[5] = w[10]
298       
299        //calculate each and combine
300        inten = PolyCoreShellRatio(form_PCR_SC,x)
301        inten *= HayterPenfoldMSA(struct_PCR_SC,x)
302        inten *= w[0]
303        inten += w[11]
304       
305        //cleanup waves
306//      Killwaves/Z form_PCR_SC,struct_PCR_SC
307       
308        return (inten)
309End
310
311/////////////////////////////////////////
312Proc PlotPolyCSRatio_SHS(num,qmin,qmax)
313        Variable num=256,qmin=0.001,qmax=0.7
314        Prompt num "Enter number of data points for model: "
315        Prompt qmin "Enter minimum q-value (^-1) for model: "
316        Prompt qmax "Enter maximum q-value (^-1) for model: "
317       
318        Make/O/D/n=(num) xwave_PCR_SHS,ywave_PCR_SHS
319        xwave_PCR_SHS =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
320        Make/O/D coef_PCR_SHS = {0.1,60,10,0.1,1e-6,2e-6,3e-6,0.05,0.2,0.0001}
321        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)"}
322        Edit/K=1 parameters_PCR_SHS,coef_PCR_SHS
323        ywave_PCR_SHS := PolyCSRatio_SHS(coef_PCR_SHS,xwave_PCR_SHS)
324        Display/K=1 ywave_PCR_SHS vs xwave_PCR_SHS
325        ModifyGraph log=1,marker=29,msize=2,mode=4
326        Label bottom "q (\\S-1\\M)"
327        Label left "Intensity (cm\\S-1\\M)"
328
329        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
330End
331
332Proc PlotSmearedPolyCSRatio_SHS()                                                               
333        //no input parameters necessary, it MUST use the experimental q-values
334        // from the experimental data read in from an AVE/QSIG data file
335       
336        // if no gQvals wave, data must not have been loaded => abort
337        if(ResolutionWavesMissing())
338                Abort
339        endif
340       
341        // Setup parameter table for model function
342        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}
343        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)"}
344        Edit smear_parameters_PCR_SHS,smear_coef_PCR_SHS                                       
345       
346        // output smeared intensity wave, dimensions are identical to experimental QSIG values
347        // make extra copy of experimental q-values for easy plotting
348        Duplicate/O $gQvals smeared_PCR_SHS,smeared_qvals                               
349        SetScale d,0,0,"1/cm",smeared_PCR_SHS                                                   
350
351        smeared_PCR_SHS := SmearedPolyCSRatio_SHS(smear_coef_PCR_SHS,$gQvals)           
352        Display smeared_PCR_SHS vs smeared_qvals                                                                       
353        ModifyGraph log=1,marker=29,msize=2,mode=4
354        Label bottom "q (\\S-1\\M)"
355        Label left "Intensity (cm\\S-1\\M)"
356
357        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
358End
359
360Function PolyCSRatio_SHS(w,x) : FitFunc
361        Wave w
362        Variable x
363       
364        Variable inten
365       
366        //setup form factor coefficient wave
367        Make/O/D/N=8 form_PCR_SHS
368        form_PCR_SHS[0] = 1
369        form_PCR_SHS[1] = w[1]
370        form_PCR_SHS[2] = w[2]
371        form_PCR_SHS[3] = w[3]
372        form_PCR_SHS[4] = w[4]
373        form_PCR_SHS[5] = w[5]
374        form_PCR_SHS[6] = w[6]
375        form_PCR_SHS[7] = 0
376       
377        //calculate the diameter of the effective one-component sphere
378        Variable pd,diam,zz,Vpoly,Ravg,thick
379        pd = w[3]
380        zz = (1/pd)^2 - 1
381        Ravg = w[1]
382        thick = w[2]
383       
384        Vpoly = 4*pi/3*(Ravg+thick)^3*(zz+3)*(zz+2)/(zz+1)^2
385        diam = (6*Vpoly/pi)^(1/3)
386       
387        //setup structure factor coefficient wave
388        Make/O/D/N=4 struct_PCR_SHS
389        struct_PCR_SHS[0] = diam/2
390        struct_PCR_SHS[1] = w[0]
391        struct_PCR_SHS[2] = w[7]
392        struct_PCR_SHS[3] = w[8]
393       
394        //calculate each and combine
395        inten = PolyCoreShellRatio(form_PCR_SHS,x)
396        inten *= StickyHS_Struct(struct_PCR_SHS,x)
397        inten *= w[0]
398        inten += w[9]
399       
400        //cleanup waves
401//      Killwaves/Z form_PCR_SHS,struct_PCR_SHS
402       
403        return (inten)
404End
405
406
407
408// this is all there is to the smeared calculation!
409Function SmearedPolyCSRatio_HS(w,x) :FitFunc
410        Wave w
411        Variable x
412       
413        Variable ans
414        SVAR sq = gSig_Q
415        SVAR qb = gQ_bar
416        SVAR sh = gShadow
417        SVAR gQ = gQVals
418       
419        //the name of your unsmeared model is the first argument
420        ans = Smear_Model_20(PolyCSRatio_HS,$sq,$qb,$sh,$gQ,w,x)
421
422        return(ans)
423End
424
425// this is all there is to the smeared calculation!
426Function SmearedPolyCSRatio_SW(w,x) :FitFunc
427        Wave w
428        Variable x
429       
430        Variable ans
431        SVAR sq = gSig_Q
432        SVAR qb = gQ_bar
433        SVAR sh = gShadow
434        SVAR gQ = gQVals
435       
436        //the name of your unsmeared model is the first argument
437        ans = Smear_Model_20(PolyCSRatio_SW,$sq,$qb,$sh,$gQ,w,x)
438
439        return(ans)
440End
441
442// this is all there is to the smeared calculation!
443Function SmearedPolyCSRatio_SC(w,x) :FitFunc
444        Wave w
445        Variable x
446       
447        Variable ans
448        SVAR sq = gSig_Q
449        SVAR qb = gQ_bar
450        SVAR sh = gShadow
451        SVAR gQ = gQVals
452       
453        //the name of your unsmeared model is the first argument
454        ans = Smear_Model_20(PolyCSRatio_SC,$sq,$qb,$sh,$gQ,w,x)
455
456        return(ans)
457End
458
459// this is all there is to the smeared calculation!
460Function SmearedPolyCSRatio_SHS(w,x) :FitFunc
461        Wave w
462        Variable x
463       
464        Variable ans
465        SVAR sq = gSig_Q
466        SVAR qb = gQ_bar
467        SVAR sh = gShadow
468        SVAR gQ = gQVals
469       
470        //the name of your unsmeared model is the first argument
471        ans = Smear_Model_20(PolyCSRatio_SHS,$sq,$qb,$sh,$gQ,w,x)
472
473        return(ans)
474End
Note: See TracBrowser for help on using the repository browser.