Copyright: help file written by Christian Braun
Citation: © 1997-99, Christian Braun, HMI Berlin


The Reflectivity Tool

Parratt32
or The Reflectivity Tool
A programme for calculating reflectivities.

  Overview

  Tutorial

  Background


Overview

Parrat32 enables you to calculate optical reflectivities (neutrons and x-rays) from a given model sample over a specified Q-range or fit model parameters to measured sets of data. For details of the calculations click here.

The programme is a Microsoft Windows application that should run on every machine that has the 32bit version of this so called operating system installed (either Windows 95, Windows 98 or Windows NT 4.0 (the i386 edition works fine, other platforms, such as FX32 on DEC Alpha could not be tested)). The 32 bit extensions for 16bit-Windows (versions 3.1x, also known as Win32s) are not sufficient!

Like tons of other programmes Parratt32 comes with a graphical user interface (GUI) which supplies these three main items:

- There is a menu bar

 -There is a button bar

 -There are always three windows open:

they are called	Model,

Profile and

Reflectivity.

Due to the constant need of these windows you cannot close them! Trying to close will only minimize them to iconic shape.


The Model window

In the model window the physical data of the sample is stored.

The window will change its appearance according to the choice of sample from the buttons on the topmost panel.

- simple samples with independent layers

- samples with analytical profile funtions

- multilayer samples


Sample Type

Here you have to select your type of sample.


Number of Layers

Changing this value will extend or collapse the worksheet at the bottom of the window. 0 means only air and bulk are present, any number larger than 0 will result in additional rows being shown in the worksheet.


Layer properties

These are the cells where the information of the sample is stored, and where you can type in different values.

d 	thickness of the layer in Ångstroms

ρ	scattering length density in 1/Å²

neutrons:	N * Re(b)

x-rays: 	ρ el * r 0 or 2π δ / λ²

Im(ρ)	imaginary part of the scattering length density in 1/Å²

neutrons:	N * Im(b)

x-rays:	2π β / λ²

σ	interfacial roughness

R(mag)	real part of magnetization (unit as in ρ)

I(mag)	imaginary part of magnetization (unit as in ρ)


Simple Samples

The most simple sample consists of only air and bulk.

In the example below the parameters for the air/water interface for Cu-Kα radiation are shown:

ρ(air) = 0	Im(ρ(air)) = 0

ρ(H2O) = 9.475*10^-6/Å²	Im(ρ(H2O)) = 3.178*10^-8/Å^-2	σ(H2O) = 3.0 Å

Changing the number of layers value will expand the worksheet by inserting empty rows inbetween air and bulk or collapse it by removing existing rows.


Function Samples

A model for a sample with an analytical profile function consists of the 'basic' layered sample like in Simple Samples with an additional part described by the function itself.

Pressing the edit function button will show the function dialogue box.

After selecting a function from this dialogue you have to fill in the required fields:

append function 	the function will be appended to the specified

to layer No.	layer of the basic sample (0 appends it to air)

A, B, C, D, E	the initial parameter values for the function calculation

thickness of 	the function will be approximated by discrete steps of this size

functional steps

number of steps	the number of pivot points along the z scale

these last two values will fix the overall range of the function

Pressing the I want to test my function button will calculate the profile as well as the reflectivity of the supplied model. The results will be shown in the corresponding windows (Profile window, Reflectivity window).

Don't forget to supply the layer properties of the basic sample in the worksheet!


Multilayer samples

Multilayer samples consist of a basic sample as in Simple Samples plus a multilayer stack.

The multilayer stack itself is similar to the basic sample but will be repeatedly inserted between two layers of the basic sample.

The model window therefore supplies two worksheets: the bottom one for the basic sample, the other one for the multilayer stack.

The multilayer stack panel has three control elements:

number of layers	sets the number of individual layers in the stack

in the stack	expands and collapses the corresponding worksheet

number of	sets the number of repetitions of the whole stack

repetitions

append ML stack	sets the number of the layer in the basic sample to which

