RotatingFrame#
- class RotatingFrame(frame_operator, atol=1e-10, rtol=1e-10)[source]#
Bases:
objectClass 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
RotatingFramecan 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[Array,Operator]) – The frame operator, which must be either Hermitian or anti-Hermitian.atol (
float) – Absolute tolerance when verifying that theframe_operatoris Hermitian or anti-Hermitian.rtol (
float) – Relative tolerance when verifying that theframe_operatoris 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,Array,csr_matrix]) – 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]) – Whetheroperatoris passed as a vectorized,(dim**2,)Array, rather than a(dim,dim)Array.
- Returns:
The generator in the rotating frame.
- Return type:
- 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 timeoperator (
Union[Operator,Array,csr_matrix]) – 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:
- 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,Array,csr_matrix]) – 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]) – Whetheroperatoris passed as a vectorized,(dim**2,)Array, rather than a(dim,dim)Array.
- Returns:
The operator in the rotating frame.
- Return type:
- 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:
- Returns:
The operator in the frame basis.
- Return type:
- 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,Array,csr_matrix]) – 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]) – Whetheroperatoris passed as a vectorized,(dim**2,)Array, rather than a(dim,dim)Array.
- Returns:
The operator out of the rotating frame.
- Return type:
- operator_out_of_frame_basis(op, convert_type=True)[source]#
Take an operator out of the frame basis, i.e. return
self.frame_basis @ to_array(op) @ self.frame_basis_adjoint.- Parameters:
- Returns:
The operator in the frame basis.
- Return type:
- 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 (
Array) – 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:
- state_into_frame_basis(y)[source]#
Take a state into the frame basis, i.e. return
self.frame_basis_adjoint @ y.
- 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_framewith time reversed.- Parameters:
t (
float) – The time.y (
Array) – 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:
- state_out_of_frame_basis(y)[source]#
Take a state out of the frame basis, i.e.
return self.frame_basis @ y.
- vectorized_map_into_frame(time, op, operator_in_frame_basis=False, return_in_frame_basis=False)[source]#
Given an operator
opof dimensiondim**2assumed 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_basisfor future use.- Parameters:
time (
float) – The time \(t\).op (
Array) – 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.
- Return type:
- Returns:
opin the frame.
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.