Quandary
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Attributes | List of all members
MasterEq Class Reference

Implementation of the real-valued right-hand-side (RHS) system matrix of the quantum dynamical equations. More...

#include <mastereq.hpp>

Collaboration diagram for MasterEq:
Collaboration graph
[legend]

Public Member Functions

 MasterEq ()
 
 MasterEq (const Config &config, Oscillator **oscil_vec_, bool quietmode=false)
 Constructor with simplified configuration-based specification.
 
 ~MasterEq ()
 
void set_RHS_MatMult_operation ()
 Pass MatMult operations for applying the RHS to PETSc.
 
void initSparseMatSolver ()
 Initializes matrices needed for the sparse matrix solver.
 
OscillatorgetOscillator (const size_t i)
 Retrieves the i-th oscillator.
 
size_t getNOscillators ()
 Retrieves the number of oscillators in the system.
 
PetscInt getDim ()
 Retrieves the dimension of the vectorized system.
 
PetscInt getDimEss ()
 Retrieves the dimension of the essential level system.
 
PetscInt getDimRho ()
 Retrieves the dimension of the density matrix.
 
int assemble_RHS (const double t)
 Assembles the real-valued system matrix (RHS) at time t.
 
Mat getRHS ()
 Retrieves the right-hand-side system matrix.
 
void compute_dRHS_dParams (const double t, const Vec x, const Vec x_bar, const double alpha, Vec grad)
 Computes gradient of RHS with respect to control parameters.
 
void setControlAmplitudes (const Vec x)
 Pass control parameters from global design vector to each oscillator.
 
double expectedEnergy (const Vec x)
 Computes expected energy of the full composite system.
 
void population (const Vec x, std::vector< double > &population_com)
 Computes population of the full composite system.
 

Public Attributes

std::vector< size_t > nlevels
 Number of levels per oscillator.
 
std::vector< size_t > nessential
 Number of essential levels per oscillator.
 
bool usematfree
 Flag for using matrix-free solver.
 
DecoherenceType decoherence_type
 Type of Lindblad operators to include (NONE means Schroedinger equation)
 

Protected Attributes

PetscInt dim
 Dimension of full vectorized system: N^2 if Lindblad, N if Schroedinger.
 
PetscInt dim_rho
 Dimension of Hilbert space = N.
 
PetscInt dim_ess
 Dimension of essential levels = N_e.
 
int noscillators
 Number of oscillators in the system.
 
Oscillator ** oscil_vec
 Array of pointers to oscillator objects.
 
Mat RHS
 MatShell for real-valued, vectorized system matrix (size 2N^2 x 2N^2)
 
MatShellCtx RHSctx
 Context containing data for applying the RHS to a state.
 
std::vector< Mat > Ac_vec
 
std::vector< Mat > Bc_vec
 
Mat Ad
 
Mat Bd
 
std::vector< Mat > Ad_vec
 
std::vector< Mat > Bd_vec
 
std::vector< double > crosskerr
 Cross-Kerr coefficients (rad/time) \(\xi_{kl}\) for ZZ-coupling \(a_k^\dagger a_k a_l^\dagger a_l\).
 
std::vector< double > Jkl
 Dipole-dipole coupling coefficients (rad/time), multiplies \(a_k^\dagger a_l + a_k a_l^\dagger\).
 
std::vector< double > eta
 Frequency differences in rotating frame (rad/time) for dipole-dipole coupling.
 
bool addT1
 
bool addT2
 Flags for including T1 decay and T2 dephasing Lindblad operators.
 
int mpirank_world
 Rank of global MPI communicator.
 
int mpirank_petsc
 Rank of PETSc's communicator.
 
int mpisize_petsc
 Size of PETSc's communicator.
 
PetscInt localsize_u
 Size of local sub vector u or v in state x=[u,v].
 
PetscInt ilow
 First index of the local sub vector u,v.
 
PetscInt iupp
 Last index (+1) of the local sub vector u,v.
 
IS isu
 
IS isv
 Vector strides for accessing real and imaginary parts u=Re(x), v=Im(x)
 
Vec aux
 Auxiliary vector for computations.
 
bool quietmode
 Flag for quiet mode operation.
 
