Skip to content

Foundation core

The dependency-light foundation namespace: typed units, physical constants, temporal grids and the optical-material interface. See Foundation core for the guide and the stable/satellite boundary.

photonics_helper.core.units

Typed unit classes — a foundation primitive.

Re-exports the unit-safe scalar/array types from :mod:photonics_helper.base. This module exists so that downstream code can type against photonics_helper.core.units as the stable foundation surface; the implementation currently lives in base.py (moving it is deferred).

Importing this module is dependency-light: numpy, scipy and pydantic only.

AngularFrequency

Angular optical frequency stored internally in rad/s.

Accepts rad/s or rad/ps on construction; converts to rad/s in __post_init__.

value instance-attribute

value: float

unit instance-attribute

unit: Literal['rad/s', 'rad/ps']

as_rad_s cached property

as_rad_s: float

Value in rad/s.

as_rad_ps cached property

as_rad_ps: float

Value in rad/ps.

as_meep cached property

as_meep: float

Convert to MEEP frequency units: f_Meep = aω/(2πc).

to_wl

to_wl() -> Wavelength

Convert to Wavelength (m).

to_freq

to_freq() -> Frequency

Convert to Frequency (Hz).

to_wn

to_wn() -> Wavenumber

Convert to Wavenumber (1/m).

to_time

to_time() -> Time

Construct the equivalent :class:Time (unit-converted).

to_energy

to_energy() -> Energy

Convert to :class:Energy (J).

from_meep classmethod

from_meep(value: float, base_length: Wavelength | None = None) -> Self

Create from MEEP frequency units.

In MEEP, c = 1, so f_Meep = ω·a/(2πc). Therefore ω = 2π·f_Meep·c/a.

AngularFrequencyArray

Array of angular frequencies stored internally in rad/s.

value instance-attribute

value: NDArray

unit instance-attribute

unit: Literal['rad/s', 'rad/ps']

as_rad_s cached property

as_rad_s: NDArray

Value in rad/s.

as_rad_ps cached property

as_rad_ps: NDArray

Value in rad/ps.

as_meep cached property

as_meep: NDArray

Convert to MEEP frequency units: f_Meep = aω/(2πc).

to_wl

to_wl() -> WavelengthArray

Convert to WavelengthArray (m).

to_freq

to_freq() -> FrequencyArray

Convert to FrequencyArray (Hz).

to_wn

to_wn() -> WavenumberArray

Convert to WavenumberArray (1/m).

to_equally_spaced

to_equally_spaced(points=51) -> NDArray

Return equally-spaced angular frequency values between min and max.

from_meep classmethod

from_meep(value: float | NDArray, base_length: Wavelength | None = None) -> Self

Create from MEEP frequency units.

In MEEP, c = 1, so f_Meep = ω·a/(2πc). Therefore ω = 2π·f_Meep·c/a.

Area

Area stored internally in square meters (m²).

Accepts m^2, cm^2, mm^2, um^2, or nm^2 on construction; converts to m² in __post_init__.

value instance-attribute

value: float

unit instance-attribute

unit: Literal['m^2', 'cm^2', 'mm^2', 'um^2', 'nm^2']

as_m2 cached property

as_m2: float

Value in square metres.

as_cm2 cached property

as_cm2: float

Value expressed in cm2 units.

as_mm2 cached property

as_mm2: float

Value expressed in mm2 units.

as_um2 cached property

as_um2: float

Value in square micrometres.

as_nm2 cached property

as_nm2: float

Value in nm².

as_meep cached property

as_meep: float

Value in MEEP normalized units.

from_meep classmethod

from_meep(value: float, base_length: Wavelength | None = None) -> Self

Energy

Energy stored internally in Joules.

Accepts J, mJ, uJ, nJ, pJ, eV, or meV on construction; converts to Joules in __post_init__.

value instance-attribute

value: float

unit instance-attribute

unit: Literal['J', 'mJ', 'uJ', 'nJ', 'pJ', 'eV', 'meV']

as_J cached property

as_J: float

as_mJ cached property

as_mJ: float

as_uJ cached property

as_uJ: float

as_nJ cached property

as_nJ: float

as_pJ cached property

as_pJ: float

as_eV cached property

as_eV: float

as_meV cached property

as_meV: float

as_meep cached property

as_meep: float

Value in MEEP normalized units.

to_freq

to_freq() -> Frequency

Convert to :class:Frequency (Hz).

to_omega

to_omega() -> AngularFrequency

Convert to :class:AngularFrequency (rad/s).

to_wl

to_wl() -> Wavelength

Convert to :class:Wavelength (m).

to_wn

