source: sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/MultiShell.ipf @ 127

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

LOTS of changes to the analysis ipf files:

-- see sphere.ipf for the simplest example of the changes --

  • #pragma Igor 6
  • #if directive to look for XOP
  • AAO unsmeared functions
  • STRUCT functions for smearing (also AAO)
  • new wrappers for dependencies to struct functions

(2006 models have NOT been completed yet, only the old models)

  • loading data files into data folders (PlotUtils?) + some streamlining of the loaders
  • Smear_Model_N is now AAO + some streamlining of the quadrature code

-- SHS and SW structure factor XOPs are crashing (need DP wave, I may have old XOP)
-- this breaks fitting of the smeared models until wrappers can be devised
-- all packages will be broken due to the new data folder structure
-- multiple instances of functions will now cause problems (MSA)
-- RPA model is a problem with its odd functional form (extra wave)

-- lots of other carnage to follow as the bugs and typos are shaken out

24 JUL 2007 SRK

File size: 4.4 KB
Line 
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//
13Proc 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 (^-1) for model: "
17        Prompt qmax "Enter maximum q-value (^-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        ywave_mss := MultiShellForm(coef_mss,xwave_mss)
25        Display/K=1 ywave_mss vs xwave_mss
26        ModifyGraph log=1,marker=29,msize=2,mode=4
27        Label bottom "q (\\S-1\\M)"
28        Label left "Intensity (cm\\S-1\\M)"
29        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)
30End
31
32Proc PlotSmearedMultiShell()                                                           
33        //no input parameters necessary, it MUST use the experimental q-values
34        // from the experimental data read in from an AVE/QSIG data file
35       
36        // if no gQvals wave, data must not have been loaded => abort
37        if(Exists("gQvals") != 2)               // 2 = string or numeric variable exists
38                Abort "6-column QSIG data not loaded. Use LoadQSIGData macro"
39        else
40                if(WaveExists($gQvals) ==0)     //wave ref does not exist
41                        Abort "6-column QSIG waves are missing. Re-load with LoadQSIGData macro"
42                endif
43        endif
44       
45        // Setup parameter table for model function
46        make/O/D smear_coef_mss = {1.,60,10,10,6.4e-6,0.4e-6,2,0.001}                                   
47        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)"}
48        Edit/K=1 smear_parameters_mss,smear_coef_mss                                   
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_mss,smeared_qvals                           
53        SetScale d,0,0,"1/cm",smeared_mss                                                       
54
55        smeared_mss := SmearedMultiShell(smear_coef_mss,$gQvals)               
56        Display/K=1 smeared_mss 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)
61End
62
63Function MultiShellForm(w,x) :FitFunc
64        Wave w
65        Variable x
66       
67        // variables are:
68        //[0] scale factor
69        //[1] radius of core []
70        //[2] thickness of the shell    []
71        //[3] thickness of the water layer
72        //[4] SLD of the core = sld of the solvent[-2]
73        //[5] SLD of the shell
74        //[6] number of pairs (tw+tsh)
75        //[7] background        [cm-1]
76       
77        // All inputs are in ANGSTROMS
78        //OUTPUT is normalized by the particle volume, and converted to [cm-1]
79       
80       
81        Variable scale,rcore,tw,ts,rhocore,rhoshel,num,bkg
82        scale = w[0]
83        rcore = w[1]
84        ts = w[2]
85        tw = w[3]
86        rhocore = w[4]
87        rhoshel = w[5]
88        num = w[6]
89        bkg = w[7]
90       
91        //calculate with a loop, two shells at a time
92        Variable ii=0,fval=0,voli,ri,sldi
93
94        do
95                ri = rcore + ii*ts + ii*tw
96                voli = 4*pi/3*ri^3
97                sldi = rhocore-rhoshel
98                fval += voli*sldi*F_func(ri*x)
99                ri += ts
100                voli = 4*pi/3*ri^3
101                sldi = rhoshel-rhocore
102                fval += voli*sldi*F_func(ri*x)
103                ii+=1           //do 2 layers at a time
104        while(ii<=num-1)  //change to make 0 < num < 2 correspond to unilamellar vesicles (C. Glinka, 11/24/03)
105       
106        fval *=fval             //square it
107        fval /=voli             //normalize by the overall volume
108        fval *=scale*1e8
109        fval += bkg
110       
111        return(fval)
112End
113
114Function F_func(qr)
115        Variable qr
116       
117        Variable val=0
118       
119        val = 3*(sin(qr) - qr*cos(qr))/qr^3
120       
121        return(val)
122End
123
124
125//
126//Function Schulz_Point_ms(x,avg,zz)
127//
128//      //Wave w
129//      Variable x,avg,zz
130//      Variable dr
131//     
132//      dr = zz*ln(x) - gammln(zz+1)+(zz+1)*ln((zz+1)/avg)-(x/avg*(zz+1))
133//     
134//      return (exp(dr))
135//     
136//End
137
138// this is all there is to the smeared calculation!
139Function SmearedMultiShell(w,x) :FitFunc
140        Wave w
141        Variable x
142       
143        Variable ans
144        SVAR sq = gSig_Q
145        SVAR qb = gQ_bar
146        SVAR sh = gShadow
147        SVAR gQ = gQVals
148       
149        //the name of your unsmeared model is the first argument
150        ans = Smear_Model_76(MultiShellForm,$sq,$qb,$sh,$gQ,w,x)
151
152        return(ans)
153End
Note: See TracBrowser for help on using the repository browser.