|
Quandary
|
Base class for time integration schemes to evolve the quantum dynamics. More...
#include <timestepper.hpp>


Public Member Functions | |
| TimeStepper () | |
| TimeStepper (MasterEq *mastereq_, int ntime_, double total_time_, Output *output_, bool storeFWD_) | |
| Constructor for time stepper. | |
| virtual | ~TimeStepper () |
| Vec | getState (size_t tindex) |
| Retrieves stored state at a specific time index. | |
| void | setEvalLeakage (bool flag) |
| void | setEvalWeightedCost (bool flag, double width) |
| void | setEvalDPDM (bool flag) |
| void | setEvalEnergy (bool flag) |
| double | getLeakageIntegral () |
| double | getWeightedCostIntegral () |
| double | getEnergyIntegral () |
| double | getDPDMIntegral () |
| Vec | solveODE (int initid, Vec rho_t0) |
| Solves the ODE forward in time. | |
| void | solveAdjointODE (Vec rho_t0_bar, Vec finalstate, double Jbar_leakage, double Jbar_weightedcost, double Jbar_dpdm, double Jbar_energy) |
| Solves the adjoint ODE backward in time. | |
| double | evalLeakage (const Vec x) |
| Evaluates leakage into guard levels. | |
| void | evalLeakage_diff (const Vec x, Vec xbar, double Jbar) |
| Computes derivative of leakage term. | |
| double | evalWeightedCost (double time, const Vec x) |
| Evaluates the weighted cost function term. | |
| void | evalWeightedCost_diff (double time, const Vec x, Vec xbar, double Jbar) |
| Computes derivative of weighted cost function term. | |
| double | evalDpDm (Vec x, Vec xm1, Vec xm2) |
| Evaluates second-order derivative variation for the state. | |
| void | evalDpDm_diff (int n, Vec xbar, double Jbar) |
| Computes derivative of second-order derivative variation term. | |
| double | evalEnergy (double time) |
| Evaluates energy integral term. | |
| void | evalEnergy_diff (double time, double Jbar, Vec redgrad) |
| Computes derivative of energy integral. | |
| virtual void | evolveFWD (const double tstart, const double tstop, Vec x)=0 |
| Evolves state forward by one time-step from tstart to tstop. | |
| virtual void | evolveBWD (const double tstart, const double tstop, const Vec x_stop, Vec x_adj, Vec grad, bool compute_gradient) |
| Evolves adjoint state backward by one time-step and updates reduced gradient. | |
Public Attributes | |
| MasterEq * | mastereq |
| Pointer to master equation solver. | |
| int | ntime |
| Number of time steps. | |
| double | total_time |
| Final evolution time. | |
| double | dt |
| Time step size. | |
| bool | writeTrajectoryDataFiles |
| Flag to determine whether or not trajectory data will be written to files during forward simulation */. | |
| Vec | redgrad |
| Reduced gradient vector for optimization. | |
| OptimTarget * | optim_target |
| Pointer to optimization target specification. | |
| Output * | output |
| Pointer to output handler. | |
| bool | storeFWD |
| Flag to store primal states during forward evaluation. | |
Protected Attributes | |
| Vec | x |
| Auxiliary vector for forward time stepping. | |
| Vec | xadj |
| Auxiliary vector needed for adjoint (backward) time stepping. | |
| Vec | xprimal |
| Auxiliary vector for backward time stepping. | |
| std::vector< Vec > | store_states |
| Storage for primal states during forward evolution. | |
| std::vector< Vec > | dpdm_states |
| Storage for states needed for second-order derivative penalty. | |
| int | mpirank_world |
| MPI rank in global communicator. | |
| int | mpisize_petsc |
| MPI size in Petsc communicator. | |
| int | mpirank_petsc |
| MPI rank in Petsc 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 | eval_leakage |
| Flag to compute leakage integral term. | |
| bool | eval_energy |
| Flag to compute energy integral term. | |
| bool | eval_dpdm |
| Flag to compute second-order derivative integral term. | |
| bool | eval_weightedcost |
| Flag to compute weighted cost integral term. | |
| double | leakage_integral |
| Sums the integral over leakage. | |
| double | energy_integral |
| Sums the energy term. | |
| double | dpdm_integral |
| Sums second-order derivative variation value. | |
| double | weightedcost_integral |
| Sums the integral over weighted cost function. | |
| double | weightedcost_width |
| Width parameter for weighted cost function. | |
Base class for time integration schemes to evolve the quantum dynamics.
This abstract class provides the interface for time-stepping methods used to integrate the quantum evolution equations (Lindblad master equation or Schroedinger equation). It supports both forward and adjoint time integration, handles output of evolution data, and evaluates penalty integral terms.
Main functionality:
This class contains references to:
| TimeStepper::TimeStepper | ( | ) |
| TimeStepper::TimeStepper | ( | MasterEq * | mastereq_, |
| int | ntime_, | ||
| double | total_time_, | ||
| Output * | output_, | ||
| bool | storeFWD_ | ||
| ) |
Constructor for time stepper.
| mastereq_ | Pointer to master equation solver |
| ntime_ | Number of time steps |
| total_time_ | Final evolution time |
| output_ | Pointer to output handler |
| storeFWD_ | Flag to store forward states |
|
virtual |
| double TimeStepper::evalDpDm | ( | Vec | x, |
| Vec | xm1, | ||
| Vec | xm2 | ||
| ) |
Evaluates second-order derivative variation for the state.
| x | Current state vector |
| xm1 | State vector at previous time step |
| xm2 | State vector at two time steps ago |
| void TimeStepper::evalDpDm_diff | ( | int | n, |
| Vec | xbar, | ||
| double | Jbar | ||
| ) |
Computes derivative of second-order derivative variation term.
| n | Time step index |
| xbar | Adjoint state vector to update |
| Jbar | Adjoint of dpdm term |
| double TimeStepper::evalEnergy | ( | double | time | ) |
Evaluates energy integral term.
| time | Current time |
| void TimeStepper::evalEnergy_diff | ( | double | time, |
| double | Jbar, | ||
| Vec | redgrad | ||
| ) |
Computes derivative of energy integral.
| time | Current time |
| Jbar | Adjoint of energy |
| redgrad | Reduced gradient vector to update |
| double TimeStepper::evalLeakage | ( | const Vec | x | ) |
Evaluates leakage into guard levels.
| x | Current state vector |
| void TimeStepper::evalLeakage_diff | ( | const Vec | x, |
| Vec | xbar, | ||
| double | Jbar | ||
| ) |
Computes derivative of leakage term.
| x | Current state vector |
| xbar | Adjoint state vector to update |
| Jbar | Adjoint of leakage integral term |
| double TimeStepper::evalWeightedCost | ( | double | time, |
| const Vec | x | ||
| ) |
Evaluates the weighted cost function term.
| time | Current time |
| x | Current state vector |
| void TimeStepper::evalWeightedCost_diff | ( | double | time, |
| const Vec | x, | ||
| Vec | xbar, | ||
| double | Jbar | ||
| ) |
Computes derivative of weighted cost function term.
| time | Current time |
| x | Current state vector |
| xbar | Adjoint state vector to update |
| Jbar | Adjoint of weighted cost term |
|
virtual |
Evolves adjoint state backward by one time-step and updates reduced gradient.
Abstract base-class implementation is empty. Derived classes that need backward time-stepping should implement this function.
| tstart | Start time (backward evolution) |
| tstop | Stop time (backward evolution) |
| x_stop | State at stop time |
| x_adj | Adjoint state vector |
| grad | Gradient vector to update |
| compute_gradient | Flag to compute gradient |
Reimplemented in ExplEuler, ImplMidpoint, and CompositionalImplMidpoint.
|
pure virtual |
Evolves state forward by one time-step from tstart to tstop.
Pure virtual function to be implemented by the derived time-stepping classes.
| tstart | Start time |
| tstop | Stop time |
| x | State vector to evolve |
Implemented in ExplEuler, ImplMidpoint, and CompositionalImplMidpoint.
|
inline |
|
inline |
|
inline |
| Vec TimeStepper::getState | ( | size_t | tindex | ) |
Retrieves stored state at a specific time index.
| tindex | Time step index |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
| void TimeStepper::solveAdjointODE | ( | Vec | rho_t0_bar, |
| Vec | finalstate, | ||
| double | Jbar_leakage, | ||
| double | Jbar_weightedcost, | ||
| double | Jbar_dpdm, | ||
| double | Jbar_energy | ||
| ) |
Solves the adjoint ODE backward in time.
This performs backward time-stepping to backpropagate an adjoint initial condition at final time (aka a terminal condtion) to time t=0, while accumulating the reduced gradient.
| rho_t0_bar | Terminal condition for adjoint state |
| finalstate | Final state from forward evolution |
| Jbar_leakage | Adjoint of leakage integral term |
| Jbar_weightedcost | Adjoint of weighted cost integral term |
| Jbar_dpdm | Adjoint of second-order derivative variation |
| Jbar_energy | Adjoint of energy integral term |
| Vec TimeStepper::solveODE | ( | int | initid, |
| Vec | rho_t0 | ||
| ) |
Solves the ODE forward in time.
This performs the time-stepping to propagate an initial condition to the final time.
| initid | Initial condition identifier |
| rho_t0 | Initial state vector |
|
protected |
Sums second-order derivative variation value.
|
protected |
Storage for states needed for second-order derivative penalty.
| double TimeStepper::dt |
Time step size.
|
protected |
Sums the energy term.
|
protected |
Flag to compute second-order derivative integral term.
|
protected |
Flag to compute energy integral term.
|
protected |
Flag to compute leakage integral term.
|
protected |
Flag to compute weighted cost integral term.
|
protected |
First index of the local sub vector u,v.
|
protected |
Last index (+1) of the local sub vector u,v.
|
protected |
Sums the integral over leakage.
|
protected |
Size of local sub vector u or v in state x=[u,v].
| MasterEq* TimeStepper::mastereq |
Pointer to master equation solver.
|
protected |
MPI rank in Petsc communicator.
|
protected |
MPI rank in global communicator.
|
protected |
MPI size in Petsc communicator.
| int TimeStepper::ntime |
Number of time steps.
| OptimTarget* TimeStepper::optim_target |
Pointer to optimization target specification.
| Output* TimeStepper::output |
Pointer to output handler.
| Vec TimeStepper::redgrad |
Reduced gradient vector for optimization.
|
protected |
Storage for primal states during forward evolution.
| bool TimeStepper::storeFWD |
Flag to store primal states during forward evaluation.
| double TimeStepper::total_time |
Final evolution time.
|
protected |
Sums the integral over weighted cost function.
|
protected |
Width parameter for weighted cost function.
| bool TimeStepper::writeTrajectoryDataFiles |
Flag to determine whether or not trajectory data will be written to files during forward simulation */.
|
protected |
Auxiliary vector for forward time stepping.
|
protected |
Auxiliary vector needed for adjoint (backward) time stepping.
|
protected |
Auxiliary vector for backward time stepping.