1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
2 | #pragma IgorVersion = 6.0 |
---|
3 | |
---|
4 | //////////////////////////////////////////////////// |
---|
5 | // |
---|
6 | // model function that calculates the scattering from |
---|
7 | // lamellar surfactant structures. contrast is two-phase, |
---|
8 | // from the solvent and uniform bilayer. The system is |
---|
9 | // considered to be DILUTE - Interference (S(Q)) effects |
---|
10 | // are NOT taken into account. ONLY the form factor is calculated |
---|
11 | // |
---|
12 | // |
---|
13 | // REFERENCE: Nallet, Laversanne, and Roux, J. Phys. II France, 3, (1993) 487-502. |
---|
14 | // also in J. Phys. Chem. B, 105, (2001) 11081-11088. |
---|
15 | // |
---|
16 | // 16 JULY 2003 SRK |
---|
17 | // |
---|
18 | //////////////////////////////////////////////////// |
---|
19 | |
---|
20 | //this macro sets up all the necessary parameters and waves that are |
---|
21 | //needed to calculate the model function. |
---|
22 | // |
---|
23 | Proc PlotLamellarFF(num,qmin,qmax) |
---|
24 | Variable num=128, qmin=.001, qmax=.5 |
---|
25 | Prompt num "Enter number of data points for model: " |
---|
26 | Prompt qmin "Enter minimum q-value (^1) for model: " |
---|
27 | Prompt qmax "Enter maximum q-value (^1) for model: " |
---|
28 | // |
---|
29 | Make/O/D/n=(num) xwave_LamellarFF, ywave_LamellarFF |
---|
30 | xwave_LamellarFF = alog(log(qmin) + x*((log(qmax)-log(qmin))/num)) |
---|
31 | Make/O/D coef_LamellarFF = {1,50,0.15,1e-6,6.3e-6,0} //CH#2 |
---|
32 | make/o/t parameters_LamellarFF = {"Scale","Bilayer Thick (delta) (A)","polydisp of thickness","SLD bilayer (A^-2)","SLD solvent (A^-2)","Incoherent Bgd (cm-1)"} //CH#3 |
---|
33 | Edit parameters_LamellarFF, coef_LamellarFF |
---|
34 | ModifyTable width(parameters_LamellarFF)=160 |
---|
35 | |
---|
36 | Variable/G root:g_LamellarFF |
---|
37 | g_LamellarFF := LamellarFF(coef_LamellarFF, ywave_LamellarFF,xwave_LamellarFF) |
---|
38 | Display ywave_LamellarFF vs xwave_LamellarFF |
---|
39 | ModifyGraph marker=29, msize=2, mode=4 |
---|
40 | ModifyGraph log=1 |
---|
41 | Label bottom "q (\\S-1\\M) " |
---|
42 | Label left "I(q) (cm\\S-1\\M)" |
---|
43 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
44 | |
---|
45 | AddModelToStrings("LamellarFF","coef_LamellarFF","LamellarFF") |
---|
46 | // |
---|
47 | End |
---|
48 | |
---|
49 | // - sets up a dependency to a wrapper, not the actual SmearedModelFunction |
---|
50 | Proc PlotSmearedLamellarFF(str) |
---|
51 | String str |
---|
52 | Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4) |
---|
53 | |
---|
54 | // if any of the resolution waves are missing => abort |
---|
55 | if(ResolutionWavesMissingDF(str)) //updated to NOT use global strings (in GaussUtils) |
---|
56 | Abort |
---|
57 | endif |
---|
58 | |
---|
59 | SetDataFolder $("root:"+str) |
---|
60 | |
---|
61 | // Setup parameter table for model function |
---|
62 | Make/O/D smear_coef_LamellarFF = {1,50,0.15,1e-6,6.3e-6,0} //CH#4 |
---|
63 | make/o/t smear_parameters_LamellarFF = {"Scale","Bilayer Thick (delta) (A)","polydisp of thickness","SLD bilayer (A^-2)","SLD solvent (A^-2)","Incoherent Bgd (cm-1)"} |
---|
64 | Edit smear_parameters_LamellarFF,smear_coef_LamellarFF //display parameters in a table |
---|
65 | |
---|
66 | // output smeared intensity wave, dimensions are identical to experimental QSIG values |
---|
67 | // make extra copy of experimental q-values for easy plotting |
---|
68 | Duplicate/O $(str+"_q") smeared_LamellarFF,smeared_qvals // |
---|
69 | SetScale d,0,0,"1/cm",smeared_LamellarFF // |
---|
70 | |
---|
71 | Variable/G gs_LamellarFF=0 |
---|
72 | gs_LamellarFF := fSmearedLamellarFF(smear_coef_LamellarFF,smeared_LamellarFF,smeared_qvals) //this wrapper fills the STRUCT |
---|
73 | |
---|
74 | Display smeared_LamellarFF vs smeared_qvals // |
---|
75 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
76 | Label bottom "q (\\S-1\\M)" |
---|
77 | Label left "I(q) (cm\\S-1\\M)" |
---|
78 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
79 | |
---|
80 | SetDataFolder root: |
---|
81 | |
---|
82 | AddModelToStrings("SmearedLamellarFF","smear_coef_LamellarFF","LamellarFF") |
---|
83 | End |
---|
84 | //////////////////////////////////////////////////// |
---|
85 | |
---|
86 | |
---|
87 | |
---|
88 | //AAO version, uses XOP if available |
---|
89 | // simply calls the original single point calculation with |
---|
90 | // a wave assignment (this will behave nicely if given point ranges) |
---|
91 | Function LamellarFF(cw,yw,xw) : FitFunc |
---|
92 | Wave cw,yw,xw |
---|
93 | |
---|
94 | #if exists("LamellarFFX") |
---|
95 | yw = LamellarFFX(cw,xw) |
---|
96 | #else |
---|
97 | yw = fLamellarFF(cw,xw) |
---|
98 | #endif |
---|
99 | return(0) |
---|
100 | End |
---|
101 | |
---|
102 | //CH#1 |
---|
103 | // you should write your function to calculate the intensity |
---|
104 | // for a single q-value (that's the input parameter x) |
---|
105 | // based on the wave (array) of parameters that you send it (w) |
---|
106 | // |
---|
107 | Function fLamellarFF(w,x) : FitFunc |
---|
108 | Wave w |
---|
109 | Variable x |
---|
110 | // Input (fitting) variables are: |
---|
111 | //[0]Scale |
---|
112 | //[1]Bilay Thick (delta) |
---|
113 | //[2] polydispersity of thickness |
---|
114 | //[3] sld bilayer |
---|
115 | //[4] sld solv |
---|
116 | //[5]Incoherent Bgd (cm-1) |
---|
117 | |
---|
118 | // give them nice names |
---|
119 | Variable scale,dd,del,sig,contr,NN,Cp,bkg,sldb,slds |
---|
120 | scale = w[0] |
---|
121 | del = w[1] |
---|
122 | sig = w[2]*del |
---|
123 | sldb = w[3] |
---|
124 | slds = w[4] |
---|
125 | bkg = w[5] |
---|
126 | |
---|
127 | contr = sldb - slds |
---|
128 | // local variables |
---|
129 | Variable inten, qval,Pq,Sq,ii,alpha,temp,t1,t2,t3,dQ |
---|
130 | |
---|
131 | // x is the q-value for the calculation |
---|
132 | qval = x |
---|
133 | |
---|
134 | Pq = 2*contr^2/qval/qval*(1-cos(qval*del)*exp(-0.5*qval^2*sig^2)) |
---|
135 | |
---|
136 | inten = 2*Pi*scale*Pq/Qval^2 //this is now dimensionless... |
---|
137 | |
---|
138 | inten /= del //normalize by the thickness (in A) |
---|
139 | |
---|
140 | inten *= 1e8 // 1/A to 1/cm |
---|
141 | |
---|
142 | Return (inten+bkg) |
---|
143 | End |
---|
144 | |
---|
145 | //wrapper to calculate the smeared model as an AAO-Struct |
---|
146 | // fills the struct and calls the ususal function with the STRUCT parameter |
---|
147 | // |
---|
148 | // used only for the dependency, not for fitting |
---|
149 | // |
---|
150 | Function fSmearedLamellarFF(coefW,yW,xW) |
---|
151 | Wave coefW,yW,xW |
---|
152 | |
---|
153 | String str = getWavesDataFolder(yW,0) |
---|
154 | String DF="root:"+str+":" |
---|
155 | |
---|
156 | WAVE resW = $(DF+str+"_res") |
---|
157 | |
---|
158 | STRUCT ResSmearAAOStruct fs |
---|
159 | WAVE fs.coefW = coefW |
---|
160 | WAVE fs.yW = yW |
---|
161 | WAVE fs.xW = xW |
---|
162 | WAVE fs.resW = resW |
---|
163 | |
---|
164 | Variable err |
---|
165 | err = SmearedLamellarFF(fs) |
---|
166 | |
---|
167 | return (0) |
---|
168 | End |
---|
169 | |
---|
170 | //the smeared model calculation |
---|
171 | Function SmearedLamellarFF(s) :FitFunc |
---|
172 | Struct ResSmearAAOStruct &s |
---|
173 | |
---|
174 | // the name of your unsmeared model (AAO) is the first argument |
---|
175 | Smear_Model_20(LamellarFF,s.coefW,s.xW,s.yW,s.resW) |
---|
176 | |
---|
177 | return(0) |
---|
178 | End |
---|