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 | // |
---|
13 | Proc 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 | |
---|
25 | Variable/G root:g_mss |
---|
26 | g_mss := MultiShellForm(coef_mss,ywave_mss,xwave_mss) |
---|
27 | Display/K=1 ywave_mss vs xwave_mss |
---|
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) |
---|
32 | End |
---|
33 | |
---|
34 | // - sets up a dependency to a wrapper, not the actual SmearedModelFunction |
---|
35 | Proc PlotSmearedMultiShell(str) |
---|
36 | String str |
---|
37 | Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4) |
---|
38 | |
---|
39 | // if any of the resolution waves are missing => abort |
---|
40 | if(ResolutionWavesMissingDF(str)) //updated to NOT use global strings (in GaussUtils) |
---|
41 | Abort |
---|
42 | endif |
---|
43 | |
---|
44 | SetDataFolder $("root:"+str) |
---|
45 | |
---|
46 | // Setup parameter table for model function |
---|
47 | make/O/D smear_coef_mss = {1.,60,10,10,6.4e-6,0.4e-6,2,0.001} |
---|
48 | 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)"} |
---|
49 | Edit/K=1 smear_parameters_mss,smear_coef_mss |
---|
50 | |
---|
51 | // output smeared intensity wave, dimensions are identical to experimental QSIG values |
---|
52 | // make extra copy of experimental q-values for easy plotting |
---|
53 | Duplicate/O $(str+"_q") smeared_mss,smeared_qvals |
---|
54 | SetScale d,0,0,"1/cm",smeared_mss |
---|
55 | |
---|
56 | Variable/G gs_mss=0 |
---|
57 | gs_mss := fSmearedMultiShell(smear_coef_mss,smeared_mss,smeared_qvals) //this wrapper fills the STRUCT |
---|
58 | |
---|
59 | Display/K=1 smeared_mss vs smeared_qvals |
---|
60 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
61 | Label bottom "q (\\S-1\\M)" |
---|
62 | Label left "Intensity (cm\\S-1\\M)" |
---|
63 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
64 | |
---|
65 | SetDataFolder root: |
---|
66 | End |
---|
67 | |
---|
68 | |
---|
69 | |
---|
70 | |
---|
71 | //AAO version, uses XOP if available |
---|
72 | // simply calls the original single point calculation with |
---|
73 | // a wave assignment (this will behave nicely if given point ranges) |
---|
74 | Function MultiShellForm(cw,yw,xw) : FitFunc |
---|
75 | Wave cw,yw,xw |
---|
76 | |
---|
77 | #if exists("MultiShellFormX") |
---|
78 | yw = MultiShellFormX(cw,xw) |
---|
79 | #else |
---|
80 | yw = fMultiShellForm(cw,xw) |
---|
81 | #endif |
---|
82 | return(0) |
---|
83 | End |
---|
84 | |
---|
85 | Function fMultiShellForm(w,x) :FitFunc |
---|
86 | Wave w |
---|
87 | Variable x |
---|
88 | |
---|
89 | // variables are: |
---|
90 | //[0] scale factor |
---|
91 | //[1] radius of core [] |
---|
92 | //[2] thickness of the shell [] |
---|
93 | //[3] thickness of the water layer |
---|
94 | //[4] SLD of the core = sld of the solvent[-2] |
---|
95 | //[5] SLD of the shell |
---|
96 | //[6] number of pairs (tw+tsh) |
---|
97 | //[7] background [cm-1] |
---|
98 | |
---|
99 | // All inputs are in ANGSTROMS |
---|
100 | //OUTPUT is normalized by the particle volume, and converted to [cm-1] |
---|
101 | |
---|
102 | |
---|
103 | Variable scale,rcore,tw,ts,rhocore,rhoshel,num,bkg |
---|
104 | scale = w[0] |
---|
105 | rcore = w[1] |
---|
106 | ts = w[2] |
---|
107 | tw = w[3] |
---|
108 | rhocore = w[4] |
---|
109 | rhoshel = w[5] |
---|
110 | num = w[6] |
---|
111 | bkg = w[7] |
---|
112 | |
---|
113 | //calculate with a loop, two shells at a time |
---|
114 | Variable ii=0,fval=0,voli,ri,sldi |
---|
115 | |
---|
116 | do |
---|
117 | ri = rcore + ii*ts + ii*tw |
---|
118 | voli = 4*pi/3*ri^3 |
---|
119 | sldi = rhocore-rhoshel |
---|
120 | fval += voli*sldi*F_func(ri*x) |
---|
121 | ri += ts |
---|
122 | voli = 4*pi/3*ri^3 |
---|
123 | sldi = rhoshel-rhocore |
---|
124 | fval += voli*sldi*F_func(ri*x) |
---|
125 | ii+=1 //do 2 layers at a time |
---|
126 | while(ii<=num-1) //change to make 0 < num < 2 correspond to unilamellar vesicles (C. Glinka, 11/24/03) |
---|
127 | |
---|
128 | fval *=fval //square it |
---|
129 | fval /=voli //normalize by the overall volume |
---|
130 | fval *=scale*1e8 |
---|
131 | fval += bkg |
---|
132 | |
---|
133 | return(fval) |
---|
134 | End |
---|
135 | |
---|
136 | Function F_func(qr) |
---|
137 | Variable qr |
---|
138 | |
---|
139 | Variable val=0 |
---|
140 | |
---|
141 | val = 3*(sin(qr) - qr*cos(qr))/qr^3 |
---|
142 | |
---|
143 | return(val) |
---|
144 | End |
---|
145 | |
---|
146 | |
---|
147 | // |
---|
148 | //Function Schulz_Point_ms(x,avg,zz) |
---|
149 | // |
---|
150 | // //Wave w |
---|
151 | // Variable x,avg,zz |
---|
152 | // Variable dr |
---|
153 | // |
---|
154 | // dr = zz*ln(x) - gammln(zz+1)+(zz+1)*ln((zz+1)/avg)-(x/avg*(zz+1)) |
---|
155 | // |
---|
156 | // return (exp(dr)) |
---|
157 | // |
---|
158 | //End |
---|
159 | |
---|
160 | //wrapper to calculate the smeared model as an AAO-Struct |
---|
161 | // fills the struct and calls the ususal function with the STRUCT parameter |
---|
162 | // |
---|
163 | // used only for the dependency, not for fitting |
---|
164 | // |
---|
165 | Function fSmearedMultiShell(coefW,yW,xW) |
---|
166 | Wave coefW,yW,xW |
---|
167 | |
---|
168 | String str = getWavesDataFolder(yW,0) |
---|
169 | String DF="root:"+str+":" |
---|
170 | |
---|
171 | WAVE resW = $(DF+str+"_res") |
---|
172 | |
---|
173 | STRUCT ResSmearAAOStruct fs |
---|
174 | WAVE fs.coefW = coefW |
---|
175 | WAVE fs.yW = yW |
---|
176 | WAVE fs.xW = xW |
---|
177 | WAVE fs.resW = resW |
---|
178 | |
---|
179 | Variable err |
---|
180 | err = SmearedMultiShell(fs) |
---|
181 | |
---|
182 | return (0) |
---|
183 | End |
---|
184 | |
---|
185 | // this is all there is to the smeared calculation! |
---|
186 | Function SmearedMultiShell(s) :FitFunc |
---|
187 | Struct ResSmearAAOStruct &s |
---|
188 | |
---|
189 | // the name of your unsmeared model (AAO) is the first argument |
---|
190 | s.yW = Smear_Model_20(MultiShellForm,s.coefW,s.xW,s.resW) |
---|
191 | |
---|
192 | return(0) |
---|
193 | End |
---|
194 | |
---|