source: sans/Analysis/trunk/Put in User Procedures/SANS_Models_v3.00/PolyCoreShellRatio.ipf @ 56

Last change on this file since 56 was 42, checked in by srkline, 16 years ago

initial checkin of Analysis v.3.00 files

File size: 7.0 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2
3////////////////////////////////////////////////
4// GaussUtils.proc and PlotUtils.proc MUST be included for the smearing calculation to compile
5// Adopting these into the experiment will insure that they are always present
6////////////////////////////////////////////////
7//
8// this function is for the form factor of a polydisperse spherical particle, with a core-shell structure
9// the polydispersity of the overall (core+shell) radius is described by a Schulz distribution
10// the ratio R(core)/ R (total) is constant
11//
12// 06 NOV 98 SRK
13////////////////////////////////////////////////
14
15Proc PlotPolyCoreShellRatio(num,qmin,qmax)
16        Variable num=128,qmin=0.001,qmax=0.7
17        Prompt num "Enter number of data points for model: "
18        Prompt qmin "Enter minimum q-value (^-1) for model: "
19        Prompt qmax "Enter maximum q-value (^-1) for model: "
20       
21        Make/O/D/n=(num) xwave_pcr,ywave_pcr
22        xwave_pcr = alog(log(qmin) + x*((log(qmax)-log(qmin))/num))     
23        Make/O/D coef_pcr = {1.,60,10,.2,1e-6,2e-6,3e-6,0.001}
24        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)"}
25        Edit parameters_pcr,coef_pcr
26        ywave_pcr := PolyCoreShellRatio(coef_pcr,xwave_pcr)
27        Display ywave_pcr vs xwave_pcr
28        ModifyGraph log=1,marker=29,msize=2,mode=4
29        Label bottom "q (\\S-1\\M)"
30        Label left "Intensity (cm\\S-1\\M)"
31        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
32End
33
34///////////////////////////////////////////////////////////
35
36Proc PlotSmearedPolyCoreShellRatio()           
37        //no input parameters necessary, it MUST use the experimental q-values
38        // from the experimental data read in from an AVE/QSIG data file
39       
40        // if no gQvals wave, data must not have been loaded => abort
41        if(ResolutionWavesMissing())
42                Abort
43        endif
44       
45        // Setup parameter table for model function
46        Make/O/D smear_coef_pcr = {1.,60,10,.2,1e-6,2e-6,3e-6,0.001}
47        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)"}
48        Edit smear_parameters_pcr,smear_coef_pcr
49       
50        // output smeared intensity wave, dimensions are identical to experimental QSIG values
51        // make extra copy of experimental q-values for easy plotting
52        Duplicate/O $gQvals smeared_pcr,smeared_qvals                           //**** mod
53        SetScale d,0,0,"1/cm",smeared_pcr                                                       //**** mod
54
55        smeared_pcr := SmearedPolyCoreShellRatio(smear_coef_pcr,$gQvals)
56        Display smeared_pcr vs smeared_qvals
57        ModifyGraph log=1,marker=29,msize=2,mode=4
58        Label bottom "q (\\S-1\\M)"
59        Label left "Intensity (cm\\S-1\\M)"
60        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
61
62End
63
64///////////////////////////////////////////////////////////////
65// unsmeared model calculation
66///////////////////////////
67//C     CALC'S THE FORM FACTOR FOR A MONOMODAL
68//c     POPULATION OF POLYDISPERSE SHERES WITH A
69//c     CORE AND SHELL TYPE SLD DISTRIBUTION. IT
70//c     ASSUMES THAT THE CORE RADIUS IS A CONSTANT
71//c     FRACTION (P) OF THE SHELL  RADIUS.
72//c
73//c
74//c     REF.:    "DETERMINATION OF THE STRUCTURE AND DYNAMICS OF
75//c              MICELLAR SOLUTIONS BY NEUTRON SMALL-ANGLE SCATTERING"
76//c              BY J.B.HAYTER IN PHYSICS OF AMPHIPHILES--MICELLES,
77//c              VESICLES, AND MICROEMULSIONS ED BY  DEGIORGIO,V;  CORTI,M,
78//c              PP59-93,1983.
79//c
80//c     EQNS: 32-37
81//c
82Function PolyCoreShellRatio(w,x) : FitFunc
83        Wave w;Variable x
84
85        //assign nice names to the input wave
86        //w[0] = scale
87        //w[1] = core radius []
88        //w[2] = shell thickness []
89        //w[3] = polydispersity index (0<p<1)
90        //w[4] = SLD core [^-2]
91        //w[5] = SLD shell  [^-2]
92        //w[6] = SLD solvent [^-2]
93        //w[7] = bkg [cm-1]
94        Variable scale,corrad,thick,shlrad,pp,drho1,drho2,sig,zz,bkg
95        Variable sld1,sld2,sld3,zp1,zp2,zp3,vpoly
96       
97        scale = w[0]
98        corrad = w[1]
99        thick = w[2]
100        sig = w[3]
101        sld1 = w[4]
102        sld2 = w[5]
103        sld3 = w[6]
104        bkg = w[7]
105       
106        //calculations on input parameters
107        shlrad = corrad + thick
108        zz = (1/sig)^2-1
109        drho1 = sld1-sld2               //core-shell
110        drho2 = sld2-sld3               //shell-solvent
111        zp1 = zz + 1.
112        zp2 = zz + 2.
113        zp3 = zz + 3.
114        vpoly = 4*Pi/3*zp3*zp2/zp1/zp1*(corrad+thick)^3
115       
116        //local variables
117        Variable pi43,c1,c2,form,volume,arg1,arg2
118       
119        PI43=4.0/3.0*PI
120        Pp=CORRAD/SHLRAD
121        VOLUME=PI43*SHLRAD*SHLRAD*SHLRAD
122        C1=DRHO1*VOLUME
123        C2=DRHO2*VOLUME
124       
125        // the beta factor is not calculated
126        // the calculated form factor <f^2> has units [length^2]
127        // and must be multiplied by number density [l^-3] and the correct unit
128        // conversion to get to absolute scale
129       
130//      DO 10  I=1,NPTSM
131//        F=P*P*P*C1*FNT1(QVALSM(I)*P*SHLRAD,Z)
132//     2   +C2*FNT1(QVALSM(I)*SHLRAD,Z)
133//       FAVE2=F*F
134               
135        arg1 = x*shlrad*pp
136        arg2 = x*shlrad
137               
138        FORM=(Pp^6.0)*C1*C1*FNT2(arg1,Zz)
139        form += C2*C2*FNT2(arg2,Zz)
140        form += 2.0*C1*C2*FNT3(arg2,Pp,Zz)
141       
142        //convert the result to [cm^-1]
143       
144        //scale the result
145        // - divide by the polydisperse volume, mult by 10^8
146        form  /= vpoly
147        form *= 1.0e8
148        form *= scale
149
150        //add in the background
151        form += bkg
152     
153        RETURN (form)
154END
155//////////////////////////////////////
156//cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
157//c
158//c      FUNCTION FNT1(Y,Z)
159//c
160        Function FNT1(Yy,Zz)
161        Variable yy,zz
162       
163        //local variables
164        Variable z1,z2,uu,vv,ww,term1,term2,fnt1
165
166        Z1=Zz+1.0
167        Z2=Zz+2.0
168        Uu=Yy/Z1
169        Vv=ATAN(Uu)
170        Ww=ATAN(2.0*Uu)
171        TERM1=SIN(Z1*Vv)/((1.0+Uu*Uu)^(Z1/2.0))
172        TERM2=Yy*COS(Z2*Vv)/((1.0+Uu*Uu)^(Z2/2.0))
173        FNT1=3.0/Yy/Yy/Yy*(TERM1-TERM2)
174       
175        RETURN (fnt1)
176END
177
178//cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
179//c
180//c      FUNCTION FNT2(Y,Z)
181//c
182FUNCTION FNT2(Yy,Zz)
183        Variable yy,zz
184       
185        //local variables
186        Variable z1,z2,z3,uu,ww,term1,term2,term3,fnt2
187       
188        Z1=Zz+1.0
189        Z2=Zz+2.0
190        Z3=Zz+3.0
191        Uu=Yy/Z1
192        Ww=ATAN(2.0*Uu)
193        TERM1=COS(Z1*Ww)/((1.0+4.0*Uu*Uu)^(Z1/2.0))
194        TERM2=2.0*Yy*SIN(Z2*Ww)/((1.0+4.0*Uu*Uu)^(Z2/2.0))
195        TERM3=1.0+COS(Z3*Ww)/((1.0+4.0*Uu*Uu)^(Z3/2.0))
196        FNT2=(4.50/Z1/Yy^6.0)*(Z1*(1.0-TERM1-TERM2)+Yy*Yy*Z2*TERM3)
197       
198        RETURN (fnt2)
199END
200
201//cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
202//c
203//c      FUNCTION FNT3(Y,P,Z)
204//c
205FUNCTION FNT3(Yy,Pp,Zz)
206        Variable yy,pp,zz
207       
208        //local variables
209        Variable z1,z2,z3,yp,yn,up,un,vp,vn,term1,term2,term3,term4,term5,term6,fnt3
210       
211        Z1=Zz+1
212        Z2=Zz+2
213        Z3=Zz+3
214        YP=(1.0+Pp)*Yy
215        YN=(1.0-Pp)*Yy
216        UP=YP/Z1
217        UN=YN/Z1
218        VP=ATAN(UP)
219        VN=ATAN(UN)
220        TERM1=COS(Z1*VN)/((1.0+UN*UN)^(Z1/2.0))
221        TERM2=COS(Z1*VP)/((1.0+UP*UP)^(Z1/2.0))
222        TERM3=COS(Z3*VN)/((1.0+UN*UN)^(Z3/2.0))
223        TERM4=COS(Z3*VP)/((1.0+UP*UP)^(Z3/2.0))
224        TERM5=YN*SIN(Z2*VN)/((1.0+UN*UN)^(Z2/2.0))
225        TERM6=YP*SIN(Z2*VP)/((1.0+UP*UP)^(Z2/2.0))
226        FNT3=(4.5/Z1/Yy^6.0)
227        fnt3 *=(Z1*(TERM1-TERM2)+Yy*Yy*Pp*Z2*(TERM3+TERM4)+Z1*(TERM5-TERM6))
228     
229        RETURN (fnt3)
230END
231/////////////////////////////////
232
233// this is all there is to the smeared calculation!
234Function SmearedPolyCoreShellRatio(w,x) :FitFunc
235        Wave w
236        Variable x
237       
238        Variable ans
239        SVAR sq = gSig_Q
240        SVAR qb = gQ_bar
241        SVAR sh = gShadow
242        SVAR gQ = gQVals
243       
244        //the name of your unsmeared model is the first argument
245        ans = Smear_Model_20(PolyCoreShellRatio,$sq,$qb,$sh,$gQ,w,x)
246
247        return(ans)
248End
Note: See TracBrowser for help on using the repository browser.