source: sans/Dev/trunk/NCNR_User_Procedures/Analysis/Models/NewModels_2006/LogNormalSphere_Sq_v40.ipf @ 774

Last change on this file since 774 was 774, checked in by srkline, 12 years ago

Added the Two-Yukawa structure factor calculations to those model functions with S(Q).

Fixed the name of Vesicle_UL_Sq.ipf to be consistent.

File size: 22.4 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma IgorVersion=6.1
3
4//
5// be sure to include all of the necessary files
6//
7#include "LogNormalSphere_v40"
8
9#include "HardSphereStruct_v40"
10#include "HPMSA_v40"
11#include "SquareWellStruct_v40"
12#include "StickyHardSphereStruct_v40"
13#include "Two_Yukawa_v40"
14
15
16Proc PlotLogNormalSphere_HS(num,qmin,qmax)
17        Variable num=128,qmin=0.001,qmax=0.7
18        Prompt num "Enter number of data points for model: "
19        Prompt qmin "Enter minimum q-value (A^-1) for model: "
20        Prompt qmax "Enter maximum q-value (A^-1) for model: "
21       
22        Make/O/D/N=(num) xwave_lns_HS,ywave_lns_HS
23        xwave_lns_HS = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) )
24        Make/O/D coef_lns_HS = {0.01,60,0.2,1e-6,3e-6,0.001}
25        make/O/T parameters_lns_HS = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","bkg (cm-1 sr-1)"}
26        Edit parameters_lns_HS,coef_lns_HS
27       
28        Variable/G root:g_lns_HS
29        g_lns_HS := LogNormalSphere_HS(coef_lns_HS,ywave_lns_HS,xwave_lns_HS)
30        Display ywave_lns_HS vs xwave_lns_HS
31        ModifyGraph log=1,marker=29,msize=2,mode=4
32        Label bottom "q (A\\S-1\\M)"
33        Label left "Intensity (cm\\S-1\\M)"
34        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
35       
36        AddModelToStrings("LogNormalSphere_HS","coef_lns_HS","parameters_lns_HS","lns_HS")
37End
38
39// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
40Proc PlotSmearedLogNormalSphere_HS(str)                                                         
41        String str
42        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
43       
44        // if any of the resolution waves are missing => abort
45        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
46                Abort
47        endif
48       
49        SetDataFolder $("root:"+str)
50       
51        // Setup parameter table for model function
52        Make/O/D smear_coef_lns_HS = {0.01,60,0.2,1e-6,3e-6,0.001}                                     
53        make/o/t smear_parameters_lns_HS = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","bkg (cm-1 sr-1)"} 
54        Edit smear_parameters_lns_HS,smear_coef_lns_HS                                 
55       
56        // output smeared intensity wave, dimensions are identical to experimental QSIG values
57        // make extra copy of experimental q-values for easy plotting
58        Duplicate/O $(str+"_q") smeared_lns_HS,smeared_qvals                           
59        SetScale d,0,0,"1/cm",smeared_lns_HS                                                   
60                                       
61        Variable/G gs_lns_HS=0
62        gs_lns_HS := fSmearedLogNormalSphere_HS(smear_coef_lns_HS,smeared_lns_HS,smeared_qvals) //this wrapper fills the STRUCT
63       
64        Display smeared_lns_HS vs smeared_qvals                                                                 
65        ModifyGraph log=1,marker=29,msize=2,mode=4
66        Label bottom "q (A\\S-1\\M)"
67        Label left "Intensity (cm\\S-1\\M)"
68        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
69       
70        SetDataFolder root:
71        AddModelToStrings("SmearedLogNormalSphere_HS","smear_coef_lns_HS","smear_parameters_lns_HS","lns_HS")
72End
73       
74
75Function LogNormalSphere_HS(w,yw,xw) : FitFunc
76        Wave w,yw,xw
77       
78        Variable inten
79       
80        //setup form factor coefficient wave
81        Make/O/D/N=6 form_lns_HS
82        form_lns_HS[0] = 1
83        form_lns_HS[1] = w[1]
84        form_lns_HS[2] = w[2]
85        form_lns_HS[3] = w[3]
86        form_lns_HS[4] = w[4]
87        form_lns_HS[5] = 0
88       
89        //calculate the diameter of the effective one-component sphere
90        Variable r3,mu,sig,diam
91        sig = w[2]                              //polydispersity
92        mu = ln(w[1])                   //ln of mean radius
93        r3 = exp(3*mu + 9/2*sig^2)              // <R^3> calculated directly for log-normal distr.
94       
95        diam = 2*(r3)^(1/3)
96       
97       
98        //setup structure factor coefficient wave
99        Make/O/D/N=2 struct_lns_HS
100        struct_lns_HS[0] = diam/2
101        struct_lns_HS[1] = w[0]
102       
103        //calculate each and combine
104        Duplicate/O xw tmp_lns_HS_PQ,tmp_lns_HS_SQ
105        LogNormalSphere(form_lns_HS,tmp_lns_HS_PQ,xw)
106        HardSphereStruct(struct_lns_HS,tmp_lns_HS_SQ,xw)
107        yw = tmp_lns_HS_PQ *tmp_lns_HS_SQ
108        yw *= w[0]
109        yw += w[5]
110       
111        //cleanup waves
112//      Killwaves/Z form_lns_HS,struct_lns_HS
113       
114        return (0)
115End
116
117/////////////////////////////////////////
118Proc PlotLogNormalSphere_SW(num,qmin,qmax)
119        Variable num=128,qmin=0.001,qmax=0.7
120        Prompt num "Enter number of data points for model: "
121        Prompt qmin "Enter minimum q-value (A^-1) for model: "
122        Prompt qmax "Enter maximum q-value (A^-1) for model: "
123       
124        Make/O/D/N=(num) xwave_lns_SW,ywave_lns_SW
125        xwave_lns_SW = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) )
126        Make/O/D coef_lns_SW = {0.01,60,0.2,1e-6,3e-6,1.0,1.2,0.001}
127        make/O/T parameters_lns_SW = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","well depth (kT)","well width (diam.)","bkg (cm-1 sr-1)"}
128        Edit parameters_lns_SW,coef_lns_SW
129       
130        Variable/G root:g_lns_SW
131        g_lns_SW := LogNormalSphere_SW(coef_lns_SW,ywave_lns_SW,xwave_lns_SW)
132        Display ywave_lns_SW vs xwave_lns_SW
133        ModifyGraph log=1,marker=29,msize=2,mode=4
134        Label bottom "q (A\\S-1\\M)"
135        Label left "Intensity (cm\\S-1\\M)"
136        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
137       
138        AddModelToStrings("LogNormalSphere_SW","coef_lns_SW","parameters_lns_SW","lns_SW")
139End
140
141// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
142Proc PlotSmearedLogNormalSphere_SW(str)                                                         
143        String str
144        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
145       
146        // if any of the resolution waves are missing => abort
147        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
148                Abort
149        endif
150       
151        SetDataFolder $("root:"+str)
152       
153        // Setup parameter table for model function
154        Make/O/D smear_coef_lns_SW = {0.01,60,0.2,1e-6,3e-6,1.0,1.2,0.001}                                     
155        make/o/t smear_parameters_lns_SW = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","well depth (kT)","well width (diam.)","bkg (cm-1 sr-1)"}   
156        Edit smear_parameters_lns_SW,smear_coef_lns_SW                                 
157       
158        // output smeared intensity wave, dimensions are identical to experimental QSIG values
159        // make extra copy of experimental q-values for easy plotting
160        Duplicate/O $(str+"_q") smeared_lns_SW,smeared_qvals                           
161        SetScale d,0,0,"1/cm",smeared_lns_SW                                                   
162                                       
163        Variable/G gs_lns_SW=0
164        gs_lns_SW := fSmearedLogNormalSphere_SW(smear_coef_lns_SW,smeared_lns_SW,smeared_qvals) //this wrapper fills the STRUCT
165       
166        Display smeared_lns_SW vs smeared_qvals                                                                 
167        ModifyGraph log=1,marker=29,msize=2,mode=4
168        Label bottom "q (A\\S-1\\M)"
169        Label left "Intensity (cm\\S-1\\M)"
170        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
171       
172        SetDataFolder root:
173        AddModelToStrings("SmearedLogNormalSphere_SW","smear_coef_lns_SW","smear_parameters_lns_SW","lns_SW")
174End
175       
176
177Function LogNormalSphere_SW(w,yw,xw) : FitFunc
178        Wave w,yw,xw
179       
180        Variable inten
181       
182        //setup form factor coefficient wave
183        Make/O/D/N=6 form_lns_SW
184        form_lns_SW[0] = 1
185        form_lns_SW[1] = w[1]
186        form_lns_SW[2] = w[2]
187        form_lns_SW[3] = w[3]
188        form_lns_SW[4] = w[4]
189        form_lns_SW[5] = 0
190       
191        //calculate the diameter of the effective one-component sphere
192        Variable r3,mu,sig,diam
193        sig = w[2]                              //polydispersity
194        mu = ln(w[1])                   //ln of mean radius
195        r3 = exp(3*mu + 9/2*sig^2)              // <R^3> calculated directly for log-normal distr.
196       
197        diam = 2*(r3)^(1/3)
198       
199        //setup structure factor coefficient wave
200        Make/O/D/N=4 struct_lns_SW
201        struct_lns_SW[0] = diam/2
202        struct_lns_SW[1] = w[0]
203        struct_lns_SW[2] = w[5]
204        struct_lns_SW[3] = w[6]
205       
206        //calculate each and combine
207        Duplicate/O xw tmp_lns_SW_PQ,tmp_lns_SW_SQ
208        LogNormalSphere(form_lns_SW,tmp_lns_SW_PQ,xw)
209        SquareWellStruct(struct_lns_SW,tmp_lns_SW_SQ,xw)
210        yw = tmp_lns_SW_PQ * tmp_lns_SW_SQ
211        yw *= w[0]
212        yw += w[7]
213       
214        //cleanup waves
215//      Killwaves/Z form_lns_SW,struct_lns_SW
216       
217        return (0)
218End
219
220
221/////////////////////////////////////////
222Proc PlotLogNormalSphere_SC(num,qmin,qmax)
223        Variable num=256,qmin=0.001,qmax=0.7
224        Prompt num "Enter number of data points for model: "
225        Prompt qmin "Enter minimum q-value (A^-1) for model: "
226        Prompt qmax "Enter maximum q-value (A^-1) for model: "
227       
228        if(!DataFolderExists(":HayPenMSA"))
229                NewDataFolder :HayPenMSA
230        endif
231        Make/O/D/N=17 :HayPenMSA:gMSAWave
232
233        Make/O/D/N=(num) xwave_lns_SC,ywave_lns_SC
234        xwave_lns_SC = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) )
235        Make/O/D coef_lns_SC = {0.01,60,0.2,1e-6,3e-6,20,0,298,78,0.001}
236        make/O/T parameters_lns_SC = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","charge","movalent salt(M)","Temperature (K)","dielectric const","bkg (cm-1 sr-1)"}
237        Edit parameters_lns_SC,coef_lns_SC
238       
239        Variable/G root:g_lns_SC
240        g_lns_SC := LogNormalSphere_SC(coef_lns_SC,ywave_lns_SC,xwave_lns_SC)
241        Display ywave_lns_SC vs xwave_lns_SC
242        ModifyGraph log=1,marker=29,msize=2,mode=4
243        Label bottom "q (A\\S-1\\M)"
244        Label left "Intensity (cm\\S-1\\M)"
245        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
246       
247        AddModelToStrings("LogNormalSphere_SC","coef_lns_SC","parameters_lns_SC","lns_SC")
248End
249
250// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
251Proc PlotSmearedLogNormalSphere_SC(str)                                                         
252        String str
253        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
254       
255        // if any of the resolution waves are missing => abort
256        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
257                Abort
258        endif
259       
260        SetDataFolder $("root:"+str)
261       
262        if(!DataFolderExists(":HayPenMSA"))
263                NewDataFolder :HayPenMSA
264        endif
265        Make/O/D/N=17 :HayPenMSA:gMSAWave
266       
267        // Setup parameter table for model function
268        Make/O/D smear_coef_lns_SC = {0.01,60,0.2,1e-6,3e-6,20,0,298,78,0.001}                                 
269        make/o/t smear_parameters_lns_SC = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","charge","movalent salt(M)","Temperature (K)","dielectric const","bkg (cm-1 sr-1)"}
270        Edit smear_parameters_lns_SC,smear_coef_lns_SC                                 
271       
272        // output smeared intensity wave, dimensions are identical to experimental QSIG values
273        // make extra copy of experimental q-values for easy plotting
274        Duplicate/O $(str+"_q") smeared_lns_SC,smeared_qvals                           
275        SetScale d,0,0,"1/cm",smeared_lns_SC                                                   
276                                       
277        Variable/G gs_lns_SC=0
278        gs_lns_SC := fSmearedLogNormalSphere_SC(smear_coef_lns_SC,smeared_lns_SC,smeared_qvals) //this wrapper fills the STRUCT
279       
280        Display smeared_lns_SC vs smeared_qvals                                                                 
281        ModifyGraph log=1,marker=29,msize=2,mode=4
282        Label bottom "q (A\\S-1\\M)"
283        Label left "Intensity (cm\\S-1\\M)"
284        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
285       
286        SetDataFolder root:
287        AddModelToStrings("SmearedLogNormalSphere_SC","smear_coef_lns_SC","smear_parameters_lns_SC","lns_SC")
288End
289
290
291
292Function LogNormalSphere_SC(w,yw,xw) : FitFunc
293        Wave w,yw,xw
294       
295        Variable inten
296       
297        //setup form factor coefficient wave
298        Make/O/D/N=6 form_lns_SC
299        form_lns_SC[0] = 1
300        form_lns_SC[1] = w[1]
301        form_lns_SC[2] = w[2]
302        form_lns_SC[3] = w[3]
303        form_lns_SC[4] = w[4]
304        form_lns_SC[5] = 0
305       
306        //calculate the diameter of the effective one-component sphere
307        Variable r3,mu,sig,diam
308        sig = w[2]                              //polydispersity
309        mu = ln(w[1])                   //ln of mean radius
310        r3 = exp(3*mu + 9/2*sig^2)              // <R^3> calculated directly for log-normal distr.
311       
312        diam = 2*(r3)^(1/3)
313       
314        //setup structure factor coefficient wave
315        Make/O/D/N=6 struct_lns_SC
316        struct_lns_SC[0] = diam
317        struct_lns_SC[1] = w[5]
318        struct_lns_SC[2] = w[0]
319        struct_lns_SC[3] = w[7]
320        struct_lns_SC[4] = w[6]
321        struct_lns_SC[5] = w[8]
322       
323        //calculate each and combine
324        Duplicate/O xw tmp_lns_SC_PQ,tmp_lns_SC_SQ
325        LogNormalSphere(form_lns_SC,tmp_lns_SC_PQ,xw)
326        HayterPenfoldMSA(struct_lns_SC,tmp_lns_SC_SQ,xw)
327        yw = tmp_lns_SC_PQ * tmp_lns_SC_SQ
328        yw *= w[0]
329        yw += w[9]
330       
331        //cleanup waves
332//      Killwaves/Z form_lns_SC,struct_lns_SC
333       
334        return (0)
335End
336
337/////////////////////////////////////////
338Proc PlotLogNormalSphere_SHS(num,qmin,qmax)
339        Variable num=256,qmin=0.001,qmax=0.7
340        Prompt num "Enter number of data points for model: "
341        Prompt qmin "Enter minimum q-value (A^-1) for model: "
342        Prompt qmax "Enter maximum q-value (A^-1) for model: "
343       
344        Make/O/D/N=(num) xwave_lns_SHS,ywave_lns_SHS
345        xwave_lns_SHS = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) )
346        Make/O/D coef_lns_SHS = {0.01,60,0.2,1e-6,3e-6,0.05,0.2,0.001}
347        make/O/T parameters_lns_SHS = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","perturbation parameter (0.1)","stickiness, tau","bkg (cm-1 sr-1)"}
348        Edit parameters_lns_SHS,coef_lns_SHS
349       
350        Variable/G root:g_lns_SHS
351        g_lns_SHS := LogNormalSphere_SHS(coef_lns_SHS,ywave_lns_SHS,xwave_lns_SHS)
352        Display ywave_lns_SHS vs xwave_lns_SHS
353        ModifyGraph log=1,marker=29,msize=2,mode=4
354        Label bottom "q (A\\S-1\\M)"
355        Label left "Intensity (cm\\S-1\\M)"
356        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
357       
358        AddModelToStrings("LogNormalSphere_SHS","coef_lns_SHS","parameters_lns_SHS","lns_SHS")
359End
360
361// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
362Proc PlotSmearedLogNormalSphere_SHS(str)                                                               
363        String str
364        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
365       
366        // if any of the resolution waves are missing => abort
367        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
368                Abort
369        endif
370       
371        SetDataFolder $("root:"+str)
372       
373        // Setup parameter table for model function
374        Make/O/D smear_coef_lns_SHS = {0.01,60,0.2,1e-6,3e-6,0.05,0.2,0.001}                                   
375        make/o/t smear_parameters_lns_SHS = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","perturbation parameter (0.1)","stickiness, tau","bkg (cm-1 sr-1)"}       
376        Edit smear_parameters_lns_SHS,smear_coef_lns_SHS                                       
377       
378        // output smeared intensity wave, dimensions are identical to experimental QSIG values
379        // make extra copy of experimental q-values for easy plotting
380        Duplicate/O $(str+"_q") smeared_lns_SHS,smeared_qvals                           
381        SetScale d,0,0,"1/cm",smeared_lns_SHS                                                   
382                                       
383        Variable/G gs_lns_SHS=0
384        gs_lns_SHS := fSmearedLogNormalSphere_SHS(smear_coef_lns_SHS,smeared_lns_SHS,smeared_qvals)     //this wrapper fills the STRUCT
385       
386        Display smeared_lns_SHS vs smeared_qvals                                                                       
387        ModifyGraph log=1,marker=29,msize=2,mode=4
388        Label bottom "q (A\\S-1\\M)"
389        Label left "Intensity (cm\\S-1\\M)"
390        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
391       
392        SetDataFolder root:
393        AddModelToStrings("SmearedLogNormalSphere_SHS","smear_coef_lns_SHS","smear_parameters_lns_SHS","lns_SHS")
394End
395       
396
397Function LogNormalSphere_SHS(w,yw,xw) : FitFunc
398        Wave w,yw,xw
399       
400        Variable inten
401       
402        //setup form factor coefficient wave
403        Make/O/D/N=6 form_lns_SHS
404        form_lns_SHS[0] = 1
405        form_lns_SHS[1] = w[1]
406        form_lns_SHS[2] = w[2]
407        form_lns_SHS[3] = w[3]
408        form_lns_SHS[4] = w[4]
409        form_lns_SHS[5] = 0
410       
411        //calculate the diameter of the effective one-component sphere
412        Variable r3,mu,sig,diam
413        sig = w[2]                              //polydispersity
414        mu = ln(w[1])                   //ln of mean radius
415        r3 = exp(3*mu + 9/2*sig^2)              // <R^3> calculated directly for log-normal distr.
416       
417        diam = 2*(r3)^(1/3)
418       
419        //setup structure factor coefficient wave
420        Make/O/D/N=4 struct_lns_SHS
421        struct_lns_SHS[0] = diam/2
422        struct_lns_SHS[1] = w[0]
423        struct_lns_SHS[2] = w[5]
424        struct_lns_SHS[3] = w[6]
425       
426        //calculate each and combine
427        Duplicate/O xw tmp_lns_SHS_PQ,tmp_lns_SHS_SQ
428        LogNormalSphere(form_lns_SHS,tmp_lns_SHS_PQ,xw)
429        StickyHS_Struct(struct_lns_SHS,tmp_lns_SHS_SQ,xw)
430        yw = tmp_lns_SHS_PQ * tmp_lns_SHS_SQ
431        yw *= w[0]
432        yw += w[7]
433       
434        //cleanup waves
435//      Killwaves/Z form_lns_SHS,struct_lns_SHS
436       
437        return (0)
438End
439
440// two yukawa
441Proc PlotLogNormalSphere_2Y(num,qmin,qmax)
442        Variable num=128,qmin=0.001,qmax=0.7
443        Prompt num "Enter number of data points for model: "
444        Prompt qmin "Enter minimum q-value (A^-1) for model: "
445        Prompt qmax "Enter maximum q-value (A^-1) for model: "
446       
447        Make/O/D/N=(num) xwave_lns_2Y,ywave_lns_2Y
448        xwave_lns_2Y = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) )
449        Make/O/D coef_lns_2Y = {0.1,60,0.2,1e-6,3e-6,6,10,-1,2,0.001}
450        make/O/T parameters_lns_2Y = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","scale, K1","charge, Z1","scale, K2","charge, Z2","bkg (cm-1 sr-1)"}
451        Edit parameters_lns_2Y,coef_lns_2Y
452       
453        Variable/G root:g_lns_2Y
454        g_lns_2Y := LogNormalSphere_2Y(coef_lns_2Y,ywave_lns_2Y,xwave_lns_2Y)
455        Display ywave_lns_2Y vs xwave_lns_2Y
456        ModifyGraph log=1,marker=29,msize=2,mode=4
457        Label bottom "q (A\\S-1\\M)"
458        Label left "Intensity (cm\\S-1\\M)"
459        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
460       
461        AddModelToStrings("LogNormalSphere_2Y","coef_lns_2Y","parameters_lns_2Y","lns_2Y")
462End
463
464// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
465Proc PlotSmearedLogNormalSphere_2Y(str)                                                         
466        String str
467        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
468       
469        // if any of the resolution waves are missing => abort
470        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
471                Abort
472        endif
473       
474        SetDataFolder $("root:"+str)
475       
476        // Setup parameter table for model function
477        Make/O/D smear_coef_lns_2Y = {0.1,60,0.2,1e-6,3e-6,6,10,-1,2,0.001}                                     
478        make/o/t smear_parameters_lns_2Y = {"Volume Fraction (scale)","mean radius (A)","polydisp (sig/avg)","SLD sphere (A-2)","SLD solvent (A-2)","scale, K1","charge, Z1","scale, K2","charge, Z2","bkg (cm-1 sr-1)"}       
479        Edit smear_parameters_lns_2Y,smear_coef_lns_2Y                                 
480       
481        // output smeared intensity wave, dimensions are identical to experimental QSIG values
482        // make extra copy of experimental q-values for easy plotting
483        Duplicate/O $(str+"_q") smeared_lns_2Y,smeared_qvals                           
484        SetScale d,0,0,"1/cm",smeared_lns_2Y                                                   
485                                       
486        Variable/G gs_lns_2Y=0
487        gs_lns_2Y := fSmearedLogNormalSphere_2Y(smear_coef_lns_2Y,smeared_lns_2Y,smeared_qvals) //this wrapper fills the STRUCT
488       
489        Display smeared_lns_2Y vs smeared_qvals                                                                 
490        ModifyGraph log=1,marker=29,msize=2,mode=4
491        Label bottom "q (A\\S-1\\M)"
492        Label left "Intensity (cm\\S-1\\M)"
493        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
494       
495        SetDataFolder root:
496        AddModelToStrings("SmearedLogNormalSphere_2Y","smear_coef_lns_2Y","smear_parameters_lns_2Y","lns_2Y")
497End
498       
499
500Function LogNormalSphere_2Y(w,yw,xw) : FitFunc
501        Wave w,yw,xw
502       
503        Variable inten
504       
505        //setup form factor coefficient wave
506        Make/O/D/N=6 form_lns_2Y
507        form_lns_2Y[0] = 1
508        form_lns_2Y[1] = w[1]
509        form_lns_2Y[2] = w[2]
510        form_lns_2Y[3] = w[3]
511        form_lns_2Y[4] = w[4]
512        form_lns_2Y[5] = 0
513       
514        //calculate the diameter of the effective one-component sphere
515        Variable r3,mu,sig,diam
516        sig = w[2]                              //polydispersity
517        mu = ln(w[1])                   //ln of mean radius
518        r3 = exp(3*mu + 9/2*sig^2)              // <R^3> calculated directly for log-normal distr.
519       
520        diam = 2*(r3)^(1/3)
521       
522       
523        //setup structure factor coefficient wave
524        Make/O/D/N=6 struct_lns_2Y
525        struct_lns_2Y[0] = w[0]
526        struct_lns_2Y[1] = diam/2
527        struct_lns_2Y[2] = w[5]
528        struct_lns_2Y[3] = w[6]
529        struct_lns_2Y[4] = w[7]
530        struct_lns_2Y[5] = w[8]
531       
532        //calculate each and combine
533        Duplicate/O xw tmp_lns_2Y_PQ,tmp_lns_2Y_SQ
534        LogNormalSphere(form_lns_2Y,tmp_lns_2Y_PQ,xw)
535        TwoYukawa(struct_lns_2Y,tmp_lns_2Y_SQ,xw)
536        yw = tmp_lns_2Y_PQ *tmp_lns_2Y_SQ
537        yw *= w[0]
538        yw += w[9]
539       
540        //cleanup waves
541//      Killwaves/Z form_lns_2Y,struct_lns_2Y
542       
543        return (0)
544End
545
546
547// this is all there is to the smeared calculation!
548Function SmearedLogNormalSphere_HS(s) : FitFunc
549        Struct ResSmearAAOStruct &s
550
551//      the name of your unsmeared model (AAO) is the first argument
552        Smear_Model_20(LogNormalSphere_HS,s.coefW,s.xW,s.yW,s.resW)
553
554        return(0)
555End
556
557// this is all there is to the smeared calculation!
558Function SmearedLogNormalSphere_SW(s) : FitFunc
559        Struct ResSmearAAOStruct &s
560
561//      the name of your unsmeared model (AAO) is the first argument
562        Smear_Model_20(LogNormalSphere_SW,s.coefW,s.xW,s.yW,s.resW)
563
564        return(0)
565End
566
567// this is all there is to the smeared calculation!
568Function SmearedLogNormalSphere_SC(s) : FitFunc
569        Struct ResSmearAAOStruct &s
570
571//      the name of your unsmeared model (AAO) is the first argument
572        Smear_Model_20(LogNormalSphere_SC,s.coefW,s.xW,s.yW,s.resW)
573
574        return(0)
575End
576
577// this is all there is to the smeared calculation!
578Function SmearedLogNormalSphere_SHS(s) : FitFunc
579        Struct ResSmearAAOStruct &s
580
581//      the name of your unsmeared model (AAO) is the first argument
582        Smear_Model_20(LogNormalSphere_SHS,s.coefW,s.xW,s.yW,s.resW)
583
584        return(0)
585End
586
587// this is all there is to the smeared calculation!
588Function SmearedLogNormalSphere_2Y(s) : FitFunc
589        Struct ResSmearAAOStruct &s
590
591//      the name of your unsmeared model (AAO) is the first argument
592        Smear_Model_20(LogNormalSphere_2Y,s.coefW,s.xW,s.yW,s.resW)
593
594        return(0)
595End
596
597//wrapper to calculate the smeared model as an AAO-Struct
598// fills the struct and calls the ususal function with the STRUCT parameter
599//
600// used only for the dependency, not for fitting
601//
602Function fSmearedLogNormalSphere_HS(coefW,yW,xW)
603        Wave coefW,yW,xW
604       
605        String str = getWavesDataFolder(yW,0)
606        String DF="root:"+str+":"
607       
608        WAVE resW = $(DF+str+"_res")
609       
610        STRUCT ResSmearAAOStruct fs
611        WAVE fs.coefW = coefW   
612        WAVE fs.yW = yW
613        WAVE fs.xW = xW
614        WAVE fs.resW = resW
615       
616        Variable err
617        err = SmearedLogNormalSphere_HS(fs)
618       
619        return (0)
620End
621
622//wrapper to calculate the smeared model as an AAO-Struct
623// fills the struct and calls the ususal function with the STRUCT parameter
624//
625// used only for the dependency, not for fitting
626//
627Function fSmearedLogNormalSphere_SW(coefW,yW,xW)
628        Wave coefW,yW,xW
629       
630        String str = getWavesDataFolder(yW,0)
631        String DF="root:"+str+":"
632       
633        WAVE resW = $(DF+str+"_res")
634       
635        STRUCT ResSmearAAOStruct fs
636        WAVE fs.coefW = coefW   
637        WAVE fs.yW = yW
638        WAVE fs.xW = xW
639        WAVE fs.resW = resW
640       
641        Variable err
642        err = SmearedLogNormalSphere_SW(fs)
643       
644        return (0)
645End
646
647//wrapper to calculate the smeared model as an AAO-Struct
648// fills the struct and calls the ususal function with the STRUCT parameter
649//
650// used only for the dependency, not for fitting
651//
652Function fSmearedLogNormalSphere_SC(coefW,yW,xW)
653        Wave coefW,yW,xW
654       
655        String str = getWavesDataFolder(yW,0)
656        String DF="root:"+str+":"
657       
658        WAVE resW = $(DF+str+"_res")
659       
660        STRUCT ResSmearAAOStruct fs
661        WAVE fs.coefW = coefW   
662        WAVE fs.yW = yW
663        WAVE fs.xW = xW
664        WAVE fs.resW = resW
665       
666        Variable err
667        err = SmearedLogNormalSphere_SC(fs)
668       
669        return (0)
670End
671
672//wrapper to calculate the smeared model as an AAO-Struct
673// fills the struct and calls the ususal function with the STRUCT parameter
674//
675// used only for the dependency, not for fitting
676//
677Function fSmearedLogNormalSphere_SHS(coefW,yW,xW)
678        Wave coefW,yW,xW
679       
680        String str = getWavesDataFolder(yW,0)
681        String DF="root:"+str+":"
682       
683        WAVE resW = $(DF+str+"_res")
684       
685        STRUCT ResSmearAAOStruct fs
686        WAVE fs.coefW = coefW   
687        WAVE fs.yW = yW
688        WAVE fs.xW = xW
689        WAVE fs.resW = resW
690       
691        Variable err
692        err = SmearedLogNormalSphere_SHS(fs)
693       
694        return (0)
695End
696
697//wrapper to calculate the smeared model as an AAO-Struct
698// fills the struct and calls the ususal function with the STRUCT parameter
699//
700// used only for the dependency, not for fitting
701//
702Function fSmearedLogNormalSphere_2Y(coefW,yW,xW)
703        Wave coefW,yW,xW
704       
705        String str = getWavesDataFolder(yW,0)
706        String DF="root:"+str+":"
707       
708        WAVE resW = $(DF+str+"_res")
709       
710        STRUCT ResSmearAAOStruct fs
711        WAVE fs.coefW = coefW   
712        WAVE fs.yW = yW
713        WAVE fs.xW = xW
714        WAVE fs.resW = resW
715       
716        Variable err
717        err = SmearedLogNormalSphere_2Y(fs)
718       
719        return (0)
720End
Note: See TracBrowser for help on using the repository browser.