to_wn() -> Wavenumber

Convert to :class:Wavenumber (1/m).

from_freq classmethod

from_freq(freq: Frequency) -> Self

from_omega classmethod

from_omega(omega: AngularFrequency) -> Self

from_wl classmethod

from_wl(wl: Wavelength) -> Self

from_wn classmethod

from_wn(wn: Wavenumber) -> Self

from_meep classmethod

from_meep(value: float, base_length: Wavelength | None = None) -> Self

Frequency

Optical frequency stored internally in Hz.

Accepts THz, GHz, MHz, or Hz on construction; converts to Hz in __post_init__.

value instance-attribute

value: float

unit instance-attribute

unit: Literal['THz', 'GHz', 'MHz', 'Hz']

as_Hz cached property

as_Hz: float

as_THz cached property

as_THz: float

as_GHz cached property

as_GHz: float

as_MHz cached property

as_MHz: float

as_meep cached property

as_meep: float

Convert to MEEP units (λ₀ = 1 μm): f_Meep = ν·a/c = a/λ.

to_wl

to_wl() -> Wavelength

Convert to Wavelength (m).

to_omega

to_omega() -> AngularFrequency

Convert to AngularFrequency (rad/s).

to_wn

to_wn() -> Wavenumber

Convert to Wavenumber (1/m).

to_time

to_time() -> Time

Construct the equivalent :class:Time (unit-converted).

to_energy

to_energy() -> Energy

Convert to :class:Energy (J).

from_meep classmethod

from_meep(value: float, base_length: Wavelength | None = None) -> Self

Create from MEEP frequency units.

In MEEP, c = 1, so f_Meep = ν·a/c. Therefore ν = f_Meep·c/a.

FrequencyArray

Array of frequencies stored internally in Hz.

value instance-attribute

value: NDArray

unit instance-attribute

unit: Literal['THz', 'GHz', 'MHz', 'Hz']

as_Hz cached property

as_Hz: NDArray

as_THz cached property

as_THz: NDArray

as_GHz cached property

as_GHz: NDArray

as_MHz cached property

as_MHz: NDArray

as_meep cached property

as_meep: NDArray

Convert to MEEP units (λ₀ = 1 μm): f_Meep = ν·a/c.

to_wl

to_wl() -> WavelengthArray

Convert to WavelengthArray (m).

to_omega

to_omega() -> AngularFrequencyArray

Convert to AngularFrequencyArray (rad/s).

to_wn

to_wn() -> WavenumberArray

Convert to WavenumberArray (1/m).

to_equally_spaced

to_equally_spaced(points=51) -> NDArray

Return equally-spaced frequency values between min and max.

from_meep classmethod

from_meep(value: float | NDArray, base_length: Wavelength | None = None) -> Self

Create from MEEP frequency units.

In MEEP, c = 1, so f_Meep = ν·a/c. Therefore ν = f_Meep·c/a.

Length

Length stored internally in meters.

Accepts km, m, cm, mm, um, nm, or pm on construction; converts to meters in __post_init__.

value instance-attribute

value: float

unit instance-attribute

unit: Literal['km', 'm', 'cm', 'mm', 'um', 'nm', 'pm']

as_km cached property

as_km: float

Value expressed in km units.

as_m cached property

as_m: float

Value in metres (the internal storage unit).

as_cm cached property

as_cm: float

Value expressed in cm units.

as_mm cached property

as_mm: float

Value expressed in mm units.

as_um cached property

as_um: float

Value in micrometres.

as_nm cached property

as_nm: float

Value in nanometres.

as_pm cached property

as_pm: float

Value expressed in pm units.

as_meep cached property

as_meep: float

Value in MEEP normalized units.

to_wl

to_wl() -> Wavelength

Convert to :class:Wavelength (m).

from_wl classmethod

from_wl(wl: Wavelength) -> Self

from_meep classmethod

from_meep(value: float, base_length: Wavelength | None = None) -> Self

PeakPower

Bases: Power

Peak power of a pulse, tying normalized envelopes to physical watts.

A thin :class:Power subclass. The conversion from a normalized envelope amplitude A (in V/m, or any consistent field unit) to a physical peak power follows from the plane-wave intensity relation

.. math::

I = \tfrac{1}{2} n \, c \, \varepsilon_0 \, |A|^2
\qquad\Longrightarrow\qquad
P_\mathrm{peak} = I_\mathrm{peak} \, A_\mathrm{eff}
= \tfrac{1}{2} n \, c \, \varepsilon_0 \, A_\mathrm{eff} \, |A|^2.

Wave.peak_power() uses the same relation; this class exposes it for one-shot conversions where only the envelope amplitude is at hand.

