source: sans/Analysis/trunk/Put in User Procedures/SANS_Models_v3.00/PolyRectSphere_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: 13.7 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2
3// be sure to include all the necessary files...
4
5#include "RectPolySpheres"
6
7#include "HardSphereStruct"
8#include "HPMSA"
9#include "SquareWellStruct"
10#include "StickyHardSphereStruct"
11
12Proc PlotPolyRectSphere_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_RECT_HS,ywave_RECT_HS
19        xwave_RECT_HS =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
20        Make/O/D coef_RECT_HS = {0.1,60,0.1,6e-6,0.0001}
21        make/o/t parameters_RECT_HS = {"volume fraction","avg radius (A)","polydispersity","contrast (A-2)","bkg (cm-1)"}
22        Edit/K=1 parameters_RECT_HS,coef_RECT_HS
23        ywave_RECT_HS := PolyRectSphere_HS(coef_RECT_HS,xwave_RECT_HS)
24        Display/K=1 ywave_RECT_HS vs xwave_RECT_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 PlotSmearedPolyRectSphere_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_RECT_HS = {0.1,60,0.1,6e-6,0.0001}
43        make/o/t smear_parameters_RECT_HS = {"volume fraction","avg radius (A)","polydispersity","contrast (A-2)","bkg (cm-1)"}
44        Edit smear_parameters_RECT_HS,smear_coef_RECT_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_RECT_HS,smeared_qvals                               
49        SetScale d,0,0,"1/cm",smeared_RECT_HS                                                   
50
51        smeared_RECT_HS := SmearedPolyRectSphere_HS(smear_coef_RECT_HS,$gQvals)         
52        Display smeared_RECT_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 PolyRectSphere_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=5 form_RECT_HS
68        form_RECT_HS[0] = 1
69        form_RECT_HS[1] = w[1]
70        form_RECT_HS[2] = w[2]
71        form_RECT_HS[3] = w[3]
72        form_RECT_HS[4] = 0
73       
74        //calculate the diameter of the effective one-component sphere
75        Variable pd,diam,zz,Vpoly,Ravg
76        pd = w[2]
77        zz = (1/pd)^2 - 1
78        Ravg = w[1]             // <R^3> = Ravg^3*(1+3*pd^2)
79       
80        Vpoly = 4*pi/3*Ravg^3*(1+3*pd^2)
81        diam = (6*Vpoly/pi)^(1/3)
82       
83        //setup structure factor coefficient wave
84        Make/O/D/N=2 struct_RECT_HS
85        struct_RECT_HS[0] = diam/2
86        struct_RECT_HS[1] = w[0]
87       
88        //calculate each and combine
89        inten = PolyRectSpheres(form_RECT_HS,x)
90        inten *= HardSphereStruct(struct_RECT_HS,x)
91        inten *= w[0]
92        inten += w[4]
93       
94        //cleanup waves
95//      Killwaves/Z form_RECT_HS,struct_RECT_HS
96       
97        return (inten)
98End
99
100/////////////////////////////////////////
101Proc PlotPolyRectSphere_SW(num,qmin,qmax)
102        Variable num=256,qmin=0.001,qmax=0.7
103        Prompt num "Enter number of data points for model: "
104        Prompt qmin "Enter minimum q-value (^-1) for model: "
105        Prompt qmax "Enter maximum q-value (^-1) for model: "
106       
107        Make/O/D/n=(num) xwave_RECT_SW,ywave_RECT_SW
108        xwave_RECT_SW =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
109        Make/O/D coef_RECT_SW = {0.1,60,0.1,6e-6,1.0,1.2,0.0001}
110        make/o/t parameters_RECT_SW = {"volume fraction","avg radius(A)","polydispersity","contrast (A-2)","well depth (kT)","well width (diam.)","bkg (cm-1)"}
111        Edit/K=1 parameters_RECT_SW,coef_RECT_SW
112        ywave_RECT_SW := PolyRectSphere_SW(coef_RECT_SW,xwave_RECT_SW)
113        Display/K=1 ywave_RECT_SW vs xwave_RECT_SW
114        ModifyGraph log=1,marker=29,msize=2,mode=4
115        Label bottom "q (\\S-1\\M)"
116        Label left "Intensity (cm\\S-1\\M)"
117
118        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
119End
120
121Proc PlotSmearedPolyRectSphere_SW()                                                             
122        //no input parameters necessary, it MUST use the experimental q-values
123        // from the experimental data read in from an AVE/QSIG data file
124       
125        // if no gQvals wave, data must not have been loaded => abort
126        if(ResolutionWavesMissing())
127                Abort
128        endif
129       
130        // Setup parameter table for model function
131        Make/O/D smear_coef_RECT_SW = {0.1,60,0.1,6e-6,1.0,1.2,0.0001}
132        make/o/t smear_parameters_RECT_SW = {"volume fraction","avg radius(A)","polydispersity","contrast (A-2)","well depth (kT)","well width (diam.)","bkg (cm-1)"}
133        Edit smear_parameters_RECT_SW,smear_coef_RECT_SW                                       
134       
135        // output smeared intensity wave, dimensions are identical to experimental QSIG values
136        // make extra copy of experimental q-values for easy plotting
137        Duplicate/O $gQvals smeared_RECT_SW,smeared_qvals                               
138        SetScale d,0,0,"1/cm",smeared_RECT_SW                                                   
139
140        smeared_RECT_SW := SmearedPolyRectSphere_SW(smear_coef_RECT_SW,$gQvals)         
141        Display smeared_RECT_SW vs smeared_qvals                                                                       
142        ModifyGraph log=1,marker=29,msize=2,mode=4
143        Label bottom "q (\\S-1\\M)"
144        Label left "Intensity (cm\\S-1\\M)"
145
146        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
147End
148
149Function PolyRectSphere_SW(w,x) : FitFunc
150        Wave w
151        Variable x
152       
153        Variable inten
154       
155        //setup form factor coefficient wave
156        Make/O/D/N=5 form_RECT_SW
157        form_RECT_SW[0] = 1
158        form_RECT_SW[1] = w[1]
159        form_RECT_SW[2] = w[2]
160        form_RECT_SW[3] = w[3]
161        form_RECT_SW[4] = 0
162       
163        //calculate the diameter of the effective one-component sphere
164        Variable pd,diam,zz,Vpoly,Ravg
165        pd = w[2]
166        zz = (1/pd)^2 - 1
167        Ravg = w[1]             // <R^3> = Ravg^3*(1+3*pd^2)
168       
169        Vpoly = 4*pi/3*Ravg^3*(1+3*pd^2)
170        diam = (6*Vpoly/pi)^(1/3)
171       
172        //setup structure factor coefficient wave
173        Make/O/D/N=4 struct_RECT_SW
174        struct_RECT_SW[0] = diam/2
175        struct_RECT_SW[1] = w[0]
176        struct_RECT_SW[2] = w[4]
177        struct_RECT_SW[3] = w[5]
178       
179        //calculate each and combine
180        inten = PolyRectSpheres(form_RECT_SW,x)
181        inten *= SquareWellStruct(struct_RECT_SW,x)
182        inten *= w[0]
183        inten += w[6]
184       
185        //cleanup waves
186//      Killwaves/Z form_RECT_SW,struct_RECT_SW
187       
188        return (inten)
189End
190
191
192/////////////////////////////////////////
193Proc PlotPolyRectSphere_SC(num,qmin,qmax)
194        Variable num=256,qmin=0.001,qmax=0.7
195        Prompt num "Enter number of data points for model: "
196        Prompt qmin "Enter minimum q-value (^-1) for model: "
197        Prompt qmax "Enter maximum q-value (^-1) for model: "
198       
199        if (DataFolderExists("root:HayPenMSA"))
200                Make/O/D/N=17 root:HayPenMSA:gMSAWave
201        else
202                NewDataFolder root:HayPenMSA
203                Make/O/D/N=17 root:HayPenMSA:gMSAWave
204        endif
205       
206        Make/O/D/n=(num) xwave_RECT_SC,ywave_RECT_SC
207        xwave_RECT_SC =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
208        Make/O/D coef_RECT_SC = {0.1,60,0.1,6e-6,10,0,298,78,0.0001}
209        make/o/t parameters_RECT_SC = {"volume fraction","avg radius (A)","polydispersity","contrast (A-2)","charge","Monovalent salt (M)","Temperature (K)","dielectric const.","bkg (cm-1)"}
210        Edit/K=1 parameters_RECT_SC,coef_RECT_SC
211        ywave_RECT_SC := PolyRectSphere_SC(coef_RECT_SC,xwave_RECT_SC)
212        Display/K=1 ywave_RECT_SC vs xwave_RECT_SC
213        ModifyGraph log=1,marker=29,msize=2,mode=4
214        Label bottom "q (\\S-1\\M)"
215        Label left "Intensity (cm\\S-1\\M)"
216
217        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
218End
219
220Proc PlotSmearedPolyRectSphere_SC()                                                             
221        //no input parameters necessary, it MUST use the experimental q-values
222        // from the experimental data read in from an AVE/QSIG data file
223       
224        // if no gQvals wave, data must not have been loaded => abort
225        if(ResolutionWavesMissing())
226                Abort
227        endif
228
229        if (DataFolderExists("root:HayPenMSA"))
230                Make/O/D/N=17 root:HayPenMSA:gMSAWave
231        else
232                NewDataFolder root:HayPenMSA
233                Make/O/D/N=17 root:HayPenMSA:gMSAWave
234        endif
235       
236        // Setup parameter table for model function
237        Make/O/D smear_coef_RECT_SC = {0.1,60,0.1,6e-6,10,0,298,78,0.0001}
238        make/o/t smear_parameters_RECT_SC = {"volume fraction","avg radius (A)","polydispersity","contrast (A-2)","charge","Monovalent salt (M)","Temperature (K)","dielectric const.","bkg (cm-1)"}
239        Edit smear_parameters_RECT_SC,smear_coef_RECT_SC                                       
240       
241        // output smeared intensity wave, dimensions are identical to experimental QSIG values
242        // make extra copy of experimental q-values for easy plotting
243        Duplicate/O $gQvals smeared_RECT_SC,smeared_qvals                               
244        SetScale d,0,0,"1/cm",smeared_RECT_SC                                                   
245
246        smeared_RECT_SC := SmearedPolyRectSphere_SC(smear_coef_RECT_SC,$gQvals)         
247        Display smeared_RECT_SC vs smeared_qvals                                                                       
248        ModifyGraph log=1,marker=29,msize=2,mode=4
249        Label bottom "q (\\S-1\\M)"
250        Label left "Intensity (cm\\S-1\\M)"
251
252        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
253End
254
255Function PolyRectSphere_SC(w,x) : FitFunc
256        Wave w
257        Variable x
258       
259        Variable inten
260       
261        //setup form factor coefficient wave
262        Make/O/D/N=5 form_RECT_SC
263        form_RECT_SC[0] = 1
264        form_RECT_SC[1] = w[1]
265        form_RECT_SC[2] = w[2]
266        form_RECT_SC[3] = w[3]
267        form_RECT_SC[4] = 0
268       
269        //calculate the diameter of the effective one-component sphere
270        Variable pd,diam,zz,Vpoly,Ravg
271        pd = w[2]
272        zz = (1/pd)^2 - 1
273        Ravg = w[1]             // <R^3> = Ravg^3*(1+3*pd^2)
274       
275        Vpoly = 4*pi/3*Ravg^3*(1+3*pd^2)
276        diam = (6*Vpoly/pi)^(1/3)
277       
278        //setup structure factor coefficient wave
279        Make/O/D/N=6 struct_RECT_SC
280        struct_RECT_SC[0] = diam
281        struct_RECT_SC[1] = w[4]
282        struct_RECT_SC[2] = w[0]
283        struct_RECT_SC[3] = w[6]
284        struct_RECT_SC[4] = w[5]
285        struct_RECT_SC[5] = w[7]
286       
287        //calculate each and combine
288        inten = PolyRectSpheres(form_RECT_SC,x)
289        inten *= HayterPenfoldMSA(struct_RECT_SC,x)
290        inten *= w[0]
291        inten += w[8]
292       
293        //cleanup waves
294//      Killwaves/Z form_RECT_SC,struct_RECT_SC
295       
296        return (inten)
297End
298
299/////////////////////////////////////////
300Proc PlotPolyRectSphere_SHS(num,qmin,qmax)
301        Variable num=256,qmin=0.001,qmax=0.7
302        Prompt num "Enter number of data points for model: "
303        Prompt qmin "Enter minimum q-value (^-1) for model: "
304        Prompt qmax "Enter maximum q-value (^-1) for model: "
305       
306        Make/O/D/n=(num) xwave_RECT_SHS,ywave_RECT_SHS
307        xwave_RECT_SHS =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
308        Make/O/D coef_RECT_SHS = {0.1,60,0.1,6e-6,0.05,0.2,0.0001}
309        make/o/t parameters_RECT_SHS = {"volume fraction","avg radius(A)","polydispersity","contrast (A-2)","perturbation parameter (0.1)","stickiness, tau","bkg (cm-1)"}
310        Edit/K=1 parameters_RECT_SHS,coef_RECT_SHS
311        ywave_RECT_SHS := PolyRectSphere_SHS(coef_RECT_SHS,xwave_RECT_SHS)
312        Display/K=1 ywave_RECT_SHS vs xwave_RECT_SHS
313        ModifyGraph log=1,marker=29,msize=2,mode=4
314        Label bottom "q (\\S-1\\M)"
315        Label left "Intensity (cm\\S-1\\M)"
316
317        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
318End
319
320Proc PlotSmearedPolyRectSphere_SHS()                                                           
321        //no input parameters necessary, it MUST use the experimental q-values
322        // from the experimental data read in from an AVE/QSIG data file
323       
324        // if no gQvals wave, data must not have been loaded => abort
325        if(ResolutionWavesMissing())
326                Abort
327        endif
328       
329        // Setup parameter table for model function
330        Make/O/D smear_coef_RECT_SHS = {0.1,60,0.1,6e-6,0.05,0.2,0.0001}
331        make/o/t smear_parameters_RECT_SHS = {"volume fraction","avg radius(A)","polydispersity","contrast (A-2)","perturbation parameter (0.1)","stickiness, tau","bkg (cm-1)"}
332        Edit smear_parameters_RECT_SHS,smear_coef_RECT_SHS                                     
333       
334        // output smeared intensity wave, dimensions are identical to experimental QSIG values
335        // make extra copy of experimental q-values for easy plotting
336        Duplicate/O $gQvals smeared_RECT_SHS,smeared_qvals                             
337        SetScale d,0,0,"1/cm",smeared_RECT_SHS                                                 
338
339        smeared_RECT_SHS := SmearedPolyRectSphere_SHS(smear_coef_RECT_SHS,$gQvals)             
340        Display smeared_RECT_SHS vs smeared_qvals                                                                       
341        ModifyGraph log=1,marker=29,msize=2,mode=4
342        Label bottom "q (\\S-1\\M)"
343        Label left "Intensity (cm\\S-1\\M)"
344
345        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
346End
347
348Function PolyRectSphere_SHS(w,x) : FitFunc
349        Wave w
350        Variable x
351       
352        Variable inten
353       
354        //setup form factor coefficient wave
355        Make/O/D/N=5 form_RECT_SHS
356        form_RECT_SHS[0] = 1
357        form_RECT_SHS[1] = w[1]
358        form_RECT_SHS[2] = w[2]
359        form_RECT_SHS[3] = w[3]
360        form_RECT_SHS[4] = 0
361       
362        //calculate the diameter of the effective one-component sphere
363        Variable pd,diam,zz,Vpoly,Ravg
364        pd = w[2]
365        zz = (1/pd)^2 - 1
366        Ravg = w[1]             // <R^3> = Ravg^3*(1+3*pd^2)
367       
368        Vpoly = 4*pi/3*Ravg^3*(1+3*pd^2)
369        diam = (6*Vpoly/pi)^(1/3)
370       
371        //setup structure factor coefficient wave
372        Make/O/D/N=4 struct_RECT_SHS
373        struct_RECT_SHS[0] = diam/2
374        struct_RECT_SHS[1] = w[0]
375        struct_RECT_SHS[2] = w[4]
376        struct_RECT_SHS[3] = w[5]
377       
378        //calculate each and combine
379        inten = PolyRectSpheres(form_RECT_SHS,x)
380        inten *= StickyHS_Struct(struct_RECT_SHS,x)
381        inten *= w[0]
382        inten += w[6]
383       
384        //cleanup waves
385//      Killwaves/Z form_RECT_SHS,struct_RECT_SHS
386       
387        return (inten)
388End
389
390
391
392// this is all there is to the smeared calculation!
393Function SmearedPolyRectSphere_HS(w,x) :FitFunc
394        Wave w
395        Variable x
396       
397        Variable ans
398        SVAR sq = gSig_Q
399        SVAR qb = gQ_bar
400        SVAR sh = gShadow
401        SVAR gQ = gQVals
402       
403        //the name of your unsmeared model is the first argument
404        ans = Smear_Model_20(PolyRectSphere_HS,$sq,$qb,$sh,$gQ,w,x)
405
406        return(ans)
407End
408
409// this is all there is to the smeared calculation!
410Function SmearedPolyRectSphere_SW(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(PolyRectSphere_SW,$sq,$qb,$sh,$gQ,w,x)
422
423        return(ans)
424End
425
426// this is all there is to the smeared calculation!
427Function SmearedPolyRectSphere_SC(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(PolyRectSphere_SC,$sq,$qb,$sh,$gQ,w,x)
439
440        return(ans)
441End
442
443// this is all there is to the smeared calculation!
444Function SmearedPolyRectSphere_SHS(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(PolyRectSphere_SHS,$sq,$qb,$sh,$gQ,w,x)
456
457        return(ans)
458End
Note: See TracBrowser for help on using the repository browser.