to layer No.	the ML stack will be appended (0 appends it to air)


The Profile window

Once the Profile calculation was invoked (by either selecting Calculate-Profile from the menu or by pressing the Profile button on the button bar) the calculated refractive index profile is shown in the profile window.

If the model data contains roughnesses (σ) then these will be calculated using an error function formalism.

The mouse cursor position on the plot is shown as real space coordinates (z and ρ(z)) on the statusbar of the main window.


The Reflectivity window

Once a model was set up, Parratt32 can calculate the reflectivity of that sample. The result of this calculation is then shown in the Reflectivity window.

If include magnetization was selected in the Settings dialogue box three curves will be plotted:

black:	reflectivity without magnetization

red:	reflectivity with plus magnetization

blue:	reflectivity with minus magnetization

grey	transmisson through the sample

If the you load some previously calculated data or load some experimental data this is as well displayed in this window. Calculated data is always shown as a solid line whereas measured data will be shown as hollow circles (O).

The mouse cursor position can be read out in the statusbar of the main window.


The Menus

The Main Menu

The menu bar has the following entries:

File

Edit

Calculate

Database

Window

Help


File Menu

Here you find all file related commands:

Load data file

Load model file

Save Reflectivity

Save Profile

Save Model

Print...

and

Exit


Load data file
data file

Clicking this shows up the standard Windows file open dialogue.

The extension is set to '*.dat' as a default, but you can alter it.

File format is plain ASCII, three columns:

Qz 	R	error(R)

These columns should be separated by either blank or a tab.

Due to logarithmic representation of the data in the reflectivity window, negative values of R(Qz) should be omitted. If your data files contain strange or unreasonable values (?!) Parratt32 will give notice. In this case you may ignore these values or cancel the loading.


Load model file
model file

You can load a previously saved model file into the model window.

Model files are simple text files with all the information from the model window plus additional background and resolution parameters. Depending on the type of sample they may look different (multi layer data, function data). After loading the model file into the programme, the reflectivity and the profile is calculated from the model data.


Save

You can save the contents of the three different windows to a file. Pressing the 'save' button from the button bar saves the contents of the active window.

If the Plot window is active the calculated reflectivities will be saved to a file (default extension is '.DAT').

If the Model window is active the model data will be saved (default extension is '.PAR').

If the Profile window is active the profile data will be saved (default extension is '.PRO')

From the file menu you can select what window to save by selecting the appropriate menu item.


Print

The printing facilities of Parratt32 are only very, very basic.

Selecting the menu entry 'print' or pressing the printer button will print a summary of the Parratt32 desktop.

The result will most probably look like this:


Exit

Exits Parratt32, no questions asked...


Edit Menu

The edit menu is enabled when either the profile window or the plot window is active. By selecting the entry copy data the data of the active window will be copied to the windows clipboard, from where you can paste it to other applications such as Microsoft Excel™ or Micocal Origin™.Data from the profile window is always two columns wide, data from the reflectivity window is either two columns or four columns, depending on whether include magnetization is checked or not.


Calculation Menu

Here the function that calculate data are accessible

Calculate Reflectivity

Calculate Profile

Fit Data

Settings


Calculate Reflectivity

Starts the calculation of the reflectivity according to the data given in the model window.

Calculation details can be found in the technical reference.


Calculate Profile

Calculates the refractive index profile (rho vs. z) from the data given in the model window.


Fit Data

This starts the fitting procedure by launching the FitIt dialogue window.

Is enabled only when data is loaded.


Settings

This will show the settings dialogue.


Help menu

Database Menu

This menu lets you either edit the current database or you can specify a new database file by selecting 'load from disk'.


Window Menu

Here you find the standard window commands like Cascade, Tile, and Arrange Icons.


Help Menu

Here you find the Help related commands.


The Button Bar

Some of the function in the menus can also be accessed via the button bar, i.e. instead of typing [ALT]-C-R (for Calculate Reflectivity) you can simply click on the button with the calculator icon.

click on a button to see what it's meaning.


Load Data Button

