Source Code#
Welcome to the PyFiberModes Source Code Documentation. This section provides a comprehensive overview of the key classes, functions, and utilities available within the PyFiberModes library. Each component is documented in detail, with information on its members, inherited properties, and direct links to the source code.
Class Documentation#
Below, you will find detailed, automatically generated documentation for significant classes and functions in the PyFiberModes library. These descriptions are intended to help you understand how each class and function fits into the overall framework, and how to utilize them effectively in your projects.
Fiber#
- class Fiber(wavelength: float, layer_names: list = <factory>, layer_radius: list = <factory>, layer_types: list = <factory>, index_list: list = <factory>)[source]#
Bases:
object
A class to represent an optical fiber with multiple layers.
This class provides functionality to define and manipulate the properties of optical fibers, including their layers, refractive indices, and propagation characteristics.
- Parameters:
wavelength (float) – The wavelength of light used for fiber simulations.
layer_names (list of str) – Names of the fiber layers.
layer_radius (list of float) – Radii of the fiber layers in meters.
layer_types (list of str) – Types of layers (e.g., core, cladding).
index_list (list of float) – Refractive indices for each layer.
- wavelength: float#
- layer_names: list#
- layer_radius: list#
- layer_types: list#
- index_list: list#
- scale(factor: float) None [source]#
Scale the fiber’s geometry by a given factor.
This method scales all radii in the fiber by the specified factor.
- Parameters:
factor (float) – Scaling factor to apply to the radii.
- Returns:
A scaled copy of the fiber.
- Return type:
Notes
This operation does not modify the original fiber.
- property n_layer: int#
Number of layers in the fiber.
- Returns:
The total number of layers.
- Return type:
int
- property n_interface: int#
Number of interfaces in the fiber.
- Returns:
The number of interfaces, calculated as n_layer - 1.
- Return type:
int
- property penultimate_layer: StepIndex#
Returns the second to last layer
- Returns:
The second to last layer.
- Return type:
- update_wavelength(wavelength: float) None [source]#
Update the wavelength of the fiber and all its layers
- Parameters:
wavelength (float) – The wavelength
- Returns:
No return
- Return type:
None
- add_layer(name: str, radius: float, index: float) None [source]#
Add a layer to the fiber.
- Parameters:
name (str) – Name of the layer (e.g., “core”, “cladding”).
radius (float) – Outer radius of the layer in meters.
index (float) – Refractive index of the layer.
Notes
Layers should be added in order, starting with the innermost layer (core).
- get_layer_at_radius(radius: float) StepIndex [source]#
Gets the layer that is associated to a given radius.
- Parameters:
radius (float) – The radius
- property radius: float#
Gets the fiber total radius taking account for all layers.
- Returns:
The fiber radius.
- Return type:
float
- get_index_at_radius(radius: float) float [source]#
Gets the refractive index at a given radius.
- Parameters:
radius (float) – The radius
- Returns:
The refractive index at given radius.
- Return type:
float
- property maximum_index: float#
Gets the maximum refractive index of the fiber.
- Parameters:
layer_idx (int) – The layer index
- Returns:
The minimum index.
- Return type:
float
- property minimum_index: float#
Gets the minimum refractive index of the fiber.
- Parameters:
layer_idx (int) – The layer index
- Returns:
The minimum index.
- Return type:
float
- get_NA() float [source]#
Compute the numerical aperture (NA) of the fiber.
The numerical aperture is defined as:
\[NA = \sqrt{n_{max}^2 - n_{min}^2}\]- where:
\(n_{max}\) is the maximum refractive index in the fiber.
\(n_{min}\) is the refractive index of the outermost layer.
- Returns:
The numerical aperture of the fiber.
- Return type:
float
- property M_number: float#
Gets the m number representing an approximation of the number of existing mode in the fiber. It’s valide only for highly multimode fibers M number is defined as:
\[M = \frac{V^2}{2}\]- Returns:
The M number.
- Return type:
float
- property V_number: float#
Compute the V-number (normalized frequency) of the fiber.
The V-number is given by:
\[V = \frac{2 \pi a}{\lambda} \cdot NA\]- where:
\(a\) is the core radius.
\(\lambda\) is the wavelength.
\(NA\) is the numerical aperture.
- Returns:
The V-number of the fiber.
- Return type:
float
Notes
The V-number determines whether the fiber supports single-mode or multimode operation.
- get_mode_cutoff_v0(mode: Mode) float [source]#
Gets the cutoff wavelength of the fiber.
- Parameters:
mode (Mode) – The mode to consider
- Returns:
The cutoff wavelength.
- Return type:
float
- get_mode_cutoff_wavelength(mode: Mode) float [source]#
Compute the cutoff wavelength for a given mode.
- Parameters:
mode (Mode) – The optical mode for which to calculate the cutoff wavelength.
- Returns:
The cutoff wavelength of the specified mode.
- Return type:
float
Notes
A mode is no longer guided when the wavelength exceeds the cutoff.
- get_effective_index(mode: Mode) float [source]#
Gets the effective index.
- Parameters:
mode (Mode) – The mode to consider
- Returns:
The effective index.
- Return type:
float
- get_normalized_beta(mode: Mode) float [source]#
Gets the normalized propagation constant [beta].
- Parameters:
mode (Mode) – The mode to consider
- Returns:
The normalized propagation constant.
- Return type:
float
- get_propagation_constant(mode: Mode) float [source]#
Gets the propagation constant [\(beta\)].
- Parameters:
mode (Mode) – The mode to consider
- Returns:
The propagation constant [\(beta\)].
- Return type:
float
- get_phase_velocity(mode: Mode) float [source]#
Compute the phase velocity of a mode in the fiber.
- Parameters:
mode (Mode) – The optical mode for which to compute the phase velocity.
- Returns:
The phase velocity of the mode, in meters per second.
- Return type:
float
Notes
Phase velocity is given by:
\[v_p = \frac{c}{n_{eff}}\]where \(n_{eff}\) is the effective refractive index.
- get_group_index(mode: Mode) float [source]#
Gets the group index.
- Parameters:
mode (Mode) – The mode to consider
- Returns:
The group index.
- Return type:
float
- get_groupe_velocity(mode: Mode) float [source]#
Gets the groupe velocity defined as:
\[\left( \frac{\partial \beta}{\partial \omega} \right)^{-1}\]- Parameters:
mode (Mode) – The mode to consider
- Returns:
The groupe velocity.
- Return type:
float
- get_group_velocity_dispersion(mode: Mode) float [source]#
Gets the fiber group velocity dispersion defined as:
\[\frac{\partial^2 \beta}{\partial \omega^2}\]- Parameters:
mode (Mode) – The mode to consider
- Returns:
The group_velocity dispersion
- Return type:
float
- get_dispersion(mode: Mode) float [source]#
Compute the modal dispersion in the fiber.
Dispersion is defined as:
\[D = - \frac{2 \pi c}{\lambda^2} \cdot \frac{\partial^2 \beta}{\partial \omega^2}\]- where:
\(c\) is the speed of light.
\(\lambda\) is the wavelength.
\(\beta\) is the propagation constant.
- Parameters:
mode (Mode) – The optical mode to consider.
- Returns:
The dispersion in units of ps/nm/km.
- Return type:
float
Notes
Dispersion affects pulse broadening in fiber optics, particularly for long-haul transmission.
- get_S_parameter(mode: Mode) float [source]#
Compute the S-parameter (third-order dispersion).
The S-parameter is defined as:
\[S = 10^{-3} \cdot \left( \frac{2 \pi c}{\lambda^2} \right)^2 \cdot \frac{\partial^3 \beta}{\partial \omega^3}\]- Parameters:
mode (Mode) – The optical mode to consider.
- Returns:
The S-parameter in appropriate units.
- Return type:
float
- get_mode_field(mode: Mode, limit: float = None, n_point: int = 101) Field [source]#
Get field class
- Parameters:
mode (Mode) – The mode to consider
wavelength (float) – The wavelength to consider
limit (float) – The limit boundary
n_point (int) – The number of point for axis discreditization
- Returns:
The field instance of the mode.
- Return type:
- get_radial_field(mode: Mode, radius: float) CylindricalCoordinates [source]#
Gets the mode field without the azimuthal component. Tuple structure is [\(E_{r}\), \(E_{\phi}\), \(E_{z}\)], [\(H_{r}\), \(H_{\phi}\), \(H_{z}\)]
- Parameters:
mode (Mode) – The mode to consider
radius (float) – The radius
- Returns:
The radial field.
- Return type:
CylindricalCoordinates
- get_radial_field_norm(mode: Mode, radius: float) float [source]#
Gets the norm of the mode field without the azimuthal component. Tuple structure is [\(E_{r}\), \(E_{\phi}\), \(E_{z}\)], [\(H_{r}\), \(H_{\phi}\), \(H_{z}\)]
- Parameters:
mode (Mode) – The mode to consider
radius (float) – The radius
- Returns:
The radial field.
- Return type:
float
Field#
- class Field(fiber: object, mode: Mode, limit: float, n_point: int = 101)[source]#
Bases:
object
A class representing the electric and magnetic field components in a fiber.
- Parameters:
fiber (Fiber) – The fiber associated with the mode.
mode (Mode) – The mode to evaluate.
limit (float) – The radius of the field to compute.
n_point (int, optional) – The number of points for the computation grid (default is 101).
- cartesian_coordinates#
Cartesian coordinates generated for the field computation.
- Type:
CartesianCoordinates
- cylindrical_coordinates#
Cylindrical coordinates corresponding to the cartesian grid.
- Type:
CylindricalCoordinates
- fiber: object#
- mode: Mode#
- limit: float#
- n_point: int = 101#
- get_azimuthal_dependency(phi: float, dependency_type: str) ndarray [source]#
Compute the azimuthal dependency for the field based on the given type.
The azimuthal dependencies are defined as:
\[f_\nu(\phi) = \cos(\nu \phi + \phi_0)\]\[g_\nu(\phi) = -\sin(\nu \phi + \phi_0)\]where \(\nu\) is the azimuthal mode number and \(\phi_0\) is the phase shift.
- Parameters:
phi (float) – Phase shift of the field in radians.
dependency_type ({'f', 'g'}) – The type of azimuthal dependency to compute: - ‘f’ for cosine dependency. - ‘g’ for sine dependency.
- Returns:
The azimuthal dependency values, computed over the cylindrical coordinates.
- Return type:
numpy.ndarray
- Raises:
ValueError – If dependency_type is not ‘f’ or ‘g’.
Notes
This method is referenced in Eq. 3.71 of Jaques Bures for the calculation of field azimuthal behavior in optical fibers.
- get_index_iterator(array: ndarray)[source]#
Generate an iterator for multi-dimensional array indices.
This method provides a way to iterate through all indices of a multi-dimensional NumPy array in a memory-efficient manner.
- Parameters:
array (numpy.ndarray) – The array for which to generate the index iterator.
- Yields:
tuple – Multi-dimensional index corresponding to the current element.
- wrapper_get_field() Callable [source]#
Decorator for wrapping field computation methods.
This decorator can be used to add pre- or post-processing steps to field computation methods in the Field class.
- Parameters:
function (Callable) – The function to be wrapped.
- Returns:
The wrapped function.
- Return type:
callable
- Ex(phi: float = 0, theta: float = 0) ndarray [source]#
Compute the x-component of the electric field, \(E_x\).
The x-component of the electric field is calculated based on the field’s mode family. For LP (linearly polarized) modes, it uses the radial electric field and the azimuthal dependency \(f_\nu(\phi)\). For other modes, the x-component is derived using the transverse electric field and its polarization angle.
\[\begin{split}E_x = \begin{cases} E_\rho \cdot f_\nu(\phi) & \text{if mode is LP} \\ E_T \cdot \cos(\theta_{\text{pol}}) & \text{otherwise} \end{cases}\end{split}\]
- where:
\(E_\rho\) is the radial electric field.
\(f_\nu(\phi) = \cos(\nu \phi + \phi_0)\) is the azimuthal dependency.
\(E_T\) is the transverse electric field.
\(\theta_{\text{pol}}\) is the polarization angle.
- Parameters:
phi (float, optional) – The phase of the field in radians (default is 0).
theta (float, optional) – The orientation of the field in radians (default is 0).
- Returns:
The x-component of the electric field, \(E_x\), computed over the Cartesian grid.
- Return type:
numpy.ndarray
- Raises:
AttributeError – If self.fiber does not implement get_radial_field.
References
Jaques Bures, Optical Fiber Theory, Eq. 3.71.
- Ey(phi: float = 0, theta: float = 0) ndarray [source]#
Compute the y-component of the electric field, \(E_y\).
The y-component of the electric field is calculated based on the field’s mode family. For LP (linearly polarized) modes, it uses the azimuthal dependency \(f_\nu(\phi)\) and the azimuthal electric field. For other modes, it is derived using the transverse electric field and its polarization angle.
\[\begin{split}E_y = \begin{cases} E_\phi \cdot f_\nu(\phi) & \text{if mode is LP} \\ E_T \cdot \sin(\theta_{\text{pol}}) & \text{otherwise} \end{cases}\end{split}\]
- where:
\(E_\phi\) is the azimuthal electric field.
\(f_\nu(\phi) = \cos(\nu \phi + \phi_0)\) is the azimuthal dependency.
\(E_T\) is the transverse electric field.
\(\theta_{\text{pol}}\) is the polarization angle.
- Parameters:
phi (float, optional) – The phase of the field in radians (default is 0).
theta (float, optional) – The orientation of the field in radians (default is 0).
- Returns:
The y-component of the electric field, \(E_y\), computed over the Cartesian grid.
- Return type:
numpy.ndarray
- Raises:
AttributeError – If self.fiber does not implement get_radial_field.
References
Jaques Bures, Optical Fiber Theory, Eq. 3.71.
- Ez(phi: float = 0, theta: float = 0) ndarray [source]#
Compute the z-component of the electric field, \(E_z\).
The z-component of the electric field is calculated using the azimuthal dependency \(f_\nu(\phi)\) and the longitudinal electric field component \(E_z\).
\[E_z = E_z \cdot f_\nu(\phi)\]
- where:
\(E_z\) is the longitudinal electric field.
\(f_\nu(\phi) = \cos(\nu \phi + \phi_0)\) is the azimuthal dependency.
- Parameters:
phi (float, optional) – The phase of the field in radians (default is 0).
theta (float, optional) – Orientation of the field in radians (not used in this calculation, default is 0).
- Returns:
The z-component of the electric field, \(E_z\), computed over the Cartesian grid.
- Return type:
numpy.ndarray
- Raises:
AttributeError – If self.fiber does not implement get_radial_field.
References
Jaques Bures, Optical Fiber Theory, Eq. 3.71.
- Er(phi: float = 0, theta: float = 0) ndarray [source]#
Compute the radial component of the electric field, \(E_r\).
The radial component of the electric field is calculated differently based on the field’s mode family. For LP (linearly polarized) modes, it uses the transverse electric field and its polarization. For other modes, it incorporates the azimuthal dependency \(f_\nu(\phi)\) and the radial electric field component \(E_\rho\).
\[\begin{split}E_r = \begin{cases} E_T \cdot \cos(\theta_{\text{pol}} - \phi) & \text{if mode is LP} \\ E_\rho \cdot f_\nu(\phi) & \text{otherwise} \end{cases}\end{split}\]
- where:
\(E_T\) is the transverse electric field.
\(\theta_{\text{pol}}\) is the polarization angle.
\(E_\rho\) is the radial electric field.
\(f_\nu(\phi) = \cos(\nu \phi + \phi_0)\) is the azimuthal dependency.
- Parameters:
phi (float, optional) – The phase of the field in radians (default is 0).
theta (float, optional) – The orientation of the field in radians (default is 0).
- Returns:
The radial component of the electric field, \(E_r\), computed over the Cartesian grid.
- Return type:
numpy.ndarray
- Raises:
AttributeError – If self.fiber does not implement get_radial_field.
References
Jaques Bures, Optical Fiber Theory, Eq. 3.71.
- Ephi(phi: float = 0, theta: float = 0) ndarray [source]#
Compute the azimuthal component of the electric field, \(E_\phi\).
The azimuthal component of the electric field is calculated based on the field’s mode family. For LP (linearly polarized) modes, it uses the transverse electric field and its polarization. For other modes, it incorporates the azimuthal dependency \(g_\nu(\phi)\) and the azimuthal electric field component \(E_\phi\).
\[\begin{split}E_\phi = \begin{cases} E_T \cdot \sin(\theta_{\text{pol}} - \phi) & \text{if mode is LP} \\ E_\phi \cdot g_\nu(\phi) & \text{otherwise} \end{cases}\end{split}\]
- where:
\(E_T\) is the transverse electric field.
\(\theta_{\text{pol}}\) is the polarization angle.
\(E_\phi\) is the azimuthal electric field.
\(g_\nu(\phi) = -\sin(\nu \phi + \phi_0)\) is the azimuthal dependency.
- Parameters:
phi (float, optional) – The phase of the field in radians (default is 0).
theta (float, optional) – The orientation of the field in radians (default is 0).
- Returns:
The azimuthal component of the electric field, \(E_\phi\), computed over the Cartesian grid.
- Return type:
numpy.ndarray
- Raises:
AttributeError – If self.fiber does not implement get_radial_field.
References
Jaques Bures, Optical Fiber Theory, Eq. 3.71.
- Et(phi: float = 0, theta: float = 0) ndarray [source]#
Compute the transverse component of the electric field, \(E_T\).
The transverse electric field is computed as the magnitude of the components perpendicular to the z-axis. For LP (linearly polarized) modes, it is derived from the x and y components. For other modes, it is computed using the radial and azimuthal components.
\[\begin{split}E_T = \begin{cases} \sqrt{E_x^2 + E_y^2} & \text{if mode is LP} \\ \sqrt{E_r^2 + E_\phi^2} & \text{otherwise} \end{cases}\end{split}\]
- where:
\(E_x, E_y\) are the Cartesian components of the electric field.
\(E_r, E_\phi\) are the cylindrical components of the electric field.
- Parameters:
phi (float, optional) – The phase of the field in radians (default is 0).
theta (float, optional) – The orientation of the field in radians (default is 0).
- Returns:
The transverse electric field, \(E_T\), computed over the Cartesian grid.
- Return type:
numpy.ndarray
- Epol(phi: float = 0, theta: float = 0) ndarray [source]#
Compute the polarization angle of the transverse electric field, \(\theta_{\text{pol}}\).
The polarization angle is the direction of the transverse electric field vector in the plane perpendicular to the z-axis. For LP (linearly polarized) modes, it is calculated using the x and y components. For other modes, it is calculated using the radial and azimuthal components.
\[\begin{split}\theta_{\text{pol}} = \begin{cases} \arctan2(E_y, E_x) & \text{if mode is LP} \\ \arctan2(E_\phi, E_r) + \phi & \text{otherwise} \end{cases}\end{split}\]
- where:
\(E_x, E_y\) are the Cartesian components of the electric field.
\(E_r, E_\phi\) are the cylindrical components of the electric field.
- Parameters:
phi (float, optional) – The phase of the field in radians (default is 0).
theta (float, optional) – The orientation of the field in radians (default is 0).
- Returns:
The polarization angle of the transverse electric field in radians.
- Return type:
numpy.ndarray
- Emod(phi: float = 0, theta: float = 0) ndarray [source]#
Compute the modulus (magnitude) of the electric field vector, \(|\vec{E}|\).
The electric field modulus is the magnitude of the field vector, which includes all components (transverse and longitudinal). For LP (linearly polarized) modes, it uses the Cartesian components. For other modes, it uses the cylindrical components.
\[\begin{split}|\vec{E}| = \begin{cases} \sqrt{E_x^2 + E_y^2 + E_z^2} & \text{if mode is LP} \\ \sqrt{E_r^2 + E_\phi^2 + E_z^2} & \text{otherwise} \end{cases}\end{split}\]
- where:
\(E_x, E_y, E_z\) are the Cartesian components of the electric field.
\(E_r, E_\phi, E_z\) are the cylindrical components of the electric field.
- Parameters:
phi (float, optional) – The phase of the field in radians (default is 0).
theta (float, optional) – The orientation of the field in radians (default is 0).
- Returns:
The modulus of the electric field, \(|\vec{E}|\), computed over the Cartesian grid.
- Return type:
numpy.ndarray
- Hx(phi: float = 0, theta: float = 0) ndarray [source]#
Compute the x-component of the magnetic field \(H_x\).
For LP (linearly polarized) modes, this is computed using the radial component \(H_r\) and the azimuthal dependency \(f_\nu(\phi)\):
\[H_x = H_r \cdot f_\nu(\phi)\]For other modes, the transverse magnetic field and polarization are used:
\[H_x = H_T \cdot \cos(\theta_{\text{pol}})\]
- Parameters:
phi (float, optional) – Phase of the field in radians (default is 0).
theta (float, optional) – Orientation of the field in radians (default is 0).
- Returns:
The magnetic field in the x-direction over the Cartesian grid.
- Return type:
np.ndarray
- Raises:
AttributeError – If the fiber object does not implement get_radial_field.
- Hy(phi: float = 0, theta: float = 0) ndarray [source]#
Compute the y-component of the magnetic field \(H_y\).
For LP modes, this is computed using the azimuthal component \(H_\phi\) and the azimuthal dependency \(f_\nu(\phi)\):
\[H_y = H_\phi \cdot f_\nu(\phi)\]For other modes, the transverse magnetic field and polarization are used:
\[H_y = H_T \cdot \sin(\theta_{\text{pol}})\]
- Parameters:
phi (float, optional) – Phase of the field in radians (default is 0).
theta (float, optional) – Orientation of the field in radians (default is 0).
- Returns:
The magnetic field in the y-direction over the Cartesian grid.
- Return type:
np.ndarray
- Raises:
AttributeError – If the fiber object does not implement get_radial_field.
- Hz(phi: float = 0, theta: float = 0) ndarray [source]#
Compute the z-component of the magnetic field \(H_z\).
The z-component is calculated for all modes using the longitudinal field \(H_z\) and the azimuthal dependency \(f_\nu(\phi)\):
\[H_z = H_z \cdot f_\nu(\phi)\]
- Parameters:
phi (float, optional) – Phase of the field in radians (default is 0).
theta (float, optional) – Orientation of the field in radians (default is 0).
- Returns:
The magnetic field in the z-direction over the Cartesian grid.
- Return type:
np.ndarray
- Raises:
AttributeError – If the fiber object does not implement get_radial_field.
- Hr(phi: float = 0, theta: float = 0) ndarray [source]#
Compute the radial component of the magnetic field \(H_r\).
For LP modes, this is computed using the transverse field \(H_T\) and the polarization angle \(\theta_{\text{pol}}\):
\[H_r = H_T \cdot \cos(\theta_{\text{pol}} - \phi)\]For other modes, the radial field and azimuthal dependency \(f_\nu(\phi)\) are used:
\[H_r = H_r \cdot f_\nu(\phi)\]
- Parameters:
phi (float, optional) – Phase of the field in radians (default is 0).
theta (float, optional) – Orientation of the field in radians (default is 0).
- Returns:
The magnetic field in the radial direction over the Cartesian grid.
- Return type:
np.ndarray
- Hphi(phi: float = 0, theta: float = 0) ndarray [source]#
Compute the azimuthal component of the magnetic field \(H_\phi\).
For LP modes, this is computed using the transverse field \(H_T\) and the polarization angle \(\theta_{\text{pol}}\):
\[H_\phi = H_T \cdot \sin(\theta_{\text{pol}} - \phi)\]For other modes, the azimuthal field and azimuthal dependency \(g_\nu(\phi)\) are used:
\[H_\phi = H_\phi \cdot g_\nu(\phi)\]
- Parameters:
phi (float, optional) – Phase of the field in radians (default is 0).
theta (float, optional) – Orientation of the field in radians (default is 0).
- Returns:
The magnetic field in the azimuthal direction over the Cartesian grid.
- Return type:
np.ndarray
- Ht(phi: float = 0, theta: float = 0) ndarray [source]#
Compute the transverse component of the magnetic field, \(H_T\).
The transverse magnetic field is calculated as the magnitude of the components perpendicular to the z-axis. For LP (linearly polarized) modes, it is derived from the x and y components. For other modes, it is computed using the radial and azimuthal components.
\[\begin{split}H_T = \begin{cases} \sqrt{H_x^2 + H_y^2} & \text{if mode is LP} \\ \sqrt{H_r^2 + H_\phi^2} & \text{otherwise} \end{cases}\end{split}\]
- Parameters:
phi (float, optional) – Phase of the field in radians (default is 0).
theta (float, optional) – Orientation of the field in radians (default is 0).
- Returns:
The transverse magnetic field, \(H_T\), computed over the Cartesian grid.
- Return type:
numpy.ndarray
- Hpol(phi: float = 0, theta: float = 0) ndarray [source]#
Compute the polarization angle of the transverse magnetic field, \(\theta_{\text{pol}}\).
The polarization angle represents the direction of the transverse magnetic field vector in the plane perpendicular to the z-axis. For LP modes, it is calculated using the x and y components. For other modes, it is calculated using the radial and azimuthal components.
\[\begin{split}\theta_{\text{pol}} = \begin{cases} \arctan2(H_y, H_x) & \text{if mode is LP} \\ \arctan2(H_\phi, H_r) + \phi & \text{otherwise} \end{cases}\end{split}\]
- Parameters:
phi (float, optional) – Phase of the field in radians (default is 0).
theta (float, optional) – Orientation of the field in radians (default is 0).
- Returns:
The polarization angle of the transverse magnetic field in radians.
- Return type:
numpy.ndarray
- Hmod(phi: float = 0, theta: float = 0) ndarray [source]#
Compute the modulus (magnitude) of the magnetic field vector, \(|\vec{H}|\).
The magnetic field modulus is the magnitude of the field vector, which includes all components (transverse and longitudinal). For LP (linearly polarized) modes, it uses the Cartesian components. For other modes, it uses the cylindrical components.
\[\begin{split}|\vec{H}| = \begin{cases} \sqrt{H_x^2 + H_y^2 + H_z^2} & \text{if mode is LP} \\ \sqrt{H_r^2 + H_\phi^2 + H_z^2} & \text{otherwise} \end{cases}\end{split}\]
- where:
\(H_x, H_y, H_z\) are the Cartesian components of the magnetic field.
\(H_r, H_\phi, H_z\) are the cylindrical components of the magnetic field.
- Parameters:
phi (float, optional) – Phase of the field in radians (default is 0).
theta (float, optional) – Orientation of the field in radians (default is 0).
- Returns:
The modulus of the magnetic field, \(|\vec{H}|\), computed over the Cartesian grid.
- Return type:
numpy.ndarray
- get_effective_area() float [source]#
Compute the effective area of the mode, \(A_{\text{eff}}\).
The effective area is defined as:
\[A_{\text{eff}} = \frac{\left( \int |E|^2 \, dx \, dy \right)^2}{\int |E|^4 \, dx \, dy}\]
- where:
\(|E|\) is the modulus of the electric field.
The integrals are evaluated over the cross-sectional area.
- Returns:
The effective area, \(A_{\text{eff}}\).
- Return type:
float
- get_integrale_square(array: ndarray) float [source]#
Compute the square of the integral of the given array.
\[\left( \int |F(x, y)|^2 \, dx \, dy \right)\]
- Parameters:
array (numpy.ndarray) – Array representing the field values over the grid.
- Returns:
The squared integral of the array.
- Return type:
float
- get_intensity() float [source]#
Compute the intensity of the mode, \(I\).
The intensity is defined as:
\[I = \frac{n_{\text{eff}}}{n_{\text{eff}}^{\text{HE11}}} \cdot \int |E_T|^2 \, dx \, dy\]
- where:
\(n_{\text{eff}}\) is the effective index of the mode.
\(n_{\text{eff}}^{\text{HE11}}\) is the effective index of the fundamental HE11 mode.
\(|E_T|^2\) is the squared transverse electric field.
- Returns:
The intensity of the mode.
- Return type:
float
- get_normalization_constant() float [source]#
Compute the normalization constant, \(N\).
The normalization constant is defined as:
\[N = \frac{I}{2} \cdot \epsilon_0 \cdot n_{\text{eff}}^{\text{HE11}} \cdot c\]
- where:
\(I\) is the intensity of the mode.
\(\epsilon_0\) is the permittivity of free space.
\(n_{\text{eff}}^{\text{HE11}}\) is the effective index of the fundamental HE11 mode.
\(c\) is the speed of light in vacuum.
- Returns:
The normalization constant, \(N\).
- Return type:
float
- plot(plot_type: list = (), show: bool = True, save_filename: str = None) Figure [source]#
Plotting function.
- Parameters:
ax (plt.Axes, optional) – A matplotlib Axes object to draw the plot on. If None, a new figure and axes are created. Default is None.
show (bool, optional) – Whether to display the plot. If False, the plot will not be shown but can still be saved or returned. Default is True.
save_filename (str, optional) – A file path to save the figure. If None, the figure will not be saved. Default is None.
- Returns:
The matplotlib Figure object created or used for the plot.
- Return type:
plt.Figure
Step-index#
- class StepIndex(radius_in: float, radius_out: float, index_list: list)[source]#
Bases:
Geometry
Step-index structure for optical fibers and waveguides.
Inherits#
Geometry
- get_index_at_radius(radius: float) float [source]#
Get the refractive index at a specific radius.
- Parameters:
radius (float) – Radius for evaluation.
- Returns:
Refractive index at the given radius if within bounds, else None.
- Return type:
float or None
- get_U_W_parameter(radius: float, neff: float) float [source]#
Calculate the U or W parameter for waveguides.
The U and W parameters are defined as:
\[ \begin{align}\begin{aligned}U = k_0 \rho \sqrt{n_{\text{core}}^2 - n_{\text{eff}}^2}\\W = k_0 \rho \sqrt{n_{\text{eff}}^2 - n_{\text{clad}}^2}\end{aligned}\end{align} \]where: - (k_0) is the free-space wave number ((2 pi / lambda)). - (n_{text{core}}), (n_{text{clad}}) are the refractive indices. - (n_{text{eff}}) is the effective refractive index.
- Parameters:
radius (float) – Radius for evaluation.
neff (float) – Effective refractive index.
- Returns:
U or W parameter value.
- Return type:
float
- get_psi(radius: float, neff: float, nu: int, C: list) tuple [source]#
Compute the \(\psi\) function and its derivative.
The function \(\psi\) is computed using Bessel functions for core layers and modified Bessel functions for cladding layers. The equations used are:
Core Layer:
\[ \begin{align}\begin{aligned}\psi = C_0 J_\nu(U) + C_1 Y_\nu(U)\\\dot{\psi} = C_0 U J'_\nu(U) + C_1 U Y'_\nu(U)\end{aligned}\end{align} \]Cladding Layer:
\[ \begin{align}\begin{aligned}\psi = C_0 I_\nu(U) + C_1 K_\nu(U)\\\dot{\psi} = C_0 U I'_\nu(U) + C_1 U K'_\nu(U)\end{aligned}\end{align} \]
- where:
J$_nu$, Y$_nu$: Bessel functions of the first and second kind.
I$_nu$, K$_nu$: Modified Bessel functions of the first and second kind.
C$_0$, C$_1$: Coefficients.
U: Parameter related to radius and refractive indices.
- Parameters:
radius (float) – The radius at which the field is evaluated.
neff (float) – The effective refractive index.
nu (int) – The order of the Bessel function (mode number).
C (list) – Coefficients for the Bessel functions. Must have at least one value, with the second value optional (defaults to 0).
- Returns:
A tuple containing \(\psi\): The field value and \(\dot{\psi}\): The derivative of the field value.
- Return type:
tuple
- get_LP_constants(radius: float, neff: float, nu: int, A: list) tuple [source]#
Calculate the LP mode constants.
The constants are derived from Bessel or modified Bessel functions for specific mode conditions.
- Parameters:
radius (float) – Radius for evaluation.
neff (float) – Effective refractive index.
nu (int) – Mode number.
A (list) – Coefficients for Bessel functions.
- Returns:
LP mode constants.
- Return type:
tuple
- EH_fields(radius_in: float, radius_out: float, nu: int, neff: float, EH: list, TM: bool = True) list [source]#
Compute the EH field components.
The EH field components are derived based on the mode parameters and the coefficients (C_i).
- Parameters:
radius_in (float) – Inner radius of the structure.
radius_out (float) – Outer radius of the structure.
nu (int) – Mode number.
neff (float) – Effective refractive index.
EH (list) – List of field components.
TM (bool, optional) – Indicates if TM mode (default is True).
- Returns:
Updated EH field components.
- Return type:
list
- get_V_constant(radius_in: float, radius_out: float, neff: float, nu: int, EH: ndarray) ndarray [source]#
Compute the V constants for the mode.
This method calculates the constants using Bessel or modified Bessel functions based on the refractive index regime.
- Parameters:
radius_in (float) – Inner radius of the structure.
radius_out (float) – Outer radius of the structure.
neff (float) – Effective refractive index.
nu (int) – Mode number.
EH (np.ndarray) – Electric and magnetic field components.
- Returns:
Solution to the linear system representing the V constants.
- Return type:
np.ndarray
- get_TE_TM_constants(radius_in: float, radius_out: float, neff: float, EH: ndarray, c: float, idx: tuple) ndarray [source]#
Compute the TE/TM constants for the waveguide.
This method calculates the constants using standard or modified Bessel functions depending on the refractive index regime.
- Parameters:
radius_in (float) – Inner radius of the structure.
radius_out (float) – Outer radius of the structure.
neff (float) – Effective refractive index.
EH (np.ndarray) – Electric and magnetic field components.
c (float) – Scaling constant for the calculation.
idx (tuple) – Indices for selecting specific components of the EH array.
- Returns:
Solution to the linear system representing the TE/TM constants.
- Return type:
np.ndarray
Fiber factory#
- class FiberFactory(wavelength: float)[source]#
Bases:
object
Factory to create and manage multiple Fiber instances with various configurations.
- Parameters:
wavelength (float) – Wavelength (in meters) used for fiber simulations.
- layers_list#
List of ProxyLayer objects representing the layers of the fiber.
- Type:
list[ProxyLayer]
- neff_solver#
Placeholder for a solver object (if required).
- Type:
None
- cutoff_solver#
Placeholder for a cutoff solver object (if required).
- Type:
None
- wavelength#
Wavelength used in simulations.
- Type:
float
- add_layer(index: float, name: str = '', radius: float = 0.0)[source]#
Add a new layer to the fiber factory.
- Parameters:
index (float) – Refractive index of the layer.
name (str, optional) – Name of the layer (default is an empty string).
radius (float, optional) – Radius of the layer (default is 0.0 meters).