source: sans/Analysis/trunk/Put in User Procedures/SANS_Models_v3.00/PolyCore.ipf @ 42

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

initial checkin of Analysis v.3.00 files

File size: 5.6 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 calculates the form factor for polydisperse spherical particles
9// the polydispersity is a Schulz distribution
10// the spherical particles have a core-shell structure, with a polydisperse core and constant
11// shell thickness
12//
13// 06 NOV 98 SRK
14////////////////////////////////////////////////
15
16Proc PlotPolyCoreForm(num,qmin,qmax)
17        Variable num=256,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_pcf,ywave_pcf
23        //xwave_pcf = qmin + x*((qmax-qmin)/num)
24        xwave_pcf = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) )
25        Make/O/D coef_pcf = {1.,60,.2,10,1e-6,2e-6,3e-6,0.001}
26        make/o/t parameters_pcf = {"scale","avg core rad (A)","core polydisp (0,1)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","bkg (cm-1)"}
27        Edit parameters_pcf,coef_pcf
28        ywave_pcf := PolyCoreForm(coef_pcf,xwave_pcf)
29        Display ywave_pcf vs xwave_pcf
30        ModifyGraph log=1,marker=29,msize=2,mode=4
31        Label bottom "q (\\S-1\\M)"
32        Label left "Intensity (cm\\S-1\\M)"
33        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
34End
35
36///////////////////////////////////////////////////////////
37
38Proc PlotSmearedPolyCoreForm()                                         
39        //no input parameters necessary, it MUST use the experimental q-values
40        // from the experimental data read in from an AVE/QSIG data file
41       
42        // if no gQvals wave, data must not have been loaded => abort
43        if(ResolutionWavesMissing())
44                Abort
45        endif
46       
47        // Setup parameter table for model function
48        Make/O/D smear_coef_pcf = {1.,60,.2,10,1e-6,2e-6,3e-6,0.001}
49        make/o/t smear_parameters_pcf = {"scale","avg core rad (A)","core polydisp (0,1)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","bkg (cm-1)"}
50        Edit smear_parameters_pcf,smear_coef_pcf
51       
52        // output smeared intensity wave, dimensions are identical to experimental QSIG values
53        // make extra copy of experimental q-values for easy plotting
54        Duplicate/O $gQvals smeared_pcf,smeared_qvals
55        SetScale d,0,0,"1/cm",smeared_pcf
56
57        smeared_pcf := SmearedPolyCoreForm(smear_coef_pcf,$gQvals)
58        Display smeared_pcf vs smeared_qvals
59        ModifyGraph log=1,marker=29,msize=2,mode=4
60        Label bottom "q (\\S-1\\M)"
61        Label left "Intensity (cm\\S-1\\M)"
62        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
63       
64End
65
66///////////////////////////////////////////////////////////////
67// unsmeared model calculation
68///////////////////////////
69Function PolyCoreForm(w,h) : FitFunc
70        Wave w
71        Variable h      // x is already used below
72
73//*             calculates <f^2> for a spherical core/shell */
74//*             geometry with a polydispersity of the core only */
75//*             The shell thickness is constant */
76//*     from  J. Chem. Phys. 96 (1992) 3306. */
77//*     beta factor is not calculated */
78
79// input parameters are
80        //[0] scale
81        //[1] average core radius       []
82        //[2] polydispersity of core (0<sig<1)
83        //[3] shell thickness   []
84        //[4] SLD core          [-2]
85        //[5] SLD shell
86        //[6] SLD solvent
87        //[7] background [cm-1]
88
89
90// OUTPUT <f^2>/Vavg IN [cm-1]
91       
92// names for inputs and returned value
93        Variable scale,corrad,sig,zz,del,drho1,drho2,form,bkg
94        scale = w[0]
95        corrad = w[1]
96        sig = w[2]
97        zz = (1/sig)^2 - 1
98        del = w[3]
99        drho1 = w[4]-w[5]               //core-shell
100        drho2 = w[5]-w[6]               //shell-solvent
101        bkg = w[7]
102       
103       
104   //* Local variables */
105    Variable d, g
106    Variable qq, x, y, c1, c2, c3, c4, c5, c6, c7, c8, c9, t1, t2, t3
107    Variable t4, t5, tb, cy, sy, tb1, tb2, tb3, c2y, zp1, zp2
108    Variable zp3,vpoly
109    Variable s2y, arg1, arg2, arg3, drh1, drh2
110
111
112//*    !!!!! drh NOW given in 1/A^2  */
113//*    core radius, del, and 1/q must be in Angstroms */
114
115    drh1 = drho1
116    drh2 = drho2
117    g = drh2 * -1. / drh1
118    zp1 = zz + 1.
119    zp2 = zz + 2.
120    zp3 = zz + 3.
121    vpoly = 4*Pi/3*zp3*zp2/zp1/zp1*(corrad+del)^3
122
123
124        qq = h  // remember that h is the passed in value of q for the calculation
125        y = h *del
126        x = h *corrad
127        d = atan(x * 2. / zp1)
128        arg1 = zp1 * d
129        arg2 = zp2 * d
130        arg3 = zp3 * d
131        sy = sin(y)
132        cy = cos(y)
133        s2y = sin(y * 2.)
134        c2y = cos(y * 2.)
135        c1 = .5 - g * (cy + y * sy) + g * g * .5 * (y * y + 1.)
136        c2 = g * y * (g - cy)
137        c3 = (g * g + 1.) * .5 - g * cy
138        c4 = g * g * (y * cy - sy) * (y * cy - sy) - c1
139        c5 = g * 2. * sy * (1. - g * (y * sy + cy)) + c2
140        c6 = c3 - g * g * sy * sy
141        c7 = g * sy - g * .5 * g * (y * y + 1.) * s2y - c5
142        c8 = c4 - .5 + g * cy - g * .5 * g * (y * y + 1.) * c2y
143        c9 = g * sy * (1. - g * cy)
144
145        tb = ln(zp1 * zp1 / (zp1 * zp1 + x * 4. * x))
146        tb1 = exp(zp1 * .5 * tb)
147        tb2 = exp(zp2 * .5 * tb)
148        tb3 = exp(zp3 * .5 * tb)
149
150        t1 = c1 + c2 * x + c3 * x * x * zp2 / zp1
151        t2 = tb1 * (c4 * cos(arg1) + c7 * sin(arg1))
152        t3 = x * tb2 * (c5 * cos(arg2) + c8 * sin(arg2))
153        t4 = zp2 / zp1 * x * x * tb3 * (c6 * cos(arg3) + c9 * sin(arg3))
154        t5 = t1 + t2 + t3 + t4
155        form = t5 * 16. * pi * pi * drh1 * drh1 / (qq^6)
156//      normalize by the average volume !!! corrected for polydispersity
157// and convert to cm-1
158        form /= vpoly
159        form *= 1.0e8
160        //Scale
161        form *= scale
162        // then add in the background
163        form += bkg
164       
165  return (form)
166
167End // end of polyCoreform
168
169// this is all there is to the smeared calculation!
170Function SmearedPolyCoreForm(w,x) :FitFunc
171        Wave w
172        Variable x
173       
174        Variable ans
175        SVAR sq = gSig_Q
176        SVAR qb = gQ_bar
177        SVAR sh = gShadow
178        SVAR gQ = gQVals
179       
180        //the name of your unsmeared model is the first argument
181        ans = Smear_Model_20(PolyCoreFormX,$sq,$qb,$sh,$gQ,w,x)
182
183        return(ans)
184End
Note: See TracBrowser for help on using the repository browser.