# Dynamic simulation¶

class DynamicSimulation(max_time_steps)

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)

Initialize self. See help(type(self)) for accurate signature.

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. Time coordinate array numpy float array
add_forward_signal(wl, input_power, wl_bandwidth=0.0, mode_shape_parameters=None, label='', reflection_target='', reflectance=0)

Adds a new forward-propagating signal to the simulation.

Parameters: wl (float) – Wavelength of the signal input_power (float or numpy array) – Input power of the signal at the beginning of the fiber wl_bandwidth (float) – Wavelength bandwidth of the channel. Finite bandwidth means including ASE. mode_shape_parameters (dict) – Defines the mode field shape. Allowed key-value pairs: functional_form -> one of [‘bessel’, ‘gaussian’, ‘tophat’] mode_diameter -> float overlaps -> list of pre-calculated overlaps between the channel and the ion populations label (str) – Optional label for the channel (required to receive reflected power from another channel) reflection_target (str) – Label of the channel receiving reflection from this channel reflectance – Reflectance R [0,1] from this channel to the target channel
add_backward_signal(wl, input_power, wl_bandwidth=0.0, mode_shape_parameters=None, label='', reflection_target='', reflectance=0)

Adds a new backward-propagating signal to the simulation.

Parameters: wl (float) – Wavelength of the signal input_power (float or numpy array) – Input power of the signal at the beginning of the fiber wl_bandwidth (float) – Wavelength bandwidth of the channel. Finite bandwidth means including ASE. mode_shape_parameters (dict) – Defines the mode field shape. Allowed key-value pairs: functional_form -> one of [‘bessel’, ‘gaussian’, ‘tophat’] mode_diameter -> float overlaps -> list of pre-calculated overlaps between the channel and the ion populations label (str) – Optional label for the channel (required to receive reflected power from another channel) reflection_target (str) – Label of the channel receiving reflection from this channel reflectance – Reflectance R [0,1] from this channel to the target channel
add_forward_pump(wl, input_power, wl_bandwidth=0.0, mode_shape_parameters=None, label='', reflection_target='', reflectance=0)

Adds a new forward-propagating pump to the simulation.

Parameters: wl (float) – Wavelength of the signal input_power (float or numpy array) – Input power of the signal at the beginning of the fiber wl_bandwidth (float) – Wavelength bandwidth of the channel. Finite bandwidth means including ASE. mode_shape_parameters (dict) – Defines the mode field shape. Allowed key-value pairs: functional_form -> one of [‘bessel’, ‘gaussian’, ‘tophat’] mode_diameter -> float overlaps -> list of pre-calculated overlaps between the channel and the ion populations label (str) – Optional label for the channel (required to receive reflected power from another channel) reflection_target (str) – Label of the channel receiving reflection from this channel reflectance – Reflectance R [0,1] from this channel to the target channel
add_backward_pump(wl, input_power, wl_bandwidth=0.0, mode_shape_parameters=None, label='', reflection_target='', reflectance=0)

Adds a new backward-propagating pump to the simulation.

Parameters: wl (float) – Wavelength of the signal input_power (float or numpy array) – Input power of the signal at the beginning of the fiber wl_bandwidth (float) – Wavelength bandwidth of the channel. Finite bandwidth means including ASE. mode_shape_parameters (dict) – Defines the mode field shape. Allowed key-value pairs: functional_form -> one of [‘bessel’, ‘gaussian’, ‘tophat’] mode_diameter -> float overlaps -> list of pre-calculated overlaps between the channel and the ion populations label (str) – Optional label for the channel (required to receive reflected power from another channel) reflection_target (str) – Label of the channel receiving reflection from this channel reflectance – Reflectance R [0,1] from this channel to the target channel
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.