Public API contract#
This page defines the supported PyFiberModes 1.0 surface. Only names imported
from the package root and listed in PyFiberModes.__all__ are stable. Public
signatures and important defaults are recorded in tests/api_snapshot.json
and checked on every supported Python version.
Unit contract#
Import ureg and physical type hints from PyFiberModes.units. This unit
module shares TypedUnit.ureg with PyMieSim. Physical inputs require explicit
Pint quantities, including dimensionless refractive indices. Physical outputs
are quantities; use .to(unit).magnitude at numerical or plotting boundaries.
Bare physical inputs raise TypeError and incompatible dimensions raise
pint.DimensionalityError. YAML geometry and private solvers use SI numbers.
Core models#
Object |
Construction |
Contract |
|---|---|---|
|
Immutable identifier. |
|
|
Mutable physical model; wavelength and radii require length quantities. Layer property assignments validate units and invalidate caches. |
|
|
Immutable validated layer input; radius is metres and index is dimensionless. |
|
|
Immutable numerical settings. Tolerances must be positive. |
|
|
Coordinate arrays |
Coordinate distances are metres and angular coordinates are radians. |
Fiber construction and analysis#
Operation |
Result |
Mutates input? |
Failure |
|---|---|---|---|
Initialized |
No |
|
|
|
|
No |
Failed numerical or unguided solve is represented by
|
|
Effective index or |
No |
|
|
Dimensionless cutoff V-number or |
No |
|
|
Sampled |
No |
|
Tuple of guided modes |
No |
Expected non-convergence is omitted; invalid input propagates |
|
|
No; copied fibers are varied |
Expected per-point convergence failure becomes |
|
|
No; candidate fibers are copies |
Invalid configuration raises |
Modal-property names and units#
Name |
Unit |
Meaning |
|---|---|---|
|
dimensionless |
Modal effective refractive index |
|
dimensionless |
Normalized propagation constant |
|
1/m (convertible to rad/m) |
Longitudinal propagation constant |
|
m/s |
Phase and group velocities |
|
dimensionless |
Group refractive index |
|
s2/m |
Second angular-frequency derivative of propagation constant |
|
ps/(nm km) |
Chromatic dispersion |
|
ps/(nm2 km) |
Dispersion slope; historical spelling retained for compatibility |
|
dimensionless |
Normalized frequency; historical property spelling retained |
|
dimensionless |
Approximate mode count \(V^2/2\); historical property spelling retained |
Failure model#
The exception hierarchy has stable meanings:
ValidationErrormeans the request or physical input is invalid. It is also aValueError.UnsupportedGeometryErrormeans the input is valid but that calculation has no backend for its geometry.ConvergenceErrormeans a supported numerical calculation failed to produce a finite result.SolverErroris the common base for supported solver failures.
SolverResult.unwrap() returns a converged value and otherwise raises
ConvergenceError. Derivative-based scalar methods also raise
ConvergenceError rather than returning an unexplained non-finite value.
Convenience effective-index and cutoff methods retain NaN for an expected
absence of a root so array workflows can represent mode cutoff naturally.
Fields, design, and propagation#
Field and coordinate objects expose sampled arrays and derived integrals;
the sampling grid is immutable by convention, while internal arrays are normal
NumPy arrays. DesignResult, PropagationResult, ModeSweepResult, and
SolverResult are result containers. Coupled-mode propagation does not
modify initial amplitudes, and overlap/coupling operations do not mutate their
fields.
Compatibility names#
V_number, M_number, and get_S_parameter predate the current naming
policy. They remain supported public Fiber members for the 1.x series.
New APIs use descriptive snake-case names, but these three spellings are not
scheduled for removal and do not emit deprecation warnings.