Chemical#

class optika.chemicals.Chemical(formula, is_amorphous=False, table=None)[source]#

Bases: AbstractChemical

An object that represents the optical properties of a chemical.

Uses the tabulated optical constants from Windt [1998].

Examples

Plot the indices of refractions of silicon and silicon dioxide.

import matplotlib.pyplot as plt
import astropy.units as u
import named_arrays as na
import optika

si = optika.chemicals.Chemical("Si")
sio2 = optika.chemicals.Chemical("SiO2")

wavelength = na.geomspace(10, 10000, axis="wavelength", num=1001) * u.AA

n_si = si.index_refraction(wavelength)
n_sio2 = sio2.index_refraction(wavelength)

fig, ax = plt.subplots(constrained_layout=True)
na.plt.plot(wavelength, n_si, label="silicon");
na.plt.plot(wavelength, n_sio2, label="silicon dioxide");
ax.set_xscale("log");
ax.set_xlabel(f"wavelength ({wavelength.unit:latex_inline})");
ax.set_ylabel("index of refraction");
ax.legend();
../_images/optika.chemicals.Chemical_0_0.png

Plot the wavenumbers of silicon and silicon dioxide

k_si = si.wavenumber(wavelength)
k_sio2 = sio2.wavenumber(wavelength)

fig, ax = plt.subplots(constrained_layout=True)
na.plt.plot(wavelength, k_si, label="silicon");
na.plt.plot(wavelength, k_sio2, label="silicon dioxide");
ax.set_xscale("log");
ax.set_xlabel(f"wavelength ({wavelength.unit:latex_inline})");
ax.set_ylabel("wavenumber");
ax.legend();
../_images/optika.chemicals.Chemical_1_0.png

Attributes

file_nk

The path to the Windt [1998] file containing the index of refaction, \(n\), and the wavenumber, \(k\).

formula

the empirical formula of the chemical compound.

formula_latex

LaTeX representation of the chemical formula, with appropriate subscripts.

is_amorphous

Boolean flag controlling whether the chemical is amorphous or crystalline.

shape

The array shape of this object.

table

Name of the table of chemical constants.

Methods

__init__(formula[, is_amorphous, table])

absorption(wavelength)

The absorption coefficient of this chemical for the given wavelength.

index_refraction(wavelength)

The index of refraction of this chemical for the given wavelength.

n(wavelength)

The complex index of refaction of this chemical for a given wavelength

to_string([prefix])

Public-facing version of the __repr__ method that allows for defining a prefix string, which can be used to calculate how much whitespace to add to the beginning of each line of the result.

wavenumber(wavelength)

The wavenumber of this chemical for the given wavelength.

Inheritance Diagram

Inheritance diagram of optika.chemicals.Chemical
Parameters:
absorption(wavelength)#

The absorption coefficient of this chemical for the given wavelength.

Parameters:

wavelength (Quantity | AbstractScalar) – The wavelength of light in vacuum for which to compute the absorption coefficient.

index_refraction(wavelength)#

The index of refraction of this chemical for the given wavelength.

Parameters:

wavelength (Quantity | AbstractScalar)

Return type:

AbstractScalar

n(wavelength)#

The complex index of refaction of this chemical for a given wavelength

Parameters:

wavelength (Quantity | AbstractScalar)

Return type:

AbstractScalar

to_string(prefix=None)#

Public-facing version of the __repr__ method that allows for defining a prefix string, which can be used to calculate how much whitespace to add to the beginning of each line of the result.

Parameters:

prefix (None | str) – an optional string, the length of which is used to calculate how much whitespace to add to the result.

Return type:

str

wavenumber(wavelength)#

The wavenumber of this chemical for the given wavelength.

Parameters:

wavelength (Quantity | AbstractScalar)

Return type:

AbstractScalar

property file_nk: ScalarArray#

The path to the Windt [1998] file containing the index of refaction, \(n\), and the wavenumber, \(k\).

formula: str | AbstractScalar = <dataclasses._MISSING_TYPE object>#

the empirical formula of the chemical compound.

For example, water would be expressed as "H2O" and hydrogen peroxide would be expressed as "H2O2".

property formula_latex: str#

LaTeX representation of the chemical formula, with appropriate subscripts.

is_amorphous: bool = False#

Boolean flag controlling whether the chemical is amorphous or crystalline.

property shape: dict[str, int]#

The array shape of this object.

table: None | str = None#

Name of the table of chemical constants.

Common options are "palik", "llnl", and "windt". The database is the same as the IMD code [Windt, 1998]. The default value, None, usually means concatenating the tables in Palik [1997] and Henke et al. [1993].