Units and constants¶
Unit-safe scalar types (Wavelength, Energy, Power, …), built-in constants and conversions. Docstrings are the source of truth, rendered with
mkdocstrings (numpydoc style).
photonics_helper.base ¶
Physical units and constants for photonics calculations.
Wavelength ¶
Wavelength stored internally in meters.
Accepts nm, um, or m on construction; converts to meters in __post_init__.
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.
Frequency ¶
Optical frequency stored internally in Hz.
Accepts THz, GHz, MHz, or Hz on construction; converts to Hz in __post_init__.
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.
AngularFrequency ¶
Angular optical frequency stored internally in rad/s.
Accepts rad/s or rad/ps on construction; converts to rad/s in __post_init__.
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.
Wavenumber ¶
Wavenumber stored internally in 1/m.
Accepts 1/cm or 1/m on construction; converts to 1/m in __post_init__.
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π).
Length ¶
Length stored internally in meters.
Accepts km, m, cm, mm, um, nm, or pm on construction; converts to meters in __post_init__.
Time ¶
Time stored internally in seconds.
Accepts s, ms, us, ns, ps, fs, or as on construction; converts to seconds in __post_init__.
Energy ¶
Energy stored internally in Joules.
Accepts J, mJ, uJ, nJ, pJ, eV, or meV on construction; converts to Joules in __post_init__.
Power ¶
Power stored internally in Watts.
Accepts kW, W, mW, uW, or nW on construction; converts to Watts in __post_init__.
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.
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__.
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`).
|
|
WavelengthArray ¶
Array of wavelengths stored internally in meters.
from_wavelengths
classmethod
¶
from_wavelengths(wavelengths: list[Wavelength]) -> Self
Build from a list of Wavelength scalars (stored internally in 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.
FrequencyArray ¶
Array of frequencies stored internally in Hz.
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.
AngularFrequencyArray ¶
Array of angular frequencies stored internally in rad/s.
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.
WavenumberArray ¶
Array of wavenumbers stored internally in 1/m.