Dynamic simulation¶
- class DynamicSimulation(max_time_steps: int, fiber)¶
DynamicSimulation is the interface class used for running fiber amplifier simulations with arbitrarily varying input powers. It also supports reflective boundary conditions and thus modeling of simple CW, gain-switched or Q-switched fiber lasers. With constant input powers, the result converges to the steady state simulation result. Setting multiple ion populations is also supported. The class defines the fiber, boundary conditions and optical channels used in the simulation.
- __init__(max_time_steps: int, fiber)¶
Constructor. The fiber must supplied already at this point and should be changed later. :param max_time_steps: The maximum number of time steps the simulation is initialized to run. :type max_time_steps: int :param fiber: The fiber to be simulated. :type fiber: Subclass of FiberBase
- use_python_backend()¶
Sets the simulation to use the slow Python finite difference solver. Using one of the faster solvers instead is highly recommended.
- use_cpp_backend()¶
Sets the simulation to use the C++ backend if available.
- use_pythran_backend()¶
Sets the simulation to use the pythran backend if available.
- use_numba_backend()¶
Sets the simulation to use the numba backend if available.
- get_time_coordinates(fiber, z_nodes, dt='auto')¶
Returns the time coordinates used in the simulation. Useful for setting time-varying input powers.
- Parameters
fiber (Subclass of FiberBase) – The fiber used in the simulation
z_nodes (int) – Number of spatial nodes used in the simulation.
dt (float) – Time step size. The ‘auto’ option uses realistic time step calculated from the Courant condition based on the speed of light in glass and the spatial step size. Larger (and physically unrealistic) time steps can be used to drastically speed up the convergence of steady state simulations.
- Returns
Time coordinate array
- Return type
numpy float array
- add_forward_signal(wl: float, input_power, wl_bandwidth=0.0, loss=None, mode=None, channel_id=None, reflection_target_id=None, reflectance=0.0)¶
Adds a new forward propagating single-frequency CW signal to the simulation.
- Parameters
wl (float) – Wavelength of the signal
input_power (float or np.ndarray) – Input input_power of the signal at the beginning of the fiber
wl_bandwidth (float) – Wavelength bandwidth of the channel. Finite bandwidth means seeding by spontaneous emission.
loss (float) – Background loss of the channel. If None, the fiber’s default loss is used.
mode (Subclass of ModeBase (such as LPMode or TophatMode)) – Fiber mode class defining the channel’s mode shape.
channel_id (int or str) – Identifier for the channel, used for reflection definitions and plotting
reflection_target_id (int or str) – Identifier for the target channel that this channel reflects to
reflectance (float) – Reflectance at the end of the channel 0<=R<=1
- add_backward_signal(wl: float, input_power, wl_bandwidth=0.0, loss=None, mode=None, channel_id=None, reflection_target_id=None, reflectance=0.0)¶
Adds a new forward propagating single-frequency CW signal to the simulation.
- Parameters
wl (float) – Wavelength of the signal
input_power (float or np.ndarray) – Input input_power of the signal at the beginning of the fiber
wl_bandwidth (float) – Wavelength bandwidth of the channel. Finite bandwidth means seeding by spontaneous emission.
loss (float) – Background loss of the channel. If None, the fiber’s default loss is used.
mode (Subclass of ModeBase (such as LPMode or TophatMode)) – Fiber mode class defining the channel’s mode shape.
channel_id (int or str) – Identifier for the channel, used for reflection definitions and plotting
reflection_target_id (int or str) – Identifier for the target channel that this channel reflects to
reflectance (float) – Reflectance at the end of the channel 0<=R<=1
- add_forward_pump(wl: float, input_power, wl_bandwidth=0.0, loss=None, mode=None, channel_id=None, reflection_target_id=None, reflectance=0.0)¶
Adds a new forward propagating single-frequency pump to the simulation.
- Parameters
wl (float) – Wavelength of the signal
input_power (float or np.ndarray) – Input input_power of the signal at the beginning of the fiber
wl_bandwidth (float) – Wavelength bandwidth of the channel. Finite bandwidth means seeding by spontaneous emission.
loss (float) – Background loss of the channel. If None, the fiber’s default loss is used.
mode (Subclass of ModeBase (such as LPMode or TophatMode)) – Fiber mode class defining the channel’s mode shape.
channel_id (int or str) – Identifier for the channel, used for reflection definitions and plotting
reflection_target_id (int or str) – Identifier for the target channel that this channel reflects to
reflectance (float) – Reflectance at the end of the channel 0<=R<=1
- add_backward_pump(wl: float, input_power, wl_bandwidth=0.0, loss=None, mode=None, channel_id=None, reflection_target_id=None, reflectance=0.0)¶
Adds a new backward propagating single-frequency pump to the simulation.
- Parameters
wl (float) – Wavelength of the signal
input_power (float or np.ndarray) – Input input_power of the signal at the beginning of the fiber
wl_bandwidth (float) – Wavelength bandwidth of the channel. Finite bandwidth means seeding by spontaneous emission.
loss (float) – Background loss of the channel. If None, the fiber’s default loss is used.
mode (Subclass of ModeBase (such as LPMode or TophatMode)) – Fiber mode class defining the channel’s mode shape.
channel_id (int or str) – Identifier for the channel, used for reflection definitions and plotting
reflection_target_id (int or str) – Identifier for the target channel that this channel reflects to
reflectance (float) – Reflectance at the end of the channel 0<=R<=1
- add_ase(wl_start, wl_end, n_bins)¶
Adds amplified spontaneous emission (ASE) channels. Using more channels improves accuracy, but incurs a heavier computational cost to the simulation.
- Parameters
wl_start (float) – The shorted wavelength of the ASE band
wl_end (float) – The longest wavelength of the ASE band
n_bins (positive int) – The number of simulated ASE channels.
- run(z_nodes, dt='auto', P=None, N2=None, stop_at_steady_state=False, steady_state_tolerance=0.0001, convergence_checking_interval=10000)¶
Runs the simulation.
- Parameters
z_nodes (int) – Number of spatial nodes used in the simulation.
dt (float or str) – Time step size. The ‘auto’ option uses realistic time step calculated from the Courant condition based on the speed of light in glass and the spatial step size. Larger (and physically unrealistic) time steps can be used to drastically speed up the convergence of steady state simulations.
P (numpy float array) – Pre-existing powers in the fiber, useful when chaining multiple simulations.
N2 (numpy float array) – Pre-existing upper state excitation in the fiber, useful when chaining multiple simulations.
stop_at_steady_state (bool) – If this flag parameter is set to True, the simulation stops when the excitation reaches a steady state (does not work if the excitation fluctuates at a specific frequency).
steady_state_tolerance (float) – Sets the relative change in excitation that is used to detect the steady state.
convergence_checking_interval (positive int) – If aiming for steady state, the simulation checks convergence always after this number of iterations and prints the average excitation. In truly dynamic simulations, only prints the excitation.