Mathcad Code - Uniformity Calculation for SPR experiments comprising a BK7-Gold-Air structure
Eduardo Fontana and Gustavo O. Cavalcanti
Final version of the code November 25, 2012 - Web Version - March 29, 2016
View the html version of this page with Safari, Chrome and IE and select UTF-8 encoding
1.List of constants, variables and functions
- x = Variable that represents wavelength in microns
- y= Angle in degrees
- d = Metal film thickness in microns
- ε1 = BK7 permittivity
- ε(x) = Column vector containing the three permittivities of the structure in increasing order
- ε2= Complex variable representing metal permittivity
- rsingle = Single interface reflectivity for either s- or p-waves
- λ = Operating wavelength
- s = sign parameter (+1,-1) for the two choices of initial guess of the best fit procdure
- cel = Used to designate the order of the data file (0,1,2,...,120)
- ref(x,y,ε2,d) = reflectivity of BK7-Gold-Air structure
- Data(cel) = Input data, with correct scale factor for reflectances
- Lorentz(y,Par) = Lorentzian function at angle y and for three parameters defined by vector Par
- ResPar(cel) = 3-element vector with the values of Rmin, ReK and ImK obtained from reflectance data. ReK and ImK are relative to free-space wavelength
- InitialGuess(cel,s) = 3-element vector with a first estimate of initial guess of Re(ε2), Im(ε2) and d
- F(cel,s,X) = 3-element vector function used to determine a better initial guess from initial vector X (containing initial estimates of Re(ε2), Im(ε2) and d) for ResPar(cel) vector
- δM(cel,s,X) = 3x3 matrix. The i-th row is the gradient of Fi relative to coordinate Xj . This matrix is used to determine a better initial guess from the solution of a set of nonlinear equations of the elements of F
- BetterGuess(cel,s) = 3-element vector with improved initial guess for the parameters Re(ε2), Im(ε2) and d
- R(y,par) = Reflectance at angle y (in degrees) for 3-element vector par, in which ε2=par0+1i*par1 and d = par2
- R1(MyVector,par) = Vectorized version of R, i.e., a vector with all reflectances for MyVector = Data(cel)<0> (column zero of Data(cel)
- dR(y,par) = Gradient of reflectance at angle y (in degrees) at the parameter vector par
- DR(MyVecor,par,n) = Vectorized version of dR
- BestFit = Best fit parameters organized in a 3x121 matrix. Each column contains real and imaginary parts of complex permittivity and thicknes, obtained for the corresponding data file.
2. BK7 permittivity from Selmeier´s Equation
p.01/10 - Copyrigh 2012 by Eduardo Fontana and Gustavo Oliveira Cavalcanti
Permittivity of the structure
3. Generalized reflectivity function
A. Single interface reflectivity
E = 2-element vector for two contacting media
pol = 0 (s polarization); pol =1 (p polarization)
K = 2-element column matrix with the two
longitudinal wavevectors of the contacting media
B. Set operating wavelength
C. Multilayer reflectivity
- λ = Wavelength in microns
- θ = Incidence angle in radians
- ε2 = Metal complex permittivity
- d = Metal film thickness in microns
p.02/10 - Copyrigh 2012 by Eduardo Fontana and Gustavo Oliveira Cavalcanti
4. Read the Data and apply a correction factor of 0.982 (obtained from calibration experiment
Parameters:
cel = Cell number, ranging from 0 to 120. Each file has 400 data points
Column zero = Angle in degrees
Column 1 in Data = Corrected internal reflectance values
csort function is used to sort all rows in ascending angle values
Find current working directory
p.03/10 - Copyrigh 2012 by Eduardo Fontana and Gustavo Oliveira Cavalcanti
5. Determine resonance parameters from the data
ResPar(cel) is a 3-element vector of the estimated parameters, as follows:
Element 1 - Minimum reflectance
Element 2 - Real part of the SP Wavevector (normalized by 2π/λ)
Element 3 - Imaginary part of SP wavevector (normalized by 2π/λ)
p.04/10 - Copyrigh 2012 by Eduardo Fontana and Gustavo Oliveira Cavalcanti
6. Determine initial guess for complex permittivity and thickness
KR= Difference between expected value of Im(K1), represented by parameter par, from data and that calculated by use of estimated complex permittivity eps and thickness w
Numerical derivative of KR
p.05/10 - Copyrigh 2012 by Eduardo Fontana and Gustavo Oliveira Cavalcanti
Rough initial guess of complex permittivity and thickness for data file cel at a given sign s (1 or -1)
p.06/10 - Copyrigh 2012 by Eduardo Fontana and Gustavo Oliveira Cavalcanti
7. Improvement in Initial Guess by solving a set of nonlinear equations
Define functions from ambiguity paper
F is a 3-element function having roots at the initial guess with initial estimated X (3-element vector).
SPR resonance parameters are set by ResPar(cel)
Differential element matrix
3x3 matrix. The i-th row is the gradient of Fi relative to coordinate Xj . This matrix is used to determine a better initial guess from the solution of a set of nonlinear equations of the elements of F
p.07/10 - Copyrigh 2012 by Eduardo Fontana and Gustavo Oliveira Cavalcanti
3-element vector with improved initial guess for the parameters Re(ε2), Im(ε2) and d
8. Calculate best fit parameters
Reflectance for metal film paramenters defined by 3-element vector par
p.08/10 - Copyrigh 2012 by Eduardo Fontana and Gustavo Oliveira Cavalcanti
The best fit procedure uses nonlinear regression analysis in the formalism developed by Fontana (http://www.ufpe.br/fontana/ee903).
The program BestFit returns all best fit parameters for all data in a 3x121 matrix (121 data files). The first initial guess for the first file is calculated with the BetterGuess function. The other initial guesses are calculated by using the best fit parameter of the previous iteration as initial guess of the current iteration.
p.09/10 - Copyrigh 2012 by Eduardo Fontana and Gustavo Oliveira Cavalcanti
9. Output Best Fit Parameters
Best Fit Output File including surface coordinates
Improved initial guess output file including surface coordinates
p.10/10 - Copyrigh 2012 by Eduardo Fontana and Gustavo Oliveira Cavalcanti