source: sans/Analysis/trunk/Put in User Procedures/SANS_Models_v3.00/UnifEllipsoid_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: 12.6 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2
3// be sure to include all the necessary files...
4
5#include "EffectiveDiameter"
6#include "UniformEllipsoid"
7
8#include "HardSphereStruct"
9#include "HPMSA"
10#include "SquareWellStruct"
11#include "StickyHardSphereStruct"
12
13Proc PlotEllipsoid_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_EOR_HS,ywave_EOR_HS
20        xwave_EOR_HS =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
21        Make/O/D coef_EOR_HS = {0.01,20.,400,3.0e-6,0.01}
22        make/o/t parameters_EOR_HS = {"volume fraction","R(a) rotation axis (A)","R(b) (A)","contrast (A^-2)","incoh. bkg (cm^-1)"}
23        Edit parameters_EOR_HS,coef_EOR_HS
24        ywave_EOR_HS := Ellipsoid_HS(coef_EOR_HS,xwave_EOR_HS)
25        Display ywave_EOR_HS vs xwave_EOR_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        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
30End
31
32Proc PlotSmearedEllipsoid_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_EOR_HS = {0.01,20.,400,3.0e-6,0.01}
43        make/o/t smear_parameters_EOR_HS = {"volume fraction","R(a) rotation axis (A)","R(b) (A)","contrast (A^-2)","incoh. bkg (cm^-1)"}
44        Edit smear_parameters_EOR_HS,smear_coef_EOR_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_EOR_HS,smeared_qvals                               
49        SetScale d,0,0,"1/cm",smeared_EOR_HS                                                   
50
51        smeared_EOR_HS := SmearedEllipsoid_HS(smear_coef_EOR_HS,$gQvals)               
52        Display smeared_EOR_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 Ellipsoid_HS(w,x) : FitFunc
61        Wave w
62        Variable x
63       
64        Variable inten,aa,bb
65        aa=w[1]
66        bb=w[2]
67       
68        //setup form factor coefficient wave
69        Make/O/D/N=5 form_EOR_HS
70        form_EOR_HS[0] = 1
71        form_EOR_HS[1] = w[1]
72        form_EOR_HS[2] = w[2]
73        form_EOR_HS[3] = w[3]
74        form_EOR_HS[4] = 0
75       
76        //setup structure factor coefficient wave
77        Make/O/D/N=2 struct_EOR_HS
78        struct_EOR_HS[0] = 0.5*DiamEllip(aa,bb)
79        struct_EOR_HS[1] = w[0]
80       
81        //calculate each and combine
82        inten = EllipsoidForm(form_EOR_HS,x)
83        inten *= HardSphereStruct(struct_EOR_HS,x)
84        inten *= w[0]
85        inten += w[4]
86       
87        //cleanup waves
88//      Killwaves/Z form_EOR_HS,struct_EOR_HS
89       
90        return (inten)
91End
92
93Proc PlotEllipsoid_SW(num,qmin,qmax)
94        Variable num=128,qmin=0.001,qmax=0.7
95        Prompt num "Enter number of data points for model: "
96        Prompt qmin "Enter minimum q-value (^-1) for model: "
97        Prompt qmax "Enter maximum q-value (^-1) for model: "
98       
99        Make/O/D/n=(num) xwave_EOR_SW,ywave_EOR_SW
100        xwave_EOR_SW =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
101        Make/O/D coef_EOR_SW = {0.01,20.,400,3.0e-6,1.0,1.2,0.01}
102        make/o/t parameters_EOR_SW = {"volume fraction","R(a) rotation axis (A)","R(b) (A)","contrast (A^-2)","well depth (kT)","well width (diam.)","incoh. bkg (cm^-1)"}
103        Edit parameters_EOR_SW,coef_EOR_SW
104        ywave_EOR_SW := Ellipsoid_SW(coef_EOR_SW,xwave_EOR_SW)
105        Display ywave_EOR_SW vs xwave_EOR_SW
106        ModifyGraph log=1,marker=29,msize=2,mode=4
107        Label bottom "q (\\S-1\\M)"
108        Label left "Intensity (cm\\S-1\\M)"
109
110        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
111End
112
113Proc PlotSmearedEllipsoid_SW()                                                         
114        //no input parameters necessary, it MUST use the experimental q-values
115        // from the experimental data read in from an AVE/QSIG data file
116       
117        // if no gQvals wave, data must not have been loaded => abort
118        if(ResolutionWavesMissing())
119                Abort
120        endif
121       
122        // Setup parameter table for model function
123        Make/O/D smear_coef_EOR_SW = {0.01,20.,400,3.0e-6,1.0,1.2,0.01}
124        make/o/t smear_parameters_EOR_SW = {"volume fraction","R(a) rotation axis (A)","R(b) (A)","contrast (A^-2)","well depth (kT)","well width (diam.)","incoh. bkg (cm^-1)"}
125        Edit smear_parameters_EOR_SW,smear_coef_EOR_SW                                 
126       
127        // output smeared intensity wave, dimensions are identical to experimental QSIG values
128        // make extra copy of experimental q-values for easy plotting
129        Duplicate/O $gQvals smeared_EOR_SW,smeared_qvals                               
130        SetScale d,0,0,"1/cm",smeared_EOR_SW                                                   
131
132        smeared_EOR_SW := SmearedEllipsoid_SW(smear_coef_EOR_SW,$gQvals)               
133        Display smeared_EOR_SW vs smeared_qvals                                                                 
134        ModifyGraph log=1,marker=29,msize=2,mode=4
135        Label bottom "q (\\S-1\\M)"
136        Label left "Intensity (cm\\S-1\\M)"
137
138        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
139End
140
141Function Ellipsoid_SW(w,x) : FitFunc
142        Wave w
143        Variable x
144       
145        Variable inten,aa,bb
146        aa=w[1]
147        bb=w[2]
148       
149        //setup form factor coefficient wave
150        Make/O/D/N=5 form_EOR_SW
151        form_EOR_SW[0] = 1
152        form_EOR_SW[1] = w[1]
153        form_EOR_SW[2] = w[2]
154        form_EOR_SW[3] = w[3]
155        form_EOR_SW[4] = 0
156       
157        //setup structure factor coefficient wave
158        Make/O/D/N=4 struct_EOR_SW
159        struct_EOR_SW[0] = 0.5*DiamEllip(aa,bb)
160        struct_EOR_SW[1] = w[0]
161        struct_EOR_SW[2] = w[4]
162        struct_EOR_SW[3] = w[5]
163       
164        //calculate each and combine
165        inten = EllipsoidForm(form_EOR_SW,x)
166        inten *= SquareWellStruct(struct_EOR_SW,x)
167        inten *= w[0]
168        inten += w[6]
169       
170        //cleanup waves
171//      Killwaves/Z form_EOR_SW,struct_EOR_SW
172       
173        return (inten)
174End
175
176Proc PlotEllipsoid_SC(num,qmin,qmax)
177        Variable num=128,qmin=0.001,qmax=0.7
178        Prompt num "Enter number of data points for model: "
179        Prompt qmin "Enter minimum q-value (^-1) for model: "
180        Prompt qmax "Enter maximum q-value (^-1) for model: "
181       
182        if (DataFolderExists("root:HayPenMSA"))
183                Make/O/D/N=17 root:HayPenMSA:gMSAWave
184        else
185                NewDataFolder root:HayPenMSA
186                Make/O/D/N=17 root:HayPenMSA:gMSAWave
187        endif
188       
189        Make/O/D/n=(num) xwave_EOR_SC,ywave_EOR_SC
190        xwave_EOR_SC =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
191        Make/O/D coef_EOR_SC = {0.01,20.,400,3.0e-6,20,0,298,78,0.01}
192        make/o/t parameters_EOR_SC = {"volume fraction","R(a) rotation axis (A)","R(b) (A)","contrast (A^-2)","charge","movalent salt(M)","Temperature (K)","dielectric const","incoh. bkg (cm^-1)"}
193        Edit parameters_EOR_SC,coef_EOR_SC
194        ywave_EOR_SC := Ellipsoid_SC(coef_EOR_SC,xwave_EOR_SC)
195        Display ywave_EOR_SC vs xwave_EOR_SC
196        ModifyGraph log=1,marker=29,msize=2,mode=4
197        Label bottom "q (\\S-1\\M)"
198        Label left "Intensity (cm\\S-1\\M)"
199
200        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
201End
202
203Proc PlotSmearedEllipsoid_SC()                                                         
204        //no input parameters necessary, it MUST use the experimental q-values
205        // from the experimental data read in from an AVE/QSIG data file
206       
207        // if no gQvals wave, data must not have been loaded => abort
208        if(ResolutionWavesMissing())
209                Abort
210        endif
211
212        if (DataFolderExists("root:HayPenMSA"))
213                Make/O/D/N=17 root:HayPenMSA:gMSAWave
214        else
215                NewDataFolder root:HayPenMSA
216                Make/O/D/N=17 root:HayPenMSA:gMSAWave
217        endif
218       
219        // Setup parameter table for model function
220        Make/O/D smear_coef_EOR_SC = {0.01,20.,400,3.0e-6,20,0,298,78,0.01}
221        make/o/t smear_parameters_EOR_SC = {"volume fraction","R(a) rotation axis (A)","R(b) (A)","contrast (A^-2)","charge","movalent salt(M)","Temperature (K)","dielectric const","incoh. bkg (cm^-1)"}
222        Edit smear_parameters_EOR_SC,smear_coef_EOR_SC                                 
223       
224        // output smeared intensity wave, dimensions are identical to experimental QSIG values
225        // make extra copy of experimental q-values for easy plotting
226        Duplicate/O $gQvals smeared_EOR_SC,smeared_qvals                               
227        SetScale d,0,0,"1/cm",smeared_EOR_SC                                                   
228
229        smeared_EOR_SC := SmearedEllipsoid_SC(smear_coef_EOR_SC,$gQvals)               
230        Display smeared_EOR_SC vs smeared_qvals                                                                 
231        ModifyGraph log=1,marker=29,msize=2,mode=4
232        Label bottom "q (\\S-1\\M)"
233        Label left "Intensity (cm\\S-1\\M)"
234
235        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
236End
237
238
239Function Ellipsoid_SC(w,x) : FitFunc
240        Wave w
241        Variable x
242       
243        Variable inten,aa,bb
244        aa=w[1]
245        bb=w[2]
246       
247        //setup form factor coefficient wave
248        Make/O/D/N=5 form_EOR_SC
249        form_EOR_SC[0] = 1
250        form_EOR_SC[1] = w[1]
251        form_EOR_SC[2] = w[2]
252        form_EOR_SC[3] = w[3]
253        form_EOR_SC[4] = 0
254       
255        //setup structure factor coefficient wave
256        Make/O/D/N=6 struct_EOR_SC
257        struct_EOR_SC[0] = DiamEllip(aa,bb)
258        struct_EOR_SC[1] = w[4]
259        struct_EOR_SC[2] = w[0]
260        struct_EOR_SC[3] = w[6]
261        struct_EOR_SC[4] = w[5]
262        struct_EOR_SC[5] = w[7]
263       
264        //calculate each and combine
265        inten = EllipsoidForm(form_EOR_SC,x)
266        inten *= HayterPenfoldMSA(struct_EOR_SC,x)
267        inten *= w[0]
268        inten += w[8]
269       
270        //cleanup waves
271//      Killwaves/Z form_EOR_SC,struct_EOR_SC
272       
273        return (inten)
274End
275
276Proc PlotEllipsoid_SHS(num,qmin,qmax)
277        Variable num=128,qmin=0.001,qmax=0.7
278        Prompt num "Enter number of data points for model: "
279        Prompt qmin "Enter minimum q-value (^-1) for model: "
280        Prompt qmax "Enter maximum q-value (^-1) for model: "
281       
282        Make/O/D/n=(num) xwave_EOR_SHS,ywave_EOR_SHS
283        xwave_EOR_SHS =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
284        Make/O/D coef_EOR_SHS = {0.01,20.,400,3.0e-6,0.05,0.2,0.01}
285        make/o/t parameters_EOR_SHS = {"volume fraction","R(a) rotation axis (A)","R(b) (A)","contrast (A^-2)","perturbation parameter (0.1)","stickiness, tau","incoh. bkg (cm^-1)"}
286        Edit parameters_EOR_SHS,coef_EOR_SHS
287        ywave_EOR_SHS := Ellipsoid_SHS(coef_EOR_SHS,xwave_EOR_SHS)
288        Display ywave_EOR_SHS vs xwave_EOR_SHS
289        ModifyGraph log=1,marker=29,msize=2,mode=4
290        Label bottom "q (\\S-1\\M)"
291        Label left "Intensity (cm\\S-1\\M)"
292
293        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
294End
295
296Proc PlotSmearedEllipsoid_SHS()                                                         
297        //no input parameters necessary, it MUST use the experimental q-values
298        // from the experimental data read in from an AVE/QSIG data file
299       
300        // if no gQvals wave, data must not have been loaded => abort
301        if(ResolutionWavesMissing())
302                Abort
303        endif
304       
305        // Setup parameter table for model function
306        Make/O/D smear_coef_EOR_SHS = {0.01,20.,400,3.0e-6,0.05,0.2,0.01}
307        make/o/t smear_parameters_EOR_SHS = {"volume fraction","R(a) rotation axis (A)","R(b) (A)","contrast (A^-2)","perturbation parameter (0.1)","stickiness, tau","incoh. bkg (cm^-1)"}
308        Edit smear_parameters_EOR_SHS,smear_coef_EOR_SHS                                       
309       
310        // output smeared intensity wave, dimensions are identical to experimental QSIG values
311        // make extra copy of experimental q-values for easy plotting
312        Duplicate/O $gQvals smeared_EOR_SHS,smeared_qvals                               
313        SetScale d,0,0,"1/cm",smeared_EOR_SHS                                                   
314
315        smeared_EOR_SHS := SmearedEllipsoid_SHS(smear_coef_EOR_SHS,$gQvals)             
316        Display smeared_EOR_SHS vs smeared_qvals                                                                       
317        ModifyGraph log=1,marker=29,msize=2,mode=4
318        Label bottom "q (\\S-1\\M)"
319        Label left "Intensity (cm\\S-1\\M)"
320
321        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
322End
323
324Function Ellipsoid_SHS(w,x) : FitFunc
325        Wave w
326        Variable x
327       
328        Variable inten,aa,bb
329        aa=w[1]
330        bb=w[2]
331       
332        //setup form factor coefficient wave
333        Make/O/D/N=5 form_EOR_SHS
334        form_EOR_SHS[0] = 1
335        form_EOR_SHS[1] = w[1]
336        form_EOR_SHS[2] = w[2]
337        form_EOR_SHS[3] = w[3]
338        form_EOR_SHS[4] = 0
339       
340        //setup structure factor coefficient wave
341        Make/O/D/N=4 struct_EOR_SHS
342        struct_EOR_SHS[0] = 0.5*DiamEllip(aa,bb)
343        struct_EOR_SHS[1] = w[0]
344        struct_EOR_SHS[2] = w[4]
345        struct_EOR_SHS[3] = w[5]
346       
347        //calculate each and combine
348        inten = EllipsoidForm(form_EOR_SHS,x)
349        inten *= StickyHS_Struct(struct_EOR_SHS,x)
350        inten *= w[0]
351        inten += w[6]
352       
353        //cleanup waves
354//      Killwaves/Z form_EOR_SHS,struct_EOR_SHS
355       
356        return (inten)
357End
358
359
360
361// this is all there is to the smeared calculation!
362Function SmearedEllipsoid_HS(w,x) :FitFunc
363        Wave w
364        Variable x
365       
366        Variable ans
367        SVAR sq = gSig_Q
368        SVAR qb = gQ_bar
369        SVAR sh = gShadow
370        SVAR gQ = gQVals
371       
372        //the name of your unsmeared model is the first argument
373        ans = Smear_Model_20(Ellipsoid_HS,$sq,$qb,$sh,$gQ,w,x)
374
375        return(ans)
376End
377
378// this is all there is to the smeared calculation!
379Function SmearedEllipsoid_SW(w,x) :FitFunc
380        Wave w
381        Variable x
382       
383        Variable ans
384        SVAR sq = gSig_Q
385        SVAR qb = gQ_bar
386        SVAR sh = gShadow
387        SVAR gQ = gQVals
388       
389        //the name of your unsmeared model is the first argument
390        ans = Smear_Model_20(Ellipsoid_SW,$sq,$qb,$sh,$gQ,w,x)
391
392        return(ans)
393End
394
395// this is all there is to the smeared calculation!
396Function SmearedEllipsoid_SC(w,x) :FitFunc
397        Wave w
398        Variable x
399       
400        Variable ans
401        SVAR sq = gSig_Q
402        SVAR qb = gQ_bar
403        SVAR sh = gShadow
404        SVAR gQ = gQVals
405       
406        //the name of your unsmeared model is the first argument
407        ans = Smear_Model_20(Ellipsoid_SC,$sq,$qb,$sh,$gQ,w,x)
408
409        return(ans)
410End
411
412// this is all there is to the smeared calculation!
413Function SmearedEllipsoid_SHS(w,x) :FitFunc
414        Wave w
415        Variable x
416       
417        Variable ans
418        SVAR sq = gSig_Q
419        SVAR qb = gQ_bar
420        SVAR sh = gShadow
421        SVAR gQ = gQVals
422       
423        //the name of your unsmeared model is the first argument
424        ans = Smear_Model_20(Ellipsoid_SHS,$sq,$qb,$sh,$gQ,w,x)
425
426        return(ans)
427End
Note: See TracBrowser for help on using the repository browser.