1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
2 | #pragma IgorVersion = 6.0 |
---|
3 | |
---|
4 | // calculates the scattering from a spherical particle made up of a core (aqueous) surrounded |
---|
5 | // by N spherical layers, each of which is a PAIR of shells, solvent + surfactant since there |
---|
6 | //must always be a surfactant layer on the outside |
---|
7 | // |
---|
8 | // bragg peaks arise naturally from the periodicity of the sample |
---|
9 | // resolution smeared version gives he most appropriate view of the model |
---|
10 | |
---|
11 | // |
---|
12 | // |
---|
13 | Proc PlotMultiShellSphere(num,qmin,qmax) |
---|
14 | Variable num=100,qmin=0.001,qmax=0.7 |
---|
15 | Prompt num "Enter number of data points for model: " |
---|
16 | Prompt qmin "Enter minimum q-value (A^-1) for model: " |
---|
17 | Prompt qmax "Enter maximum q-value (A^-1) for model: " |
---|
18 | |
---|
19 | make/O/D/N=(num) xwave_mss,ywave_mss |
---|
20 | xwave_mss = alog(log(qmin) + x*((log(qmax)-log(qmin))/num)) |
---|
21 | make/O/D coef_mss = {1.,60,10,10,6.4e-6,0.4e-6,2,0.001} |
---|
22 | make/O/T parameters_mss = {"scale","core radius (A)","shell thickness (A)","water thickness","core & solvent SLD (A-2)","Shell SLD (A-2)","number of water/shell pairs","bkg (cm-1)"} |
---|
23 | Edit/K=1 parameters_mss,coef_mss |
---|
24 | |
---|
25 | Variable/G root:g_mss |
---|
26 | g_mss := MultiShellSphere(coef_mss,ywave_mss,xwave_mss) |
---|
27 | Display/K=1 ywave_mss vs xwave_mss |
---|
28 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
29 | Label bottom "q (A\\S-1\\M)" |
---|
30 | Label left "Intensity (cm\\S-1\\M)" |
---|
31 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
32 | |
---|
33 | AddModelToStrings("MultiShellSphere","coef_mss","parameters_mss","mss") |
---|
34 | End |
---|
35 | |
---|
36 | // - sets up a dependency to a wrapper, not the actual SmearedModelFunction |
---|
37 | Proc PlotSmearedMultiShellSphere(str) |
---|
38 | String str |
---|
39 | Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4) |
---|
40 | |
---|
41 | // if any of the resolution waves are missing => abort |
---|
42 | if(ResolutionWavesMissingDF(str)) //updated to NOT use global strings (in GaussUtils) |
---|
43 | Abort |
---|
44 | endif |
---|
45 | |
---|
46 | SetDataFolder $("root:"+str) |
---|
47 | |
---|
48 | // Setup parameter table for model function |
---|
49 | make/O/D smear_coef_mss = {1.,60,10,10,6.4e-6,0.4e-6,2,0.001} |
---|
50 | make/O/T smear_parameters_mss = {"scale","core radius (A)","shell thickness (A)","water thickness","core & solvent SLD (A-2)","Shell SLD (A-2)","number of water/shell pairs","bkg (cm-1)"} |
---|
51 | Edit/K=1 smear_parameters_mss,smear_coef_mss |
---|
52 | |
---|
53 | // output smeared intensity wave, dimensions are identical to experimental QSIG values |
---|
54 | // make extra copy of experimental q-values for easy plotting |
---|
55 | Duplicate/O $(str+"_q") smeared_mss,smeared_qvals |
---|
56 | SetScale d,0,0,"1/cm",smeared_mss |
---|
57 | |
---|
58 | Variable/G gs_mss=0 |
---|
59 | gs_mss := fSmearedMultiShellSphere(smear_coef_mss,smeared_mss,smeared_qvals) //this wrapper fills the STRUCT |
---|
60 | |
---|
61 | Display/K=1 smeared_mss vs smeared_qvals |
---|
62 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
63 | Label bottom "q (A\\S-1\\M)" |
---|
64 | Label left "Intensity (cm\\S-1\\M)" |
---|
65 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
66 | |
---|
67 | SetDataFolder root: |
---|
68 | AddModelToStrings("SmearedMultiShellSphere","smear_coef_mss","smear_parameters_mss","mss") |
---|
69 | End |
---|
70 | |
---|
71 | |
---|
72 | |
---|
73 | |
---|
74 | //AAO version, uses XOP if available |
---|
75 | // simply calls the original single point calculation with |
---|
76 | // a wave assignment (this will behave nicely if given point ranges) |
---|
77 | Function MultiShellSphere(cw,yw,xw) : FitFunc |
---|
78 | Wave cw,yw,xw |
---|
79 | |
---|
80 | #if exists("MultiShellSphereX") |
---|
81 | yw = MultiShellSphereX(cw,xw) |
---|
82 | #else |
---|
83 | yw = fMultiShellSphere(cw,xw) |
---|
84 | #endif |
---|
85 | return(0) |
---|
86 | End |
---|
87 | |
---|
88 | Function fMultiShellSphere(w,x) :FitFunc |
---|
89 | Wave w |
---|
90 | Variable x |
---|
91 | |
---|
92 | // variables are: |
---|
93 | //[0] scale factor |
---|
94 | //[1] radius of core [A] |
---|
95 | //[2] thickness of the shell [A] |
---|
96 | //[3] thickness of the water layer |
---|
97 | //[4] SLD of the core = sld of the solvent[A-2] |
---|
98 | //[5] SLD of the shell |
---|
99 | //[6] number of pairs (tw+tsh) |
---|
100 | //[7] background [cm-1] |
---|
101 | |
---|
102 | // All inputs are in ANGSTROMS |
---|
103 | //OUTPUT is normalized by the particle volume, and converted to [cm-1] |
---|
104 | |
---|
105 | |
---|
106 | Variable scale,rcore,tw,ts,rhocore,rhoshel,num,bkg |
---|
107 | scale = w[0] |
---|
108 | rcore = w[1] |
---|
109 | ts = w[2] |
---|
110 | tw = w[3] |
---|
111 | rhocore = w[4] |
---|
112 | rhoshel = w[5] |
---|
113 | num = w[6] |
---|
114 | bkg = w[7] |
---|
115 | |
---|
116 | //calculate with a loop, two shells at a time |
---|
117 | Variable ii=0,fval=0,voli,ri,sldi |
---|
118 | |
---|
119 | do |
---|
120 | ri = rcore + ii*ts + ii*tw |
---|
121 | voli = 4*pi/3*ri^3 |
---|
122 | sldi = rhocore-rhoshel |
---|
123 | fval += voli*sldi*F_func(ri*x) |
---|
124 | ri += ts |
---|
125 | voli = 4*pi/3*ri^3 |
---|
126 | sldi = rhoshel-rhocore |
---|
127 | fval += voli*sldi*F_func(ri*x) |
---|
128 | ii+=1 //do 2 layers at a time |
---|
129 | while(ii<=num-1) //change to make 0 < num < 2 correspond to unilamellar vesicles (C. Glinka, 11/24/03) |
---|
130 | |
---|
131 | fval *=fval //square it |
---|
132 | fval /=voli //normalize by the overall volume |
---|
133 | fval *=scale*1e8 |
---|
134 | fval += bkg |
---|
135 | |
---|
136 | return(fval) |
---|
137 | End |
---|
138 | |
---|
139 | Function F_func(qr) |
---|
140 | Variable qr |
---|
141 | |
---|
142 | Variable val=0 |
---|
143 | |
---|
144 | val = 3*(sin(qr) - qr*cos(qr))/qr^3 |
---|
145 | |
---|
146 | return(val) |
---|
147 | End |
---|
148 | |
---|
149 | |
---|
150 | // |
---|
151 | //Function Schulz_Point_ms(x,avg,zz) |
---|
152 | // |
---|
153 | // //Wave w |
---|
154 | // Variable x,avg,zz |
---|
155 | // Variable dr |
---|
156 | // |
---|
157 | // dr = zz*ln(x) - gammln(zz+1)+(zz+1)*ln((zz+1)/avg)-(x/avg*(zz+1)) |
---|
158 | // |
---|
159 | // return (exp(dr)) |
---|
160 | // |
---|
161 | //End |
---|
162 | |
---|
163 | //wrapper to calculate the smeared model as an AAO-Struct |
---|
164 | // fills the struct and calls the ususal function with the STRUCT parameter |
---|
165 | // |
---|
166 | // used only for the dependency, not for fitting |
---|
167 | // |
---|
168 | Function fSmearedMultiShellSphere(coefW,yW,xW) |
---|
169 | Wave coefW,yW,xW |
---|
170 | |
---|
171 | String str = getWavesDataFolder(yW,0) |
---|
172 | String DF="root:"+str+":" |
---|
173 | |
---|
174 | WAVE resW = $(DF+str+"_res") |
---|
175 | |
---|
176 | STRUCT ResSmearAAOStruct fs |
---|
177 | WAVE fs.coefW = coefW |
---|
178 | WAVE fs.yW = yW |
---|
179 | WAVE fs.xW = xW |
---|
180 | WAVE fs.resW = resW |
---|
181 | |
---|
182 | Variable err |
---|
183 | err = SmearedMultiShellSphere(fs) |
---|
184 | |
---|
185 | return (0) |
---|
186 | End |
---|
187 | |
---|
188 | // this model needs 76 Gauss points for a proper smearing calculation |
---|
189 | // since there can be sharp interference fringes that develop from the stacking |
---|
190 | Function SmearedMultiShellSphere(s) :FitFunc |
---|
191 | Struct ResSmearAAOStruct &s |
---|
192 | |
---|
193 | // the name of your unsmeared model (AAO) is the first argument |
---|
194 | Smear_Model_76(MultiShellSphere,s.coefW,s.xW,s.yW,s.resW) |
---|
195 | |
---|
196 | return(0) |
---|
197 | End |
---|
198 | |
---|