MagnusSolver#

class MagnusSolver(operators, rotating_frame, dt, carrier_freqs, chebyshev_orders, expansion_order=None, expansion_labels=None, integration_method=None, include_imag=None, **kwargs)[source]#

Bases: _PerturbativeSolver

Solver for linear matrix differential equations based on the Magnus expansion.

This class implements the Magnus expansion-based solver presented in [[1]], which is a Magnus expansion variant of the Dysolve algorithm originally introduced in [[2]]. Its setup and behaviour are the same as as the DysonSolver class, with the sole exception being that it uses a truncated Magnus expansion and matrix exponentiation to solve over a single time step. See the Time-dependent perturbation theory and multi-variable series expansions review for a description of the Magnus expansion, and the documentation for DysonSolver for more detailed behaviour of this class.

Initialize.

Parameters:
  • operators (List[Operator]) – List of constant operators specifying the operators with signal coefficients.

  • rotating_frame (Union[ndarray, number, int, float, complex, Tracer, Array, Array, spmatrix, BCOO, list, RotatingFrame, None]) – Rotating frame to setup the solver in. Must be Hermitian or anti-Hermitian.

  • dt (float) – Fixed step size to compile to.

  • carrier_freqs (Union[ndarray, number, int, float, complex, Tracer, Array, Array, spmatrix, BCOO, list]) – Carrier frequencies of the signals in the generator decomposition.

  • chebyshev_orders (List[int]) – Approximation degrees for each signal over the interval [0, dt].

  • expansion_order (Optional[int]) – Order of perturbation terms to compute up to. Specifying this argument results in computation of all terms up to the given order. Can be used in conjunction with expansion_terms.

  • expansion_labels (Optional[List[Multiset]]) – Specific perturbation terms to compute. If both expansion_order and expansion_terms are specified, then all terms up to expansion_order are computed, along with the additional terms specified in expansion_terms. Labels are specified either as Multiset or as valid arguments to the Multiset constructor. This function further requires that Multisets consist only of non-negative integers.

  • integration_method (Optional[str]) – ODE solver method to use when computing perturbation terms.

  • include_imag (Optional[List[bool]]) – List of bools determining whether to keep imaginary components in the signal approximation. Defaults to True for all signals.

  • kwargs – Additional arguments to pass to the solver when computing perturbation terms.

Methods

solve(t0, n_steps, y0, signals, jax_control_flow=None)#

Solve given an initial time, number of steps, signals, and initial state.

Note that this method can be used to solve a list of simulations at once, by specifying one or more of the arguments t0, n_steps, y0, or signals as a list of valid inputs. For this mode of operation, all of these arguments must be either lists of the same length, or a single valid input, which will be used repeatedly.

Parameters:
  • t0 (Union[float, List[float]]) – Initial time.

  • n_steps (Union[int, List[int]]) – Number of time steps to solve for.

  • y0 (Union[ndarray, number, int, float, complex, Tracer, Array, Array, spmatrix, BCOO, list, List[Union[ndarray, number, int, float, complex, Tracer, Array, Array, spmatrix, BCOO, list]]]) – Initial state at time t0.

  • signals (Union[List[Signal], List[List[Signal]]]) – List of signals.

  • jax_control_flow (Optional[bool]) – Whether or not to use JAX control flow during solver runs. If unspecified it will be automatically determined based on the input state type, whether the call is taking place within a JAX transformation, or if the underlying expansion polynomial consists of JAX arrays.

Returns:

Results object, or list of results objects.

Return type:

OdeResult

Raises:

QiskitError – If improperly formatted arguments.

Attributes

model#

Model object storing expansion details.