RotatingFrame#

class RotatingFrame(frame_operator, atol=1e-10, rtol=1e-10)[source]#

Bases: object

Class for representing a rotation frame transformation.

This class provides functionality for transforming various objects into or out-of a rotating frame specified by an anti-Hermitian operator \(F = -iH\). For example:

  • Bringing a “state” into/out of the frame: \(t, y \mapsto e^{\mp tF}y\)

  • Bringing an “operator” into/out of the frame: \(t, A \mapsto e^{\mp tF}Ae^{\pm tF}\)

  • Bringing a generator for a LMDE into/out of the frame: \(t, G \mapsto e^{\mp tF}Ge^{\pm tF} - F\)

This class also contains functions for bringing states/operators into/out of the basis in which \(F\) is diagonalized, which we refer to as the “frame basis”. All previously mentioned functions also include optional arguments specifying whether the input/output are meant to be in the frame basis.

Note

RotatingFrame can be instantiated with a 1d array, which is understood to correspond to the diagonal entries of a diagonal \(H\) or \(F = -i H\).

Initialize with a frame operator.

Parameters:
  • frame_operator (Union[ndarray, number, int, float, complex, Tracer, Array, Array, spmatrix, BCOO, list, Operator, None]) – The frame operator, which must be either Hermitian or anti-Hermitian.

  • atol (float) – Absolute tolerance when verifying that the frame_operator is Hermitian or anti-Hermitian.

  • rtol (float) – Relative tolerance when verifying that the frame_operator is Hermitian or anti-Hermitian.

Methods

generator_into_frame(t, operator, operator_in_frame_basis=False, return_in_frame_basis=False, vectorized_operators=False)[source]#

Take an generator into the rotating frame, i.e. return exp(-tF) @ operator @ exp(tF) - F.

The default implementation is to use _conjugate_and_add().

Parameters:
  • t (float) – Time.

  • operator (Union[Operator, ndarray, number, int, float, complex, Tracer, Array, Array, spmatrix, BCOO, list]) – Generator (array of appropriate size).

  • operator_in_frame_basis (Optional[bool]) – Whether or not the generator is already in the basis in which the frame is diagonal.

  • return_in_frame_basis (Optional[bool]) – Whether or not to return the result in the frame basis.

  • vectorized_operators (Optional[bool]) – Whether operator is passed as a vectorized, (dim**2,) array, rather than a (dim,dim) array.

Returns:

The generator in the rotating frame.

Return type:

ArrayLike

generator_out_of_frame(t, operator, operator_in_frame_basis=False, return_in_frame_basis=False)[source]#

Take an operator out of the frame using the generator transformaton rule, i.e. return exp(tF) @ operator @ exp(-tF) + F.

The default implementation is to use self._conjugate_and_add.

Parameters:
  • t (float) – The time

  • operator (Union[Operator, ndarray, number, int, float, complex, Tracer, Array, Array, spmatrix, BCOO, list]) – Generator (array of appropriate size).

  • operator_in_frame_basis (Optional[bool]) – Whether or not the operator is already in the basis in which the frame is diagonal.

  • return_in_frame_basis (Optional[bool]) – Whether or not to return the result in the frame basis.

Returns:

The generator out of the rotating frame.

Return type:

ArrayLike

operator_into_frame(t, operator, operator_in_frame_basis=False, return_in_frame_basis=False, vectorized_operators=False)[source]#

Bring an operator into the frame, i.e. return exp(-tF) @ operator @ exp(tF).

The default implementation is to use self._conjugate_and_add.

Parameters:
  • t (float) – The time.

  • operator (Union[Operator, ndarray, number, int, float, complex, Tracer, Array, Array, spmatrix, BCOO, list]) – An array of appropriate size.

  • operator_in_frame_basis (Optional[bool]) – Whether or not the operator is already in the basis in which the frame is diagonal.

  • return_in_frame_basis (Optional[bool]) – Whether or not to return the result in the frame basis.

  • vectorized_operators (Optional[bool]) – Whether operator is passed as a vectorized, (dim**2,) array, rather than a (dim,dim) array.

Returns:

The operator in the rotating frame.

Return type:

ArrayLike

operator_into_frame_basis(op, convert_type=True)[source]#

Take an operator into the frame basis, i.e. return self.frame_basis_adjoint @ A @ self.frame_basis

Parameters:
  • op (Union[Operator, List[Operator], ndarray, number, int, float, complex, Tracer, Array, Array, spmatrix, BCOO, list, None]) – The operator or array of operators.

  • convert_type (bool) – Whether or not to initially convert op into an expected type. Should only be set to False in situations in which it is gauranteed that op is a handled input type.

Returns:

The operator in the frame basis.

Return type:

ArrayLike

operator_out_of_frame(t, operator, operator_in_frame_basis=False, return_in_frame_basis=False, vectorized_operators=False)[source]#