loads a reflectivity data file (same as File-Load data file).


Load Model Button

loads a previously saved model file, including background and resolution information.

After successful loading the reflectivity and the profile will be calculated and displayed.


Save Button

saves the contents of the active window to a file (same as File-Save).


Print Button

Prints the active window (same as File-Print).


Calculate Profile Button

calculates the refractive index profile from the model data (same as Calculate-Profile).


Calculate Reflectivity Button

calculates the reflectivity from the given model (same as Calculate-Reflectivity).


Fit Data Button

is enabled when measured data is loaded and shows the fitting dialogue (same as Calculate-Fit data).


The Settings Dialogue

Here you can type in the information that is needed to perform the different calculations.

This notebook is made up of a lot of pages:

Reflectivity

When there is no data loaded you can still calculate

reflectivities. Therefore you have to set the Qz range

by yourself (default is 0 to 0.5 Å^-1 in 50 points).

Loading data will reset the respective edit fields to the

values found in the data file.

You have to specify a wavelength for the reflectivity calculation

in case absorption cannot be neglected for x-rays, since the

wavevector calculation is done according to

k = sqrt( k0² - 4π ρ ),  where ρ is complex!

Transmission

For a free sample (i.e. a thin wafer) the transmission can be calculated.

You have to specify the overall thickness of the bulk material.

Profile

Just like for the reflectivity you can specify the z-range for the profile calculation.

Default values are -25Å to +25Å for bulk materials, or -25% to +25% of the
overall sample thickness for coated materials.

Background

Your data may or may not contain background noise.

In the case of uncorrected data (which is, no background

substracted) you can supply this background to the

calculations.

There are four different kinds of background:

a) the typical noise threshold of the reflectivity instrument

that is added to every datapoint (constant background),

b) linear increasing or decreasing background,

c) and d) peaking background (either of gaussian or

lorentzian shape) that is characterized by four values:

area, width, centre, and baseline.

Resolution

Sometimes reflectivity curves are measured with different

resolutions in different Qz regimes, due to different slit

settings of the collimating system.

Up to eight regions with different resolutions can be

defined here: just type in the region's starting value (in  units

of Qz) and the corresponding resolution.

For data simulation it might be useful to neglect the

instrument's resolution, so one would chose only one region

with its value set to zero.

Database

The default database file (<InstallDir>\database\Parratt32.db) is loaded at programme start-up.

In order to use the data one has to specify which properties are

to be used in the model window. You can either select neutrons

or x-rays. The values found in the database file can then be included

in the model window by right-clicking on column 1 and selecting either

Element or Compound from the popup menu.

The formulae for calculating the real and imaginary parts of the scattering

length density from the given values are as follows:

neutrons:

V [Å³]   = mass[g/mol] / (mass density[g/cm³] * 1e24 * NA[1/mol])

ρ [1/Å²] = b[fm] *1e-5 / V

Im(ρ) [1/Å²] = absorption cross section[barn] * 1e-8 / (1.789 Å * 2 * V[Å³])

where 1.789Å is the wavelength for the tabulated absorption values.

x-rays:

ρ = 2π δ / (1.541 Å)²

Im(ρ) = 2π β / (1.541 Å)²

where 1.541Å is the wavelength of the tabulated values for δ and β.


The Function Dialogue

This is where one wants to select a function to calculate the density between two given layers.

Basically, two types of function can be used.

There are four different predefined functions:

 	exponentially decaying,

 	oscillating,

 	the Liu-Fisher function and

a combination of a) and b): 	oscillating with a damped amplitude.

Or you can supply a parametric function by using the built-in function parser of Parratt32.


The Function Parser

The function parser of Parratt32 allows the user to enter functions in algebraic notation, which are then used to calculate the scattering length density between two given layers of the basic model sample. The functions are given with z as the independent variable. Up to five parameters can be supplied.

valid operators are:

+ , - , * , / , ^ , MOD, DIV.

valid functions are:

COS, SIN, SINH, COSH, TAN, COTAN, ARCTAN, ARG,

