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

Quantum oscillator (multi-level qubit) with control capabilities. More...

#include <oscillator.hpp>

Public Member Functions

 Oscillator ()
 
 Oscillator (const Config &config, size_t id, std::mt19937 rand_engine, int param_offset, bool quietmode)
 Constructor with simplified configuration-based specification.
 
virtual ~Oscillator ()
 
size_t getNParams ()
 Retrieves the number of control parameters.
 
size_t getNLevels ()
 Retrieves the number of energy levels.
 
double getSelfkerr ()
 Retrieves the self-Kerr coefficient.
 
double getDetuning ()
 Retrieves the detuning frequency.
 
double getDecayTime ()
 Retrieves the T1 decay time.
 
double getDephaseTime ()
 Retrieves the T2 dephasing time.
 
size_t getNParameterizations ()
 Retrieves the number of control parameterizations in this oscillator (currently always 1).
 
size_t getNCarrierfrequencies ()
 Retrieves the number of carrier frequencies.
 
ControlType getControlType ()
 Retrieves the type of control parameterization.
 
int getNSplines ()
 Retrieves the number of splines used in the control parameterization.
 
double getRotFreq ()
 Retrieves the rotating frame frequency.
 
int getNSegParams (int parameterizationID)
 Retrieves the number of parameters for a specific parameterization.
 
void setParams (const double *x)
 Sets control parameters from a global storage.
 
void getParams (double *x)
 Retrieves control parameters into a global storage.
 
void clearParams ()
 Clears all control parameters.
 
int evalControl (const double t, double *Re_ptr, double *Im_ptr)
 Evaluates the rotating-frame control functions.
 
int evalControl_diff (const double t, double *grad_for_this_oscillator, const double pbar, const double qbar)
 Computes derivatives of control functions p(t) and q(t) with respect to the parameters.
 
int evalControl_Labframe (const double t, double *f_ptr)
 Evaluates lab-frame control function.
 
double expectedEnergy (const Vec x)
 Computes expected energy for this oscillator.
 
void expectedEnergy_diff (const Vec x, Vec x_bar, const double obj_bar)
 Computes derivative of expected energy computation.
 
void population (const Vec x, std::vector< double > &pop)
 Computes population in each energy level of this oscillator.
 
double evalControlVariation ()
 Evaluates control variation penalty term.
 
void evalControlVariationDiff (Vec G, double var_reg_bar, int skip_to_oscillator)
 Computes derivative of control variation penalty.
 

Public Attributes

PetscInt dim_preOsc
 Dimension of coupled subsystems preceding this oscillator.
 
PetscInt dim_postOsc
 Dimension of coupled subsystems following this oscillator.
 

Protected Attributes

int myid
 Integer identifier for this oscillator.
 
size_t nlevels
 Number of energy levels for this oscillator.
 
double ground_freq
 Fundamental 0-1 transition frequency of this oscillator \(\omega_k\).
 
double selfkerr
 Self-Kerr frequency \(\xi_k\), multiplies \(a_k^\dagger a_k^\dagger a_k a_k\).
 
double detuning_freq
 Detuning frequency, detuning = ground_freq - rotational_freq, multiplies \(a_k^\dagger a_k\).
 
DecoherenceType decoherence_type
 Type of Lindblad decoherence operators to include.
 
double decay_time
 Characteristic time for T1 decay operations.
 
double dephase_time
 Characteristic time for T2 dephasing operations.
 
std::vector< double > params
 Control parameters for this oscillator.
 
double Tfinal
 Final evolution time.
 
std::vector< ControlBasis * > basisfunctions
 Basis functions for control parameterization foreach time parameterization. Note: Currently only one parameterization is supported!
 
std::vector< double > carrier_freq
 Frequencies of the carrier waves.
 
int mpirank_world
 Rank of MPI_COMM_WORLD.
 
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.
 
bool control_zero_boundary_condition
 Flag to enforce boundary conditions on controls.
 

Detailed Description

Quantum oscillator (multi-level qubit) with control capabilities.

This class represents a single quantum oscillator that is controlled by external control pulses. It stores the oscillator parameters, such as number of energy levels, frequency detuning, anharmonicity and Lindblad decay and dephasing times.
It also manages this oscillator's control pulse parameterization and carrier wave frequencies.

