source: sans/Analysis/trunk/Put in User Procedures/SANS_Models_v3.00/OblateCS_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.9 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 "OblateForm"
6#include "EffectiveDiameter"
7
8#include "HardSphereStruct"
9#include "HPMSA"
10#include "SquareWellStruct"
11#include "StickyHardSphereStruct"
12
13Proc PlotOblate_HS(num,qmin,qmax)
14        Variable num=128,qmin=0.001,qmax=0.7
15        Prompt num "Enter number of data points for model: "
16        Prompt qmin "Enter minimum q-value (^-1) for model: "
17        Prompt qmax "Enter maximum q-value (^-1) for model: "
18       
19        Make/O/D/n=(num) xwave_OEF_HS,ywave_OEF_HS
20        xwave_OEF_HS =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
21        Make/O/D coef_OEF_HS = {0.01,100,50,110,60,1e-6,2e-6,0.0001}
22        make/o/t parameters_OEF_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)"}
23        Edit parameters_OEF_HS,coef_OEF_HS
24        ywave_OEF_HS := Oblate_HS(coef_OEF_HS,xwave_OEF_HS)
25        Display ywave_OEF_HS vs xwave_OEF_HS
26        ModifyGraph log=1,marker=29,msize=2,mode=4
27        Label bottom "q (\\S-1\\M)"
28        Label left "Intensity (cm\\S-1\\M)"
29
30        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
31End
32
33Proc PlotSmearedOblate_HS()                                                             
34        //no input parameters necessary, it MUST use the experimental q-values
35        // from the experimental data read in from an AVE/QSIG data file
36       
37        // if no gQvals wave, data must not have been loaded => abort
38        if(ResolutionWavesMissing())
39                Abort
40        endif
41       
42        // Setup parameter table for model function
43        Make/O/D smear_coef_OEF_HS = {0.01,100,50,110,60,1e-6,2e-6,0.0001}
44        make/o/t smear_parameters_OEF_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)"}
45        Edit smear_parameters_OEF_HS,smear_coef_OEF_HS                                 
46       
47        // output smeared intensity wave, dimensions are identical to experimental QSIG values
48        // make extra copy of experimental q-values for easy plotting
49        Duplicate/O $gQvals smeared_OEF_HS,smeared_qvals                               
50        SetScale d,0,0,"1/cm",smeared_OEF_HS                                                   
51
52        smeared_OEF_HS := SmearedOblate_HS(smear_coef_OEF_HS,$gQvals)           
53        Display smeared_OEF_HS vs smeared_qvals                                                                 
54        ModifyGraph log=1,marker=29,msize=2,mode=4
55        Label bottom "q (\\S-1\\M)"
56        Label left "Intensity (cm\\S-1\\M)"
57
58        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
59End
60
61Function Oblate_HS(w,x) : FitFunc
62        Wave w
63        Variable x
64       
65        Variable inten,Ras,Rbs
66        Ras = w[4]      //Ras is the rotation axis, the minor axis for an oblate ellipsoid
67        Rbs = w[3]
68       
69        //setup form factor coefficient wave
70        Make/O/D/N=8 form_OEF_HS
71        form_OEF_HS[0] = 1
72        form_OEF_HS[1] = w[1]
73        form_OEF_HS[2] = w[2]
74        form_OEF_HS[3] = w[3]
75        form_OEF_HS[4] = w[4]
76        form_OEF_HS[5] = w[5]
77        form_OEF_HS[6] = w[6]
78        form_OEF_HS[7] = 0
79       
80        //setup structure factor coefficient wave
81        Make/O/D/N=2 struct_OEF_HS
82        struct_OEF_HS[0] = 0.5*DiamEllip(Ras,Rbs)
83        struct_OEF_HS[1] = w[0]
84       
85        //calculate each and combine
86        inten = OblateForm(form_OEF_HS,x)
87        inten *= HardSphereStruct(struct_OEF_HS,x)
88        inten *= w[0]
89        inten += w[7]
90       
91        //cleanup waves
92//      Killwaves/Z form_OEF_HS,struct_OEF_HS
93       
94        return (inten)
95End
96
97Proc PlotOblate_SW(num,qmin,qmax)
98        Variable num=128,qmin=0.001,qmax=0.7
99        Prompt num "Enter number of data points for model: "
100        Prompt qmin "Enter minimum q-value (^-1) for model: "
101        Prompt qmax "Enter maximum q-value (^-1) for model: "
102       
103        Make/O/D/n=(num) xwave_OEF_SW,ywave_OEF_SW
104        xwave_OEF_SW =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
105        Make/O/D coef_OEF_SW = {0.01,100,50,110,60,1e-6,2e-6,1.0,1.2,0.0001}
106        make/o/t parameters_OEF_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)"}
107        Edit parameters_OEF_SW,coef_OEF_SW
108        ywave_OEF_SW := Oblate_SW(coef_OEF_SW,xwave_OEF_SW)
109        Display ywave_OEF_SW vs xwave_OEF_SW
110        ModifyGraph log=1,marker=29,msize=2,mode=4
111        Label bottom "q (\\S-1\\M)"
112        Label left "Intensity (cm\\S-1\\M)"
113
114        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
115End
116
117Proc PlotSmearedOblate_SW()                                                             
118        //no input parameters necessary, it MUST use the experimental q-values
119        // from the experimental data read in from an AVE/QSIG data file
120       
121        // if no gQvals wave, data must not have been loaded => abort
122        if(ResolutionWavesMissing())
123                Abort
124        endif
125       
126        // Setup parameter table for model function
127        Make/O/D smear_coef_OEF_SW = {0.01,100,50,110,60,1e-6,2e-6,1.0,1.2,0.0001}
128        make/o/t smear_parameters_OEF_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)"}
129        Edit smear_parameters_OEF_SW,smear_coef_OEF_SW                                 
130       
131        // output smeared intensity wave, dimensions are identical to experimental QSIG values
132        // make extra copy of experimental q-values for easy plotting
133        Duplicate/O $gQvals smeared_OEF_SW,smeared_qvals                               
134        SetScale d,0,0,"1/cm",smeared_OEF_SW                                                   
135
136        smeared_OEF_SW := SmearedOblate_SW(smear_coef_OEF_SW,$gQvals)           
137        Display smeared_OEF_SW vs smeared_qvals                                                                 
138        ModifyGraph log=1,marker=29,msize=2,mode=4
139        Label bottom "q (\\S-1\\M)"
140        Label left "Intensity (cm\\S-1\\M)"
141
142        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
143End
144
145Function Oblate_SW(w,x) : FitFunc
146        Wave w
147        Variable x
148       
149        Variable inten,Ras,Rbs
150        Ras = w[4]      //Ras is the rotation axis
151        Rbs = w[3]
152       
153        //setup form factor coefficient wave
154        Make/O/D/N=8 form_OEF_SW
155        form_OEF_SW[0] = 1
156        form_OEF_SW[1] = w[1]
157        form_OEF_SW[2] = w[2]
158        form_OEF_SW[3] = w[3]
159        form_OEF_SW[4] = w[4]
160        form_OEF_SW[5] = w[5]
161        form_OEF_SW[6] = w[6]
162        form_OEF_SW[7] = 0
163       
164        //setup structure factor coefficient wave
165        Make/O/D/N=4 struct_OEF_SW
166        struct_OEF_SW[0] = 0.5*DiamEllip(Ras,Rbs)
167        struct_OEF_SW[1] = w[0]
168        struct_OEF_SW[2] = w[7]
169        struct_OEF_SW[3] = w[8]
170       
171        //calculate each and combine
172        inten = OblateForm(form_OEF_SW,x)
173        inten *= SquareWellStruct(struct_OEF_SW,x)
174        inten *= w[0]
175        inten += w[9]
176       
177        //cleanup waves
178//      Killwaves/Z form_OEF_SW,struct_OEF_SW
179       
180        return (inten)
181End
182
183Proc PlotOblate_SC(num,qmin,qmax)
184        Variable num=128,qmin=0.001,qmax=0.7
185        Prompt num "Enter number of data points for model: "
186        Prompt qmin "Enter minimum q-value (^-1) for model: "
187        Prompt qmax "Enter maximum q-value (^-1) for model: "
188       
189        if (DataFolderExists("root:HayPenMSA"))
190                Make/O/D/N=17 root:HayPenMSA:gMSAWave
191        else
192                NewDataFolder root:HayPenMSA
193                Make/O/D/N=17 root:HayPenMSA:gMSAWave
194        endif
195       
196        Make/O/D/n=(num) xwave_OEF_SC,ywave_OEF_SC
197        xwave_OEF_SC =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
198        Make/O/D coef_OEF_SC = {0.01,100,50,110,60,1e-6,2e-6,20,0,298,78,0.0001}
199        make/o/t parameters_OEF_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)"}
200        Edit parameters_OEF_SC,coef_OEF_SC
201        ywave_OEF_SC := Oblate_SC(coef_OEF_SC,xwave_OEF_SC)
202        Display ywave_OEF_SC vs xwave_OEF_SC
203        ModifyGraph log=1,marker=29,msize=2,mode=4
204        Label bottom "q (\\S-1\\M)"
205        Label left "Intensity (cm\\S-1\\M)"
206
207        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
208End
209
210Proc PlotSmearedOblate_SC()                                                             
211        //no input parameters necessary, it MUST use the experimental q-values
212        // from the experimental data read in from an AVE/QSIG data file
213       
214        // if no gQvals wave, data must not have been loaded => abort
215        if(ResolutionWavesMissing())
216                Abort
217        endif
218
219        if (DataFolderExists("root:HayPenMSA"))
220                Make/O/D/N=17 root:HayPenMSA:gMSAWave
221        else
222                NewDataFolder root:HayPenMSA
223                Make/O/D/N=17 root:HayPenMSA:gMSAWave
224        endif
225       
226        // Setup parameter table for model function
227        Make/O/D smear_coef_OEF_SC = {0.01,100,50,110,60,1e-6,2e-6,20,0,298,78,0.0001}
228        make/o/t smear_parameters_OEF_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)"}
229        Edit smear_parameters_OEF_SC,smear_coef_OEF_SC                                 
230       
231        // output smeared intensity wave, dimensions are identical to experimental QSIG values
232        // make extra copy of experimental q-values for easy plotting
233        Duplicate/O $gQvals smeared_OEF_SC,smeared_qvals                               
234        SetScale d,0,0,"1/cm",smeared_OEF_SC                                                   
235
236        smeared_OEF_SC := SmearedOblate_SC(smear_coef_OEF_SC,$gQvals)           
237        Display smeared_OEF_SC vs smeared_qvals                                                                 
238        ModifyGraph log=1,marker=29,msize=2,mode=4
239        Label bottom "q (\\S-1\\M)"
240        Label left "Intensity (cm\\S-1\\M)"
241
242        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
243End
244
245Function Oblate_SC(w,x) : FitFunc
246        Wave w
247        Variable x
248       
249        Variable inten,Ras,Rbs
250        Ras = w[4]      //Ras is the rotation axis
251        Rbs = w[3]
252       
253        //setup form factor coefficient wave
254        Make/O/D/N=8 form_OEF_SC
255        form_OEF_SC[0] = 1
256        form_OEF_SC[1] = w[1]
257        form_OEF_SC[2] = w[2]
258        form_OEF_SC[3] = w[3]
259        form_OEF_SC[4] = w[4]
260        form_OEF_SC[5] = w[5]
261        form_OEF_SC[6] = w[6]
262        form_OEF_SC[7] = 0
263       
264        //setup structure factor coefficient wave
265        Make/O/D/N=6 struct_OEF_SC
266        struct_OEF_SC[0] = DiamEllip(Ras,Rbs)
267        struct_OEF_SC[1] = w[7]
268        struct_OEF_SC[2] = w[0]
269        struct_OEF_SC[3] = w[9]
270        struct_OEF_SC[4] = w[8]
271        struct_OEF_SC[5] = w[10]
272       
273        //calculate each and combine
274        inten = OblateForm(form_OEF_SC,x)
275        inten *= HayterPenfoldMSA(struct_OEF_SC,x)
276        inten *= w[0]
277        inten += w[11]
278       
279        //cleanup waves
280//      Killwaves/Z form_OEF_SC,struct_OEF_SC
281       
282        return (inten)
283End
284
285
286Proc PlotOblate_SHS(num,qmin,qmax)
287        Variable num=128,qmin=0.001,qmax=0.7
288        Prompt num "Enter number of data points for model: "
289        Prompt qmin "Enter minimum q-value (^-1) for model: "
290        Prompt qmax "Enter maximum q-value (^-1) for model: "
291       
292        Make/O/D/n=(num) xwave_OEF_SHS,ywave_OEF_SHS
293        xwave_OEF_SHS =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
294        Make/O/D coef_OEF_SHS = {0.01,100,50,110,60,1e-6,2e-6,0.05,0.2,0.0001}
295        make/o/t parameters_OEF_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)"}
296        Edit parameters_OEF_SHS,coef_OEF_SHS
297        ywave_OEF_SHS := Oblate_SHS(coef_OEF_SHS,xwave_OEF_SHS)
298        Display ywave_OEF_SHS vs xwave_OEF_SHS
299        ModifyGraph log=1,marker=29,msize=2,mode=4
300        Label bottom "q (\\S-1\\M)"
301        Label left "Intensity (cm\\S-1\\M)"
302
303        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
304End
305
306Proc PlotSmearedOblate_SHS()                                                           
307        //no input parameters necessary, it MUST use the experimental q-values
308        // from the experimental data read in from an AVE/QSIG data file
309       
310        // if no gQvals wave, data must not have been loaded => abort
311        if(ResolutionWavesMissing())
312                Abort
313        endif
314       
315        // Setup parameter table for model function
316        Make/O/D smear_coef_OEF_SHS = {0.01,100,50,110,60,1e-6,2e-6,0.05,0.2,0.0001}
317        make/o/t smear_parameters_OEF_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)"}
318        Edit smear_parameters_OEF_SHS,smear_coef_OEF_SHS                                       
319       
320        // output smeared intensity wave, dimensions are identical to experimental QSIG values
321        // make extra copy of experimental q-values for easy plotting
322        Duplicate/O $gQvals smeared_OEF_SHS,smeared_qvals                               
323        SetScale d,0,0,"1/cm",smeared_OEF_SHS                                                   
324
325        smeared_OEF_SHS := SmearedOblate_SHS(smear_coef_OEF_SHS,$gQvals)               
326        Display smeared_OEF_SHS vs smeared_qvals                                                                       
327        ModifyGraph log=1,marker=29,msize=2,mode=4
328        Label bottom "q (\\S-1\\M)"
329        Label left "Intensity (cm\\S-1\\M)"
330
331        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
332End
333
334Function Oblate_SHS(w,x) : FitFunc
335        Wave w
336        Variable x
337       
338        Variable inten,Ras,Rbs
339        Ras = w[4]      //Ras is the rotation axis
340        Rbs = w[3]
341       
342        //setup form factor coefficient wave
343        Make/O/D/N=8 form_OEF_SHS
344        form_OEF_SHS[0] = 1
345        form_OEF_SHS[1] = w[1]
346        form_OEF_SHS[2] = w[2]
347        form_OEF_SHS[3] = w[3]
348        form_OEF_SHS[4] = w[4]
349        form_OEF_SHS[5] = w[5]
350        form_OEF_SHS[6] = w[6]
351        form_OEF_SHS[7] = 0
352       
353        //setup structure factor coefficient wave
354        Make/O/D/N=4 struct_OEF_SHS
355        struct_OEF_SHS[0] = 0.5*DiamEllip(Ras,Rbs)
356        struct_OEF_SHS[1] = w[0]
357        struct_OEF_SHS[2] = w[7]
358        struct_OEF_SHS[3] = w[8]
359       
360        //calculate each and combine
361        inten = OblateForm(form_OEF_SHS,x)
362        inten *= StickyHS_Struct(struct_OEF_SHS,x)
363        inten *= w[0]
364        inten += w[9]
365       
366        //cleanup waves
367//      Killwaves/Z form_OEF_SHS,struct_OEF_SHS
368       
369        return (inten)
370End
371
372
373// this is all there is to the smeared calculation!
374Function SmearedOblate_HS(w,x) :FitFunc
375        Wave w
376        Variable x
377       
378        Variable ans
379        SVAR sq = gSig_Q
380        SVAR qb = gQ_bar
381        SVAR sh = gShadow
382        SVAR gQ = gQVals
383       
384        //the name of your unsmeared model is the first argument
385        ans = Smear_Model_20(Oblate_HS,$sq,$qb,$sh,$gQ,w,x)
386
387        return(ans)
388End
389
390// this is all there is to the smeared calculation!
391Function SmearedOblate_SW(w,x) :FitFunc
392        Wave w
393        Variable x
394       
395        Variable ans
396        SVAR sq = gSig_Q
397        SVAR qb = gQ_bar
398        SVAR sh = gShadow
399        SVAR gQ = gQVals
400       
401        //the name of your unsmeared model is the first argument
402        ans = Smear_Model_20(Oblate_SW,$sq,$qb,$sh,$gQ,w,x)
403
404        return(ans)
405End
406
407// this is all there is to the smeared calculation!
408Function SmearedOblate_SC(w,x) :FitFunc
409        Wave w
410        Variable x
411       
412        Variable ans
413        SVAR sq = gSig_Q
414        SVAR qb = gQ_bar
415        SVAR sh = gShadow
416        SVAR gQ = gQVals
417       
418        //the name of your unsmeared model is the first argument
419        ans = Smear_Model_20(Oblate_SC,$sq,$qb,$sh,$gQ,w,x)
420
421        return(ans)
422End
423
424// this is all there is to the smeared calculation!
425Function SmearedOblate_SHS(w,x) :FitFunc
426        Wave w
427        Variable x
428       
429        Variable ans
430        SVAR sq = gSig_Q
431        SVAR qb = gQ_bar
432        SVAR sh = gShadow
433        SVAR gQ = gQVals
434       
435        //the name of your unsmeared model is the first argument
436        ans = Smear_Model_20(Oblate_SHS,$sq,$qb,$sh,$gQ,w,x)
437
438        return(ans)
439End
Note: See TracBrowser for help on using the repository browser.