from_envelope classmethod

from_envelope(A: NDArray | float, A_eff: Area, n: float = 1.0, lambda0: Wavelength | None = None) -> PeakPower

Convert a normalized envelope amplitude to a physical peak power.

Parameters:

Name Type Description Default
A complex envelope amplitude (array or scalar) in field units.
required
A_eff effective mode area.
required
n refractive index at the carrier wavelength (default 1.0).
1.0
lambda0 optional vacuum carrier wavelength. Retained so call sites

record the wavelength the refractive index refers to; validated when supplied.

None

Returns:

Type Description
PeakPower — the peak power in watts (a :class:`Power`).

Permeability

Bases: float

Magnetic permeability (H/m). Wraps float with a convenience constructor.

value instance-attribute

value: float

from_relative classmethod

from_relative(relative_value: float)

Create from relative permeability (μ_r): μ = μ₀ × μ_r.

Permittivity

Bases: float

Electric permittivity (F/m). Wraps float with a convenience constructor.

value instance-attribute

value: float

from_relative classmethod

from_relative(relative_value: float)

Create from relative permittivity (ε_r): ε = ε₀ × ε_r.

Power

Power stored internally in Watts.

Accepts kW, W, mW, uW, or nW on construction; converts to Watts in __post_init__.

value instance-attribute

value: float

unit instance-attribute

unit: Literal['kW', 'W', 'mW', 'uW', 'nW']

as_kW cached property

as_kW: float

as_W cached property

as_W: float

as_mW cached property

as_mW: float

as_uW cached property

as_uW: float

as_nW cached property

as_nW: float

as_meep cached property

as_meep: float

Convert to MEEP units: P_meep = P·a²/(h·c²) for a = 1 μm.

from_meep classmethod

from_meep(value: float, base_length: Wavelength | None = None) -> Self

Create from MEEP power units.

Energy unit ħc/a joined with Energy.as_meep (which uses the Planck constant h, not ħ) gives P_meep = P·a²/(h·c²), the exact inverse of :attr:as_meep.

Time

Time stored internally in seconds.

Accepts s, ms, us, ns, ps, fs, or as on construction; converts to seconds in __post_init__.

value instance-attribute

value: float

unit instance-attribute

unit: Literal['s', 'ms', 'us', 'ns', 'ps', 'fs', 'as']

as_s cached property

as_s: float

Value in seconds.

as_ms cached property

as_ms: float

Value expressed in ms units.

as_us cached property

as_us: float

Value expressed in us units.

as_ns cached property

as_ns: float

Value in nanoseconds.

as_ps cached property

as_ps: float

Value in picoseconds.

as_fs cached property

as_fs: float

Value in femtoseconds.

as_as cached property

as_as: float

Value expressed in as units.

as_meep cached property

as_meep: float

Value in MEEP normalized units.

to_freq

to_freq() -> Frequency

Convert to :class:Frequency (Hz).

to_omega

to_omega() -> AngularFrequency

Convert to :class:AngularFrequency (rad/s).

from_freq classmethod

from_freq(freq: Frequency) -> Self

from_omega classmethod

from_omega(omega: AngularFrequency) -> Self

from_meep classmethod

from_meep(value: float, base_length: Wavelength | None = None) -> Self

Wavelength

Wavelength stored internally in meters.

Accepts nm, um, or m on construction; converts to meters in __post_init__.

value instance-attribute

value: float

unit instance-attribute

unit: Literal['nm', 'um', 'm']

as_m cached property

as_m: float

Value in metres (the internal storage unit).

as_um cached property

as_um: float

Value in micrometres.

as_nm cached property

as_nm: float

Value in nanometres.

as_meep cached property

as_meep: float

Convert to MEEP frequency units: f_Meep = a/λ.

to_freq

to_freq() -> Frequency

Convert to Frequency (Hz).

to_omega

to_omega() -> AngularFrequency

Convert to AngularFrequency (rad/s).

to_energy

to_energy() -> Energy

Convert to :class:Energy (J).

to_wn

to_wn() -> Wavenumber

Convert to Wavenumber (1/m).

from_meep classmethod

from_meep(value: float, base_length: Wavelength | None = None) -> Self

Create from MEEP frequency units.

In MEEP, c = 1, so f_Meep = a/λ where a is the base_length.

WavelengthArray

Array of wavelengths stored internally in meters.

value instance-attribute

value: NDArray

unit instance-attribute

unit: Literal['nm', 'um', 'm']

as_m cached property

as_m: NDArray

Value in metres (the internal storage unit).

as_um cached property

as_um: NDArray

Value in micrometres.