EXP, LN, LOG10, LOG2, LOGN,

SQRT, SQR, POWER, INTPOWER,

MIN, MAX, ABS, TRUNC, INT, CEIL, FLOOR,

some special functions:

HEAV 	heav(x) is =1 for x>0 and =0 for x<=0,

SIGN 	sign(x) is 1 for x>1, 0 for x=0, -1 for x<0,

ZERO 	zero(x) is 0 for x=0, 1 for x<>0,

PH 	ph(x) = x - 2*pi*round(x/2/pi)

RND 	rnd(x) = int(x) * Random

RANDOM 	random(X) = Random; the argument X is not used

there is a predefined constant 'PI'= 3.1415...

Remarks:

Use the parameter names in their alphabetical order. This means, that in functions with only one parameter it has to be called 'A', in functions with two parameters these have to be called 'A' and 'B' and so on.

The trigonometric functions work on radians not on degrees!


The Fitting Dialogue

This notebook has two pages. On page one there are the following elements:

The parameter list

In this list the parameter of the fitting function are stored. Every parameter is preceded by a checkbox which signals, if checked, that this particular parameter will be varied during the fit.

The χ² label

The χ² of the current set of parameters will be shown here. For the calculation of the χ² see below.

The radio buttons

You can choose between two actions: calculate the χ² of the current set of parameters or iterate to a minimum in χ² by varying the selected parameters.

The tolerance edit field

The value in this edit field establishes the termination criteria for the automatic fitting process that begins when you press the do it button and the radio button iterate to minimum is pressed. When the difference between the χ² of successive iterations is less than this value, then iterations for the current parameter cease.

The do it button

Clicking here either starts the fit or a single calculation of χ².

The stop button

While iterating this button is enabled to stop the fitting procedure. If there is no minimum in χ² (?!) or the initial set of parameters was too far from being good (?!) then fitting can take quite some time or will even never stop. If you feel that there is nothing happening any more, try pressing this button.

On page two of the notebook some more sophisticated things can be tuned.

The χ² calculation

Three ways of calculating the merit function χ² are available:

a) divide every deviation of the calculated value from the measured value

    by the error of the measured value (use given errors),

b) divide every deviation of the calculated value from the measured value

    by the measured value itself (1/y),

c) don't divide anything (no weight at all)

χ² is then calculated as the sum over the squares of either a), b) or c) divided by the number of data points.

In the case of reflectivity data, which decays over orders of magnitude, the best way to achieve a converging fit is b)! If someone tells you something else ...

The include resolution checkbox

Most measured data is in some way correlated to an instrumental resolution, which is something like an uncertainty in the x-values.

Therefore you can include this instrumental resolution in the calculation of the fitting function.

You should supply the necessary values in the settings dialogue.

The include background checkbox

If your data was not corrected for background scattering you might want to add some to your data while fitting.

Setting the respective values is done in the settings dialogue.

The display graph... checkbox

This was mainly for testing the fitting algorithm. Checking this will update the reflectivity curve every time a parameter has changed, which happens quite often during a fitting session, so better leave it unchecked.

The Three Big Buttons at the bottom

After you are done with fitting you can either press OK or Cancel.

Pressing OK will accept the fitted parameters which will lead to updating of the model window, redrawing of the reflectivity curve and recalculation of the scattering length density profile.

Pressing Cancel hopefully discards all changes made while fitting and leaves you with the original set of parameters for your model.

The Help button most probably has lead you here.


Fitting Guide

Modelling of data is an easy task.

Fitting models to measured data is different, especially when one wants to fit large sets of parameters.

Therefore this guide will give you some hints on how to achieve satisfactory results from the fitting routines that are used by Parratt32.

The three basic points are

1.	do not try to optimize all parameters at the same time!

2.	try to keep the number of parameters that will be optimized small!

3.	never select a too large number of parameters to be optimized simultaneously!

