source: sans/Release/trunk/NCNR_User_Procedures/SANS/Analysis/Models_v3.00/CoreShell.ipf @ 381

Last change on this file since 381 was 381, checked in by srkline, 14 years ago

Merging Dev/trunk revision 374+ into Release/trunk for version 6.004

File size: 4.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 sphere with a core-shell structure
9//
10// 06 NOV 98 SRK
11////////////////////////////////////////////////
12
13Proc PlotCoreShellSphere(num,qmin,qmax)
14        Variable num=128,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_css,ywave_css
20        xwave_css =alog(log(qmin) + x*((log(qmax)-log(qmin))/num))
21        make/o/d coef_css = {1.,60,10,1e-6,2e-6,3e-6,0.001}
22        make/o/t parameters_css = {"scale","core radius (A)","shell thickness (A)","Core SLD (A-2)","Shell SLD (A-2)","Solvent SLD (A-2)","bkg (cm-1)"}
23        Edit parameters_css,coef_css
24        ywave_css := CoreShellForm(coef_css,xwave_css)
25        Display ywave_css vs xwave_css
26        ModifyGraph log=1,marker=29,msize=2,mode=4
27        Label bottom "q (A\\S-1\\M)"
28        Label left "Intensity (cm\\S-1\\M)"
29        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
30End
31
32///////////////////////////////////////////////////////////
33
34Proc PlotSmearedCoreShellSphere()                                                               //**** name of your function
35        //no input parameters necessary, it MUST use the experimental q-values
36        // from the experimental data read in from an AVE/QSIG data file
37       
38        // if no gQvals wave, data must not have been loaded => abort
39        if(ResolutionWavesMissing())
40                Abort
41        endif
42       
43        // Setup parameter table for model function
44        make/o/d smear_coef_css = {1.,60,10,1e-6,2e-6,3e-6,0.001}
45        make/o/t smear_parameters_css = {"scale","core radius (A)","shell thickness (A)","Core SLD (A-2)","Shell SLD (A-2)","Solvent SLD (A-2)","bkg (cm-1)"}
46        Edit smear_parameters_css,smear_coef_css
47       
48        // output smeared intensity wave, dimensions are identical to experimental QSIG values
49        // make extra copy of experimental q-values for easy plotting
50       
51        Duplicate/O $gQvals smeared_css,smeared_qvals                           
52        SetScale d,0,0,"1/cm",smeared_css                                                       
53
54        smeared_css := SmearedCoreShellForm(smear_coef_css,$gQvals)                                                                     
55        Display smeared_css vs smeared_qvals                                                                   
56        ModifyGraph log=1,marker=29,msize=2,mode=4
57        Label bottom "q (A\\S-1\\M)"
58        Label left "Intensity (cm\\S-1\\M)"
59        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
60End
61
62///////////////////////////////////////////////////////////////
63// unsmeared model calculation
64///////////////////////////
65Function CoreShellForm(w,x) : FitFunc
66        Wave w
67        Variable x
68       
69        // variables are:
70        //[0] scale factor
71        //[1] radius of core [A]
72        //[2] thickness of the shell    [A]
73        //[3] SLD of the core   [A-2]
74        //[4] SLD of the shell
75        //[5] SLD of the solvent
76        //[6] background        [cm-1]
77       
78        // All inputs are in ANGSTROMS
79        //OUTPUT is normalized by the particle volume, and converted to [cm-1]
80       
81       
82        Variable scale,rcore,thick,rhocore,rhoshel,rhosolv,bkg
83        scale = w[0]
84        rcore = w[1]
85        thick = w[2]
86        rhocore = w[3]
87        rhoshel = w[4]
88        rhosolv = w[5]
89        bkg = w[6]
90       
91        // calculates scale *( f^2 + bkg)
92        Variable bes,f,vol,qr,contr,f2
93       
94        // core first, then add in shell
95        qr=x*rcore
96        contr = rhocore-rhoshel
97        bes = 3*(sin(qr)-qr*cos(qr))/qr^3
98        vol = 4*pi/3*rcore^3
99        f = vol*bes*contr
100        //now the shell
101        qr=x*(rcore+thick)
102        contr = rhoshel-rhosolv
103        bes = 3*(sin(qr)-qr*cos(qr))/qr^3
104        vol = 4*pi/3*(rcore+thick)^3
105        f += vol*bes*contr
106       
107        // normalize to particle volume and rescale from [A-1] to [cm-1]
108        f2 = f*f/vol*1.0e8
109       
110        //scale if desired
111        f2 *= scale
112        // then add in the background
113        f2 += bkg
114       
115        return (f2)
116End
117
118// this is all there is to the smeared calculation!
119Function SmearedCoreShellForm(w,x) :FitFunc
120        Wave w
121        Variable x
122       
123        Variable ans
124        SVAR sq = gSig_Q
125        SVAR qb = gQ_bar
126        SVAR sh = gShadow
127        SVAR gQ = gQVals
128       
129        //the name of your unsmeared model is the first argument
130        ans = Smear_Model_20(CoreShellForm,$sq,$qb,$sh,$gQ,w,x)
131
132        return(ans)
133End
Note: See TracBrowser for help on using the repository browser.