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 polydisperse spherical particle, with a core-shell structure |
---|
10 | // the polydispersity of the overall (core+shell) radius is described by a Schulz distribution |
---|
11 | // the ratio R(core)/ R (total) is constant |
---|
12 | // |
---|
13 | // 06 NOV 98 SRK |
---|
14 | //////////////////////////////////////////////// |
---|
15 | |
---|
16 | Proc PlotPolyCoreShellRatio(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 (^-1) for model: " |
---|
20 | Prompt qmax "Enter maximum q-value (^-1) for model: " |
---|
21 | |
---|
22 | Make/O/D/n=(num) xwave_pcr,ywave_pcr |
---|
23 | xwave_pcr = alog(log(qmin) + x*((log(qmax)-log(qmin))/num)) |
---|
24 | Make/O/D coef_pcr = {1.,60,10,.2,1e-6,2e-6,3e-6,0.001} |
---|
25 | Make/O/t parameters_pcr = {"scale","avg core rad (A)","avg shell thickness (A)","overall polydisp (0,1)",,"SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","bkg (cm-1)"} |
---|
26 | Edit parameters_pcr,coef_pcr |
---|
27 | Variable/G root:g_pcr |
---|
28 | g_pcr := PolyCoreShellRatio(coef_pcr,ywave_pcr,xwave_pcr) |
---|
29 | // ywave_pcr := PolyCoreShellRatio(coef_pcr,xwave_pcr) |
---|
30 | Display ywave_pcr vs xwave_pcr |
---|
31 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
32 | Label bottom "q (\\S-1\\M)" |
---|
33 | Label left "Intensity (cm\\S-1\\M)" |
---|
34 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
35 | End |
---|
36 | |
---|
37 | /////////////////////////////////////////////////////////// |
---|
38 | // - sets up a dependency to a wrapper, not the actual SmearedModelFunction |
---|
39 | Proc PlotSmearedPolyCoreShellRatio(str) |
---|
40 | String str |
---|
41 | Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4) |
---|
42 | |
---|
43 | // if any of the resolution waves are missing => abort |
---|
44 | if(ResolutionWavesMissingDF(str)) //updated to NOT use global strings (in GaussUtils) |
---|
45 | Abort |
---|
46 | endif |
---|
47 | |
---|
48 | SetDataFolder $("root:"+str) |
---|
49 | |
---|
50 | // Setup parameter table for model function |
---|
51 | Make/O/D smear_coef_pcr = {1.,60,10,.2,1e-6,2e-6,3e-6,0.001} |
---|
52 | make/o/t smear_parameters_pcr = {"scale","avg core rad (A)","avg shell thickness (A)","overall polydisp (0,1)",,"SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","bkg (cm-1)"} |
---|
53 | Edit smear_parameters_pcr,smear_coef_pcr |
---|
54 | |
---|
55 | // output smeared intensity wave, dimensions are identical to experimental QSIG values |
---|
56 | // make extra copy of experimental q-values for easy plotting |
---|
57 | Duplicate/O $(str+"_q") smeared_pcr,smeared_qvals //**** mod |
---|
58 | SetScale d,0,0,"1/cm",smeared_pcr //**** mod |
---|
59 | |
---|
60 | Variable/G gs_pcr=0 |
---|
61 | gs_pcr := fSmearedPolyCoreShellRatio(smear_coef_pcr,smeared_pcr,smeared_qvals) //this wrapper fills the STRUCT |
---|
62 | |
---|
63 | Display smeared_pcr vs smeared_qvals |
---|
64 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
65 | Label bottom "q (\\S-1\\M)" |
---|
66 | Label left "Intensity (cm\\S-1\\M)" |
---|
67 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
68 | |
---|
69 | SetDataFolder root: |
---|
70 | End |
---|
71 | |
---|
72 | |
---|
73 | //AAO version |
---|
74 | Function PolyCoreShellRatio(cw,yw,xw) : FitFunc |
---|
75 | Wave cw,yw,xw |
---|
76 | |
---|
77 | #if exists("PolyCoreShellRatioX") |
---|
78 | yw = PolyCoreShellRatioX(cw,xw) |
---|
79 | #else |
---|
80 | yw = fPolyCoreShellRatio(cw,xw) |
---|
81 | #endif |
---|
82 | return(0) |
---|
83 | End |
---|
84 | |
---|
85 | /////////////////////////////////////////////////////////////// |
---|
86 | // unsmeared model calculation |
---|
87 | /////////////////////////// |
---|
88 | //C CALC'S THE FORM FACTOR FOR A MONOMODAL |
---|
89 | //c POPULATION OF POLYDISPERSE SHERES WITH A |
---|
90 | //c CORE AND SHELL TYPE SLD DISTRIBUTION. IT |
---|
91 | //c ASSUMES THAT THE CORE RADIUS IS A CONSTANT |
---|
92 | //c FRACTION (P) OF THE SHELL RADIUS. |
---|
93 | //c |
---|
94 | //c |
---|
95 | //c REF.: "DETERMINATION OF THE STRUCTURE AND DYNAMICS OF |
---|
96 | //c MICELLAR SOLUTIONS BY NEUTRON SMALL-ANGLE SCATTERING" |
---|
97 | //c BY J.B.HAYTER IN PHYSICS OF AMPHIPHILES--MICELLES, |
---|
98 | //c VESICLES, AND MICROEMULSIONS ED BY DEGIORGIO,V; CORTI,M, |
---|
99 | //c PP59-93,1983. |
---|
100 | //c |
---|
101 | //c EQNS: 32-37 |
---|
102 | //c |
---|
103 | Function fPolyCoreShellRatio(w,x) : FitFunc |
---|
104 | Wave w;Variable x |
---|
105 | |
---|
106 | //assign nice names to the input wave |
---|
107 | //w[0] = scale |
---|
108 | //w[1] = core radius [] |
---|
109 | //w[2] = shell thickness [] |
---|
110 | //w[3] = polydispersity index (0<p<1) |
---|
111 | //w[4] = SLD core [^-2] |
---|
112 | //w[5] = SLD shell [^-2] |
---|
113 | //w[6] = SLD solvent [^-2] |
---|
114 | //w[7] = bkg [cm-1] |
---|
115 | Variable scale,corrad,thick,shlrad,pp,drho1,drho2,sig,zz,bkg |
---|
116 | Variable sld1,sld2,sld3,zp1,zp2,zp3,vpoly |
---|
117 | |
---|
118 | scale = w[0] |
---|
119 | corrad = w[1] |
---|
120 | thick = w[2] |
---|
121 | sig = w[3] |
---|
122 | sld1 = w[4] |
---|
123 | sld2 = w[5] |
---|
124 | sld3 = w[6] |
---|
125 | bkg = w[7] |
---|
126 | |
---|
127 | //calculations on input parameters |
---|
128 | shlrad = corrad + thick |
---|
129 | zz = (1/sig)^2-1 |
---|
130 | drho1 = sld1-sld2 //core-shell |
---|
131 | drho2 = sld2-sld3 //shell-solvent |
---|
132 | zp1 = zz + 1. |
---|
133 | zp2 = zz + 2. |
---|
134 | zp3 = zz + 3. |
---|
135 | vpoly = 4*Pi/3*zp3*zp2/zp1/zp1*(corrad+thick)^3 |
---|
136 | |
---|
137 | //local variables |
---|
138 | Variable pi43,c1,c2,form,volume,arg1,arg2 |
---|
139 | |
---|
140 | PI43=4.0/3.0*PI |
---|
141 | Pp=CORRAD/SHLRAD |
---|
142 | VOLUME=PI43*SHLRAD*SHLRAD*SHLRAD |
---|
143 | C1=DRHO1*VOLUME |
---|
144 | C2=DRHO2*VOLUME |
---|
145 | |
---|
146 | // the beta factor is not calculated |
---|
147 | // the calculated form factor <f^2> has units [length^2] |
---|
148 | // and must be multiplied by number density [l^-3] and the correct unit |
---|
149 | // conversion to get to absolute scale |
---|
150 | |
---|
151 | // DO 10 I=1,NPTSM |
---|
152 | // F=P*P*P*C1*FNT1(QVALSM(I)*P*SHLRAD,Z) |
---|
153 | // 2 +C2*FNT1(QVALSM(I)*SHLRAD,Z) |
---|
154 | // FAVE2=F*F |
---|
155 | |
---|
156 | arg1 = x*shlrad*pp |
---|
157 | arg2 = x*shlrad |
---|
158 | |
---|
159 | FORM=(Pp^6.0)*C1*C1*FNT2(arg1,Zz) |
---|
160 | form += C2*C2*FNT2(arg2,Zz) |
---|
161 | form += 2.0*C1*C2*FNT3(arg2,Pp,Zz) |
---|
162 | |
---|
163 | //convert the result to [cm^-1] |
---|
164 | |
---|
165 | //scale the result |
---|
166 | // - divide by the polydisperse volume, mult by 10^8 |
---|
167 | form /= vpoly |
---|
168 | form *= 1.0e8 |
---|
169 | form *= scale |
---|
170 | |
---|
171 | //add in the background |
---|
172 | form += bkg |
---|
173 | |
---|
174 | RETURN (form) |
---|
175 | END |
---|
176 | ////////////////////////////////////// |
---|
177 | //cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
---|
178 | //c |
---|
179 | //c FUNCTION FNT1(Y,Z) |
---|
180 | //c |
---|
181 | Function FNT1(Yy,Zz) |
---|
182 | Variable yy,zz |
---|
183 | |
---|
184 | //local variables |
---|
185 | Variable z1,z2,uu,vv,ww,term1,term2,fnt1 |
---|
186 | |
---|
187 | Z1=Zz+1.0 |
---|
188 | Z2=Zz+2.0 |
---|
189 | Uu=Yy/Z1 |
---|
190 | Vv=ATAN(Uu) |
---|
191 | Ww=ATAN(2.0*Uu) |
---|
192 | TERM1=SIN(Z1*Vv)/((1.0+Uu*Uu)^(Z1/2.0)) |
---|
193 | TERM2=Yy*COS(Z2*Vv)/((1.0+Uu*Uu)^(Z2/2.0)) |
---|
194 | FNT1=3.0/Yy/Yy/Yy*(TERM1-TERM2) |
---|
195 | |
---|
196 | RETURN (fnt1) |
---|
197 | END |
---|
198 | |
---|
199 | //cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
---|
200 | //c |
---|
201 | //c FUNCTION FNT2(Y,Z) |
---|
202 | //c |
---|
203 | FUNCTION FNT2(Yy,Zz) |
---|
204 | Variable yy,zz |
---|
205 | |
---|
206 | //local variables |
---|
207 | Variable z1,z2,z3,uu,ww,term1,term2,term3,fnt2 |
---|
208 | |
---|
209 | Z1=Zz+1.0 |
---|
210 | Z2=Zz+2.0 |
---|
211 | Z3=Zz+3.0 |
---|
212 | Uu=Yy/Z1 |
---|
213 | Ww=ATAN(2.0*Uu) |
---|
214 | TERM1=COS(Z1*Ww)/((1.0+4.0*Uu*Uu)^(Z1/2.0)) |
---|
215 | TERM2=2.0*Yy*SIN(Z2*Ww)/((1.0+4.0*Uu*Uu)^(Z2/2.0)) |
---|
216 | TERM3=1.0+COS(Z3*Ww)/((1.0+4.0*Uu*Uu)^(Z3/2.0)) |
---|
217 | FNT2=(4.50/Z1/Yy^6.0)*(Z1*(1.0-TERM1-TERM2)+Yy*Yy*Z2*TERM3) |
---|
218 | |
---|
219 | RETURN (fnt2) |
---|
220 | END |
---|
221 | |
---|
222 | //cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
---|
223 | //c |
---|
224 | //c FUNCTION FNT3(Y,P,Z) |
---|
225 | //c |
---|
226 | FUNCTION FNT3(Yy,Pp,Zz) |
---|
227 | Variable yy,pp,zz |
---|
228 | |
---|
229 | //local variables |
---|
230 | Variable z1,z2,z3,yp,yn,up,un,vp,vn,term1,term2,term3,term4,term5,term6,fnt3 |
---|
231 | |
---|
232 | Z1=Zz+1 |
---|
233 | Z2=Zz+2 |
---|
234 | Z3=Zz+3 |
---|
235 | YP=(1.0+Pp)*Yy |
---|
236 | YN=(1.0-Pp)*Yy |
---|
237 | UP=YP/Z1 |
---|
238 | UN=YN/Z1 |
---|
239 | VP=ATAN(UP) |
---|
240 | VN=ATAN(UN) |
---|
241 | TERM1=COS(Z1*VN)/((1.0+UN*UN)^(Z1/2.0)) |
---|
242 | TERM2=COS(Z1*VP)/((1.0+UP*UP)^(Z1/2.0)) |
---|
243 | TERM3=COS(Z3*VN)/((1.0+UN*UN)^(Z3/2.0)) |
---|
244 | TERM4=COS(Z3*VP)/((1.0+UP*UP)^(Z3/2.0)) |
---|
245 | TERM5=YN*SIN(Z2*VN)/((1.0+UN*UN)^(Z2/2.0)) |
---|
246 | TERM6=YP*SIN(Z2*VP)/((1.0+UP*UP)^(Z2/2.0)) |
---|
247 | FNT3=(4.5/Z1/Yy^6.0) |
---|
248 | fnt3 *=(Z1*(TERM1-TERM2)+Yy*Yy*Pp*Z2*(TERM3+TERM4)+Z1*(TERM5-TERM6)) |
---|
249 | |
---|
250 | RETURN (fnt3) |
---|
251 | END |
---|
252 | ///////////////////////////////// |
---|
253 | |
---|
254 | // this is all there is to the smeared calculation! |
---|
255 | Function SmearedPolyCoreShellRatio(s) :FitFunc |
---|
256 | Struct ResSmearAAOStruct &s |
---|
257 | |
---|
258 | ////the name of your unsmeared model is the first argument |
---|
259 | Smear_Model_20(PolyCoreShellRatio,s.coefW,s.xW,s.yW,s.resW) |
---|
260 | |
---|
261 | return(0) |
---|
262 | End |
---|
263 | |
---|
264 | //wrapper to calculate the smeared model as an AAO-Struct |
---|
265 | // fills the struct and calls the ususal function with the STRUCT parameter |
---|
266 | // |
---|
267 | // used only for the dependency, not for fitting |
---|
268 | // |
---|
269 | Function fSmearedPolyCoreShellRatio(coefW,yW,xW) |
---|
270 | Wave coefW,yW,xW |
---|
271 | |
---|
272 | String str = getWavesDataFolder(yW,0) |
---|
273 | String DF="root:"+str+":" |
---|
274 | |
---|
275 | WAVE resW = $(DF+str+"_res") |
---|
276 | |
---|
277 | STRUCT ResSmearAAOStruct fs |
---|
278 | WAVE fs.coefW = coefW |
---|
279 | WAVE fs.yW = yW |
---|
280 | WAVE fs.xW = xW |
---|
281 | WAVE fs.resW = resW |
---|
282 | |
---|
283 | Variable err |
---|
284 | err = SmearedPolyCoreShellRatio(fs) |
---|
285 | |
---|
286 | return (0) |
---|
287 | End |
---|