Getting started#
Installation#
Install PyOptik and download the independently maintained material snapshot:
python -m pip install PyOptik
pyoptik setup
Install the optional terminal browser with python -m pip install
"PyOptik[ui]".
Your first calculation#
Use a familiar glass name and attach units to every wavelength:
from TypedUnit import ureg
from PyOptik import material
glass = material("N-BK7")
wavelength = 550 * ureg.nanometer
print(glass.n(wavelength))
print(glass.catalog_id) # specs/SCHOTT-optical/N-BK7
BK7 and N-BK7 select SCHOTT N-BK7. Common material names also have
documented sources, so a first calculation needs no catalog browsing:
silica = material("fused silica") # main/SiO2/Malitson
gold = material("gold") # main/Au/Johnson
print(gold.nk(633 * ureg.nm))
Pass source="Rakic-LD" to choose another gold dataset. Use
material("Au", use_default=False) to require an explicit source; if
several datasets match it raises AmbiguousMaterialError with descriptions
and canonical IDs. Names without a documented default follow the same rule.
Defaults never depend on catalog ordering or cache availability. See
Materials and catalog for the default-source table and discovery.
The shortcut downloads a snapshot if no local catalog exists. Subsequent
lookups use the local index. To repair an incomplete cache, run
pyoptik setup again.
Arrays use the same API:
wavelengths = [486.1, 587.6, 656.3] * ureg.nanometer
indices = glass.compute_refractive_index(wavelengths)
Common properties#
Every material provides a consistent set of derived quantities:
n = glass.n(wavelength)
k = glass.k(wavelength)
epsilon_r = glass.relative_permittivity(wavelength)
alpha = glass.absorption_coefficient(wavelength)
group_index = glass.compute_group_index(wavelength)
Use out_of_range="raise" when calculations must stay inside the source
validity interval.
Next steps#
Materials and catalog explains model types, search, and provenance.
Custom materials covers arrays, CSV import, coefficients, and export.
Interfaces and thin films covers interfaces and multilayer coatings.
Example gallery contains complete executable workflows.
Physical and numerical conventions records physical and numerical conventions.