materials.gradient_material#

Gradient-index (GRIN) material.

This module defines GradientMaterial, a material whose refractive index varies with position inside the medium.

Jie Cai (zhazhajust), 2025

Classes

GradientMaterial([n0, nr2, nr4, nr6, nz1, ...])

Material with a radial and axial gradient index.

class GradientMaterial(n0: ScalarOrArray = 1.5, nr2: ScalarOrArray = 0.0, nr4: ScalarOrArray = 0.0, nr6: ScalarOrArray = 0.0, nz1: ScalarOrArray = 0.0, nz2: ScalarOrArray = 0.0, nz3: ScalarOrArray = 0.0, propagation_model: GRINPropagation | None = None)[source]#

Material with a radial and axial gradient index.

The index follows the Gradient 3 law

\[n(r, z) = n_0 + n_{r2} r^2 + n_{r4} r^4 + n_{r6} r^6 + n_{z1} z + n_{z2} z^2 + n_{z3} z^3,\]

with \(r^2 = x^2 + y^2\). Coordinates are in mm, in the local frame of the surface where the medium starts. The index does not depend on wavelength, and the medium does not absorb.

Rays are traced through the medium by GRINPropagation.

Parameters:
  • n0 – Index at the medium origin.

  • nr2 – Coefficient of \(r^2\), in mm⁻².

  • nr4 – Coefficient of \(r^4\), in mm⁻⁴.

  • nr6 – Coefficient of \(r^6\), in mm⁻⁶.

  • nz1 – Coefficient of \(z\), in mm⁻¹.

  • nz2 – Coefficient of \(z^2\), in mm⁻².

  • nz3 – Coefficient of \(z^3\), in mm⁻³.

  • propagation_model – The integrator settings. Defaults to GRINPropagation().

abbe() → float#

Calculate the Abbe number (Vd) of the material.

The Abbe number is a measure of the material’s dispersion, defined as Vd = (n_d - 1) / (n_F - n_C), where n_d, n_F, and n_C are the refractive indices at the Fraunhofer d (587.5618 nm), F (486.1327 nm), and C (656.2725 nm) spectral lines, respectively.

Returns:

The Abbe number of the material.

Return type:

float

property display_name: str#

Human-readable identity; never a serialization or lookup key.

classmethod from_dict(data: dict) → GradientMaterial[source]#

Creates a material from a dictionary representation.

Parameters:

data – The dictionary representation.

Returns:

The material.

index_and_gradient(x: BEArray, y: BEArray, z: BEArray, wavelength: ScalarOrArray) → tuple[BEArray, BEArray, BEArray, BEArray][source]#

Returns the index and its gradient at points in the medium.

Parameters:
  • x – x-coordinates in the medium frame, in mm.

  • y – y-coordinates in the medium frame, in mm.

  • z – z-coordinates in the medium frame, in mm.

  • wavelength – Wavelength in µm. Not used by this law.

Returns:

The index n and the partial derivatives dn/dx, dn/dy and dn/dz.

k(wavelength: float | be.ndarray, **kwargs) → float | be.ndarray#

Calculates the extinction coefficient at a given wavelength with caching.

Parameters:
  • wavelength (float | be.ndarray) – The wavelength(s) of light in microns. Can be a float, numpy array, or torch tensor.

  • **kwargs – Additional keyword arguments for calculation.

Returns:

The extinction coefficient at the given wavelength(s).

Return type:

float | be.ndarray

n(wavelength: float | be.ndarray, **kwargs) → float | be.ndarray#

Calculates the refractive index at a given wavelength with caching.

Parameters:
  • wavelength (float | be.ndarray) – The wavelength(s) of light in microns. Can be a float, numpy array, or torch tensor.

  • **kwargs – Additional keyword arguments for calculation (e.g., temperature).

Returns:

The refractive index at the given wavelength(s).

Return type:

float | be.ndarray

spectral_range(property_name: str = 'n') → tuple[float, float] | None#

Known validity limits in micrometers, or None if unspecified.

Consumers must supply a range when none is known. This information does not change each material’s evaluation or extrapolation policy.

to_dict() → dict[source]#

Returns a dictionary representation of the material.

Returns:

The dictionary representation.