Defining fibers and materials#
Bundled definitions#
The simplest route is load_fiber(). Pass a bundled
YAML filename without its extension and always provide the wavelength when a
layer uses a dispersive material:
from PyFiberModes.units import ureg
from PyFiberModes import load_fiber
fiber = load_fiber("SMF28", wavelength=1.55e-6 * ureg.meter)
for layer in fiber.layers:
print(layer.name, layer.radius_in, layer.radius_out, layer.refractive_index)
The bundled catalog lives in PyFiberModes/fiber_files. Definitions may use
an explicit index, a registered material, or a numerical aperture
relative to the adjacent outer layer. A compact two-layer definition is:
# Layers are listed from outside to inside.
layers:
cladding:
name: cladding
radius: 62.5e-6
material: fused_silica
core:
name: core
radius: 4.1e-6
NA: 0.14
Custom material models#
Use MaterialRegistry when a definition names a
material that is not built in. A model can be any callable receiving wavelength
as a length quantity and returning a dimensionless index quantity:
from PyFiberModes.units import ureg
from PyFiberModes import MaterialRegistry, load_fiber
materials = MaterialRegistry({
"my_glass": lambda wavelength: (1.46 - 0.003 * (wavelength.to("micrometer").magnitude - 1.0)) * ureg.dimensionless,
})
fiber = load_fiber("my_fiber", wavelength=1.55e-6 * ureg.meter, materials=materials)
Programmatic construction#
For a single structure, create a Fiber, add layers
from the center outward, and initialize it once all interfaces are defined:
from PyFiberModes.units import ureg
from PyFiberModes import Fiber
fiber = Fiber(wavelength=1.55e-6 * ureg.meter)
fiber.add_layer(name="core", radius=4.1e-6 * ureg.meter, index=1.450 * ureg.dimensionless)
fiber.add_layer(name="cladding", radius=62.5e-6 * ureg.meter, index=1.444 * ureg.dimensionless)
fiber.initialize_layers()
Use FiberFactory when radii or indices are
iterables and you want the Cartesian product of several designs.
Mutation and caches#
Call update_wavelength() when changing
wavelength; it updates dependent state and clears cached modal and radial-field
solutions. Layer radius and refractive-index assignments also validate units and clear caches. Prefer
sweep() or the optimization helpers for repeated
calculations because they work on copies and keep the input fiber unchanged.