source: sans/Analysis/trunk/Put in User Procedures/SANS_Models_v3.00/PolyCore_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.3 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2//
3// be sure to include all of the necessary files
4//
5#include "PolyCore"
6
7#include "HardSphereStruct"
8#include "HPMSA"
9#include "SquareWellStruct"
10#include "StickyHardSphereStruct"
11
12Proc PlotPolyCore_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_PCF_HS,ywave_PCF_HS
19        xwave_PCF_HS = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) )
20        Make/O/D coef_PCF_HS = {0.1,60,.2,10,1e-6,2e-6,3e-6,0.0001}
21        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)"}
22        Edit/K=1 parameters_PCF_HS,coef_PCF_HS
23        ywave_PCF_HS := PolyCore_HS(coef_PCF_HS,xwave_PCF_HS)
24        Display/K=1 ywave_PCF_HS vs xwave_PCF_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 PlotSmearedPolyCore_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_PCF_HS = {0.1,60,.2,10,1e-6,2e-6,3e-6,0.0001}
43        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)"}
44        Edit smear_parameters_PCF_HS,smear_coef_PCF_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_PCF_HS,smeared_qvals                               
49        SetScale d,0,0,"1/cm",smeared_PCF_HS                                                   
50
51        smeared_PCF_HS := SmearedPolyCore_HS(smear_coef_PCF_HS,$gQvals)         
52        Display smeared_PCF_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 PolyCore_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_PCF_HS
68        form_PCF_HS[0] = 1
69        form_PCF_HS[1] = w[1]
70        form_PCF_HS[2] = w[2]
71        form_PCF_HS[3] = w[3]
72        form_PCF_HS[4] = w[4]
73        form_PCF_HS[5] = w[5]
74        form_PCF_HS[6] = w[6]
75        form_PCF_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[2]
80        zz = (1/pd)^2 - 1
81        Ravg = w[1]
82        thick = w[3]
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       
88        //setup structure factor coefficient wave
89        Make/O/D/N=2 struct_PCF_HS
90        struct_PCF_HS[0] = diam/2
91        struct_PCF_HS[1] = w[0]
92       
93        //calculate each and combine
94        inten = PolyCoreForm(form_PCF_HS,x)
95        inten *= HardSphereStruct(struct_PCF_HS,x)
96        inten *= w[0]
97        inten += w[7]
98       
99        //cleanup waves
100//      Killwaves/Z form_PCF_HS,struct_PCF_HS
101       
102        return (inten)
103End
104
105/////////////////////////////////////////
106Proc PlotPolyCore_SW(num,qmin,qmax)
107        Variable num=256,qmin=0.001,qmax=0.7
108        Prompt num "Enter number of data points for model: "
109        Prompt qmin "Enter minimum q-value (^-1) for model: "
110        Prompt qmax "Enter maximum q-value (^-1) for model: "
111       
112        Make/O/D/n=(num) xwave_PCF_SW,ywave_PCF_SW
113        xwave_PCF_SW = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) )
114        Make/O/D coef_PCF_SW = {0.1,60,.2,10,1e-6,2e-6,3e-6,1.0,1.2,0.0001}
115        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)"}
116        Edit/K=1 parameters_PCF_SW,coef_PCF_SW
117        ywave_PCF_SW := PolyCore_SW(coef_PCF_SW,xwave_PCF_SW)
118        Display/K=1 ywave_PCF_SW vs xwave_PCF_SW
119        ModifyGraph log=1,marker=29,msize=2,mode=4
120        Label bottom "q (\\S-1\\M)"
121        Label left "Intensity (cm\\S-1\\M)"
122
123        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
124End
125
126Proc PlotSmearedPolyCore_SW()                                                           
127        //no input parameters necessary, it MUST use the experimental q-values
128        // from the experimental data read in from an AVE/QSIG data file
129       
130        // if no gQvals wave, data must not have been loaded => abort
131        if(ResolutionWavesMissing())
132                Abort
133        endif
134       
135        // Setup parameter table for model function
136        Make/O/D smear_coef_PCF_SW = {0.1,60,.2,10,1e-6,2e-6,3e-6,1.0,1.2,0.0001}
137        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)"}
138        Edit smear_parameters_PCF_SW,smear_coef_PCF_SW                                 
139       
140        // output smeared intensity wave, dimensions are identical to experimental QSIG values
141        // make extra copy of experimental q-values for easy plotting
142        Duplicate/O $gQvals smeared_PCF_SW,smeared_qvals                               
143        SetScale d,0,0,"1/cm",smeared_PCF_SW                                                   
144
145        smeared_PCF_SW := SmearedPolyCore_SW(smear_coef_PCF_SW,$gQvals)         
146        Display smeared_PCF_SW vs smeared_qvals                                                                 
147        ModifyGraph log=1,marker=29,msize=2,mode=4
148        Label bottom "q (\\S-1\\M)"
149        Label left "Intensity (cm\\S-1\\M)"
150
151        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
152End
153
154Function PolyCore_SW(w,x) : FitFunc
155        Wave w
156        Variable x
157       
158        Variable inten
159       
160        //setup form factor coefficient wave
161        Make/O/D/N=8 form_PCF_SW
162        form_PCF_SW[0] = 1
163        form_PCF_SW[1] = w[1]
164        form_PCF_SW[2] = w[2]
165        form_PCF_SW[3] = w[3]
166        form_PCF_SW[4] = w[4]
167        form_PCF_SW[5] = w[5]
168        form_PCF_SW[6] = w[6]
169        form_PCF_SW[7] = 0
170       
171        //calculate the diameter of the effective one-component sphere
172        Variable pd,diam,zz,Vpoly,Ravg,thick
173        pd = w[2]
174        zz = (1/pd)^2 - 1
175        Ravg = w[1]
176        thick = w[3]
177       
178        Vpoly = 4*pi/3*(Ravg+thick)^3*(zz+3)*(zz+2)/(zz+1)^2
179        diam = (6*Vpoly/pi)^(1/3)
180       
181        //setup structure factor coefficient wave
182        Make/O/D/N=4 struct_PCF_SW
183        struct_PCF_SW[0] = diam/2
184        struct_PCF_SW[1] = w[0]
185        struct_PCF_SW[2] = w[7]
186        struct_PCF_SW[3] = w[8]
187       
188        //calculate each and combine
189        inten = PolyCoreForm(form_PCF_SW,x)
190        inten *= SquareWellStruct(struct_PCF_SW,x)
191        inten *= w[0]
192        inten += w[9]
193       
194        //cleanup waves
195//      Killwaves/Z form_PCF_SW,struct_PCF_SW
196       
197        return (inten)
198End
199
200
201/////////////////////////////////////////
202Proc PlotPolyCore_SC(num,qmin,qmax)
203        Variable num=256,qmin=0.001,qmax=0.7
204        Prompt num "Enter number of data points for model: "
205        Prompt qmin "Enter minimum q-value (^-1) for model: "
206        Prompt qmax "Enter maximum q-value (^-1) for model: "
207       
208        if (DataFolderExists("root:HayPenMSA"))
209                Make/O/D/N=17 root:HayPenMSA:gMSAWave
210        else
211                NewDataFolder root:HayPenMSA
212                Make/O/D/N=17 root:HayPenMSA:gMSAWave
213        endif
214       
215        Make/O/D/n=(num) xwave_PCF_SC,ywave_PCF_SC
216        xwave_PCF_SC = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) )
217        Make/O/D coef_PCF_SC = {0.1,60,.2,10,1e-6,2e-6,3e-6,10,0,298,78,0.0001}
218        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)"}
219        Edit/K=1 parameters_PCF_SC,coef_PCF_SC
220        ywave_PCF_SC := PolyCore_SC(coef_PCF_SC,xwave_PCF_SC)
221        Display/K=1 ywave_PCF_SC vs xwave_PCF_SC
222        ModifyGraph log=1,marker=29,msize=2,mode=4
223        Label bottom "q (\\S-1\\M)"
224        Label left "Intensity (cm\\S-1\\M)"
225
226        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
227End
228
229Proc PlotSmearedPolyCore_SC()                                                           
230        //no input parameters necessary, it MUST use the experimental q-values
231        // from the experimental data read in from an AVE/QSIG data file
232       
233        // if no gQvals wave, data must not have been loaded => abort
234        if(ResolutionWavesMissing())
235                Abort
236        endif
237
238        if (DataFolderExists("root:HayPenMSA"))
239                Make/O/D/N=17 root:HayPenMSA:gMSAWave
240        else
241                NewDataFolder root:HayPenMSA
242                Make/O/D/N=17 root:HayPenMSA:gMSAWave
243        endif
244       
245        // Setup parameter table for model function
246        Make/O/D smear_coef_PCF_SC = {0.1,60,.2,10,1e-6,2e-6,3e-6,10,0,298,78,0.0001}
247        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)"}
248        Edit smear_parameters_PCF_SC,smear_coef_PCF_SC                                 
249       
250        // output smeared intensity wave, dimensions are identical to experimental QSIG values
251        // make extra copy of experimental q-values for easy plotting
252        Duplicate/O $gQvals smeared_PCF_SC,smeared_qvals                               
253        SetScale d,0,0,"1/cm",smeared_PCF_SC                                                   
254
255        smeared_PCF_SC := SmearedPolyCore_SC(smear_coef_PCF_SC,$gQvals)         
256        Display smeared_PCF_SC vs smeared_qvals                                                                 
257        ModifyGraph log=1,marker=29,msize=2,mode=4
258        Label bottom "q (\\S-1\\M)"
259        Label left "Intensity (cm\\S-1\\M)"
260
261        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
262End
263
264Function PolyCore_SC(w,x) : FitFunc
265        Wave w
266        Variable x
267       
268        Variable inten
269       
270        //setup form factor coefficient wave
271        Make/O/D/N=8 form_PCF_SC
272        form_PCF_SC[0] = 1
273        form_PCF_SC[1] = w[1]
274        form_PCF_SC[2] = w[2]
275        form_PCF_SC[3] = w[3]
276        form_PCF_SC[4] = w[4]
277        form_PCF_SC[5] = w[5]
278        form_PCF_SC[6] = w[6]
279        form_PCF_SC[7] = 0
280       
281        //calculate the diameter of the effective one-component sphere
282        Variable pd,diam,zz,Vpoly,Ravg,thick
283        pd = w[2]
284        zz = (1/pd)^2 - 1
285        Ravg = w[1]
286        thick = w[3]
287       
288        Vpoly = 4*pi/3*(Ravg+thick)^3*(zz+3)*(zz+2)/(zz+1)^2
289        diam = (6*Vpoly/pi)^(1/3)
290       
291        //setup structure factor coefficient wave
292        Make/O/D/N=6 struct_PCF_SC
293        struct_PCF_SC[0] = diam
294        struct_PCF_SC[1] = w[7]
295        struct_PCF_SC[2] = w[0]
296        struct_PCF_SC[3] = w[9]
297        struct_PCF_SC[4] = w[8]
298        struct_PCF_SC[5] = w[10]
299       
300        //calculate each and combine
301        inten = PolyCoreForm(form_PCF_SC,x)
302        inten *= HayterPenfoldMSA(struct_PCF_SC,x)
303        inten *= w[0]
304        inten += w[11]
305       
306        //cleanup waves
307//      Killwaves/Z form_PCF_SC,struct_PCF_SC
308       
309        return (inten)
310End
311
312/////////////////////////////////////////
313Proc PlotPolyCore_SHS(num,qmin,qmax)
314        Variable num=256,qmin=0.001,qmax=0.7
315        Prompt num "Enter number of data points for model: "
316        Prompt qmin "Enter minimum q-value (^-1) for model: "
317        Prompt qmax "Enter maximum q-value (^-1) for model: "
318       
319        Make/O/D/n=(num) xwave_PCF_SHS,ywave_PCF_SHS
320        xwave_PCF_SHS = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) )
321        Make/O/D coef_PCF_SHS = {0.1,60,.2,10,1e-6,2e-6,3e-6,0.05,0.2,0.0001}
322        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)"}
323        Edit/K=1 parameters_PCF_SHS,coef_PCF_SHS
324        ywave_PCF_SHS := PolyCore_SHS(coef_PCF_SHS,xwave_PCF_SHS)
325        Display/K=1 ywave_PCF_SHS vs xwave_PCF_SHS
326        ModifyGraph log=1,marker=29,msize=2,mode=4
327        Label bottom "q (\\S-1\\M)"
328        Label left "Intensity (cm\\S-1\\M)"
329
330        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
331End
332
333Proc PlotSmearedPolyCore_SHS()                                                         
334        //no input parameters necessary, it MUST use the experimental q-values
335        // from the experimental data read in from an AVE/QSIG data file
336       
337        // if no gQvals wave, data must not have been loaded => abort
338        if(ResolutionWavesMissing())
339                Abort
340        endif
341       
342        // Setup parameter table for model function
343        Make/O/D smear_coef_PCF_SHS = {0.1,60,.2,10,1e-6,2e-6,3e-6,0.05,0.2,0.0001}
344        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)"}
345        Edit smear_parameters_PCF_SHS,smear_coef_PCF_SHS                                       
346       
347        // output smeared intensity wave, dimensions are identical to experimental QSIG values
348        // make extra copy of experimental q-values for easy plotting
349        Duplicate/O $gQvals smeared_PCF_SHS,smeared_qvals                               
350        SetScale d,0,0,"1/cm",smeared_PCF_SHS                                                   
351
352        smeared_PCF_SHS := SmearedPolyCore_SHS(smear_coef_PCF_SHS,$gQvals)             
353        Display smeared_PCF_SHS vs smeared_qvals                                                                       
354        ModifyGraph log=1,marker=29,msize=2,mode=4
355        Label bottom "q (\\S-1\\M)"
356        Label left "Intensity (cm\\S-1\\M)"
357
358        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
359End
360
361Function PolyCore_SHS(w,x) : FitFunc
362        Wave w
363        Variable x
364       
365        Variable inten
366       
367        //setup form factor coefficient wave
368        Make/O/D/N=8 form_PCF_SHS
369        form_PCF_SHS[0] = 1
370        form_PCF_SHS[1] = w[1]
371        form_PCF_SHS[2] = w[2]
372        form_PCF_SHS[3] = w[3]
373        form_PCF_SHS[4] = w[4]
374        form_PCF_SHS[5] = w[5]
375        form_PCF_SHS[6] = w[6]
376        form_PCF_SHS[7] = 0
377       
378        //calculate the diameter of the effective one-component sphere
379        Variable pd,diam,zz,Vpoly,Ravg,thick
380        pd = w[2]
381        zz = (1/pd)^2 - 1
382        Ravg = w[1]
383        thick = w[3]
384       
385        Vpoly = 4*pi/3*(Ravg+thick)^3*(zz+3)*(zz+2)/(zz+1)^2
386        diam = (6*Vpoly/pi)^(1/3)
387       
388        //setup structure factor coefficient wave
389        Make/O/D/N=4 struct_PCF_SHS
390        struct_PCF_SHS[0] = diam/2
391        struct_PCF_SHS[1] = w[0]
392        struct_PCF_SHS[2] = w[7]
393        struct_PCF_SHS[3] = w[8]
394       
395        //calculate each and combine
396        inten = PolyCoreForm(form_PCF_SHS,x)
397        inten *= StickyHS_Struct(struct_PCF_SHS,x)
398        inten *= w[0]
399        inten += w[9]
400       
401        //cleanup waves
402//      Killwaves/Z form_PCF_SW,struct_PCF_SW
403       
404        return (inten)
405End
406
407
408
409// this is all there is to the smeared calculation!
410Function SmearedPolyCore_HS(w,x) :FitFunc
411        Wave w
412        Variable x
413       
414        Variable ans
415        SVAR sq = gSig_Q
416        SVAR qb = gQ_bar
417        SVAR sh = gShadow
418        SVAR gQ = gQVals
419       
420        //the name of your unsmeared model is the first argument
421        ans = Smear_Model_20(PolyCore_HS,$sq,$qb,$sh,$gQ,w,x)
422
423        return(ans)
424End
425
426// this is all there is to the smeared calculation!
427Function SmearedPolyCore_SW(w,x) :FitFunc
428        Wave w
429        Variable x
430       
431        Variable ans
432        SVAR sq = gSig_Q
433        SVAR qb = gQ_bar
434        SVAR sh = gShadow
435        SVAR gQ = gQVals
436       
437        //the name of your unsmeared model is the first argument
438        ans = Smear_Model_20(PolyCore_SW,$sq,$qb,$sh,$gQ,w,x)
439
440        return(ans)
441End
442
443// this is all there is to the smeared calculation!
444Function SmearedPolyCore_SC(w,x) :FitFunc
445        Wave w
446        Variable x
447       
448        Variable ans
449        SVAR sq = gSig_Q
450        SVAR qb = gQ_bar
451        SVAR sh = gShadow
452        SVAR gQ = gQVals
453       
454        //the name of your unsmeared model is the first argument
455        ans = Smear_Model_20(PolyCore_SC,$sq,$qb,$sh,$gQ,w,x)
456
457        return(ans)
458End
459
460// this is all there is to the smeared calculation!
461Function SmearedPolyCore_SHS(w,x) :FitFunc
462        Wave w
463        Variable x
464       
465        Variable ans
466        SVAR sq = gSig_Q
467        SVAR qb = gQ_bar
468        SVAR sh = gShadow
469        SVAR gQ = gQVals
470       
471        //the name of your unsmeared model is the first argument
472        ans = Smear_Model_20(PolyCore_SHS,$sq,$qb,$sh,$gQ,w,x)
473
474        return(ans)
475End
Note: See TracBrowser for help on using the repository browser.