Bring an operator into the rotating frame, i.e. return exp(tF) @ operator @ exp(-tF).

The default implmentation is to use self.operator_into_frame.

Parameters:
  • t (float) – Time.

  • operator (Union[Operator, ndarray, number, int, float, complex, Tracer, Array, Array, spmatrix, BCOO, list]) – An array of appropriate size.

  • operator_in_frame_basis (Optional[bool]) – Whether or not the operator is already in the basis in which the frame is diagonal.

  • return_in_frame_basis (Optional[bool]) – Whether or not to return the result in the frame basis.

  • vectorized_operators (Optional[bool]) – Whether operator is passed as a vectorized, (dim**2,) array, rather than a (dim,dim) array.

Returns:

The operator out of the rotating frame.

Return type:

ArrayLike

operator_out_of_frame_basis(op, convert_type=True)[source]#

Take an operator out of the frame basis, i.e. return self.frame_basis @ op @ self.frame_basis_adjoint.

Parameters:
  • op (Union[Operator, List[Operator], ndarray, number, int, float, complex, Tracer, Array, Array, spmatrix, BCOO, list, None]) – The operator or array of operators.

  • convert_type (bool) – Whether or not to initially convert op into an expected type. Should only be set to False in situations in which it is gauranteed that that op is a handled input type.

Returns:

The operator in the frame basis.

Return type:

ArrayLike

state_into_frame(t, y, y_in_frame_basis=False, return_in_frame_basis=False)[source]#

Take a state into the rotating frame, i.e. return exp(-tF) @ y.

Parameters:
  • t (float) – The time.

  • y (Union[ndarray, number, int, float, complex, Tracer, Array, Array, spmatrix, BCOO, list]) – The state.

  • y_in_frame_basis (Optional[bool]) – Whether or not the array y is already in the basis in which the frame is diagonal.

  • return_in_frame_basis (Optional[bool]) – Whether or not to return the result in the frame basis.

Returns:

The state in the rotating frame.

Return type:

ArrayLike

state_into_frame_basis(y)[source]#

Take a state into the frame basis, i.e. return self.frame_basis_adjoint @ y.

Parameters:

y (Union[ndarray, number, int, float, complex, Tracer, Array, Array, spmatrix, BCOO, list]) – The state.

Returns:

The state in the frame basis.

Return type:

ArrayLike

state_out_of_frame(t, y, y_in_frame_basis=False, return_in_frame_basis=False)[source]#

Take a state out of the rotating frame, i.e. return exp(tF) @ y.

Calls self.state_into_frame with time reversed.

Parameters:
  • t (float) – The time.

  • y (Union[ndarray, number, int, float, complex, Tracer, Array, Array, spmatrix, BCOO, list]) – The state..

  • y_in_frame_basis (Optional[bool]) – Whether or not the array y is already in the basis in which the frame is diagonal.

  • return_in_frame_basis (Optional[bool]) – Whether or not to return the result in the frame basis.

Returns:

The state out of the rotating frame.

Return type:

ArrayLike

state_out_of_frame_basis(y)[source]#

Take a state out of the frame basis, i.e. return self.frame_basis @ y.

Parameters:

y (Union[ndarray, number, int, float, complex, Tracer, Array, Array, spmatrix, BCOO, list]) – The state.

Returns:

The state in the frame basis.

Return type:

ArrayLike

vectorized_map_into_frame(time, op, operator_in_frame_basis=False, return_in_frame_basis=False)[source]#

Given an operator op of dimension dim**2 assumed to represent vectorized linear map in column stacking convention, returns:

\[((e^{tF})^T \otimes e^{-tF}) \times op \times ((e^{-tF})^T \otimes e^{tF}).\]

Utilizes element-wise multiplication \(op \to \Delta\otimes\bar{\Delta} \odot op\), where \(\Delta_{ij}=\exp((-d_i+d_j)t)\) is the frame difference matrix, as well as caches array \(\bar{C}\otimes C\), where C = self.frame_basis for future use.

Parameters:
  • time (float) – The time \(t\).

  • op (Union[ndarray, number, int, float, complex, Tracer, Array, Array, spmatrix, BCOO, list]) – The (dim**2,dim**2) array.

  • operator_in_frame_basis (Optional[bool]) – Whether the operator is in the frame basis.

  • return_in_frame_basis (Optional[bool]) – Whether the operator should be returned in the frame basis.

Returns:

op in the frame.

Return type:

ArrayLike

Attributes

dim#

The dimension of the frame.

frame_basis#

The array containing diagonalizing unitary.

frame_basis_adjoint#

The adjoint of the diagonalizing unitary.

frame_diag#

The diagonal of the frame operator.

frame_operator#

The original frame operator.

vectorized_frame_basis#

Lazily evaluated operator for mapping vectorized operators into the frame basis.

vectorized_frame_basis_adjoint#

Lazily evaluated operator for mapping vectorized operators out of the frame basis.