Moreover, it is necessary to supply reasonable starting values for the parameters. Before starting a fitting session it is a good idea to calculate the reflectivity from the given model. A comparison of the calculated curve with the measured data gives a first hint of how well the model parameters were chosen. In case of a poor agreement of the calculated curve with the measured data different values for the parameters should be chosen. Once a reasonable well agreement is achieved the fitting session can be invoked.

Fitting not always converges to the tolerance limit given. In some, not necessarily rare cases parameter changes lead to alternating contributions in χ², in other words changing parameter a reduces the χ² whereas changes in parameter b increase the χ² by an identical amount: the fit will never converge. To overcome this problem the tolerance limit can be changed even when the fitting is under way! To be more precise: the tolerance limit is read out from the edit field every time the fitting algorithm needs it (i.e. after every reduction in χ²). So, if the fitting seems to hang (a good readout for this is the statusbar at the bottom of the main window, where the parameter number and the number of iterations are displayed, separated by a colon) just try to alter the tolerance limit. Even decreasing it will, in most cases, lead to a converging fit.

During fitting it sometimes can happen that parameters run out of bounds (i.e. negative thicknesses or negative scattering length densities for x-ray samples). This is not the programme's fault. The only way to overcome this would be so called constraints for every single parameter. This, of course, will slow down the whole fitting procedure to an unacceptable speed. Therefore, constraints are not the solution in Parratt32. If out-of-bounds parameters occur the fitting session has to be interrupted, the respective parameter re-initialised to a physical meaningful value, and fitting can start again. Maybe it then is a good idea to leave this parameter untouched by the fitting procedure as the other parameters are optimized. Later, when these parameters lead to a converging fit the questionable parameter can be included in the fit.


Database editor

The Database editor

The database is user expandable. The Parratt32 installation comes with a sample database file: 'parratt32.db'. This file is basically a Paradox 7.0 table that can be edited using the built-in database editor. You can add or remove elements or compounds. Pressing the 'Done'-button will save your changes to disk.

Adding something is done by pressing the '+'-button of the navigation bar at the bottom. You may then type in the name and the data of the respective element in the edit fields. To make the changes permanent in the database you have to press the '\/'-button. To delete an element from the database simply select it by scrolling through the database ('<' or '>'-button) and press the '–'-button.

The two pages of the database editor dialogue window are sorted in different ways: The nuclei are sorted according to their charge (Z), the compounds are sorted by their name.

Working with values for different wavelengths:

Since Parratt32  calculates real and imaginary parts of the scattering length density from the values given in the database instead of using these values directly for the model, there is an easy way to overcome the strict ‘type in for 8047 eV’-rule.

X-rays: The formulae for calculating ρ and Im(ρ) are as follows

ρ = 2πδ/λ² and Im(ρ)=2πβ/λ² , Parratt32 automatically uses 1.541Å for λ. For a different wavelength just look up the δ and β values, multiply them by 1.541² and divide them by your λ². That’s it.

Neutrons: The b_coh values are independent of the wavelength, not the abs_xs values. The Im(ρ) is calculated by Parratt32 according to Im(ρ)= abs_xs*1e-8/1.798/2/volume, so all you have to do is look up the absorption cross section for the material and wavelength you like to have in the database, multiply this value by 1.789 and divide it by your wavelength value.

It is definitely a good idea to make some comment in the field labeled ‘comment’, since this shows a little asterisk (*) beneath the element's name will remind you that something special is going on when inserting these values in your model.


Background
Parratt32´s secrets revealed

Reflectivity calculation:

The calculations are carried out by means of Parratt's - remember the parrot icon?- dynamical approach (L. G. Parratt, Phys. Rev., 95(2), 359-369, 1954). This approach is based on stratified media, hence only the refractive index differences perpendicular to the surface are considered.

Roughnesses are included in the Fresnel coefficient as suggested by Névot and Croce (L. Névot, P. Croce, Revue de physique appliquée, 15 (1980), 761). Keep in mind that by this approach only roughnesses that are small compared to the layer thickness are handled correctly!

Profile calculation:

