source: sans/Release/trunk/NCNR_User_Procedures/SANS/Analysis/Models_v3.00/CoreShell_and_Struct.ipf @ 381

Last change on this file since 381 was 381, checked in by srkline, 15 years ago

Merging Dev/trunk revision 374+ into Release/trunk for version 6.004

File size: 13.1 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2//// include everything that is necessary
3//
4#include "CoreShell"
5
6#include "HardSphereStruct"
7#include "HPMSA"
8#include "SquareWellStruct"
9#include "StickyHardSphereStruct"
10
11Proc PlotCoreShell_HS(num,qmin,qmax)
12        Variable num=256,qmin=0.001,qmax=0.7
13        Prompt num "Enter number of data points for model: "
14        Prompt qmin "Enter minimum q-value (A^-1) for model: "
15        Prompt qmax "Enter maximum q-value (A^-1) for model: "
16       
17        Make/O/D/n=(num) xwave_CSS_HS,ywave_CSS_HS
18        xwave_CSS_HS =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
19        Make/O/D coef_CSS_HS = {0.1,60,10,1e-6,2e-6,3e-6,0.0001}
20        make/o/t parameters_CSS_HS = {"volume fraction","core rad (A)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","bkg (cm-1)"}
21        Edit/K=1 parameters_CSS_HS,coef_CSS_HS
22        ywave_CSS_HS := CoreShell_HS(coef_CSS_HS,xwave_CSS_HS)
23        Display/K=1 ywave_CSS_HS vs xwave_CSS_HS
24        ModifyGraph log=1,marker=29,msize=2,mode=4
25        Label bottom "q (A\\S-1\\M)"
26        Label left "Intensity (cm\\S-1\\M)"
27
28        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
29End
30
31Proc PlotSmearedCoreShell_HS()                                                         
32        //no input parameters necessary, it MUST use the experimental q-values
33        // from the experimental data read in from an AVE/QSIG data file
34       
35        // if no gQvals wave, data must not have been loaded => abort
36        if(ResolutionWavesMissing())
37                Abort
38        endif
39       
40        // Setup parameter table for model function
41        Make/O/D smear_coef_CSS_HS = {0.1,60,10,1e-6,2e-6,3e-6,0.0001}
42        make/o/t smear_parameters_CSS_HS = {"volume fraction","core rad (A)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","bkg (cm-1)"}
43        Edit smear_parameters_CSS_HS,smear_coef_CSS_HS                                 
44       
45        // output smeared intensity wave, dimensions are identical to experimental QSIG values
46        // make extra copy of experimental q-values for easy plotting
47        Duplicate/O $gQvals smeared_CSS_HS,smeared_qvals                               
48        SetScale d,0,0,"1/cm",smeared_CSS_HS                                                   
49
50        smeared_CSS_HS := SmearedCoreShell_HS(smear_coef_CSS_HS,$gQvals)               
51        Display smeared_CSS_HS vs smeared_qvals                                                                 
52        ModifyGraph log=1,marker=29,msize=2,mode=4
53        Label bottom "q (A\\S-1\\M)"
54        Label left "Intensity (cm\\S-1\\M)"
55
56        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
57End
58
59Function CoreShell_HS(w,x) : FitFunc
60        Wave w
61        Variable x
62       
63        Variable inten
64       
65        //setup form factor coefficient wave
66        Make/O/D/N=7 form_CSS_HS
67        form_CSS_HS[0] = 1
68        form_CSS_HS[1] = w[1]
69        form_CSS_HS[2] = w[2]
70        form_CSS_HS[3] = w[3]
71        form_CSS_HS[4] = w[4]
72        form_CSS_HS[5] = w[5]
73        form_CSS_HS[6] = 0
74       
75        //setup structure factor coefficient wave
76        Make/O/D/N=2 struct_CSS_HS
77        struct_CSS_HS[0] = w[1] + w[2]
78        struct_CSS_HS[1] = w[0]
79       
80        //calculate each and combine
81        inten = CoreShellForm(form_CSS_HS,x)
82        inten *= HardSphereStruct(struct_CSS_HS,x)
83        inten *= w[0]
84        inten += w[6]
85       
86        //cleanup waves
87//      Killwaves/Z form_CSS_HS,struct_CSS_HS
88       
89        return (inten)
90End
91
92/////////////////////////////////////////
93Proc PlotCoreShell_SW(num,qmin,qmax)
94        Variable num=256,qmin=0.001,qmax=0.7
95        Prompt num "Enter number of data points for model: "
96        Prompt qmin "Enter minimum q-value (A^-1) for model: "
97        Prompt qmax "Enter maximum q-value (A^-1) for model: "
98       
99        Make/O/D/n=(num) xwave_CSS_SW,ywave_CSS_SW
100        xwave_CSS_SW =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
101        Make/O/D coef_CSS_SW = {0.1,60,10,1e-6,2e-6,3e-6,1.0,1.2,0.0001}
102        make/o/t parameters_CSS_SW = {"volume fraction","core rad (A)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","well depth (kT)","well width (diam.)","bkg (cm-1)"}
103        Edit/K=1 parameters_CSS_SW,coef_CSS_SW
104        ywave_CSS_SW := CoreShell_SW(coef_CSS_SW,xwave_CSS_SW)
105        Display/K=1 ywave_CSS_SW vs xwave_CSS_SW
106        ModifyGraph log=1,marker=29,msize=2,mode=4
107        Label bottom "q (A\\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 PlotSmearedCoreShell_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_CSS_SW = {0.1,60,10,1e-6,2e-6,3e-6,1.0,1.2,0.0001}
124        make/o/t smear_parameters_CSS_SW = {"volume fraction","core rad (A)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","well depth (kT)","well width (diam.)","bkg (cm-1)"}
125        Edit smear_parameters_CSS_SW,smear_coef_CSS_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_CSS_SW,smeared_qvals                               
130        SetScale d,0,0,"1/cm",smeared_CSS_SW                                                   
131
132        smeared_CSS_SW := SmearedCoreShell_SW(smear_coef_CSS_SW,$gQvals)               
133        Display smeared_CSS_SW vs smeared_qvals                                                                 
134        ModifyGraph log=1,marker=29,msize=2,mode=4
135        Label bottom "q (A\\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 CoreShell_SW(w,x) : FitFunc
142        Wave w
143        Variable x
144       
145        Variable inten
146       
147        //setup form factor coefficient wave
148        Make/O/D/N=7 form_CSS_SW
149        form_CSS_SW[0] = 1
150        form_CSS_SW[1] = w[1]
151        form_CSS_SW[2] = w[2]
152        form_CSS_SW[3] = w[3]
153        form_CSS_SW[4] = w[4]
154        form_CSS_SW[5] = w[5]
155        form_CSS_SW[6] = 0
156       
157        //setup structure factor coefficient wave
158        Make/O/D/N=4 struct_CSS_SW
159        struct_CSS_SW[0] = w[1] + w[2]
160        struct_CSS_SW[1] = w[0]
161        struct_CSS_SW[2] = w[6]
162        struct_CSS_SW[3] = w[7]
163       
164        //calculate each and combine
165        inten = CoreShellForm(form_CSS_SW,x)
166        inten *= SquareWellStruct(struct_CSS_SW,x)
167        inten *= w[0]
168        inten += w[8]
169       
170        //cleanup waves
171//      Killwaves/Z form_CSS_SW,struct_CSS_SW
172       
173        return (inten)
174End
175
176
177/////////////////////////////////////////
178Proc PlotCoreShell_SC(num,qmin,qmax)
179        Variable num=256,qmin=0.001,qmax=0.7
180        Prompt num "Enter number of data points for model: "
181        Prompt qmin "Enter minimum q-value (A^-1) for model: "
182        Prompt qmax "Enter maximum q-value (A^-1) for model: "
183       
184        if (DataFolderExists("root:HayPenMSA"))
185                Make/O/D/N=17 root:HayPenMSA:gMSAWave
186        else
187                NewDataFolder root:HayPenMSA
188                Make/O/D/N=17 root:HayPenMSA:gMSAWave
189        endif
190       
191        Make/O/D/n=(num) xwave_CSS_SC,ywave_CSS_SC
192        xwave_CSS_SC = alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
193        Make/O/D coef_CSS_SC = {0.1,60,10,1e-6,2e-6,3e-6,10,0,298,78,0.0001}
194        make/o/t parameters_CSS_SC = {"volume fraction","core rad (A)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","charge","Monovalent salt (M)","Temperature (K)","dielectric const.","bkg (cm-1)"}
195        Edit/K=1 parameters_CSS_SC,coef_CSS_SC
196        ywave_CSS_SC := CoreShell_SC(coef_CSS_SC,xwave_CSS_SC)
197        Display/K=1 ywave_CSS_SC vs xwave_CSS_SC
198        ModifyGraph log=1,marker=29,msize=2,mode=4
199        Label bottom "q (A\\S-1\\M)"
200        Label left "Intensity (cm\\S-1\\M)"
201
202        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
203End
204
205Proc PlotSmearedCoreShell_SC()                                                         
206        //no input parameters necessary, it MUST use the experimental q-values
207        // from the experimental data read in from an AVE/QSIG data file
208       
209        // if no gQvals wave, data must not have been loaded => abort
210        if(ResolutionWavesMissing())
211                Abort
212        endif
213       
214        if (DataFolderExists("root:HayPenMSA"))
215                Make/O/D/N=17 root:HayPenMSA:gMSAWave
216        else
217                NewDataFolder root:HayPenMSA
218                Make/O/D/N=17 root:HayPenMSA:gMSAWave
219        endif
220       
221        // Setup parameter table for model function
222        Make/O/D smear_coef_CSS_SC = {0.1,60,10,1e-6,2e-6,3e-6,10,0,298,78,0.0001}
223        make/o/t smear_parameters_CSS_SC = {"volume fraction","core rad (A)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","charge","Monovalent salt (M)","Temperature (K)","dielectric const.","bkg (cm-1)"}
224        Edit smear_parameters_CSS_SC,smear_coef_CSS_SC                                 
225       
226        // output smeared intensity wave, dimensions are identical to experimental QSIG values
227        // make extra copy of experimental q-values for easy plotting
228        Duplicate/O $gQvals smeared_CSS_SC,smeared_qvals                               
229        SetScale d,0,0,"1/cm",smeared_CSS_SC                                                   
230
231        smeared_CSS_SC := SmearedCoreShell_SC(smear_coef_CSS_SC,$gQvals)               
232        Display smeared_CSS_SC vs smeared_qvals                                                                 
233        ModifyGraph log=1,marker=29,msize=2,mode=4
234        Label bottom "q (A\\S-1\\M)"
235        Label left "Intensity (cm\\S-1\\M)"
236
237        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
238End
239
240Function CoreShell_SC(w,x) : FitFunc
241        Wave w
242        Variable x
243       
244        Variable inten
245       
246        //setup form factor coefficient wave
247        Make/O/D/N=7 form_CSS_SC
248        form_CSS_SC[0] = 1
249        form_CSS_SC[1] = w[1]
250        form_CSS_SC[2] = w[2]
251        form_CSS_SC[3] = w[3]
252        form_CSS_SC[4] = w[4]
253        form_CSS_SC[5] = w[5]
254        form_CSS_SC[6] = 0
255       
256        //setup structure factor coefficient wave
257        Make/O/D/N=6 struct_CSS_SC
258        struct_CSS_SC[0] = 2*(w[1]+w[2])
259        struct_CSS_SC[1] = w[6]
260        struct_CSS_SC[2] = w[0]
261        struct_CSS_SC[3] = w[8]
262        struct_CSS_SC[4] = w[7]
263        struct_CSS_SC[5] = w[9]
264       
265        //calculate each and combine
266        inten = CoreShellForm(form_CSS_SC,x)
267        inten *= HayterPenfoldMSA(struct_CSS_SC,x)
268        inten *= w[0]
269        inten += w[10]
270       
271        //cleanup waves
272//      Killwaves/Z form_CSS_SC,struct_CSS_SC
273       
274        return (inten)
275End
276
277/////////////////////////////////////////
278Proc PlotCoreShell_SHS(num,qmin,qmax)
279        Variable num=256,qmin=0.001,qmax=0.7
280        Prompt num "Enter number of data points for model: "
281        Prompt qmin "Enter minimum q-value (A^-1) for model: "
282        Prompt qmax "Enter maximum q-value (A^-1) for model: "
283       
284        Make/O/D/n=(num) xwave_CSS_SHS,ywave_CSS_SHS
285        xwave_CSS_SHS =  alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
286        Make/O/D coef_CSS_SHS = {0.1,60,10,1e-6,2e-6,3e-6,0.05,0.2,0.0001}
287        make/o/t parameters_CSS_SHS = {"volume fraction","core rad (A)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","perturbation parameter (0.1)","stickiness, tau","bkg (cm-1)"}
288        Edit/K=1 parameters_CSS_SHS,coef_CSS_SHS
289        ywave_CSS_SHS := CoreShell_SHS(coef_CSS_SHS,xwave_CSS_SHS)
290        Display/K=1 ywave_CSS_SHS vs xwave_CSS_SHS
291        ModifyGraph log=1,marker=29,msize=2,mode=4
292        Label bottom "q (A\\S-1\\M)"
293        Label left "Intensity (cm\\S-1\\M)"
294
295        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
296End
297
298Proc PlotSmearedCoreShell_SHS()                                                         
299        //no input parameters necessary, it MUST use the experimental q-values
300        // from the experimental data read in from an AVE/QSIG data file
301       
302        // if no gQvals wave, data must not have been loaded => abort
303        if(ResolutionWavesMissing())
304                Abort
305        endif
306       
307        // Setup parameter table for model function
308        Make/O/D smear_coef_CSS_SHS = {0.1,60,10,1e-6,2e-6,3e-6,0.05,0.2,0.0001}
309        make/o/t smear_parameters_CSS_SHS = {"volume fraction","core rad (A)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","perturbation parameter (0.1)","stickiness, tau","bkg (cm-1)"}
310        Edit smear_parameters_CSS_SHS,smear_coef_CSS_SHS                                       
311       
312        // output smeared intensity wave, dimensions are identical to experimental QSIG values
313        // make extra copy of experimental q-values for easy plotting
314        Duplicate/O $gQvals smeared_CSS_SHS,smeared_qvals                               
315        SetScale d,0,0,"1/cm",smeared_CSS_SHS                                                   
316
317        smeared_CSS_SHS := SmearedCoreShell_SHS(smear_coef_CSS_SHS,$gQvals)             
318        Display smeared_CSS_SHS vs smeared_qvals                                                                       
319        ModifyGraph log=1,marker=29,msize=2,mode=4
320        Label bottom "q (A\\S-1\\M)"
321        Label left "Intensity (cm\\S-1\\M)"
322
323        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
324End
325
326Function CoreShell_SHS(w,x) : FitFunc
327        Wave w
328        Variable x
329       
330        Variable inten
331       
332        //setup form factor coefficient wave
333        Make/O/D/N=7 form_CSS_SHS
334        form_CSS_SHS[0] = 1
335        form_CSS_SHS[1] = w[1]
336        form_CSS_SHS[2] = w[2]
337        form_CSS_SHS[3] = w[3]
338        form_CSS_SHS[4] = w[4]
339        form_CSS_SHS[5] = w[5]
340        form_CSS_SHS[6] = 0
341       
342        //setup structure factor coefficient wave
343        Make/O/D/N=4 struct_CSS_SHS
344        struct_CSS_SHS[0] = w[1] + w[2]
345        struct_CSS_SHS[1] = w[0]
346        struct_CSS_SHS[2] = w[6]
347        struct_CSS_SHS[3] = w[7]
348       
349        //calculate each and combine
350        inten = CoreShellForm(form_CSS_SHS,x)
351        inten *= StickyHS_Struct(struct_CSS_SHS,x)
352        inten *= w[0]
353        inten += w[8]
354       
355        //cleanup waves
356//      Killwaves/Z form_CSS_SHS,struct_CSS_SHS
357       
358        return (inten)
359End
360
361
362
363// this is all there is to the smeared calculation!
364Function SmearedCoreShell_HS(w,x) :FitFunc
365        Wave w
366        Variable x
367       
368        Variable ans
369        SVAR sq = gSig_Q
370        SVAR qb = gQ_bar
371        SVAR sh = gShadow
372        SVAR gQ = gQVals
373       
374        //the name of your unsmeared model is the first argument
375        ans = Smear_Model_20(CoreShell_HS,$sq,$qb,$sh,$gQ,w,x)
376
377        return(ans)
378End
379
380// this is all there is to the smeared calculation!
381Function SmearedCoreShell_SW(w,x) :FitFunc
382        Wave w
383        Variable x
384       
385        Variable ans
386        SVAR sq = gSig_Q
387        SVAR qb = gQ_bar
388        SVAR sh = gShadow
389        SVAR gQ = gQVals
390       
391        //the name of your unsmeared model is the first argument
392        ans = Smear_Model_20(CoreShell_SW,$sq,$qb,$sh,$gQ,w,x)
393
394        return(ans)
395End
396
397// this is all there is to the smeared calculation!
398Function SmearedCoreShell_SC(w,x) :FitFunc
399        Wave w
400        Variable x
401       
402        Variable ans
403        SVAR sq = gSig_Q
404        SVAR qb = gQ_bar
405        SVAR sh = gShadow
406        SVAR gQ = gQVals
407       
408        //the name of your unsmeared model is the first argument
409        ans = Smear_Model_20(CoreShell_SC,$sq,$qb,$sh,$gQ,w,x)
410
411        return(ans)
412End
413
414// this is all there is to the smeared calculation!
415Function SmearedCoreShell_SHS(w,x) :FitFunc
416        Wave w
417        Variable x
418       
419        Variable ans
420        SVAR sq = gSig_Q
421        SVAR qb = gQ_bar
422        SVAR sh = gShadow
423        SVAR gQ = gQVals
424       
425        //the name of your unsmeared model is the first argument
426        ans = Smear_Model_20(CoreShell_SHS,$sq,$qb,$sh,$gQ,w,x)
427
428        return(ans)
429End
Note: See TracBrowser for help on using the repository browser.