# Software

**The software from the division is free to use. The coder should however be acknowledged if the use results in published scientific work. **

**KKKTON - **A program for Kramers-Kronig (KK) analysis of optical data.

**Multifresnel_general** - A program for thin film optics calculations. Contains the main program library that is needed for all multifresnel programs listed.

**Mulifresnel_sol_vis **- Incluces solar and luminous values into the optical calculations.

**RT_Invert** - A program for calculations of optical constants from experimental data. This program uses the mulitfresnel library.

**RT_Invert-variant** - A program for calculations of optical constants from the raw data files from the spectrophotometer. This program uses the mulitfresnel library.raw data using the mulitfresnel library.

**nk-felyta** - Calculates all possible optical constants values from experimental data. Can be used as an aid to determine possible solutions. This program uses the mulitfresnel library.

## KKKTON - A PROGRAM FOR KRAMERS-KRONIG (KK) ANALYSIS OF OPTICAL DATA.

The KK analysis is carried out using the extinction coefficient (k) as input and the refractive index (n) is calculated. Low energy Drude and high-energy Lorentz extrapolations are used and parameters for these need also to be inputs. The Matlab program contains a routine for calculating reflectance (R) and transmittance (T) for a film on a substrate and comparing with experimental R and T that need to be entered into the program. kdata.txt is an example of an input file of k-data. See attached files for detailed instructions and program files.

Coder: Annette Hultåker

## "Multifresnel_general" program: Thin film optics calculations.

This program calculates reflectance, back reflectance and transmittance for a stack of thin films on a substrate. The multilayer stack can have an arbitrary number of layers. A thin film optics formalism using layer and interface matrices is used (P. Pfrommer et al. Sol. Energy, vol 54, No 5, pp. 287-299). The layers can be either coherent or non-coherent, while the substrate is always non-coherent.

Inputs are wavelength (nm), refractive index and extinction coefficient (n and k; from files) for each layer and the substrate, as well as thicknesses (nm), angle of incidence and whether the layers are coherent or not. Wavelength interval and substrate thickness can be adjusted directly in the code.

Output data are plotted in a figure and saved in file ”calcspectra.txt”

**Warning**: Numerical errors can occur for thick substrates with significant absorption.

The main program calls a number of functions, where different parts of the calculations are carried out. These are:

RT_calc.m - Calculates reflectance and transmittance for s-, p- and unpolarized light from the transfer matrix.

transfer_matrix.m - Calculates the transfer matrix of the multilayer.

rt2RT.m - Calculates reflectance and transmittance from reflection and transmission coefficients.

coherent_l.m - Calculates the layer matrix of a coherent layer.

coherent_i.m - Calculates the corresponding interface matrix.

non-coherent_L.m - Calculates the layer matrix of a non-coherent layer.

non-coherent_I.m - Calculates the corresponding interface matrix.

Fresnel_calc.m - Calculates Fresnel reflection and transmission coefficients at an interface for s- and p-polarized light.

theta_calc.m - Calculates the local angle of incidence at each layer.

mult_3D.m - Function for multiplying 3D matrices required for optical calculations.

**Note**: These functions are also used in all our thin film optics programs on this webpage. By modifying the main program one can use the calculations of the functions for different purposes, for example solving the inverse problem of obtaining optical constants of one layer from experimental data.

## Multifresnel_solar_vis program

This version of the multifresnel program does the same basic calculations as the ”general” version, using the same functions that were supplied with ”multifresnel_general”. However the main program has an additional code that computes solar and luminmous transmittance and reflectance by averaging over the AM1.5 solar spectrum and the luminous eye sensitivity spectrum.

Inputs are wavelength (nm), n and k for each layer, as well as thicknesses (nm) and angle of incidence. The substrate optical constants are also needed. The program needs access, in the same folder, to solar AM1.5 (iso9845tot.txt) and eye sensitivity (eye1.txt) spectra.

Coder: Arne Roos, Anna Werner

## RT_invert - Program for calculations of optical constants.