The calculation of the scattering length density includes the roughnesses σ for the interfaces. According to Névot and Croce (see above) these are calculated by an error function formalism. The given value can be interpreted as the fwhm of the gaussian in the scattering length density gradient at the given interface

Fitting algorithm:

the χ² minimization is implemented as a simplified one dimensional Newton-Raphson method (see for example: W. Press, B. Flannery, S. Teukolsky, and W. Vetterling, 'Numerical Recipes', Cambridge Univ Press, Cambridge 1986). This method converges quadratically into the nearest minima, by varying the parameter to be optimized, somewhat more global minima can be found.


parroticon


Tutorial

A short introduction to Parratt32

This is a step-by-step example on how to use the Parratt32 programme.

choose your type of sample in the model window:

click on the radio button labeled independent layers for

a sample with layers whose physical properties are

independent of each other.

or

click on the radio button labeled analytical profile function

for a sample where there's some functional relation

between the refractive index and the z-coordinate.

or

click on the radio button labeled multiple layers for

a sample that is made up of regular stacks of layers.

What to do next?

 set up a model


simulate data
set up a model

type in the data in the model window

or

load the parameters of a previously saved model

select File-Load model data from the

file menu

What to do next?

 calculate the reflectivity

 calculate the scattering length density

 load experimental data


load data
load experimental data

select File-Load data file from the file menu

or

press the Load button on the button bar.

The data file must contain exactly three columns: Q, R, and δR. These columns have to be separated by a single TAB (ASCII 9). Q values should be given in 1/Å, δR values can be set to zero.

What to do next?

 calculate the reflectivity

 calculate the scattering length density


calculate reflectivity

supply the necessary parameters for the calculation

by opening the Settings dialogue box.

Select Calculate-Settings from the calculate menu.

set the Qz range and the number of points to

be calculated, include magnetization if you like to,

or

leave the numbers unchanged when experimental data

has been loaded.

set the desired background

supply the information about the resolution of your

instrument

calculate the reflectivity of your sample along Qz by

selecting Calculate-calculate reflectivity from the menu.

or

by pressing the reflectivity button

When fitting data you probably have to repeat steps 2.1 to 3.2 to obtain

reasonable starting values for the parameters

What to do next?

 fit parameters to experimental data

 save the results of the calculations


calculate profile
calculate scattering length density profile

supply the necessary parameters for the calculation

by opening the Settings dialogue box.

Select Calculate-Settings from the calculate menu.

set the z-axis increment of the profile calculation,

1Å is the default, but if your sample is thin you might want

to reduce this value.

calculate the scattering length density profile of your sample by

selecting Calculate-calculate profile from the menu.

or

by pressing the profile button

What to do next?

 fit parameters to experimental data

 save the results of the calculations


fitting data
fitting of measured data

start the fitting session by

selecting Calculate-fit data from the calculate menu.

or

press the FitIt button

make the necessary settings on page two of the

FitIt dialogue: chi^2, resolution, background...

select either calculate chi^2 or iterate to minimum

select the parameter(s) you want to optimize by

checking the tiny box next to it

press the do it button

now the fitting is in progress, in case something ugly

happens you can press the stop button. This will usually

abort the fit.

if everything works out fine the fitting should converge to

the given tolerance. This is indicated on the chi² label.

press the OK button

- the model window will be updated with the

  optimized set of parameters

- the profile will be calculated

- the reflectivity will be calculated

if it does not

press the CANCEL button

-all changes in the parameters will be discarded

-nothing will be updated

What to do next?

 save your results


saving results
saving of calculation results

click on the respective window and press the save button

model: the model file will be saved

reflectivity: the calculated reflectivity will be saved,

if magnetization is included there will be 5 columns:

Qz, R, err(R), R+, R-, T

profile: the scattering length density profile

will be saved

z, ρ(z)

Apart from saving data to a file you can copy-and-paste the calculated

profile and the calculated reflectivity to other applications by selecting

Edit-Copy data from the menu.

If you want to how to quit Parratt32, click here


quit Parratt32

select File-Exit from the main menu