as_nm cached property

as_nm: NDArray

Value in nanometres.

as_meep cached property

as_meep: NDArray

Convert to MEEP frequency units: f_Meep = a/λ.

from_wavelengths classmethod

from_wavelengths(wavelengths: list[Wavelength]) -> Self

Build from a list of Wavelength scalars (stored internally in m).

to_freq

to_freq() -> FrequencyArray

Convert to FrequencyArray (Hz).

to_omega

to_omega() -> AngularFrequencyArray

Convert to AngularFrequencyArray (rad/s).

to_wn

to_wn() -> WavenumberArray

Convert to WavenumberArray (1/m).

to_equally_spaced

to_equally_spaced(points=51) -> NDArray

Return equally-spaced wavelength values between min and max.

from_meep classmethod

from_meep(value: float | NDArray, base_length: Wavelength | None = None) -> Self

Create from MEEP frequency units.

In MEEP, c = 1, so f_Meep = a/λ where a is the base_length.

Wavenumber

Wavenumber stored internally in 1/m.

Accepts 1/cm or 1/m on construction; converts to 1/m in __post_init__.

value instance-attribute

value: float

unit instance-attribute

unit: Literal['1/cm', '1/m']

as_1_m cached property

as_1_m: float

Value in 1/m (inverse metres).

as_1_cm cached property

as_1_cm: float

Value in 1/cm (per centimetre).

as_angular cached property

as_angular: float

Value expressed in angular units.

as_meep cached property

as_meep: float

Convert to MEEP frequency units: f_Meep = ak/(2π).

to_wl

to_wl() -> Wavelength

Convert to Wavelength (m).

to_freq

to_freq() -> Frequency

Convert to Frequency (Hz).

to_omega

to_omega() -> AngularFrequency

Convert to AngularFrequency (rad/s).

to_energy

to_energy() -> Energy

Convert to :class:Energy (J).

from_meep classmethod

from_meep(value: float, base_length: Wavelength | None = None) -> Self

Create from MEEP frequency units.

In MEEP, c = 1, so f_Meep = k·a/(2π).

WavenumberArray

Array of wavenumbers stored internally in 1/m.

value instance-attribute

value: NDArray

unit instance-attribute

unit: Literal['1/cm', '1/m']

as_1_m cached property

as_1_m: NDArray

Value in 1/m (inverse metres).

as_1_cm cached property

as_1_cm: NDArray

Value in 1/cm (per centimetre).

as_angular cached property

as_angular: NDArray

Value expressed in angular units.

as_meep cached property

as_meep: NDArray

Convert to MEEP frequency units: f_Meep = ak/(2π).

to_wl

to_wl() -> WavelengthArray

Convert to WavelengthArray (m).

to_freq

to_freq() -> FrequencyArray

Convert to FrequencyArray (Hz).

to_omega

to_omega() -> AngularFrequencyArray

Convert to AngularFrequencyArray (rad/s).

to_equally_spaced

to_equally_spaced(points=51) -> NDArray

Return equally-spaced wavenumber values between min and max.

from_meep classmethod

from_meep(value: float | NDArray, base_length: Wavelength | None = None) -> Self

Create from MEEP frequency units.

In MEEP, c = 1, so f_Meep = k·a/(2π).

photonics_helper.core.constants

Physical constants — a foundation primitive.

Re-exports the constants from :mod:photonics_helper.base under a stable namespace. Values come from :mod:scipy.constants (CODATA).

C_MS module-attribute

C_MS: float = const.c

EPS_0 module-attribute

EPS_0: float = const.epsilon_0

H_PLANCK module-attribute

H_PLANCK: float = const.h

HBAR module-attribute

HBAR: float = const.hbar

MU_0 module-attribute

MU_0: float = const.mu_0

PI module-attribute

PI: float = const.pi

Z0 module-attribute

Z0: float = 1.0 / (const.epsilon_0 * const.c)

photonics_helper.core.grids

Temporal grids — a foundation primitive.

TemporalGrid defines the time/frequency sampling and the FFT convention used throughout the library (FFT(A)·dt forward, /dt inverse, both fftshifted), so Parseval holds with the paired transforms. It is deliberately free of plotting dependencies: :mod:photonics_helper.pulse re-exports this same class object for backwards compatibility.

The FFTs execute on the configured backend (:mod:photonics_helper._fftw) — FFTW3 when pyfftw is installed, otherwise numpy.

TemporalGrid

Uniform temporal grid with FFT helpers.

Parameters:

Name Type Description Default
N number of samples.
required
Tmax total time window.
required

N instance-attribute

N: int

Tmax instance-attribute

Tmax: Time

