paraqeet.model package¶
Submodules¶
paraqeet.model.closed_system module¶
Class definition of a closed model.
- class paraqeet.model.closed_system.ClosedSystem¶
Bases:
EquationOfMotionModel of a closed physical system, defined by a Hamiltonian.
Its dynamics is given by the Schrödinger equation.
- Parameters:
hamiltonian (Hamiltonian) – Matrix representation of a Hamiltonian.
- __init__(hamiltonian, ode_propagation=False)¶
- Parameters:
hamiltonian (DifferentiableHamiltonian)
ode_propagation (bool)
- get_parameters()¶
Get a list of optimizable parameters.
- Returns:
List of optimizable parameters of the system.
- Return type:
List[Quantity]
- get_value(times)¶
Get the matrix equations of motion.
Computes the right hand side of the Schrödinger equation without multiplying the state. Used for unitary solvers.
- Parameters:
times (Array) – Vector of time samples.
- Returns:
RHS with dimension [t, n, n] with ‘t’ as time and ‘n’ as Hilbert space dimension.
- Return type:
Array
- get_value_and_gradient(times)¶
Compute the gradient of getMatrix.
- Parameters:
times (Array) – Vector of time samples.
- Returns:
Returns the gradient of getMatrix.
- Return type:
Array
- property ode_propagation: bool¶
Flag to set method of propagation to ODE.
- Returns:
Flag to use ODE propagation.
- Return type:
bool
paraqeet.model.composite_hamiltonian module¶
Class definition of the composite Hamiltonian model.
- class paraqeet.model.composite_hamiltonian.CompositeHamiltonian¶
Bases:
DifferentiableHamiltonianA hamiltonian that consists of subsystems and couplings.
This class takes care of the tensor products. The list of parameters will contain the parameters of all subsystems and couplings in the order they were added.
- Parameters:
subsystems (list[DifferentiableHamiltonian]) – List of DifferentiableHamiltonians forming the subsystems of a composite system.
couplings (list[Coupling], optional) – List of couplings between the various subsystems
- __init__(subsystems, couplings=None)¶
- Parameters:
subsystems (list[DifferentiableHamiltonian])
couplings (list[TwoBodyCoupling] | None)
- dimension()¶
Return the dimension of the system.
- Returns:
Dimension of the system.
- Return type:
int
- get_collapseops()¶
Gather collapse operators from the subsystems and then tensor product them with identity to create the collapse operators of the right dimension.
- Return type:
list[tuple[Array, Array]]
- get_gradient_at_timestep(time)¶
Return the gradient of each parameter as an array for one timestamp.
Collects the gradients from every subsytem and coupling and constructs the matrix in the dimension of the composite system.
- Parameters:
time (float) – One time point.
- Returns:
Gradient at time t.
- Return type:
Array
- get_parameters()¶
Collect parameters from all subsystems and couplings.
- Parameters:
list[Quantity] – Returns the list of parameters of the system.
- Return type:
list[Quantity]
- get_subsystem_dimensions()¶
Return a list of dimensions of each subsystem in the composite Hamiltonian.
- Returns:
list of dimension of each subsystem.
- Return type:
list[int]
- get_value_at_timestep(timestep)¶
Get matrix representation of the Hamiltonian for a single time point.
- Parameters:
timestep (float) – One time step.
- Returns:
Hamiltonian of shape [n, n] with ‘n’ as the Hilbert space dimension.
- Return type:
Array
paraqeet.model.coupling module¶
Class definition of a coupling optimizable model.
- class paraqeet.model.coupling.TwoBodyCoupling¶
Bases:
OptimizableCreate a coupling optimizable model.
Represents the coupling of two or more subsystems in a composite Hamiltonian. This class implements longitudinal and transversal coupling with a constant scalar coefficient. The coefficient is the only optimizable parameter. Subclasses can alter the behavior by overriding the get_couplings function.
- Parameters:
subsystems (list[Hamiltonian]) – The coupled subsystems.
coefficient (Quantity) – Either a constant coefficient as float or a callable that returns the coefficient for a given time.
is_longitudinal (bool) – Whether the coupling is longitudinal or transversal.
use_rwa (bool, optional) – If the transversal coupling should use the rotating-wave approximation or should include double excitation terms.
- __init__(subsystem_A, subsystem_B, coefficient, is_longitudinal, use_rwa=False)¶
- Parameters:
subsystem_A (DifferentiableHamiltonian)
subsystem_B (DifferentiableHamiltonian)
coefficient (Quantity)
is_longitudinal (bool)
use_rwa (bool)
- get_coupling_gradients()¶
Return the gradients of the coupling terms.
- Returns:
The outer list represents the gradients with respect to all optimized parameters. The rest is in the same shape as the result of get_matrices.
- Return type:
list[Array]
- get_couplings()¶
Return the matrix representation of a time-indepedent coupling.
- Returns:
The outer list are the coupling terms. The inner list represents the subsystems. The matrices (Array) have the same shape as the subsystem’s Hamiltonian.get_value: (t,n,n) with t the time and n the subsystem dimension.
- Return type:
list[Array]
- get_parameters()¶
Collect parameters from all subsystems and couplings.
- Parameters:
list[Quantity] – Returns the list of parameters of the system.
- Return type:
list[Quantity]
- property subsystem_A: DifferentiableHamiltonian¶
Return subsystem A that is coupled by this term.
- Returns:
List of subystems.
- Return type:
list[Hamiltonian]
- property subsystem_B: DifferentiableHamiltonian¶
Return subsystem A that is coupled by this term.
- Returns:
List of subystems.
- Return type:
list[Hamiltonian]
- property subsystems: list[DifferentiableHamiltonian]¶
Return the subsystems as a list to be compatible with other couplings with potentially more subsystems.
paraqeet.model.custom_hamiltonian module¶
Custom Hamiltonian wrapper for H(t).
- class paraqeet.model.custom_hamiltonian.CustomHamiltonian¶
Bases:
DifferentiableHamiltonianCustom Hamiltonian class to simulate systems using a user defined Hamitonian function..
Here we expect a Hamiltonian function of the form H(t, *params). Here params is a list of scalars (NOT `Quantity`).
But, parameters is a list of Quantity that would be optimized.
It is advised to make the Hamiltonian function vmap and jit compatible. Furthermore, it is advised to write the Hamiltonian function in a way such that it takes a single time point (scalar) as input and returns a jax array of dimensions [n, n].
Additionally, to optimize the parameters, one needs to pass a list of gradient functions correspoding to each parameter, in the same order as the parameter list.
To use open system simulation, provide a list of tuples of decay rates and corresponding collapse opearators.
- __init__(hamiltonian_function, parameters, gradient_functions=None, collapse_operators=None)¶
- Parameters:
hamiltonian_function (Callable[[Array, Any], Array] | Callable[[float, Any], Array])
parameters (list[Quantity])
gradient_functions (list[Callable] | None)
collapse_operators (list[tuple[Array, Array]] | None)
- property collapse_operators: list[tuple[Array, Array]] | None¶
Return collapse operators.
- dimension()¶
Return dimension of the Hilbert space.
- get_collapseops()¶
Return collapse operators.
- Return type:
list[tuple[Array, Array]]
- get_gradient_at_timestep(timestep)¶
Return the gradient as a function of time for a single time point.
- Parameters:
timestep (float)
- Return type:
Array
- get_value(times)¶
Return Hamiltonian as a function of time for an array of time.
- Parameters:
times (Array)
- Return type:
Array
- get_value_and_gradient(times)¶
Return Hamiltonian and its gradient as a function of time.
- Parameters:
times (Array)
- Return type:
tuple[Array, Array]
- get_value_at_timestep(timestep)¶
Return Hamiltonian as a function of time for a single time point.
- Parameters:
timestep (float)
- Return type:
Array
- property gradient_functions: list[Callable] | None¶
Return gradient functions.
- value_and_get_gradient_at_timestep(time)¶
Return Hamiltonian and its gradient for one timestep.
- Return type:
tuple[Array, Array] | tuple[float, Array]
paraqeet.model.differentiable_hamiltonian module¶
- class paraqeet.model.differentiable_hamiltonian.DifferentiableHamiltonian¶
Bases:
Differentiable,HamiltonianA Hamiltonian that also satisfies the differentiable interface. It requires a gradient function that works on a per timestep basis and provides a vectorized mapping to evaluate multiple time values.
- abstract get_gradient_at_timestep(time)¶
Compute the gradient of this Hamiltonian wrt to parameters for a single timestep.
- Parameters:
time (float)
- Return type:
Array
- get_value_and_gradient(times)¶
Compute value and gradient for given timesteps. The gradient call uses vmap over at_timestep methods.
- Parameters:
times (Array)
- Return type:
tuple[Array, Array]
paraqeet.model.drive module¶
Class definition of a Drive optimizable model.
- class paraqeet.model.drive.Drive¶
Bases:
OptimizableRepresents a time-dependent drive on a subsystem.
This can for example be a microwave or flux drive.
- get_gradient(annihilation_operator, times)¶
Return the gradient of the system.
Returns the gradient of the matrix representation of the Hamiltonian with respect to each parameter as a list.
- Parameters:
annihilation_operator (Array) – Operator of the subsystem to which this drive is attached.
times (Array) – Vector of time samples.
- Returns:
Array of shape [t, p, n, n] with ‘t’ as time, ‘p’ as number of parameters and ‘n’ as the Hilbert space dimension.
- Return type:
Array
- abstract get_gradient_at_timestep(annihilation_operator, timestep)¶
Get the one-time gradient of the system.
Returns the gradient of the matrix representation of the Hamiltonian with respect to each parameter as a list.
- Parameters:
annihilation_operator (Array) – Operator of the subsystem to which this drive is attached.
timestep (float) – One time step.
- Returns:
Array of shape [p, n, n] with ‘p’ as the number of parameters and ‘n’ as the Hilbert space dimension.
- Return type:
Array
- get_value(annihilation_operator, times)¶
Return the matrix representation of the drive.
The dimension is given by the Hamiltonian to which this drive is attached. The default implementation calls getMatrixOneTime for each time step. Subclasses can override this function for a more efficient implementation.
- Parameters:
annihilation_operator (Array) – Operator of the subsystem to which this drive is attached
times (Array) – Vector of time samples.
- Returns:
Matrix of shape [t, n, n] with ‘t’ as time and ‘n’ as the Hilbert space dimension.
- Return type:
Array
- abstract get_value_at_timestep(annihilation_operator, t)¶
Return the matrix representation of the drive.
The dimension is given by the Hamiltonian to which this drive is attached.
- Parameters:
annihilation_operator (Array) – Operator of the subsystem to which this drive is attached.
t (float) – One time point.
- Returns:
Matrix of shape [n, n] with n as the Hilbert space dimension.
- Return type:
Array
paraqeet.model.drive_operator module¶
Class definition of the Generator Drive model.
- class paraqeet.model.drive_operator.DriveOperator¶
Bases:
DriveCreate a generator drive model.
Transversal (a^\dagger + a or \sigma_x type) or longitudinal (a^\dagger a or \sigma_z type) drive with a time-dependent scalar coefficient that is generated by a Generator object.
- Parameters:
generator (Generator) – Signal generator stack.
is_longitudinal (bool) – Generator is longitudinal or transversal depending on this boolean.
- property generator: Generator¶
Get the signal generator from the system.
- Returns:
Returns the signal generator object from the system.
- Return type:
- get_gradient_at_timestep(a, timestep)¶
Get the one-time gradient of the system.
Fetches the gradient from the drive and transforms it into the correct shape for the Hamiltonian.
- Parameters:
a (Array) – Operator for longitudinal or transverse drive.
timestep (Array) – One-dimensional vector of timestamps.
- Returns:
Returns the shape-shifted gradient from the drive.
- Return type:
Array
- get_parameters()¶
Get a list of parameters of the system.
- Returns:
List of optimizable parameters of the system.
- Return type:
list[Quantity]
- get_value_at_timestep(a, t)¶
Get the one-time matrix of the system.
Fetches the coefficient from the drive and transforms it into the correct shape for the Hamiltonian.
- Parameters:
a (Array) – Operator for longitudinal or transverse drive.
t (Array) – One-dimensional vector of timestamps.
- Returns:
Returns the shape-shifted coefficient from the drive.
- Return type:
Array
paraqeet.model.equation_of_motion module¶
Class definition of the optimizable model.
- class paraqeet.model.equation_of_motion.EquationOfMotion¶
Bases:
OptimizableRepresents the equation of motion for a given Hamiltonian.
Implementations can for example be the Schrödinger equation for a closed system, Lindbladian for an open system, or Hamilton’s equations for a classical system.
- Parameters:
hamiltonian (Hamiltonian) – Matrix representation of a Hamiltonian.
- __init__(hamiltonian)¶
- Parameters:
hamiltonian (DifferentiableHamiltonian)
- get_right_hand_side(time, state)¶
Return the right-hand side of the equations of motion.
The format depends on the implementation and could for example be a state vector or a matrix. Default implementation assumes a homogeneous ODE with matrix operator given by self.getMatrix().
- Parameters:
time (Array) – Any one-dimensional vector of timestamps.
state (Array)
- Returns:
The right-hand side of the equation of motion at each time stamp.
- Return type:
Array
- abstract get_value(times)¶
Abstract method to get the prefactor matrix.
- Parameters:
times (Array) – Any one-dimensional vector of timestamps.
- Returns:
Returns matrix equations of motion.
- Return type:
Array
- Raises:
NotImplementedError – Subclasses derived from this class must implement this method.
- abstract get_value_and_gradient(times)¶
Implement the gradient of either getEquationOfMotion or getMatrixEOM.
- Parameters:
times (Array) – Any one-dimensional vector of timestamps.
- Raises:
NotImplementedError – Subclasses derived from this class must implement this method.
- Return type:
tuple[Array, Array]
- ode_propagation: bool = False¶
paraqeet.model.hamiltonian module¶
Class definition for a matrix representation of a Hamiltonian.
- class paraqeet.model.hamiltonian.Hamiltonian¶
Bases:
OptimizableClass definition for a matrix representation of a Hamiltonian.
Implementations can contain subsystems, couplings, and drive lines and have to take care of frame transformations. Derived classes need to implement the functions get_matrix, gradient, dimension, get_collapse_ops, get_value_at_timestep
- Parameters:
drives (list[Drive]) – List of time-dependent drives.
- abstract dimension()¶
Return the dimension of the Hilbert space of this Hamiltonian.
- Returns:
Returns the dimension of the Hilbert space of this Hamiltonian.
- Return type:
int
- property drives: list[Drive]¶
Return the list of Drives of the system.
- Returns:
Returns a list of time-dependent drives of the system.
- Return type:
list[Drive]
- abstract get_collapseops()¶
Return a list tuples of decay rates and collapse operators for each subsystem.
- Returns:
List of collapse operators
- Return type:
list[Tuple[Array, Array]]
- get_value(times)¶
Return the matrix representation of the Hamiltonian.
The default implementation calls get_value_at_timestep for each time step. Subclasses can override this function for a more efficient implementation.
- Parameters:
times (Array) – Vector of time samples.
- Returns:
Hamiltonian of shape [t, n, n] with ‘t’ as time and ‘n’ as the Hilbert space dimension.
- Return type:
Array
- abstract get_value_at_timestep(timestep)¶
Return the matrix representation of the Hamiltonian.
- Parameters:
timestep (float) – One time point.
- Returns:
Hamiltonian of shape [n, n] with n as the Hilbert space dimension.
- Return type:
Array
paraqeet.model.open_system module¶
Class definition of an open system.
- class paraqeet.model.open_system.OpenSystem¶
Bases:
EquationOfMotionModel of an open quantum system, defined by the Hamiltonian and collapse operators. Its dynamics given by the Lindblad master equation.
Currently the gradients for ODE propagation methods is not supported.
- Parameters:
hamiltonian (Hamiltonian) – Matrix representation of a Hamiltonian.
sparse_superop (bool) – Flag to save superoperator as sparse matrices.
ode_propagation (bool) – Flag to use ODE methods for propgation. If true then get_value method returns list of Hamiltonian (with time) and collapse operator. Else returns Lindblad superoperator.
- __init__(hamiltonian, sparse_superop=False, ode_propagation=False)¶
- Parameters:
hamiltonian (DifferentiableHamiltonian)
sparse_superop (bool)
ode_propagation (bool)
- get_collapseops()¶
Get a list of tuples of decay rates and collapse operators for each subsystem.
- Returns:
list of collapse operators
- Return type:
list[tuple[float, Array]]
- get_parameters()¶
Get a list of optimizable parameters.
- Returns:
list of optimizable parameters of the system.
- Return type:
list[Quantity]
- get_value(times)¶
Computes the right hand side of the Schrödinger equation without multiplying the state. Used for unitary solvers.
- Parameters:
times (Array) – Vector of time samples
- Returns:
RHS with dimension [t, n, n] with t: time, n: hilbert space
- Return type:
Array
- get_value_and_gradient(times)¶
Compute the gradient of get_value.
- Parameters:
times (Array)
- Return type:
tuple[Array, Array]
- property ode_propagation: bool¶
Flag to set method of propagation to ODE.
- Returns:
Flag to use ODE propagation.
- Return type:
bool
- property sparse_superop: bool¶
Flag to store superoperators as sparse matrices.
- Returns:
Flag to store sparse matrices.
- Return type:
bool
paraqeet.model.qubit module¶
Class definition of a qubit model.
- class paraqeet.model.qubit.Qubit¶
Bases:
DifferentiableHamiltonianHamiltonian of a single qubit frequency/2 * sigma_z.
The implementation uses the convention of having the excited state of the qubit as the first entry in the state. If you need a two-level system that is compatible with the projection of a higher-dimensional system (ground state as first entry), use a resonator and restrict its dimension to 2.
- Parameters:
- __init__(frequency, drives=None, t1=None, temp=None, t2star=None)¶
- dimension()¶
Dimension of the qubit.
- Returns:
Returns 2 as the dimension.
- Return type:
int
- get_collapseops()¶
Return a list tuples of decay rates and collapse operators for each subsystem.
- Return type:
list[tuple[Array, Array]]
- get_decay_rates()¶
Return decay rate for T1, T2star and Temp respectively.
- Return type:
list[Array]
- get_gradient_at_timestep(time)¶
Get the matrix representations of value and gradient of the drive as a tuple.
- Parameters:
times (Array) – Array of timestamps of interest.
time (float)
- Returns:
Returns the value und gradients of the drive.
- Return type:
tuple[Array, Array]
- get_parameters()¶
Get parameters of the model.
- Returns:
Returns the list of parameters of the system.
- Return type:
list[Quantity]
- get_value_at_timestep(timestep)¶
Get the drive matrix.
- Parameters:
timestep (Array) – One time stamp.
- Returns:
The repeated drive matrix.
- Return type:
Array
paraqeet.model.resonator module¶
Class definition of the Resonator Hamiltonian model.
- class paraqeet.model.resonator.Resonator¶
Bases:
DifferentiableHamiltonianHamiltonian of a harmonic oscillator.
The only optimizable parameter is the frequency.
- Parameters:
- __init__(dimension, frequency, drives=None, t1=None, temp=None, t2star=None)¶
- dimension()¶
Get the dimension of the resonator.
- get_collapseops()¶
Return a list tuples of decay rates and collapse operators for each subsystem.
- Returns:
List of collapse operators
- Return type:
list[tuple[Array, Array]]
- get_decay_rates()¶
Return decay rate for T1, T2star and Temp respectively.
- Return type:
list[Array]
- get_gradient_at_timestep(time)¶
Get the gradient of the drive.
- Parameters:
times (float) – One time stamp.
time (float)
- Returns:
Returns the gradients of the drive.
- Return type:
Array
- get_parameters()¶
Get parameters of the model.
- Returns:
Returns the list of parameters of the system.
- Return type:
List[Quantity]
- get_value_at_timestep(timestep)¶
Get the drive matrix.
- Parameters:
timestep (float) – One time stamp.
- Returns:
The drive matrix at a single timestamp.
- Return type:
Array
paraqeet.model.rotating_frame_coupling module¶
Coupling Hamiltonian in the rotating frame of drive.
- class paraqeet.model.rotating_frame_coupling.RotatingFrameCoupling¶
Bases:
TwoBodyCouplingImplements the coupling in the rotating frame of the drive.
If multiple subsystems are coupled specify the difference frequency of the individual drive frames.
NOTE - Right now this only works for TWO SUBSYSTEMS. TODO - Generalize this for multiple subsystems
- Parameters:
subsystems (list[Hamiltonian]) – A set of Hamiltonians which represent the coupling
coefficient (Quantity) – Constant drive coefficient.
diffFreq (Quantity) – Diffrence of drive frequencies for multiple subsystems.
- __init__(subsystem_A, subsystem_B, coefficient, diffFreq)¶
- Parameters:
subsystem_A (DifferentiableHamiltonian)
subsystem_B (DifferentiableHamiltonian)
coefficient (Quantity)
diffFreq (Quantity)
- get_RWA_couplings(t)¶
Return the matrix representation of the coupling for all subsystems.
A list of terms in the coupling is returned, where each of the term contains operators for each subsystem. A composite Hamiltonian puts these operators in the correct position in the tensor space to create the operators and then sum over the terms.
- Parameters:
t (Array) – One time step.
- Returns:
The outer list are the coupling terms. The inner list contains matrices for each subsystem. The matrices (Array) have the same shape as the subsystem’s Hamiltonian.get_value_one_time: (n,n) with n the subsystem dimension.
- Return type:
list[list[Array]]
- get_RWA_gradients(times)¶
Compute the gradients of the coupling expression in the rotating frame, i.e. include a phase factor for several timesteps.
- Parameters:
times (Array)
- get_RWA_gradients_one_time(t)¶
Get the one-time gradient of the matrix.
Returns the gradient of the matrix representation of the coupling for all subsystems. Each entry in the list is the gradient with respect to one parameter, factorised into subsystems (representing a list of term in the coupling).
- Parameters:
t (Array) – One time point.
- Returns:
The outer list represents the gradients with respect to all optimized parameters. The rest is in the same shape as the result of get_matrices_one_time.
- Return type:
list[list[list[Array]]]
paraqeet.model.rotating_frame_drive module¶
Class definition of the Drive Hamiltonian in the rotating frame of drive.
- class paraqeet.model.rotating_frame_drive.RotatingFrameDrive¶
Bases:
DriveDrive Hamiltonian in the Frame rotating at the frequency of the drive.
- _signal_generator: Generator
Signal Generator without a LO, like the PWCGenerator
- property generator: Generator¶
Get the signal generator from the system.
- Returns:
Returns the signal generator object from the system.
- Return type:
- get_gradient_at_timestep(annihilation_operator, timestep)¶
Get the one-time gradient of the system.
Fetches the gradient from the drive and transforms it into the correct shape for the Hamiltonian.
- Parameters:
annihilation_operator (Array) – Operator for longitudinal or transverse drive.
timestep (Array) – One-dimensional vector of timestamps.
- Returns:
Returns the shape-shifted gradient from the drive.
- Return type:
Array
- get_parameters()¶
Get a list of parameters of the system.
- Returns:
List of optimizable parameters of the system.
- Return type:
list[Quantity]
- get_value_at_timestep(annihilation_operator, t)¶
Implement drive in the rotating frame of drive.
Drive Hamiltonian is implemented as \big\{ \Omega a + \Omega^* a^\dagger \big\} Where \Omega is the envelope (without the LO).
- Parameters:
annihilation_operator (Array) – Annihilation operator of the subsystem
t (Array) – One time step
- Return type:
Array
paraqeet.model.transmon module¶
Class definition of the Transmon Hamiltonian model.
- class paraqeet.model.transmon.Transmon¶
Bases:
DifferentiableHamiltonianHamiltonian of an anharmonic oscillator.
Optimizable parameters are the ground frequency and the anharmonicity.
- Parameters:
- __init__(dimension, frequency, anharmonicity, drives=None, t1=None, temp=None, t2star=None)¶
- dimension()¶
Get the dimension of the Transmon system.
- Return type:
int
- get_collapseops()¶
Return a list tuples of decay rates and collapse operators for each subsystem.
- Returns:
List of collapse operators
- Return type:
list[tuple[Array, Array]]
- get_decay_rates()¶
Return decay rate for T1, T2star and Temp respectively.
- Return type:
list[Array]
- get_gradient_at_timestep(time)¶
Get the gradient of the drive.
- Parameters:
t (Array) – Single time stamp.
time (float)
- Returns:
Returns the gradients of the drive.
- Return type:
Array
- get_parameters()¶
Get parameters of the model.
- Returns:
Returns the list of parameters of the system.
- Return type:
List[Quantity]
- get_value_at_timestep(timestep)¶
Get the drive matrix.
- Parameters:
timestep (Array) – Vector of time samples.
- Returns:
The repeated drive matrix.
- Return type:
Array
Module contents¶
Base model module.