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

2. BK7 permittivity from Selmeier´s Equation

Expansion coefficients

p.01/10 - Copyrigh 2012 by Eduardo Fontana and Gustavo Oliveira Cavalcanti

BK7 permittivity

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

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

Differential matrix

Vectorized version of R

Vectorized version of dR

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