std::optional< std::string > hamiltonian_file_Hsys
 Filename if a custom system Hamiltonian is read from file.
 
std::optional< std::string > hamiltonian_file_Hc
 Filename if a custom control Hamiltonians are read from file.
 

Detailed Description

Implementation of the real-valued right-hand-side (RHS) system matrix of the quantum dynamical equations.

This class provides functionality for evaluating and applying the real-valued right-hand-side (RHS) system matrix of the vectorized Lindblad master equation (open quantum systems) or Schroedinger equation (closed systems). It supports a matrix-free and a sparse-matrix version for applying the RHS to a state vector. The system matrix (RHS) is stored as a Matrix Shell, that applies the real and imaginary parts of the system matrix to the corresponding parts of the state vector separately. The RHS needs to be assembled (evaluated at each time step t) before usage.

Main functionality:

This class contains references to:

Constructor & Destructor Documentation

◆ MasterEq() [1/2]

MasterEq::MasterEq ( )

◆ MasterEq() [2/2]

MasterEq::MasterEq ( const Config config,
Oscillator **  oscil_vec_,
bool  quietmode = false 
)

Constructor with simplified configuration-based specification.

Parameters
configConfiguration parameters containing all master equation settings
oscil_vec_Array of pointers to oscillator objects
quietmodeFlag for quiet operation (default: false)

◆ ~MasterEq()

MasterEq::~MasterEq ( )

Member Function Documentation

◆ assemble_RHS()

int MasterEq::assemble_RHS ( const double  t)

Assembles the real-valued system matrix (RHS) at time t.

Updates the time-dependent parameters in the RHS MatShell context. This must be called before applying the RHS to a state vector.

Parameters
tCurrent time
Returns
int Error code

◆ compute_dRHS_dParams()

void MasterEq::compute_dRHS_dParams ( const double  t,
const Vec  x,
const Vec  x_bar,
const double  alpha,
Vec  grad 
)

Computes gradient of RHS with respect to control parameters.

Updates grad += alpha * x^T * (d RHS / d params)^T * x_bar. Supports both the sparse-matrix and the matrix-free version of the RHS.

Parameters
tCurrent time
xState vector
x_barAdjoint state vector
alphaScaling factor
gradGradient vector to update

◆ expectedEnergy()

double MasterEq::expectedEnergy ( const Vec  x)

Computes expected energy of the full composite system.

Parameters
xState vector
Returns
double Expected energy value

◆ getDim()

PetscInt MasterEq::getDim ( )
inline

Retrieves the dimension of the vectorized system.

Returns
PetscInt \(N^2\) for Lindblad solver, \(N\) for Schroedinger solver

◆ getDimEss()

PetscInt MasterEq::getDimEss ( )
inline

Retrieves the dimension of the essential level system.

Returns
PetscInt Dimension N_e of essential levels

◆ getDimRho()

PetscInt MasterEq::getDimRho ( )
inline

Retrieves the dimension of the density matrix.

Returns
PetscInt Dimension N of the Hilbert space

◆ getNOscillators()

size_t MasterEq::getNOscillators ( )
inline

Retrieves the number of oscillators in the system.

Returns
size_t Number of oscillators

◆ getOscillator()

Oscillator * MasterEq::getOscillator ( const size_t  i)
inline

Retrieves the i-th oscillator.

Parameters
iIndex of the oscillator
Returns
Oscillator* Pointer to the oscillator object

◆ getRHS()

Mat MasterEq::getRHS ( )

Retrieves the right-hand-side system matrix.

Returns
Mat PETSc matrix shell object representing the RHS.

◆ initSparseMatSolver()

void MasterEq::initSparseMatSolver ( )

Initializes matrices needed for the sparse matrix solver.

◆ population()

void MasterEq::population ( const Vec  x,
std::vector< double > &  population_com 
)

Computes population of the full composite system.

Parameters
xState vector
population_comReference to vector to store population values

◆ set_RHS_MatMult_operation()

void MasterEq::set_RHS_MatMult_operation ( )

Pass MatMult operations for applying the RHS to PETSc.

The RHS is stored as a Matrix Shell. This routine passes the (transpose) Matrix-Multiplication operation for applying the RHS to a state vector to PETSc.

