source: sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/Vesicle_UL.ipf @ 131

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

Typo in dialog in every model...

File size: 7.0 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma IgorVersion = 6.0
3
4////////////////////////////////////////////////
5// GaussUtils.proc and PlotUtils.proc MUST be included for the smearing calculation to compile
6// Adopting these into the experiment will insure that they are always present
7////////////////////////////////////////////////
8//
9// this function is for the form factor of a unilamellar vesicle
10//
11// the "scale" or "volume fraction" factor is the "material" volume fraction
12// - i.e. the volume fraction of surfactant added. NOT the excluded volume
13// of the vesicles, which can be much larger. See the Vesicle_Volume_N_Rg macro
14//
15// this excluded volume is accounted for in the structure factor calculations.
16//
17// a macro is also provided to calculate the number density, I(q=0)
18// the Rg, and all of the volumes of the particle.
19//
20// 13 JUL 04 SRK
21////////////////////////////////////////////////
22
23Proc PlotVesicle(num,qmin,qmax)
24        Variable num=128,qmin=0.001,qmax=0.7
25        Prompt num "Enter number of data points for model: "
26        Prompt qmin "Enter minimum q-value (^-1) for model: "
27        Prompt qmax "Enter maximum q-value (^-1) for model: "
28       
29        make/o/d/n=(num) xwave_vesicle,ywave_vesicle
30        xwave_vesicle =alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
31        make/o/d coef_vesicle = {1.,100,30,6.36e-6,0.5e-6,0}
32        make/o/t parameters_vesicle = {"scale","core radius (A)","shell thickness (A)","Core and Solvent SLD (A-2)","Shell SLD (A-2)","bkg (cm-1)"}
33        Edit parameters_vesicle,coef_vesicle
34       
35        Variable/G root:g_vesicle
36        g_vesicle := VesicleForm(coef_vesicle,ywave_vesicle,xwave_vesicle)
37        Display ywave_vesicle vs xwave_vesicle
38        ModifyGraph log=1,marker=29,msize=2,mode=4
39        Label bottom "q (\\S-1\\M)"
40        Label left "Intensity (cm\\S-1\\M)"
41        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
42End
43
44///////////////////////////////////////////////////////////
45
46// - sets up a dependency to a wrapper, not the actual SmearedModelFunction
47Proc PlotSmearedVesicle(str)                                                           
48        String str
49        Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4)
50       
51        // if any of the resolution waves are missing => abort
52        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils)
53                Abort
54        endif
55       
56        SetDataFolder $("root:"+str)
57       
58        // Setup parameter table for model function
59        make/o/d smear_coef_vesicle = {1.,100,30,6.36e-6,0.5e-6,0}
60        make/o/t smear_parameters_vesicle = {"scale","core radius (A)","shell thickness (A)","Core and Solvent SLD (A-2)","Shell SLD (A-2)","bkg (cm-1)"}
61        Edit smear_parameters_vesicle,smear_coef_vesicle
62       
63        // output smeared intensity wave, dimensions are identical to experimental QSIG values
64        // make extra copy of experimental q-values for easy plotting
65       
66        Duplicate/O $(str+"_q") smeared_vesicle,smeared_qvals                           
67        SetScale d,0,0,"1/cm",smeared_vesicle                                                   
68                                       
69        Variable/G gs_vesicle=0
70        gs_vesicle := fSmearedVesicleForm(smear_coef_vesicle,smeared_vesicle,smeared_qvals)     //this wrapper fills the STRUCT
71       
72        Display smeared_vesicle vs smeared_qvals                                                                       
73        ModifyGraph log=1,marker=29,msize=2,mode=4
74        Label bottom "q (\\S-1\\M)"
75        Label left "Intensity (cm\\S-1\\M)"
76        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
77       
78        SetDataFolder root:
79End
80
81
82//AAO version, uses XOP if available
83// simply calls the original single point calculation with
84// a wave assignment (this will behave nicely if given point ranges)
85Function VesicleForm(cw,yw,xw) : FitFunc
86        Wave cw,yw,xw
87       
88#if exists("VesicleFormX")
89        yw = VesicleFormX(cw,xw)
90#else
91        yw = fVesicleForm(cw,xw)
92#endif
93        return(0)
94End
95
96///////////////////////////////////////////////////////////////
97// unsmeared model calculation
98///////////////////////////
99Function fVesicleForm(w,x) : FitFunc
100        Wave w
101        Variable x
102       
103        // variables are:
104        //[0] scale factor
105        //[1] radius of core []
106        //[2] thickness of the shell    []
107        //[3] SLD of the core and solvent[-2]
108        //[4] SLD of the shell
109        //[5] background        [cm-1]
110       
111        // All inputs are in ANGSTROMS
112        //OUTPUT is normalized by the particle volume, and converted to [cm-1]
113       
114       
115        Variable scale,rcore,thick,rhocore,rhoshel,rhosolv,bkg
116        scale = w[0]
117        rcore = w[1]
118        thick = w[2]
119        rhocore = w[3]
120        rhosolv = rhocore
121        rhoshel = w[4]
122        bkg = w[5]
123       
124        // calculates scale *( f^2 + bkg)
125        Variable bes,f,vol,qr,contr,f2
126       
127        // core first, then add in shell
128        qr=x*rcore
129        contr = rhocore-rhoshel
130        bes = 3*(sin(qr)-qr*cos(qr))/qr^3
131        vol = 4*pi/3*rcore^3
132        f = vol*bes*contr
133        //now the shell
134        qr=x*(rcore+thick)
135        contr = rhoshel-rhosolv
136        bes = 3*(sin(qr)-qr*cos(qr))/qr^3
137        vol = 4*pi/3*(rcore+thick)^3
138        f += vol*bes*contr
139       
140        // normalize to the particle volume and rescale from [-1] to [cm-1]
141        //note that for the vesicle model, the volume is ONLY the shell volume
142        vol = 4*pi/3*((rcore+thick)^3-rcore^3)
143        f2 = f*f/vol*1.0e8
144       
145        //scale if desired
146        f2 *= scale
147        // then add in the background
148        f2 += bkg
149       
150        return (f2)
151End
152
153//wrapper to calculate the smeared model as an AAO-Struct
154// fills the struct and calls the ususal function with the STRUCT parameter
155//
156// used only for the dependency, not for fitting
157//
158Function fSmearedVesicleForm(coefW,yW,xW)
159        Wave coefW,yW,xW
160       
161        String str = getWavesDataFolder(yW,0)
162        String DF="root:"+str+":"
163       
164        WAVE resW = $(DF+str+"_res")
165       
166        STRUCT ResSmearAAOStruct fs
167        WAVE fs.coefW = coefW   
168        WAVE fs.yW = yW
169        WAVE fs.xW = xW
170        WAVE fs.resW = resW
171       
172        Variable err
173        err = SmearedVesicleForm(fs)
174       
175        return (0)
176End
177
178// this is all there is to the smeared calculation!
179Function SmearedVesicleForm(s) :FitFunc
180        Struct ResSmearAAOStruct &s
181
182//      the name of your unsmeared model (AAO) is the first argument
183        s.yW = Smear_Model_20(VesicleForm,s.coefW,s.xW,s.resW)
184
185        return(0)
186End
187
188Macro Vesicle_Volume_N_Rg()
189        Variable totVol,core,shell,i0,nden,rhoCore,rhoShell,rhoSolvent
190        Variable phi
191       
192        if(WaveExists(coef_vesicle)==0)
193                abort "You need to plot the vesicle model first to create the coefficient table"
194        Endif
195        totvol=4*pi/3*(coef_vesicle[1]+coef_vesicle[2])^3
196        core=4*pi/3*(coef_vesicle[1])^3
197        shell = totVol-core
198       
199//      nden = phi/(shell volume) or phi/Vtotal
200        nden = coef_vesicle[0]/shell
201        rhoCore = coef_vesicle[3]
202        rhoShell = coef_vesicle[4]
203        rhoSolvent = rhoCore
204       
205        i0 = nden*shell*shell*(rhoCore-rhoShell)^2*1e8
206        Print "Total Volume [A^3] = ",totVol
207        Print "Core Volume [A^3] = ",core
208        Print "Shell Volume [A^3] = ",shell
209        Print "Material volume fraction = ",coef_vesicle[0]
210        Print "Excluded volume fraction = ",nden*totvol
211//      Print "I(q=0) = ",i0
212        Print "I(Q=0) = n Vshell^2(DR)^2 [1/cm] = ",i0
213        Print "Number Density [1/A^3]= ",nden
214//      Print "model I(0) = ",ywave_vesicle[0]
215//      Print "model/limit = ",ywave_vesicle[0]/i0
216       
217        CalcRg_Vesicle(coef_vesicle)
218End
219
220
221Function CalcRg_Vesicle(coef_vesicle)
222        Wave coef_vesicle
223
224        Variable Rc,Rsh,r1,r2,rs,ans
225       
226        Rc = coef_vesicle[1]
227        Rsh = Rc + coef_vesicle[2]
228        r1 = coef_vesicle[3]
229        r2 = coef_vesicle[4]
230        rs = coef_vesicle[3]
231       
232//      ans = 0
233//      ans = ( (r1-r2)/(r2-rs) )*Rc^5/Rsh^5 - 1
234//      ans /= ( (r1-r2)/(r2-rs) )*Rc^3/Rsh^3 - 1
235//      ans *= 3/5*Rsh^2
236//      Print "Rg of vesicle [A] = ",sqrt(ans)
237       
238        ans = 0
239        ans = Rc^5/Rsh^5 + 1
240        ans /= Rc^3/Rsh^3 + 1
241        ans *= 3/5*Rsh^2
242       
243        Print "Rg of vesicle [A] = ",sqrt(ans)
244End
Note: See TracBrowser for help on using the repository browser.