Compare the Refractive Index of BK7 and Fused Silica#

This example compares two common optical glasses available in MaterialCatalog. It computes and plots the refractive index of BK7 and fused silica over the visible to near infrared wavelength range.

import numpy
import matplotlib.pyplot as plt
from TypedUnit import ureg

from PyOptik import MaterialCatalog


# Retrieve materials
catalog = MaterialCatalog.from_snapshot()
bk7 = catalog.get("specs/SCHOTT-optical/P-BK7").load()
silica = catalog.get("main/SiO2/Malitson").load()

# Prepare wavelength range
wavelengths = numpy.linspace(0.4, 1.6, 300) * ureg.micrometer

n_bk7 = bk7.compute_refractive_index(wavelengths)
n_silica = silica.compute_refractive_index(wavelengths)
fig, ax = plt.subplots()

ax.set(
    title="BK7 vs Fused Silica",
    xlabel="Wavelength [µm]",
    ylabel="Refractive index",
)
ax.plot(wavelengths, n_bk7.real, label="BK7")
ax.plot(wavelengths, n_silica.real, label="Fused Silica")
ax.legend()

plt.show()
BK7 vs Fused Silica
/opt/hostedtoolcache/Python/3.11.16/x64/lib/python3.11/site-packages/matplotlib/cbook.py:1408: UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray.
  return np.asanyarray(x, float)

Total running time of the script: (0 minutes 1.323 seconds)

Gallery generated by Sphinx-Gallery