◆ setControlAmplitudes()

void MasterEq::setControlAmplitudes ( const Vec  x)

Pass control parameters from global design vector to each oscillator.

Parameters
xGlobal design vector containing control parameters

Member Data Documentation

◆ Ac_vec

std::vector<Mat> MasterEq::Ac_vec
protected

◆ Ad

Mat MasterEq::Ad
protected

◆ Ad_vec

std::vector<Mat> MasterEq::Ad_vec
protected

◆ addT1

bool MasterEq::addT1
protected

◆ addT2

bool MasterEq::addT2
protected

Flags for including T1 decay and T2 dephasing Lindblad operators.

◆ aux

Vec MasterEq::aux
protected

Auxiliary vector for computations.

◆ Bc_vec

std::vector<Mat> MasterEq::Bc_vec
protected

◆ Bd

Mat MasterEq::Bd
protected

◆ Bd_vec

std::vector<Mat> MasterEq::Bd_vec
protected

◆ crosskerr

std::vector<double> MasterEq::crosskerr
protected

Cross-Kerr coefficients (rad/time) \(\xi_{kl}\) for ZZ-coupling \(a_k^\dagger a_k a_l^\dagger a_l\).

◆ decoherence_type

DecoherenceType MasterEq::decoherence_type

Type of Lindblad operators to include (NONE means Schroedinger equation)

◆ dim

PetscInt MasterEq::dim
protected

Dimension of full vectorized system: N^2 if Lindblad, N if Schroedinger.

◆ dim_ess

PetscInt MasterEq::dim_ess
protected

Dimension of essential levels = N_e.

◆ dim_rho

PetscInt MasterEq::dim_rho
protected

Dimension of Hilbert space = N.

◆ eta

std::vector<double> MasterEq::eta
protected

Frequency differences in rotating frame (rad/time) for dipole-dipole coupling.

◆ hamiltonian_file_Hc

std::optional<std::string> MasterEq::hamiltonian_file_Hc
protected

Filename if a custom control Hamiltonians are read from file.

◆ hamiltonian_file_Hsys

std::optional<std::string> MasterEq::hamiltonian_file_Hsys
protected

Filename if a custom system Hamiltonian is read from file.

◆ ilow

PetscInt MasterEq::ilow
protected

First index of the local sub vector u,v.

◆ isu

IS MasterEq::isu
protected

◆ isv

IS MasterEq::isv
protected

Vector strides for accessing real and imaginary parts u=Re(x), v=Im(x)

◆ iupp

PetscInt MasterEq::iupp
protected

Last index (+1) of the local sub vector u,v.

◆ Jkl

std::vector<double> MasterEq::Jkl
protected

Dipole-dipole coupling coefficients (rad/time), multiplies \(a_k^\dagger a_l + a_k a_l^\dagger\).

◆ localsize_u

PetscInt MasterEq::localsize_u
protected

Size of local sub vector u or v in state x=[u,v].

◆ mpirank_petsc

int MasterEq::mpirank_petsc
protected

Rank of PETSc's communicator.

◆ mpirank_world

int MasterEq::mpirank_world
protected

Rank of global MPI communicator.

◆ mpisize_petsc

int MasterEq::mpisize_petsc
protected

Size of PETSc's communicator.

◆ nessential

std::vector<size_t> MasterEq::nessential

Number of essential levels per oscillator.

◆ nlevels

std::vector<size_t> MasterEq::nlevels

Number of levels per oscillator.

◆ noscillators

int MasterEq::noscillators
protected

Number of oscillators in the system.

◆ oscil_vec

Oscillator** MasterEq::oscil_vec
protected

Array of pointers to oscillator objects.

◆ quietmode

bool MasterEq::quietmode
protected

Flag for quiet mode operation.

◆ RHS

Mat MasterEq::RHS
protected

MatShell for real-valued, vectorized system matrix (size 2N^2 x 2N^2)

◆ RHSctx

MatShellCtx MasterEq::RHSctx
protected

Context containing data for applying the RHS to a state.

◆ usematfree

bool MasterEq::usematfree

Flag for using matrix-free solver.


The documentation for this class was generated from the following files: