The Material Class

This class defines the optical parameters for a given material. The optical parameters are defined via the complex refractive index or equivalently the complex permittivity. As a shorthand, we will refer to the real part of the refractive index as n, the imaginary part as k and the complex refractive index as nk. Similarly, the shorthand for permittivity is eps_r, eps_i and eps

There are multiple ways to initalise this class. Typically the objects of this class will be generated using the catalogue.

It can also be initalised in the following ways,

  • using the path to a file
  • using a constant value for n, nk, eps_r or eps.
  • using tabulated data for n, nk or eps
  • using a predefined model

Apart from the file path, these different definitions can be mixed and matched. For example a model or tabulated data for n, while taking a constant value for k.

A material is full defined when either both the real and imaginary parts of the refractive index or permittivity are defined, or alternatively a complex value for either refractive index or permittivity is defined.

Once a material has been fully defined, the refractive index or permittivity can be evaluated on a given spectrum. The spectrum can be wavelength, frequency, angular frequency or energy. For more information see Spectrum

import numpy as np
from dispersion import Material, Spectrum
mat = Material(fixed_n = 1.5) # k will be set = 0
spm = Spectrum( np.arange(380, 750, 10 ),
               spectrum_type= 'Wavelength',
               unit = 'nanometer')
nk_values = mat.get_nk_data(spm)
eps = mat.get_permittivity(spm)

Interpolation

If tabulated data is used to initalise the MaterialData, it will be automatically interpolated. The order of interpolation can be set by passing interp_order as a keyword to the MaterialData constructor. The order must be an integer. The default value is 1 (linear interpolation).

Extrapolation

Data can be extrapolated outside of the range in which it is defined. This should be done with great care, as extrapolated values may not even be qualitatively correct. However in circumstances where the material dispersion is very low, it may be practical to extrapolate the close to the spectrum of known values. Note that since the real and imaginary parts are extrapolated separately they must be independent of one another. Therefore, the material must be defined via separate real and imaginary parts, rather than via a complex value.

Extrapolation is achieved as follows,

new_spectrum = Spectrum(800., spectrum_type='Wavelength', unit='nm')
mat.extrapolate(new_spectrum, spline_order=2)

Due to extrapolation using splines, the results can vary greatly depending on the spline order used. For this reason it is recommended to verify the results of extrapolation before using the results for further calculations.

Removing Absorption

Sometimes it is useful to remove the absorption by setting the imaginary part of material data to a constant zero value. This can be achieved by,

mat.remove_absorption()

Note that this is only valid for data which have independent real and imaginary parts.

Full API

holds the complex refactive index or permittivity data

material_data implements the Material class which can hold different representations of spectral data (e.g. refractive index or permittivity). The data is in the form of either a constant value, tabulated data or a model. These different representations can be combined e.g. model for n (real part of refractive index) and constant value for k (imaginary part of refractive index)

Functions

_check_table_shape
validate that a numpy array has a given shape

Classes

Material
processes and interfaces refractive index data.
class material.Bruggeman(spectrum, material1, material2, filling_fraction)

Methods

create_effective_data(self) this must be implemented in a subclass
dataset_to_dict(self) generate a file_data type dictionary from this object
extrapolate(self, new_spectrum[, spline_order]) extrpolates the material data
get_maximum_valid_range(self) find maximum spectral range that spans real and imaginary data.
get_nk_data(self, spectrum[, spectrum_type, …]) return complex refractive index for a given input spectrum.
get_permittivity(self, spectrum_values[, …]) return complex permittivity for a given input spectrum.
get_sample_spectrum(self) spectrum which covers the maximum valid range of the material data
plot_nk_data(self, **kwargs) plots the real and imaginary part of the refractive index
plot_permittivity(self, **kwargs) plots the real and imaginary part of the permittivity
print_comment(self) print material comment
print_reference(self) print material reference
remove_absorption(self) sets loss (k or epsi) to constant zero value
utf8_to_ascii(string) converts a string from utf8 to ascii
add_dtype_suffix  
collapse_datasets  
prepare_file_dict  
create_effective_data(self)

this must be implemented in a subclass

class material.EffectiveMedium(spectrum, material1, material2, filling_fraction)

Methods

create_effective_data(self) this must be implemented in a subclass
dataset_to_dict(self) generate a file_data type dictionary from this object
extrapolate(self, new_spectrum[, spline_order]) extrpolates the material data
get_maximum_valid_range(self) find maximum spectral range that spans real and imaginary data.
get_nk_data(self, spectrum[, spectrum_type, …]) return complex refractive index for a given input spectrum.
get_permittivity(self, spectrum_values[, …]) return complex permittivity for a given input spectrum.
get_sample_spectrum(self) spectrum which covers the maximum valid range of the material data
plot_nk_data(self, **kwargs) plots the real and imaginary part of the refractive index
plot_permittivity(self, **kwargs) plots the real and imaginary part of the permittivity
print_comment(self) print material comment
print_reference(self) print material reference
remove_absorption(self) sets loss (k or epsi) to constant zero value
utf8_to_ascii(string) converts a string from utf8 to ascii
add_dtype_suffix  
collapse_datasets  
prepare_file_dict  
create_effective_data(self)

this must be implemented in a subclass

class material.Material(**kwargs)

Class for processing refractive index and permittivity data

Parameters:
file_path: str

file path from which to load data

fixed_n: float

fixed real part of refractive index

fixed_nk: complex

fixed complex refractive index

fixed_eps_r: float

fixed real part of permittivity

fixed_eps: complex

fixed complex permittivity

tabulated_n: Nx2 array

table of real part of refractive index to interpolate