These programs fit calculations of reflectance and transmittance for an arbitrary stack of thin films, wherein one layer is unknown, to experimental data. This is done in order to determine the optical constants (refractive index (n) and extinction coefficient (k)) of the unknown layer. Before proceeding to the programs a cautionary note is in order. The inverse problem of thin film optics has multiple solutions and one must be careful to check that the program fits to the physical solution, for example by using independent knowledge of the material under study. Furthermore it is common that the results given by the program cross over from one solution to another one at certain points. This behaviour is especially comon at interference fringes. Hence it may be necessary to perform calculations in different wavelength ranges, in order to obtain the physical solution everywhere. These complications makes determination of optical constants by direct inversion somewhat cumbersome.

The programs listed below all use the MATLAB functions listed in the description of the Multifresnel programs. These must be accessible in the same folder as the main programs listed below.

RT_invert_optconst program

This program calculates optical constants of a coherent or non-coherent layer from an input file containing wavelength, transmittance and reflectance data. The unknown film is situated upon a number of underlayers, which can be either coherent or non-coherent and whose optical constants must be known. The layers are numbered from the top and the substrate is the last underlayer. If number of underlayers is put to zero the remaining layer must be coherent.

Input files are interpolated to the same wavelengths (input data must be given in a wider wavelength region than the interpolation range!). The program uses non-linear least squares fitting starting at the shortest wavelength.

The main program calls the function find_nk as well as RT_calc. The latter one uses the other functions in the multifresnel library.

Input: File with experimental wavelength, transmittance and reflectance. Incidence angle, film thickness and coherence of the unknown layer. Number of underlayers. Optical constants, thickness and coherence of each underlayer.

Output: Figures of n and k; experimental and fitted R and T; deviations between experiment and calculations. Wavelength and calculated n.k are saved in a file.

Coder: Jonas Backholm, Arne Roos (edited by Gunnar Niklasson)

## RT_invert variant - program for calculating optical constants

This program is identical to the one above with the following exception: It is intended to be used directly with datafiles from the spectrophotometer. Spectrophotometer measurements start at long wavelengths and proceed to shorter ones. This is often an advantage for the inverse problem, since it is often easier to get good convergence of the calculation at long wavelengths and the problem of multiple solutions is at least less severe. Hence this program uses non-linear least squares fitting starting at the longest wavelength.

The main program calls the function find_nk as well as RT_calc. The latter one uses the other functions in the multifresnel library.

Input: File with experimental wavelength, transmittance and reflectance. Incidence angle, film thickness and coherence of the unknown layer. Number of underlayers. Optical constants, thickness and coherence of each underlayer.

Output: Figures of n and k; experimental and fitted R and T; deviation between experiment and calculations. Wavelength and calculated n.k are saved in a file.

Coder: Jonas Backholm, Arne Roos

## nk_felyta - Calculates all possible n and k values. from experimental data

This program calculates contours in the n,k-plane pertaining to experimental input values of transmittance and reflectance for each wavelength. Hence the program calculates all n,k values that give those values of R and T and plots them in a figure. The intersections between the R and T contours give all possible solutions of n, k that are compatible with the experimental data. Calculations take long time so it is advisable to use the program for a single or 10-20 wavelengths only.

This type of calculation is especially useful when calculated optical constants fail to reproduce experimental data or when multiple solutions exist and the calculated values cross over from one solution to another. In these cases the contours show which solutions may exist, if for example you are uncertain of whether your solution is the physical one. They also give qualitative guidance on the accuracy of the obtained optical constants. If R and T contours are almost parallel the optical constants will be very uncertain and an intersection may easily be missed due to experimental errors.

The program calls RT_calc and by that all the functions in the Multifresnel library. They are all needed in order to run the program.

Input: An experimental file with transmittance and reflectance data, number of underlayers (substrates), n and k of substrates (Note that the wavelengths must be the same as in the experimental file), thickness and coherence property of the underlayers, angle of incidence.

The output is given as figures appearing on the screen. The video part of the program needs further development. A video movie is played but the figure information is not properly updated in the movie. The video is stored in a file "optcontour" but the frame rate of that movie format seems far too high, so I am not sure if this is useful.

Coder: Jonas Backholm