# cstool optical data file format

cstool needs optical data to represent the probability of electron energy loss
in a material. The specific optical data we need is the dielectric function, or
*n* and *k* values as they are sometimes known.

## Sourcing the data

Good sources for optical data include:

- The book
*Handbook of Optical Constants of Solids*by E.D. Palik - The website refractiveindex.info
- The CXRO database for high energy photons (30 eV and beyond).

In the visible light range, the dielectric function is often given as *n* and *k*
values. They are related to the dielectric function by

```
ϵ = (n + ik)²
```

where i is the imaginary unit. In the X-ray range, the popular parameters are
*δ* and *β*. They are related to *n* and *k* by

```
n = 1 - δ
k = β
```

Note that the CXRO website is incorrect: it has a header saying that k = -β, but that's not true.

Nebula needs to know the *energy loss function* (ELF), equal to

```
ELF = Im(-1/ϵ)
```

Loosely speaking, the ELF reflects the probability that an electron loses a certain amount of energy. Therefore, an accurate simulation requires this optical data to be tabulated over a very large range of photon energies, from sub-eV to the highest energy of interest (typically in the keV range).

## The file format

We use an older file format first used in the simulator of Kieft and Bosch. Such a file may look as follows:

```
1.12 5 8.9 100 1839 -1
0.01116 1.45249E-05
0.04959 4.57441E-06
[snip]
4000 5.12708E-06
8000 3.54308E-07
-1 -1
```

The first line contains binding energies of electrons. This is only relevant for the semi-empirical model of Kieft and Bosch, which we don't reccommend to use. These energies are in units of electronvolts, the list is terminated by -1. If you are not interested in the model by Kieft and Bosch, a line with only -1 is sufficient. (It must be present, though!)

The lines below that have two columns. The first value is the photon energy in eV. The second value is the ELF (which is unitless).

Finally, the last line is two times -1. This line must always be there.