Material Base Class

This is the base class for all other specific material models.

Overview

The Material class provides an abstract interface for all material models used in the electromagnetic solvers. It defines the structure that all material classes must follow, including initialization and permittivity evaluation over specified wavelengths.

This class should be subclassed to create specific material models. At a minimum, subclasses must override:

  • __init__ to initialize material-specific parameters.

  • eps(wavelengths) to return the material permittivity at given wavelengths.

  • index(wavelengths) to return the material refractive index at given wavelengths.

Examples

To define a custom material model, inherit from Material and implement the required methods.

Creating a Custom Material Object

This examples shows how to create a custom material object and override the __init__, eps() and index() methods.

from pyOptiShared.Material import Material
import numpy as np

class CustomMaterial(Material):
     def __init__(self, n):
     super.__init__()
     self.n = n  # Refractive index

     def eps(self, wavelengths):
         # Return constant permittivity for all wavelengths
         return np.full_like(wavelengths, self.n**2, dtype=np.complex64)

     def index(self, wavelengths):
         # Return constant permittivity for all wavelengths
         return np.full_like(wavelengths, self.n, dtype=np.complex64)