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 forDysonSolver
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 withexpansion_terms
.expansion_labels (
Optional
[List
[Multiset
]]) – Specific perturbation terms to compute. If bothexpansion_order
andexpansion_terms
are specified, then all terms up toexpansion_order
are computed, along with the additional terms specified inexpansion_terms
. Labels are specified either asMultiset
or as valid arguments to theMultiset
constructor. This function further requires thatMultiset
s 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
, orsignals
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 timet0
.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.