Main functionality:

This class contains references to:

Constructor & Destructor Documentation

◆ Oscillator() [1/2]

Oscillator::Oscillator ( )

◆ Oscillator() [2/2]

Oscillator::Oscillator ( const Config config,
size_t  id,
std::mt19937  rand_engine,
int  param_offset,
bool  quietmode 
)

Constructor with simplified configuration-based specification.

Parameters
configConfiguration parameters containing all oscillator settings
idOscillator identifier
rand_engineRandom number generator engine
param_offsetOffset for global control parameter indexing
quietmodeFlag for quiet mode operation

◆ ~Oscillator()

Oscillator::~Oscillator ( )
virtual

Member Function Documentation

◆ clearParams()

void Oscillator::clearParams ( )
inline

Clears all control parameters.

Makes this oscillator non-controllable by removing all parameters.

◆ evalControl()

int Oscillator::evalControl ( const double  t,
double *  Re_ptr,
double *  Im_ptr 
)

Evaluates the rotating-frame control functions.

Computes the real and imaginary parts of the control function: Re = p(t), Im = q(t)

Parameters
[in]tTime at which to evaluate
[out]Re_ptrPointer to store real part p(t)
[out]Im_ptrPointer to store imaginary part q(t)
Returns
int Error code

◆ evalControl_diff()

int Oscillator::evalControl_diff ( const double  t,
double *  grad_for_this_oscillator,
const double  pbar,
const double  qbar 
)

Computes derivatives of control functions p(t) and q(t) with respect to the parameters.

Parameters
[in]tTime at which to evaluate derivatives
[out]grad_for_this_oscillatorArray to update the gradient
[in]pbarAdjoint scaling factor for the gradient of p (seed)
[in]qbarAdjoint scaling factor for the gradient of q (seed)
Returns
int Error code

◆ evalControl_Labframe()

int Oscillator::evalControl_Labframe ( const double  t,
double *  f_ptr 
)

Evaluates lab-frame control function.

Parameters
tTime at which to evaluate
f_ptrPointer to store lab-frame control value
Returns
int Error code

◆ evalControlVariation()

double Oscillator::evalControlVariation ( )

Evaluates control variation penalty term.

Computes finite-difference based regularization of control parameters.

Returns
double Control variation penalty value

◆ evalControlVariationDiff()

void Oscillator::evalControlVariationDiff ( Vec  G,
double  var_reg_bar,
int  skip_to_oscillator 
)

Computes derivative of control variation penalty.

Parameters
GGradient vector to update
var_reg_barAdjoint of variation penalty
skip_to_oscillatorOffset to this oscillator's parameters in global vector

◆ expectedEnergy()

double Oscillator::expectedEnergy ( const Vec  x)

Computes expected energy for this oscillator.

Returns the expected value of the number operator for this oscillator's subsystem.

Parameters
xState vector
Returns
double Expected energy value

◆ expectedEnergy_diff()

void Oscillator::expectedEnergy_diff ( const Vec  x,
Vec  x_bar,
const double  obj_bar 
)

Computes derivative of expected energy computation.

Parameters
xState vector
x_barAdjoint state vector to update
obj_barAdjoint of expected energy

◆ getControlType()

ControlType Oscillator::getControlType ( )
inline

Retrieves the type of control parameterization.

Returns
ControlType Type of control parameterization

◆ getDecayTime()

double Oscillator::getDecayTime ( )
inline

Retrieves the T1 decay time.

Returns
double Decay time

◆ getDephaseTime()

double Oscillator::getDephaseTime ( )
inline

Retrieves the T2 dephasing time.

Returns
double Dephasing time

◆ getDetuning()

double Oscillator::getDetuning ( )
inline

Retrieves the detuning frequency.

Returns
double Detuning frequency (rad/time)

◆ getNCarrierfrequencies()

size_t Oscillator::getNCarrierfrequencies ( )
inline

Retrieves the number of carrier frequencies.

Returns
size_t Number of carrier frequencies

◆ getNLevels()

size_t Oscillator::getNLevels ( )
inline

Retrieves the number of energy levels.

Returns
size_t Number of energy levels

