Add Material to nk Database¶
Importing Libraries¶
Importing visualize_material_properties and add_material_to_nk_database function from tmmax.data is sufficient for data visualizations.
[ ]:
import jax.numpy as jnp
from jax import jit
from tmmax.data import add_material_to_nk_database, visualize_material_properties
Creating Dummy n, k Data Generator Function¶
Here, I created a function that generates n and k data for a dummy material. In your case, this is not necessary—you can directly use your own n and k data.
[ ]:
@jit
def dummy_material_n_k(wavelength_um):
"""
Calculate refractive index and extinction coefficient for dummy material
Args:
wavelength_um: Wavelength in micrometers (1.5-1.6 um range)
Returns:
n: Refractive index
k: Extinction coefficient
"""
# Create a fake wavelength-dependent refractive index with some features
n_base = 3.2
n_peak = 0.15 * jnp.exp(-((wavelength_um - 1.55) / 0.02)**2)
n = n_base + n_peak
# Create a fake wavelength-dependent extinction coefficient
k_base = 0.001
k_peak = 0.0005 * jnp.exp(-((wavelength_um - 1.53) / 0.03)**2)
k = k_base + k_peak
return n, k
Creating dummy_n and dummy_k data arrays.
[ ]:
dummy_wavelengths = jnp.linspace(1.5, 1.6, 100)
dummy_n, dummy_k = dummy_material_n_k(dummy_wavelengths)
Adding Materials to the Database¶
The following line adds a new material named 'dummy_material' to the internal n-k database. It takes four arguments:
wavelength_arr: an array of wavelength values,refractive_index_arr: an array representing the real part of the refractive index (n),extinction_coeff_arr: an array representing the imaginary part (k),material_name: the name of the material to be added.
In this example, dummy data (dummy_wavelengths, dummy_n, and dummy_k) is used to simulate a material entry. In practice, you can replace these arrays with your actual n and k data.
[ ]:
add_material_to_nk_database(wavelength_arr = dummy_wavelengths,
refractive_index_arr = dummy_n,
extinction_coeff_arr = dummy_k,
material_name='dummy_material')
'dummy_material.csv' recreated successfully.
Plotting the Material Data¶
You can directly plot the materials you’ve added to the database using visualize_material_properties.
[ ]:
visualize_material_properties(material_name = "dummy_material")