dt cached property

dt

Temporal grid step (s).

t cached property

t

w cached property

w

dw cached property

dw

Frequency grid spacing (rad/ps).

omega_max property

omega_max

Maximum angular frequency on the grid (rad/ps).

time_window property

time_window

Total simulated time window (s).

fft

fft(A_t)

Forward FFT — analysis kernel e^{+iΩt}, scaled by dt.

Convention swap 2026-09 (openspec fix-audit-issues-batch, ISSUES.md #0): the analysis kernel is now e^{+iΩt} and the companion :meth:ifft synthesis kernel e^{−iΩt}, the standard Agrawal pairing (A(z,T) = ∫Ã(Ω)·e^{−iΩT}; the carrier factor is e^{−iω₀t}). Implemented as conj(DFT(conj(·))) on the same backend primitive (the DFT pair mirrored). Bin w > 0 under the λ map λ = c/(ω₀ + grid.w) is the blue side, and Parseval still holds with the paired transforms.

ifft

ifft(A_w)

Inverse FFT paired with :meth:fft (includes 1/dt scaling).

Synthesis kernel e^{−iΩt} after the #0 convention swap; see :meth:fft.

for_pulse_train classmethod

for_pulse_train(repetition_rate: Frequency, n_pulses: int, pulse_width: Time, N: int = 2 ** 12) -> Self

Compute the right Tmax to cover a pulse train.

Parameters:

Name Type Description Default
repetition_rate Frequency — pulse spacing = 1 / repetition_rate
required
n_pulses number of pulses
required
pulse_width T₀ — characteristic width, used to estimate needed padding
required
N number of time points (default 2¹²)
2 ** 12

photonics_helper.core.materials

Optical-material interface — a foundation primitive.

Two things live here:

  • :class:OpticalMaterial, a runtime-checkable protocol describing a wavelength-dependent material (a name, the tabulated n/k and wl arrays, the interpolating n_func/k_func, and a provenance source). Downstream code can type against the interface instead of the concrete :class:~photonics_helper.materials.RefractiveIndex.
  • :func:material, a convenience lookup that builds a :class:Material from the bundled database via the existing :meth:RefractiveIndex.from_material_database path.

This module is additive: nothing here replaces the existing photonics_helper.materials API.

OpticalMaterial

Bases: Protocol

Wavelength-dependent optical material.

Satisfied structurally by any object exposing these attributes/methods.

name instance-attribute

name: str

source instance-attribute

source: str | None

license instance-attribute

license: str | None

wl instance-attribute

wl: WavelengthArray

n instance-attribute

n: NDArray

k instance-attribute

k: NDArray

n_func

n_func(wavelength: float) -> float

Refractive index n at wavelength (μm).

k_func

k_func(wavelength: float) -> float

Extinction coefficient k at wavelength (μm).

Material dataclass

Material(name: str, index: RefractiveIndex, source: str | None = None, license: str | None = None)

Concrete :class:OpticalMaterial wrapping a :class:RefractiveIndex.

Parameters:

Name Type Description Default
name material name (as looked up in the database).
required
index the underlying tabulated/interpolated refractive index.
required
source provenance string (citation/author key) when known, else ``None``.
None
license licence identifier/sentinel for the data when known, else ``None``.
None

name instance-attribute

name: str

index instance-attribute

index: RefractiveIndex

source class-attribute instance-attribute

source: str | None = None

license class-attribute instance-attribute

license: str | None = None

wl property

wl: WavelengthArray

Wavelength samples of the underlying table.

n property

n: NDArray

Real refractive index samples.

k property

k: NDArray

Extinction-coefficient samples.

nk property

nk: NDArray

Complex refractive index samples (n + ik).

n_func

n_func(wavelength: float) -> float

Refractive index n at wavelength (μm).

k_func

k_func(wavelength: float) -> float

Extinction coefficient k at wavelength (μm).

nk_func

nk_func(wavelength: float) -> complex

Complex index n + ik at wavelength (μm).

group_index

group_index(wavelength: float) -> float

Group index at wavelength (μm).

material

material(name: str, *, axis: str | None = None, n_points: int = 200) -> Material

Load a material from the bundled database.

Parameters:

Name Type Description Default
name material name or ``material-author`` tabulated key.
required
axis for birefringent crystals, ``"extraordinary"`` (default canonical

row) or "ordinary".

None
n_points number of samples when the source is a Sellmeier equation.
200

Returns:

Type Description
Material

A concrete :class:OpticalMaterial.

Raises:

Type Description
ValueError

With an actionable message when the material is unknown, the axis is unknown/unavailable, or the database is missing, empty or corrupt.