◆ getNParameterizations()

size_t Oscillator::getNParameterizations ( )
inline

Retrieves the number of control parameterizations in this oscillator (currently always 1).

Returns
size_t Number of time parameterizations (currently always returns 1)

◆ getNParams()

size_t Oscillator::getNParams ( )
inline

Retrieves the number of control parameters.

Returns
size_t Number of control parameters

◆ getNSegParams()

int Oscillator::getNSegParams ( int  parameterizationID)

Retrieves the number of parameters for a specific parameterization.

Parameters
parameterizationIDSegment identifier // Currently always 0!
Returns
int Number of parameters for this parameterization

◆ getNSplines()

int Oscillator::getNSplines ( )
inline

Retrieves the number of splines used in the control parameterization.

Returns
int Number of splines

◆ getParams()

void Oscillator::getParams ( double *  x)

Retrieves control parameters into a global storage.

Parameters
xArray to store control parameter values

◆ getRotFreq()

double Oscillator::getRotFreq ( )
inline

Retrieves the rotating frame frequency.

Returns
double Rotating frame frequency (Hz)

◆ getSelfkerr()

double Oscillator::getSelfkerr ( )
inline

Retrieves the self-Kerr coefficient.

Returns
double Self-Kerr frequency

◆ population()

void Oscillator::population ( const Vec  x,
std::vector< double > &  pop 
)

Computes population in each energy level of this oscillator.

Extracts the diagonal elements of the reduced density matrix for this oscillator.

Parameters
xState vector
popReference to vector to store population values

◆ setParams()

void Oscillator::setParams ( const double *  x)

Sets control parameters from a global storage.

Parameters
xArray of control parameter values

Member Data Documentation

◆ basisfunctions

std::vector<ControlBasis *> Oscillator::basisfunctions
protected

Basis functions for control parameterization foreach time parameterization. Note: Currently only one parameterization is supported!

◆ carrier_freq

std::vector<double> Oscillator::carrier_freq
protected

Frequencies of the carrier waves.

◆ control_zero_boundary_condition

bool Oscillator::control_zero_boundary_condition
protected

Flag to enforce boundary conditions on controls.

◆ decay_time

double Oscillator::decay_time
protected

Characteristic time for T1 decay operations.

◆ decoherence_type

DecoherenceType Oscillator::decoherence_type
protected

Type of Lindblad decoherence operators to include.

◆ dephase_time

double Oscillator::dephase_time
protected

Characteristic time for T2 dephasing operations.

◆ detuning_freq

double Oscillator::detuning_freq
protected

Detuning frequency, detuning = ground_freq - rotational_freq, multiplies \(a_k^\dagger a_k\).

◆ dim_postOsc

PetscInt Oscillator::dim_postOsc

Dimension of coupled subsystems following this oscillator.

◆ dim_preOsc

PetscInt Oscillator::dim_preOsc

Dimension of coupled subsystems preceding this oscillator.

◆ ground_freq

double Oscillator::ground_freq
protected

Fundamental 0-1 transition frequency of this oscillator \(\omega_k\).

◆ ilow

PetscInt Oscillator::ilow
protected

First index of the local sub vector u,v.

◆ iupp

PetscInt Oscillator::iupp
protected

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

◆ localsize_u

PetscInt Oscillator::localsize_u
protected

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

◆ mpirank_petsc

int Oscillator::mpirank_petsc
protected

Rank of PETSc's communicator.

◆ mpirank_world

int Oscillator::mpirank_world
protected

Rank of MPI_COMM_WORLD.

◆ mpisize_petsc

int Oscillator::mpisize_petsc
protected

Size of PETSc's communicator.

◆ myid

int Oscillator::myid
protected

Integer identifier for this oscillator.

◆ nlevels

size_t Oscillator::nlevels
protected

Number of energy levels for this oscillator.

◆ params

std::vector<double> Oscillator::params
protected

Control parameters for this oscillator.

◆ selfkerr

double Oscillator::selfkerr
protected

Self-Kerr frequency \(\xi_k\), multiplies \(a_k^\dagger a_k^\dagger a_k a_k\).

◆ Tfinal

double Oscillator::Tfinal
protected

Final evolution time.


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