source: sans/Analysis/trunk/Put in User Procedures/SANS_Models_v3.00/ProlateCS_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.8 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2
3// be sure to include all the necessary files...
4#include "ProlateForm"
5#include "EffectiveDiameter"
6
7#include "HardSphereStruct"
8#include "HPMSA"
9#include "SquareWellStruct"
10#include "StickyHardSphereStruct"
11
12Proc PlotProlate_HS(num,qmin,qmax)
13        Variable num=128,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_PEF_HS,ywave_PEF_HS
19        xwave_PEF_HS =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
20        Make/O/D coef_PEF_HS = {0.01,100,50,110,60,1e-6,2e-6,0.0001}
21        make/o/t parameters_PEF_HS = {"volume fraction","major core radius (A)","minor core radius (A)","major shell radius (A)","minor shell radius (A)","Contrast (core-shell) (A-2)","Constrast (shell-solvent) (A-2)","bkg (cm-1)"}
22        Edit parameters_PEF_HS,coef_PEF_HS
23        ywave_PEF_HS := Prolate_HS(coef_PEF_HS,xwave_PEF_HS)
24        Display ywave_PEF_HS vs xwave_PEF_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 PlotSmearedProlate_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_PEF_HS = {0.01,100,50,110,60,1e-6,2e-6,0.0001}
43        make/o/t smear_parameters_PEF_HS = {"volume fraction","major core radius (A)","minor core radius (A)","major shell radius (A)","minor shell radius (A)","Contrast (core-shell) (A-2)","Constrast (shell-solvent) (A-2)","bkg (cm-1)"}
44        Edit smear_parameters_PEF_HS,smear_coef_PEF_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_PEF_HS,smeared_qvals                               
49        SetScale d,0,0,"1/cm",smeared_PEF_HS                                                   
50
51        smeared_PEF_HS := SmearedProlate_HS(smear_coef_PEF_HS,$gQvals)         
52        Display smeared_PEF_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 Prolate_HS(w,x) : FitFunc
61        Wave w
62        Variable x
63       
64        Variable inten,Ras,Rbs
65        Ras = w[3]      //Ras is the rotation axis
66        Rbs = w[4]
67       
68        //setup form factor coefficient wave
69        Make/O/D/N=8 form_PEF_HS
70        form_PEF_HS[0] = 1
71        form_PEF_HS[1] = w[1]
72        form_PEF_HS[2] = w[2]
73        form_PEF_HS[3] = w[3]
74        form_PEF_HS[4] = w[4]
75        form_PEF_HS[5] = w[5]
76        form_PEF_HS[6] = w[6]
77        form_PEF_HS[7] = 0
78       
79        //setup structure factor coefficient wave
80        Make/O/D/N=2 struct_PEF_HS
81        struct_PEF_HS[0] = 0.5*DiamEllip(Ras,Rbs)
82        struct_PEF_HS[1] = w[0]
83       
84        //calculate each and combine
85        inten = ProlateForm(form_PEF_HS,x)
86        inten *= HardSphereStruct(struct_PEF_HS,x)
87        inten *= w[0]
88        inten += w[7]
89       
90        //cleanup waves
91//      Killwaves/Z form_PEF_HS,struct_PEF_HS
92       
93        return (inten)
94End
95
96Proc PlotProlate_SW(num,qmin,qmax)
97        Variable num=128,qmin=0.001,qmax=0.7
98        Prompt num "Enter number of data points for model: "
99        Prompt qmin "Enter minimum q-value (^-1) for model: "
100        Prompt qmax "Enter maximum q-value (^-1) for model: "
101       
102        Make/O/D/n=(num) xwave_PEF_SW,ywave_PEF_SW
103        xwave_PEF_SW =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
104        Make/O/D coef_PEF_SW = {0.01,100,50,110,60,1e-6,2e-6,1.0,1.2,0.0001}
105        make/o/t parameters_PEF_SW = {"volume fraction","major core radius (A)","minor core radius (A)","major shell radius (A)","minor shell radius (A)","Contrast (core-shell) (A-2)","Constrast (shell-solvent) (A-2)","well depth (kT)","well width (diam.)","bkg (cm-1)"}
106        Edit parameters_PEF_SW,coef_PEF_SW
107        ywave_PEF_SW := Prolate_SW(coef_PEF_SW,xwave_PEF_SW)
108        Display ywave_PEF_SW vs xwave_PEF_SW
109        ModifyGraph log=1,marker=29,msize=2,mode=4
110        Label bottom "q (\\S-1\\M)"
111        Label left "Intensity (cm\\S-1\\M)"
112
113        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
114End
115
116Proc PlotSmearedProlate_SW()                                                           
117        //no input parameters necessary, it MUST use the experimental q-values
118        // from the experimental data read in from an AVE/QSIG data file
119       
120        // if no gQvals wave, data must not have been loaded => abort
121        if(ResolutionWavesMissing())
122                Abort
123        endif
124       
125        // Setup parameter table for model function
126        Make/O/D smear_coef_PEF_SW = {0.01,100,50,110,60,1e-6,2e-6,1.0,1.2,0.0001}
127        make/o/t smear_parameters_PEF_SW = {"volume fraction","major core radius (A)","minor core radius (A)","major shell radius (A)","minor shell radius (A)","Contrast (core-shell) (A-2)","Constrast (shell-solvent) (A-2)","well depth (kT)","well width (diam.)","bkg (cm-1)"}
128        Edit smear_parameters_PEF_SW,smear_coef_PEF_SW                                 
129       
130        // output smeared intensity wave, dimensions are identical to experimental QSIG values
131        // make extra copy of experimental q-values for easy plotting
132        Duplicate/O $gQvals smeared_PEF_SW,smeared_qvals                               
133        SetScale d,0,0,"1/cm",smeared_PEF_SW                                                   
134
135        smeared_PEF_SW := SmearedProlate_SW(smear_coef_PEF_SW,$gQvals)         
136        Display smeared_PEF_SW vs smeared_qvals                                                                 
137        ModifyGraph log=1,marker=29,msize=2,mode=4
138        Label bottom "q (\\S-1\\M)"
139        Label left "Intensity (cm\\S-1\\M)"
140
141        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
142End
143
144Function Prolate_SW(w,x) : FitFunc
145        Wave w
146        Variable x
147       
148        Variable inten,Ras,Rbs
149        Ras = w[3]      //Ras is the rotation axis
150        Rbs = w[4]
151       
152        //setup form factor coefficient wave
153        Make/O/D/N=8 form_PEF_SW
154        form_PEF_SW[0] = 1
155        form_PEF_SW[1] = w[1]
156        form_PEF_SW[2] = w[2]
157        form_PEF_SW[3] = w[3]
158        form_PEF_SW[4] = w[4]
159        form_PEF_SW[5] = w[5]
160        form_PEF_SW[6] = w[6]
161        form_PEF_SW[7] = 0
162       
163        //setup structure factor coefficient wave
164        Make/O/D/N=4 struct_PEF_SW
165        struct_PEF_SW[0] = 0.5*DiamEllip(Ras,Rbs)
166        struct_PEF_SW[1] = w[0]
167        struct_PEF_SW[2] = w[7]
168        struct_PEF_SW[3] = w[8]
169       
170        //calculate each and combine
171        inten = ProlateForm(form_PEF_SW,x)
172        inten *= SquareWellStruct(struct_PEF_SW,x)
173        inten *= w[0]
174        inten += w[9]
175       
176        //cleanup waves
177//      Killwaves/Z form_PEF_SW,struct_PEF_SW
178       
179        return (inten)
180End
181
182Proc PlotProlate_SC(num,qmin,qmax)
183        Variable num=128,qmin=0.001,qmax=0.7
184        Prompt num "Enter number of data points for model: "
185        Prompt qmin "Enter minimum q-value (^-1) for model: "
186        Prompt qmax "Enter maximum q-value (^-1) for model: "
187       
188        if (DataFolderExists("root:HayPenMSA"))
189                Make/O/D/N=17 root:HayPenMSA:gMSAWave
190        else
191                NewDataFolder root:HayPenMSA
192                Make/O/D/N=17 root:HayPenMSA:gMSAWave
193        endif
194       
195        Make/O/D/n=(num) xwave_PEF_SC,ywave_PEF_SC
196        xwave_PEF_SC =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
197        Make/O/D coef_PEF_SC = {0.01,100,50,110,60,1e-6,2e-6,20,0,298,78,0.0001}
198        make/o/t parameters_PEF_SC = {"volume fraction","major core radius (A)","minor core radius (A)","major shell radius (A)","minor shell radius (A)","Contrast (core-shell) (A-2)","Constrast (shell-solvent) (A-2)","charge","movalent salt(M)","Temperature (K)","dielectric const","bkg (cm-1)"}
199        Edit parameters_PEF_SC,coef_PEF_SC
200        ywave_PEF_SC := Prolate_SC(coef_PEF_SC,xwave_PEF_SC)
201        Display ywave_PEF_SC vs xwave_PEF_SC
202        ModifyGraph log=1,marker=29,msize=2,mode=4
203        Label bottom "q (\\S-1\\M)"
204        Label left "Intensity (cm\\S-1\\M)"
205
206        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
207End
208
209Proc PlotSmearedProlate_SC()                                                           
210        //no input parameters necessary, it MUST use the experimental q-values
211        // from the experimental data read in from an AVE/QSIG data file
212       
213        // if no gQvals wave, data must not have been loaded => abort
214        if(ResolutionWavesMissing())
215                Abort
216        endif
217
218        if (DataFolderExists("root:HayPenMSA"))
219                Make/O/D/N=17 root:HayPenMSA:gMSAWave
220        else
221                NewDataFolder root:HayPenMSA
222                Make/O/D/N=17 root:HayPenMSA:gMSAWave
223        endif
224       
225        // Setup parameter table for model function
226        Make/O/D smear_coef_PEF_SC = {0.01,100,50,110,60,1e-6,2e-6,20,0,298,78,0.0001}
227        make/o/t smear_parameters_PEF_SC = {"volume fraction","major core radius (A)","minor core radius (A)","major shell radius (A)","minor shell radius (A)","Contrast (core-shell) (A-2)","Constrast (shell-solvent) (A-2)","charge","movalent salt(M)","Temperature (K)","dielectric const","bkg (cm-1)"}
228        Edit smear_parameters_PEF_SC,smear_coef_PEF_SC                                 
229       
230        // output smeared intensity wave, dimensions are identical to experimental QSIG values
231        // make extra copy of experimental q-values for easy plotting
232        Duplicate/O $gQvals smeared_PEF_SC,smeared_qvals                               
233        SetScale d,0,0,"1/cm",smeared_PEF_SC                                                   
234
235        smeared_PEF_SC := SmearedProlate_SC(smear_coef_PEF_SC,$gQvals)         
236        Display smeared_PEF_SC vs smeared_qvals                                                                 
237        ModifyGraph log=1,marker=29,msize=2,mode=4
238        Label bottom "q (\\S-1\\M)"
239        Label left "Intensity (cm\\S-1\\M)"
240
241        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
242End
243
244Function Prolate_SC(w,x) : FitFunc
245        Wave w
246        Variable x
247       
248        Variable inten,Ras,Rbs
249        Ras = w[3]      //Ras is the rotation axis
250        Rbs = w[4]
251       
252        //setup form factor coefficient wave
253        Make/O/D/N=8 form_PEF_SC
254        form_PEF_SC[0] = 1
255        form_PEF_SC[1] = w[1]
256        form_PEF_SC[2] = w[2]
257        form_PEF_SC[3] = w[3]
258        form_PEF_SC[4] = w[4]
259        form_PEF_SC[5] = w[5]
260        form_PEF_SC[6] = w[6]
261        form_PEF_SC[7] = 0
262       
263        //setup structure factor coefficient wave
264        Make/O/D/N=6 struct_PEF_SC
265        struct_PEF_SC[0] = DiamEllip(Ras,Rbs)
266        struct_PEF_SC[1] = w[7]
267        struct_PEF_SC[2] = w[0]
268        struct_PEF_SC[3] = w[9]
269        struct_PEF_SC[4] = w[8]
270        struct_PEF_SC[5] = w[10]
271       
272        //calculate each and combine
273        inten = ProlateForm(form_PEF_SC,x)
274        inten *= HayterPenfoldMSA(struct_PEF_SC,x)
275        inten *= w[0]
276        inten += w[11]
277       
278        //cleanup waves
279//      Killwaves/Z form_PEF_SC,struct_PEF_SC
280       
281        return (inten)
282End
283
284
285Proc PlotProlate_SHS(num,qmin,qmax)
286        Variable num=128,qmin=0.001,qmax=0.7
287        Prompt num "Enter number of data points for model: "
288        Prompt qmin "Enter minimum q-value (^-1) for model: "
289        Prompt qmax "Enter maximum q-value (^-1) for model: "
290       
291        Make/O/D/n=(num) xwave_PEF_SHS,ywave_PEF_SHS
292        xwave_PEF_SHS =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
293        Make/O/D coef_PEF_SHS = {0.01,100,50,110,60,1e-6,2e-6,0.05,0.2,0.0001}
294        make/o/t parameters_PEF_SHS = {"volume fraction","major core radius (A)","minor core radius (A)","major shell radius (A)","minor shell radius (A)","Contrast (core-shell) (A-2)","Constrast (shell-solvent) (A-2)","perturbation parameter (0.1)","stickiness, tau","bkg (cm-1)"}
295        Edit parameters_PEF_SHS,coef_PEF_SHS
296        ywave_PEF_SHS := Prolate_SHS(coef_PEF_SHS,xwave_PEF_SHS)
297        Display ywave_PEF_SHS vs xwave_PEF_SHS
298        ModifyGraph log=1,marker=29,msize=2,mode=4
299        Label bottom "q (\\S-1\\M)"
300        Label left "Intensity (cm\\S-1\\M)"
301
302        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
303End
304
305Proc PlotSmearedProlate_SHS()                                                           
306        //no input parameters necessary, it MUST use the experimental q-values
307        // from the experimental data read in from an AVE/QSIG data file
308       
309        // if no gQvals wave, data must not have been loaded => abort
310        if(ResolutionWavesMissing())
311                Abort
312        endif
313       
314        // Setup parameter table for model function
315        Make/O/D smear_coef_PEF_SHS = {0.01,100,50,110,60,1e-6,2e-6,0.05,0.2,0.0001}
316        make/o/t smear_parameters_PEF_SHS = {"volume fraction","major core radius (A)","minor core radius (A)","major shell radius (A)","minor shell radius (A)","Contrast (core-shell) (A-2)","Constrast (shell-solvent) (A-2)","perturbation parameter (0.1)","stickiness, tau","bkg (cm-1)"}
317        Edit smear_parameters_PEF_SHS,smear_coef_PEF_SHS                                       
318       
319        // output smeared intensity wave, dimensions are identical to experimental QSIG values
320        // make extra copy of experimental q-values for easy plotting
321        Duplicate/O $gQvals smeared_PEF_SHS,smeared_qvals                               
322        SetScale d,0,0,"1/cm",smeared_PEF_SHS                                                   
323
324        smeared_PEF_SHS := SmearedProlate_SHS(smear_coef_PEF_SHS,$gQvals)               
325        Display smeared_PEF_SHS vs smeared_qvals                                                                       
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
333Function Prolate_SHS(w,x) : FitFunc
334        Wave w
335        Variable x
336       
337        Variable inten,Ras,Rbs
338        Ras = w[3]      //Ras is the rotation axis
339        Rbs = w[4]
340       
341        //setup form factor coefficient wave
342        Make/O/D/N=8 form_PEF_SHS
343        form_PEF_SHS[0] = 1
344        form_PEF_SHS[1] = w[1]
345        form_PEF_SHS[2] = w[2]
346        form_PEF_SHS[3] = w[3]
347        form_PEF_SHS[4] = w[4]
348        form_PEF_SHS[5] = w[5]
349        form_PEF_SHS[6] = w[6]
350        form_PEF_SHS[7] = 0
351       
352        //setup structure factor coefficient wave
353        Make/O/D/N=4 struct_PEF_SHS
354        struct_PEF_SHS[0] = 0.5*DiamEllip(Ras,Rbs)
355        struct_PEF_SHS[1] = w[0]
356        struct_PEF_SHS[2] = w[7]
357        struct_PEF_SHS[3] = w[8]
358       
359        //calculate each and combine
360        inten = ProlateForm(form_PEF_SHS,x)
361        inten *= StickyHS_Struct(struct_PEF_SHS,x)
362        inten *= w[0]
363        inten += w[9]
364       
365        //cleanup waves
366//      Killwaves/Z form_PEF_SHS,struct_PEF_SHS
367       
368        return (inten)
369End
370
371
372// this is all there is to the smeared calculation!
373Function SmearedProlate_HS(w,x) :FitFunc
374        Wave w
375        Variable x
376       
377        Variable ans
378        SVAR sq = gSig_Q
379        SVAR qb = gQ_bar
380        SVAR sh = gShadow
381        SVAR gQ = gQVals
382       
383        //the name of your unsmeared model is the first argument
384        ans = Smear_Model_20(Prolate_HS,$sq,$qb,$sh,$gQ,w,x)
385
386        return(ans)
387End
388
389// this is all there is to the smeared calculation!
390Function SmearedProlate_SW(w,x) :FitFunc
391        Wave w
392        Variable x
393       
394        Variable ans
395        SVAR sq = gSig_Q
396        SVAR qb = gQ_bar
397        SVAR sh = gShadow
398        SVAR gQ = gQVals
399       
400        //the name of your unsmeared model is the first argument
401        ans = Smear_Model_20(Prolate_SW,$sq,$qb,$sh,$gQ,w,x)
402
403        return(ans)
404End
405
406// this is all there is to the smeared calculation!
407Function SmearedProlate_SC(w,x) :FitFunc
408        Wave w
409        Variable x
410       
411        Variable ans
412        SVAR sq = gSig_Q
413        SVAR qb = gQ_bar
414        SVAR sh = gShadow
415        SVAR gQ = gQVals
416       
417        //the name of your unsmeared model is the first argument
418        ans = Smear_Model_20(Prolate_SC,$sq,$qb,$sh,$gQ,w,x)
419
420        return(ans)
421End
422
423// this is all there is to the smeared calculation!
424Function SmearedProlate_SHS(w,x) :FitFunc
425        Wave w
426        Variable x
427       
428        Variable ans
429        SVAR sq = gSig_Q
430        SVAR qb = gQ_bar
431        SVAR sh = gShadow
432        SVAR gQ = gQVals
433       
434        //the name of your unsmeared model is the first argument
435        ans = Smear_Model_20(Prolate_SHS,$sq,$qb,$sh,$gQ,w,x)
436
437        return(ans)
438End
Note: See TracBrowser for help on using the repository browser.