source: sans/Analysis/trunk/Put in User Procedures/SANS_Models_v3.00/Cylinder_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#include "EffectiveDiameter"
5#include "CylinderForm"
6
7#include "HardSphereStruct"
8#include "HPMSA"
9#include "SquareWellStruct"
10#include "StickyHardSphereStruct"
11
12Proc PlotCylinder_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_CYL_HS,ywave_CYL_HS
19        xwave_CYL_HS =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
20        Make/O/D coef_CYL_HS = {0.01,20.,400,3.0e-6,0.01}
21        make/o/t parameters_CYL_HS = {"volume fraction","radius (A)","length (A)","contrast (A^-2)","incoh. bkg (cm^-1)"}
22        Edit parameters_CYL_HS,coef_CYL_HS
23        ywave_CYL_HS := Cylinder_HS(coef_CYL_HS,xwave_CYL_HS)
24        Display ywave_CYL_HS vs xwave_CYL_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 PlotSmearedCylinder_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_CYL_HS = {0.01,20.,400,3.0e-6,0.01}
43        make/o/t smear_parameters_CYL_HS = {"volume fraction","radius (A)","length (A)","contrast (A^-2)","incoh. bkg (cm^-1)"}
44        Edit smear_parameters_CYL_HS,smear_coef_CYL_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_CYL_HS,smeared_qvals                               
49        SetScale d,0,0,"1/cm",smeared_CYL_HS                                                   
50
51        smeared_CYL_HS := SmearedCylinder_HS(smear_coef_CYL_HS,$gQvals)         
52        Display smeared_CYL_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 Cylinder_HS(w,x) : FitFunc
61        Wave w
62        Variable x
63       
64        Variable inten,rad,len
65        rad=w[1]
66        len=w[2]
67       
68        //setup form factor coefficient wave
69        Make/O/D/N=5 form_CYL_HS
70        form_CYL_HS[0] = 1
71        form_CYL_HS[1] = w[1]
72        form_CYL_HS[2] = w[2]
73        form_CYL_HS[3] = w[3]
74        form_CYL_HS[4] = 0
75       
76        //setup structure factor coefficient wave
77        Make/O/D/N=2 struct_CYL_HS
78        struct_CYL_HS[0] = 0.5*DiamCyl(len,rad)
79        struct_CYL_HS[1] = w[0]
80       
81        //calculate each and combine
82        inten = CylinderForm(form_CYL_HS,x)
83        inten *= HardSphereStruct(struct_CYL_HS,x)
84        inten *= w[0]
85        inten += w[4]
86       
87        //cleanup waves (don't do this - it takes a lot of time...)
88//      Killwaves/Z form_CYL_HS,struct_CYL_HS
89       
90        return (inten)
91End
92
93Proc PlotCylinder_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_CYL_SW,ywave_CYL_SW
100        xwave_CYL_SW =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
101        Make/O/D coef_CYL_SW = {0.01,20.,400,3.0e-6,1.0,1.2,0.01}
102        make/o/t parameters_CYL_SW = {"volume fraction","radius (A)","length (A)","contrast (A^-2)","well depth (kT)","well width (diam.)","incoh. bkg (cm^-1)"}
103        Edit parameters_CYL_SW,coef_CYL_SW
104        ywave_CYL_SW := Cylinder_SW(coef_CYL_SW,xwave_CYL_SW)
105        Display ywave_CYL_SW vs xwave_CYL_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 PlotSmearedCylinder_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_CYL_SW = {0.01,20.,400,3.0e-6,1.0,1.2,0.01}
124        make/o/t smear_parameters_CYL_SW = {"volume fraction","radius (A)","length (A)","contrast (A^-2)","well depth (kT)","well width (diam.)","incoh. bkg (cm^-1)"}
125        Edit smear_parameters_CYL_SW,smear_coef_CYL_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_CYL_SW,smeared_qvals                               
130        SetScale d,0,0,"1/cm",smeared_CYL_SW                                                   
131
132        smeared_CYL_SW := SmearedCylinder_SW(smear_coef_CYL_SW,$gQvals)         
133        Display smeared_CYL_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 Cylinder_SW(w,x) : FitFunc
142        Wave w
143        Variable x
144       
145        Variable inten,rad,len
146        rad=w[1]
147        len=w[2]
148       
149        //setup form factor coefficient wave
150        Make/O/D/N=5 form_CYL_SW
151        form_CYL_SW[0] = 1
152        form_CYL_SW[1] = w[1]
153        form_CYL_SW[2] = w[2]
154        form_CYL_SW[3] = w[3]
155        form_CYL_SW[4] = 0
156       
157        //setup structure factor coefficient wave
158        Make/O/D/N=4 struct_CYL_SW
159        struct_CYL_SW[0] = 0.5*DiamCyl(len,rad)
160        struct_CYL_SW[1] = w[0]
161        struct_CYL_SW[2] = w[4]
162        struct_CYL_SW[3] = w[5]
163       
164        //calculate each and combine
165        inten = CylinderForm(form_CYL_SW,x)
166        inten *= SquareWellStruct(struct_CYL_SW,x)
167        inten *= w[0]
168        inten += w[6]
169       
170        //cleanup waves
171//      Killwaves/Z form_CYL_SW,struct_CYL_SW
172       
173        return (inten)
174End
175
176Proc PlotCylinder_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_CYL_SC,ywave_CYL_SC
190        xwave_CYL_SC =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
191        Make/O/D coef_CYL_SC = {0.01,20.,400,3.0e-6,20,0,298,78,0.01}
192        make/o/t parameters_CYL_SC = {"volume fraction","radius (A)","length (A)","contrast (A^-2)","charge","movalent salt(M)","Temperature (K)","dielectric const","incoh. bkg (cm^-1)"}
193        Edit parameters_CYL_SC,coef_CYL_SC
194        ywave_CYL_SC := Cylinder_SC(coef_CYL_SC,xwave_CYL_SC)
195        Display ywave_CYL_SC vs xwave_CYL_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 PlotSmearedCylinder_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_CYL_SC = {0.01,20.,400,3.0e-6,20,0,298,78,0.01}
221        make/o/t smear_parameters_CYL_SC = {"volume fraction","radius (A)","length (A)","contrast (A^-2)","charge","movalent salt(M)","Temperature (K)","dielectric const","incoh. bkg (cm^-1)"}
222        Edit smear_parameters_CYL_SC,smear_coef_CYL_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_CYL_SC,smeared_qvals                               
227        SetScale d,0,0,"1/cm",smeared_CYL_SC                                                   
228
229        smeared_CYL_SC := SmearedCylinder_SC(smear_coef_CYL_SC,$gQvals)         
230        Display smeared_CYL_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
238Function Cylinder_SC(w,x) : FitFunc
239        Wave w
240        Variable x
241       
242        Variable inten,rad,len
243        rad=w[1]
244        len=w[2]
245       
246        //setup form factor coefficient wave
247        Make/O/D/N=5 form_CYL_SC
248        form_CYL_SC[0] = 1
249        form_CYL_SC[1] = w[1]
250        form_CYL_SC[2] = w[2]
251        form_CYL_SC[3] = w[3]
252        form_CYL_SC[4] = 0
253       
254        //setup structure factor coefficient wave
255        Make/O/D/N=6 struct_CYL_SC
256        struct_CYL_SC[0] = DiamCyl(len,rad)
257        struct_CYL_SC[1] = w[4]
258        struct_CYL_SC[2] = w[0]
259        struct_CYL_SC[3] = w[6]
260        struct_CYL_SC[4] = w[5]
261        struct_CYL_SC[5] = w[7]
262       
263        //calculate each and combine
264        inten = CylinderForm(form_CYL_SC,x)
265        inten *= HayterPenfoldMSA(struct_CYL_SC,x)
266        inten *= w[0]
267        inten += w[8]
268       
269        //cleanup waves
270//      Killwaves/Z form_CYL_SC,struct_CYL_SC
271       
272        return (inten)
273End
274
275
276Proc PlotCylinder_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_CYL_SHS,ywave_CYL_SHS
283        xwave_CYL_SHS =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
284        Make/O/D coef_CYL_SHS = {0.01,20.0,400,3.0e-6,0.05,0.2,0.01}
285        make/o/t parameters_CYL_SHS = {"volume fraction","radius (A)","length (A)","contrast (A^-2)","perturbation parameter (0.1)","stickiness, tau","incoh. bkg (cm^-1)"}
286        Edit parameters_CYL_SHS,coef_CYL_SHS
287        ywave_CYL_SHS := Cylinder_SHS(coef_CYL_SHS,xwave_CYL_SHS)
288        Display ywave_CYL_SHS vs xwave_CYL_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 PlotSmearedCylinder_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_CYL_SHS = {0.01,20.0,400,3.0e-6,0.05,0.2,0.01}
307        make/o/t smear_parameters_CYL_SHS = {"volume fraction","radius (A)","length (A)","contrast (A^-2)","perturbation parameter (0.1)","stickiness, tau","incoh. bkg (cm^-1)"}
308        Edit smear_parameters_CYL_SHS,smear_coef_CYL_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_CYL_SHS,smeared_qvals                               
313        SetScale d,0,0,"1/cm",smeared_CYL_SHS                                                   
314
315        smeared_CYL_SHS := SmearedCylinder_SHS(smear_coef_CYL_SHS,$gQvals)             
316        Display smeared_CYL_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 Cylinder_SHS(w,x) : FitFunc
325        Wave w
326        Variable x
327       
328        Variable inten,rad,len
329        rad=w[1]
330        len=w[2]
331       
332        //setup form factor coefficient wave
333        Make/O/D/N=5 form_CYL_SHS
334        form_CYL_SHS[0] = 1
335        form_CYL_SHS[1] = w[1]
336        form_CYL_SHS[2] = w[2]
337        form_CYL_SHS[3] = w[3]
338        form_CYL_SHS[4] = 0
339       
340        //setup structure factor coefficient wave
341        Make/O/D/N=4 struct_CYL_SHS
342        struct_CYL_SHS[0] = 0.5*DiamCyl(len,rad)
343        struct_CYL_SHS[1] = w[0]
344        struct_CYL_SHS[2] = w[4]
345        struct_CYL_SHS[3] = w[5]
346       
347        //calculate each and combine
348        inten = CylinderForm(form_CYL_SHS,x)
349        inten *= StickyHS_Struct(struct_CYL_SHS,x)
350        inten *= w[0]
351        inten += w[6]
352       
353        //cleanup waves
354//      Killwaves/Z form_CYL_SHS,struct_CYL_SHS
355       
356        return (inten)
357End
358
359
360
361// this is all there is to the smeared calculation!
362Function SmearedCylinder_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(Cylinder_HS,$sq,$qb,$sh,$gQ,w,x)
374
375        return(ans)
376End
377
378// this is all there is to the smeared calculation!
379Function SmearedCylinder_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(Cylinder_SW,$sq,$qb,$sh,$gQ,w,x)
391
392        return(ans)
393End
394
395// this is all there is to the smeared calculation!
396Function SmearedCylinder_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(Cylinder_SC,$sq,$qb,$sh,$gQ,w,x)
408
409        return(ans)
410End
411
412// this is all there is to the smeared calculation!
413Function SmearedCylinder_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(Cylinder_SHS,$sq,$qb,$sh,$gQ,w,x)
425
426        return(ans)
427End
Note: See TracBrowser for help on using the repository browser.