tabulated_nk: Nx3 array

table of real and imaginary refractive index values to interpolate

tabulated_eps: Nx3 array

table of real and imaginary permittivity values to interpolate

model_kw: dict

model parameters

spectrum_type: str

sets the default spectrum type

unit: str

sets the default unit

meta_data: dict

contains the meta data for the material

data: dict

holds one or two SpectralData objects to describe the data

options: dict

holds options for the material object

defaults: dict

default values for spectrum data

Warning

the parameters file_path, fixed_n, fixed_nk, fixed_eps_r, fixed_eps, tabulated_n, tabulated_nk, tabulated_eps and model_kw are mututally exclusive.

Methods

dataset_to_dict(self) generate a file_data type dictionary from this object
extrapolate(self, new_spectrum[, spline_order]) extrpolates the material data
get_maximum_valid_range(self) find maximum spectral range that spans real and imaginary data.
get_nk_data(self, spectrum[, spectrum_type, …]) return complex refractive index for a given input spectrum.
get_permittivity(self, spectrum_values[, …]) return complex permittivity for a given input spectrum.
get_sample_spectrum(self) spectrum which covers the maximum valid range of the material data
plot_nk_data(self, **kwargs) plots the real and imaginary part of the refractive index
plot_permittivity(self, **kwargs) plots the real and imaginary part of the permittivity
print_comment(self) print material comment
print_reference(self) print material reference
remove_absorption(self) sets loss (k or epsi) to constant zero value
utf8_to_ascii(string) converts a string from utf8 to ascii
add_dtype_suffix  
collapse_datasets  
prepare_file_dict  
dataset_to_dict(self)

generate a file_data type dictionary from this object

Parameters:
material_data: dict

keys: name, real, imag, complex

Returns:
dict

a list of dicts that has a format suitable for writing to file

extrapolate(self, new_spectrum, spline_order=2)

extrpolates the material data

extrapolates the material data to cover the range defined by the spectrum new_spectrum. if new_spectrum has only one element, the data will be extrapolated from the relevant end of its valid range up to the value given by new_spectrum. spline_order defines the order of the spline used for extrapolation. The results of the extrapolation depend heavily on the order chosen, so please check the end result to make sure it make physical sense.

Parameters:
new_spectrum: Spectrum

the values to exrapolate to

spline_order: int

the order of spline to use for interpolation -> extrpolation

Raises:
NotImplementedError

if the material is defined as via a complex value

get_maximum_valid_range(self)

find maximum spectral range that spans real and imaginary data.

Checks both real and imaginary parts of spectral data and finds the maximum spectral range which is valid for both parts.

Returns:
2x1 np.array

the maximum valid range

get_nk_data(self, spectrum, spectrum_type='wavelength', unit='meter')

return complex refractive index for a given input spectrum.

Parameters:
spectrum: np.array or Spectrum

the spectral values to evaluate

spectrum_type: str {‘wavelength’, ‘frequency’, ‘energy’}

type of spectrum

unit: str {‘meter’, ‘nanometer’, ‘micrometer’, ‘hertz’, ‘electronvolt’}

unit of spectrum (must match spectrum type)

Returns:
np.complex128

the complex n/k values (if input spectrum has size == 1)

np.array with np.complex128 dtype

the complex n/k values (if input spectrum has size > 1)

get_permittivity(self, spectrum_values, spectrum_type='wavelength', unit='meter')

return complex permittivity for a given input spectrum.

Parameters:
spectrum: np.array or Spectrum

the spectral values to evaluate

spectrum_type: str {‘wavelength’, ‘frequency’, ‘energy’}

type of spectrum

unit: str {‘meter’, ‘nanometer’, ‘micrometer’, ‘hertz’, ‘electronvolt’}

unit of spectrum (must match spectrum type)

Returns:
np.complex128

the complex permittivity values (if input spectrum has size == 1)

np.array with np.complex128 dtype

the complex permittivity values (if input spectrum has size > 1)

get_sample_spectrum(self)

spectrum which covers the maximum valid range of the material data

plot_nk_data(self, **kwargs)

plots the real and imaginary part of the refractive index

plot_permittivity(self, **kwargs)

plots the real and imaginary part of the permittivity

print_comment(self)

print material comment

print_reference(self)

print material reference

remove_absorption(self)

sets loss (k or epsi) to constant zero value

Warning

has no effect if the material is defined as via complex data instead of separate real and imaginary parts.

static utf8_to_ascii(string)

converts a string from utf8 to ascii

class material.MaxwellGarnett(spectrum, material1, material2, filling_fraction)

Methods

create_effective_data(self) this must be implemented in a subclass
dataset_to_dict(self) generate a file_data type dictionary from this object
extrapolate(self, new_spectrum[, spline_order]) extrpolates the material data
get_maximum_valid_range(self) find maximum spectral range that spans real and imaginary data.
get_nk_data(self, spectrum[, spectrum_type, …]) return complex refractive index for a given input spectrum.
get_permittivity(self, spectrum_values[, …]) return complex permittivity for a given input spectrum.
get_sample_spectrum(self) spectrum which covers the maximum valid range of the material data
plot_nk_data(self, **kwargs) plots the real and imaginary part of the refractive index
plot_permittivity(self, **kwargs) plots the real and imaginary part of the permittivity
print_comment(self) print material comment
print_reference(self) print material reference
remove_absorption(self) sets loss (k or epsi) to constant zero value
utf8_to_ascii(string) converts a string from utf8 to ascii
add_dtype_suffix  
collapse_datasets  
prepare_file_dict  
create_effective_data(self)

this must be implemented in a subclass