|
Quandary
|
#include "defs.hpp"#include "oscillator.hpp"#include "util.hpp"#include <optional>#include <petscts.h>#include <vector>#include <assert.h>#include <iostream>#include "gate.hpp"#include "hamiltonianfilereader.hpp"

Go to the source code of this file.
Classes | |
| struct | MatShellCtx |
| Matrix shell context containing data needed for applying the right-hand-side (RHS) system matrix to a vector. More... | |
| class | MasterEq |
| Implementation of the real-valued right-hand-side (RHS) system matrix of the quantum dynamical equations. More... | |
Functions | |
| int | applyRHS_matfree_1Osc (Mat RHS, Vec x, Vec y) |
| Matrix-vector products to apply the RHS system matrix to a state vector. | |
| int | applyRHS_matfree_transpose_1Osc (Mat RHS, Vec x, Vec y) |
| Transpose matrix-free MatMult for 1 oscillator. | |
| int | applyRHS_matfree_2Osc (Mat RHS, Vec x, Vec y) |
| Matrix-free MatMult for 2 oscillators. | |
| int | applyRHS_matfree_transpose_2Osc (Mat RHS, Vec x, Vec y) |
| Transpose matrix-free MatMult for 2 oscillators. | |
| int | applyRHS_matfree_3Osc (Mat RHS, Vec x, Vec y) |
| Matrix-free MatMult for 3 oscillators. | |
| int | applyRHS_matfree_transpose_3Osc (Mat RHS, Vec x, Vec y) |
| Transpose matrix-free MatMult for 3 oscillators. | |
| int | applyRHS_matfree_4Osc (Mat RHS, Vec x, Vec y) |
| Matrix-free MatMult for 4 oscillators. | |
| int | applyRHS_matfree_transpose_4Osc (Mat RHS, Vec x, Vec y) |
| Transpose matrix-free MatMult for 4 oscillators. | |
| int | applyRHS_matfree_5Osc (Mat RHS, Vec x, Vec y) |
| Matrix-free MatMult for 5 oscillators. | |
| int | applyRHS_matfree_transpose_5Osc (Mat RHS, Vec x, Vec y) |
| Transpose matrix-free MatMult for 5 oscillators. | |
| int | applyRHS_sparsemat (Mat RHS, Vec x, Vec y) |
| Sparse matrix MatMult. | |
| int | applyRHS_sparsemat_transpose (Mat RHS, Vec x, Vec y) |
| Transpose sparse matrix MatMult. | |
| void | compute_dRHS_dParams_sparsemat (const double t, const Vec x, const Vec x_bar, const double alpha, Vec grad, std::vector< size_t > &nlevels, IS isu, IS isv, std::vector< Mat > &Ac_vec, std::vector< Mat > &Bc_vec, Vec aux, Oscillator **oscil_vec) |
| : Sparse-matrix version to compute gradient of RHS with respect to parameters | |
| void | compute_dRHS_dParams_matfree (const PetscInt dim, const double t, const Vec x, const Vec x_bar, const double alpha, Vec grad, std::vector< size_t > &nlevels, DecoherenceType decoherence_type, Oscillator **oscil_vec) |
| : Matrix free version to compute gradient of RHS with respect to parameters | |
| double | H_detune (const double detuning0, const int a) |
| Inline for Matrix-free RHS to Compute detuning for 1 oscillator. | |
| double | H_selfkerr (const double xi0, const int a) |
| Inline for Matrix-free RHS to Compute self-Kerr coefficient for 1 oscillator. | |
| double | L2 (const double dephase0, const int i0, const int i0p) |
| Inline for Matrix-free RHS to compute L2 dephasing coefficient for 1 oscillator. | |
| double | L1diag (const double decay0, const int i0, const int i0p) |
| Inline for Matrix-free RHS to compute L1 decay coefficient for 1 oscillator. | |
| int | TensorGetIndex (const int nlevels0, const int i0, const int i0p) |
| Inline for Matrix-free RHS to compute tensor product index for 1 oscillator system. | |
| double | H_detune (const double detuning0, const double detuning1, const int a, const int b) |
| Inline for Matrix-free RHS, Computes detuning Hamiltonian term for 2 oscillators. | |
| double | H_selfkerr (const double xi0, const double xi1, const int a, const int b) |
| Inline for Matrix-free RHS, Computes self-Kerr nonlinearity terms for 2 oscillators. | |
| double | H_crosskerr (const double xi01, const int a, const int b) |
| Inline for Matrix-free RHS, Computes cross-Kerr coupling between 2 oscillators. | |
| double | L2 (const double dephase0, const double dephase1, const int i0, const int i1, const int i0p, const int i1p) |
| Inline for Matrix-free RHS, Computes L2 dephasing Lindblad operator for 2 oscillators. | |
| double | L1diag (const double decay0, const double decay1, const int i0, const int i1, const int i0p, const int i1p) |
| Inline for Matrix-free RHS, Computes L1 decay Lindblad operator diagonal term for 2 oscillators. | |
| int | TensorGetIndex (const int nlevels0, const int nlevels1, const int i0, const int i1, const int i0p, const int i1p) |
| Inline for Matrix-free RHS, Computes tensor product index for 2 oscillator system. | |
| double | H_detune (const double detuning0, const double detuning1, const double detuning2, const int i0, const int i1, const int i2) |
| double | H_selfkerr (const double xi0, const double xi1, const double xi2, const int i0, const int i1, const int i2) |
| double | H_crosskerr (const double xi01, const double xi02, const double xi12, const int i0, const int i1, const int i2) |
| double | L2 (const double dephase0, const double dephase1, const double dephase2, const int i0, const int i1, const int i2, const int i0p, const int i1p, const int i2p) |
| double | L1diag (const double decay0, const double decay1, const double decay2, const int i0, const int i1, const int i2, const int i0p, const int i1p, const int i2p) |
| int | TensorGetIndex (const int nlevels0, const int nlevels1, const int nlevels2, const int i0, const int i1, const int i2, const int i0p, const int i1p, const int i2p) |
| double | H_detune (const double detuning0, const double detuning1, const double detuning2, const double detuning3, const int i0, const int i1, const int i2, const int i3) |
| double | H_selfkerr (const double xi0, const double xi1, const double xi2, const double xi3, const int i0, const int i1, const int i2, const int i3) |
| double | H_crosskerr (const double xi01, const double xi02, const double xi03, const double xi12, const double xi13, const double xi23, const int i0, const int i1, const int i2, const int i3) |
| double | L2 (const double dephase0, const double dephase1, const double dephase2, const double dephase3, const int i0, const int i1, const int i2, const int i3, const int i0p, const int i1p, const int i2p, const int i3p) |
| double | L1diag (const double decay0, const double decay1, const double decay2, const double decay3, const int i0, const int i1, const int i2, const int i3, const int i0p, const int i1p, const int i2p, const int i3p) |
| int | TensorGetIndex (const int nlevels0, const int nlevels1, const int nlevels2, const int nlevels3, const int i0, const int i1, const int i2, const int i3, const int i0p, const int i1p, const int i2p, const int i3p) |
| double | H_detune (const double detuning0, const double detuning1, const double detuning2, const double detuning3, const double detuning4, const int i0, const int i1, const int i2, const int i3, const int i4) |
| double | H_selfkerr (const double xi0, const double xi1, const double xi2, const double xi3, const double xi4, const int i0, const int i1, const int i2, const int i3, const int i4) |
| double | H_crosskerr (const double xi01, const double xi02, const double xi03, const double xi04, const double xi12, const double xi13, const double xi14, const double xi23, const double xi24, const double xi34, const int i0, const int i1, const int i2, const int i3, const int i4) |
| double | L2 (const double dephase0, const double dephase1, const double dephase2, const double dephase3, const double dephase4, const int i0, const int i1, const int i2, const int i3, const int i4, const int i0p, const int i1p, const int i2p, const int i3p, const int i4p) |
| double | L1diag (const double decay0, const double decay1, const double decay2, const double decay3, const double decay4, const int i0, const int i1, const int i2, const int i3, const int i4, const int i0p, const int i1p, const int i2p, const int i3p, const int i4p) |
| int | TensorGetIndex (const int nlevels0, const int nlevels1, const int nlevels2, const int nlevels3, const int nlevels4, const int i0, const int i1, const int i2, const int i3, const int i4, const int i0p, const int i1p, const int i2p, const int i3p, const int i4p) |
| void | dRHSdp_getcoeffs (const PetscInt dim, const int it, const int n, const int np, const int i, const int ip, const int stridei, const int strideip, const double *xptr, double *res_p_re, double *res_p_im, double *res_q_re, double *res_q_im) |
| Inline for Matrix-free RHS for gradient updates. | |
| void | Jkl_coupling (const PetscInt dim, const int it, const int ni, const int nj, const int nip, const int njp, const int i, const int ip, const int j, const int jp, const int stridei, const int strideip, const int stridej, const int stridejp, const double *xptr, const double Jij, const double cosij, const double sinij, double *yre, double *yim) |
| Matrix-free solver inline for dipole-dipole coupling between oscillators. | |
| void | Jkl_coupling_T (const PetscInt dim, const int it, const int ni, const int nj, const int nip, const int njp, const int i, const int ip, const int j, const int jp, const int stridei, const int strideip, const int stridej, const int stridejp, const double *xptr, const double Jij, const double cosij, const double sinij, double *yre, double *yim) |
| Transpose of dipole-dipole coupling for adjoint computations. | |
| void | L1decay (const PetscInt dim, const int it, const int n, const int i, const int ip, const int stridei, const int strideip, const double *xptr, const double decayi, double *yre, double *yim) |
| Matrix-free solver inline for off-diagonal L1 decay term. | |
| void | L1decay_T (const PetscInt dim, const int it, const int i, const int ip, const int stridei, const int strideip, const double *xptr, const double decayi, double *yre, double *yim) |
| Matrix-free inline Transpose of off-diagonal L1 decay for adjoint computations. | |
| void | control (const PetscInt dim, const int it, const int n, const int i, const int np, const int ip, const int stridei, const int strideip, const double *xptr, const double pt, const double qt, double *yre, double *yim) |
| Matrix-free solver inline for control terms. | |
| void | control_T (const PetscInt dim, const int it, const int n, const int i, const int np, const int ip, const int stridei, const int strideip, const double *xptr, const double pt, const double qt, double *yre, double *yim) |
| Matrix-free Transpose of control terms for adjoint computations. | |
| int applyRHS_matfree_1Osc | ( | Mat | RHS, |
| Vec | x, | ||
| Vec | y | ||
| ) |
Matrix-vector products to apply the RHS system matrix to a state vector.
Each function returns y = RHS*x. Matrix-free versions as well as sparse-matrix versions are implemented. Those functions will be passed to PETSc's MatMult operations to realize a Matrix-Vector Multiplication of the RHS with a state vector, such that one can call PETSc's MatMult(RHS, x, y) for the RHS. Note: The RHS matrix must be assembled before usage, see MasterEq::assemble_RHS. Matrix-free MatMult for 1 oscillator
| int applyRHS_matfree_2Osc | ( | Mat | RHS, |
| Vec | x, | ||
| Vec | y | ||
| ) |
Matrix-free MatMult for 2 oscillators.
| int applyRHS_matfree_3Osc | ( | Mat | RHS, |
| Vec | x, | ||
| Vec | y | ||
| ) |
Matrix-free MatMult for 3 oscillators.
| int applyRHS_matfree_4Osc | ( | Mat | RHS, |
| Vec | x, | ||
| Vec | y | ||
| ) |
Matrix-free MatMult for 4 oscillators.
| int applyRHS_matfree_5Osc | ( | Mat | RHS, |
| Vec | x, | ||
| Vec | y | ||
| ) |
Matrix-free MatMult for 5 oscillators.
| int applyRHS_matfree_transpose_1Osc | ( | Mat | RHS, |
| Vec | x, | ||
| Vec | y | ||
| ) |
Transpose matrix-free MatMult for 1 oscillator.
| int applyRHS_matfree_transpose_2Osc | ( | Mat | RHS, |
| Vec | x, | ||
| Vec | y | ||
| ) |
Transpose matrix-free MatMult for 2 oscillators.
| int applyRHS_matfree_transpose_3Osc | ( | Mat | RHS, |
| Vec | x, | ||
| Vec | y | ||
| ) |
Transpose matrix-free MatMult for 3 oscillators.
| int applyRHS_matfree_transpose_4Osc | ( | Mat | RHS, |
| Vec | x, | ||
| Vec | y | ||
| ) |
Transpose matrix-free MatMult for 4 oscillators.
| int applyRHS_matfree_transpose_5Osc | ( | Mat | RHS, |
| Vec | x, | ||
| Vec | y | ||
| ) |
Transpose matrix-free MatMult for 5 oscillators.
| int applyRHS_sparsemat | ( | Mat | RHS, |
| Vec | x, | ||
| Vec | y | ||
| ) |
Sparse matrix MatMult.
| int applyRHS_sparsemat_transpose | ( | Mat | RHS, |
| Vec | x, | ||
| Vec | y | ||
| ) |
Transpose sparse matrix MatMult.
| void compute_dRHS_dParams_matfree | ( | const PetscInt | dim, |
| const double | t, | ||
| const Vec | x, | ||
| const Vec | x_bar, | ||
| const double | alpha, | ||
| Vec | grad, | ||
| std::vector< size_t > & | nlevels, | ||
| DecoherenceType | decoherence_type, | ||
| Oscillator ** | oscil_vec | ||
| ) |
: Matrix free version to compute gradient of RHS with respect to parameters
Updates grad += alpha * x^T * (d RHS / d params)^T * x_bar in a matrix-free manner. See compute_dRHS_dParams_sparsemat for the sparse-matrix version of this routine.
| [in] | dim | Dimension of full vectorized system: N^2 if Lindblad, N if Schroedinger |
| [in] | t | Current time |
| [in] | x | State vector |
| [in] | x_bar | Adjoint state vector |
| [in] | alpha | Scaling factor |
| [out] | grad | Gradient vector to update |
| [in] | nlevels | Number of energy levels per subsystem |
| [in] | decoherence_type | Type of Lindblad decoherence operators, or NONE |
| [in] | oscil_vec | Vector of quantum oscillators |
| void compute_dRHS_dParams_sparsemat | ( | const double | t, |
| const Vec | x, | ||
| const Vec | x_bar, | ||
| const double | alpha, | ||
| Vec | grad, | ||
| std::vector< size_t > & | nlevels, | ||
| IS | isu, | ||
| IS | isv, | ||
| std::vector< Mat > & | Ac_vec, | ||
| std::vector< Mat > & | Bc_vec, | ||
| Vec | aux, | ||
| Oscillator ** | oscil_vec | ||
| ) |
: Sparse-matrix version to compute gradient of RHS with respect to parameters
Updates grad += alpha * x^T * (d RHS / d params)^T * x_bar with sparse-matrix version of RHS. Compare compute_dRHS_dParams_matfree for the matrix-free version of this routine.
| [in] | t | Current time |
| [in] | x | State vector |
| [in] | x_bar | Adjoint state vector |
| [in] | alpha | Scaling factor |
| [out] | grad | Gradient vector to update |
| [in] | nlevels | Number of energy levels per subsystem |
| [in] | isu | Index stride to access real parts of a state vector |
| [in] | isv | Index stride to access imaginar parts of a state vector |
| [in] | Ac_vec | Vector of real parts of control matrices per oscillator |
| [in] | Bc_vec | Vector of imaginary parts of control matrices per oscillator |
| [in] | aux | Auxiliary vector for computations |
| [in] | oscil_vec | Vector of quantum oscilators |
|
inline |
Matrix-free solver inline for control terms.
Applies control Hamiltonian terms (ladder operators) to the state.
| dim | Dimension of full vectorized system: N^2 if Lindblad, N if Schroedinger |
| it | Current tensor index |
| n | Number of levels |
| i | Occupation number (bra) |
| np | Number of levels (conjugate) |
| ip | Occupation number (ket) |
| stridei | Stride for bra index |
| strideip | Stride for ket index |
| xptr | Pointer to state vector data |
| pt | Real part of control amplitude |
| qt | Imaginary part of control amplitude |
| yre | Pointer to store real part of result |
| yim | Pointer to store imaginary part of result |
|
inline |
Matrix-free Transpose of control terms for adjoint computations.
| dim | Dimension of full vectorized system: N^2 if Lindblad, N if Schroedinger |
| it | Current tensor index |
| n | Number of levels |
| i | Occupation number (bra) |
| np | Number of levels (conjugate) |
| ip | Occupation number (ket) |
| stridei | Stride for bra index |
| strideip | Stride for ket index |
| xptr | Pointer to state vector data |
| pt | Real part of control amplitude |
| qt | Imaginary part of control amplitude |
| yre | Pointer to store real part of result |
| yim | Pointer to store imaginary part of result |
|
inline |
Inline for Matrix-free RHS for gradient updates.
Computes coefficients for gradient computation with respect to control parameters.
| dim | Dimension of full vectorized system: N^2 if Lindblad, N if Schroedinger |
| it | Current tensor index |
| n | Number of levels for current oscillator |
| np | Number of levels for conjugate oscillator |
| i | Current occupation number |
| ip | Conjugate occupation number |
| stridei | Stride for current oscillator |
| strideip | Stride for conjugate oscillator |
| xptr | Pointer to state vector data |
| res_p_re | Pointer to store real part of p result |
| res_p_im | Pointer to store imaginary part of p result |
| res_q_re | Pointer to store real part of q result |
| res_q_im | Pointer to store imaginary part of q result |
|
inline |
|
inline |
|
inline |
|
inline |
Inline for Matrix-free RHS, Computes cross-Kerr coupling between 2 oscillators.
| xi01 | Cross-Kerr coefficient between oscillators 0 and 1 |
| a | Occupation number for oscillator 0 |
| b | Occupation number for oscillator 1 |
|
inline |
|
inline |
|
inline |
|
inline |
Inline for Matrix-free RHS, Computes detuning Hamiltonian term for 2 oscillators.
| detuning0 | Detuning frequency for oscillator 0 |
| detuning1 | Detuning frequency for oscillator 1 |
| a | Occupation number for oscillator 0 |
| b | Occupation number for oscillator 1 |
|
inline |
Inline for Matrix-free RHS to Compute detuning for 1 oscillator.
| detuning0 | Detuning frequency |
| a | Occupation number |
|
inline |
|
inline |
|
inline |
|
inline |
Inline for Matrix-free RHS, Computes self-Kerr nonlinearity terms for 2 oscillators.
| xi0 | Self-Kerr coefficient for oscillator 0 |
| xi1 | Self-Kerr coefficient for oscillator 1 |
| a | Occupation number for oscillator 0 |
| b | Occupation number for oscillator 1 |
|
inline |
Inline for Matrix-free RHS to Compute self-Kerr coefficient for 1 oscillator.
| xi0 | Self-Kerr coefficient for oscillator 0 |
| a | Occupation number |
|
inline |
Matrix-free solver inline for dipole-dipole coupling between oscillators.
Implements J_kl coupling terms in the rotating frame between oscillator i and j.
| dim | Dimension of full vectorized system: N^2 if Lindblad, N if Schroedinger |
| it | Current tensor index |
| ni | Number of levels for oscillator i |
| nj | Number of levels for oscillator j |
| nip | Number of levels for oscillator i (conjugate) |
| njp | Number of levels for oscillator j (conjugate) |
| i | Occupation number for oscillator i |
| ip | Occupation number for oscillator i (conjugate) |
| j | Occupation number for oscillator j |
| jp | Occupation number for oscillator j (conjugate) |
| stridei | Stride for oscillator i |
| strideip | Stride for oscillator i (conjugate) |
| stridej | Stride for oscillator j |
| stridejp | Stride for oscillator j (conjugate) |
| xptr | Pointer to state vector data |
| Jij | Coupling coefficient |
| cosij | Cosine of frequency difference |
| sinij | Sine of frequency difference |
| yre | Pointer to store real part of result |
| yim | Pointer to store imaginary part of result |
|
inline |
Transpose of dipole-dipole coupling for adjoint computations.
| dim | Dimension of full vectorized system: N^2 if Lindblad, N if Schroedinger |
| it | Current tensor index |
| ni | Number of levels for oscillator i |
| nj | Number of levels for oscillator j |
| nip | Number of levels for oscillator i (conjugate) |
| njp | Number of levels for oscillator j (conjugate) |
| i | Occupation number for oscillator i |
| ip | Occupation number for oscillator i (conjugate) |
| j | Occupation number for oscillator j |
| jp | Occupation number for oscillator j (conjugate) |
| stridei | Stride for oscillator i |
| strideip | Stride for oscillator i (conjugate) |
| stridej | Stride for oscillator j |
| stridejp | Stride for oscillator j (conjugate) |
| xptr | Pointer to state vector data |
| Jij | Coupling coefficient |
| cosij | Cosine of frequency difference |
| sinij | Sine of frequency difference |
| yre | Pointer to store real part of result |
| yim | Pointer to store imaginary part of result |
|
inline |
Matrix-free solver inline for off-diagonal L1 decay term.
| dim | Dimension of full vectorized system: N^2 if Lindblad, N if Schroedinger |
| it | Current tensor index |
| n | Number of levels |
| i | Occupation number (bra) |
| ip | Occupation number (ket) |
| stridei | Stride for bra index |
| strideip | Stride for ket index |
| xptr | Pointer to state vector data |
| decayi | Decay rate |
| yre | Pointer to store real part of result |
| yim | Pointer to store imaginary part of result |
|
inline |
Matrix-free inline Transpose of off-diagonal L1 decay for adjoint computations.
| dim | Dimension of full vectorized system: N^2 if Lindblad, N if Schroedinger |
| it | Current tensor index |
| i | Occupation number (bra) |
| ip | Occupation number (ket) |
| stridei | Stride for bra index |
| strideip | Stride for ket index |
| xptr | Pointer to state vector data |
| decayi | Decay rate |
| yre | Pointer to store real part of result |
| yim | Pointer to store imaginary part of result |
|
inline |
|
inline |
|
inline |
|
inline |
Inline for Matrix-free RHS, Computes L1 decay Lindblad operator diagonal term for 2 oscillators.
| decay0 | Decay rate for oscillator 0 |
| decay1 | Decay rate for oscillator 1 |
| i0 | Occupation number for oscillator 0 (bra) |
| i1 | Occupation number for oscillator 1 (bra) |
| i0p | Occupation number for oscillator 0 (ket) |
| i1p | Occupation number for oscillator 1 (ket) |
|
inline |
Inline for Matrix-free RHS to compute L1 decay coefficient for 1 oscillator.
| decay0 | Decay rate for oscillator 0 |
| i0 | Occupation number (bra) |
| i0p | Occupation number (ket) |
|
inline |
|
inline |
|
inline |
|
inline |
Inline for Matrix-free RHS, Computes L2 dephasing Lindblad operator for 2 oscillators.
| dephase0 | Dephasing rate for oscillator 0 |
| dephase1 | Dephasing rate for oscillator 1 |
| i0 | Occupation number for oscillator 0 (bra) |
| i1 | Occupation number for oscillator 1 (bra) |
| i0p | Occupation number for oscillator 0 (ket) |
| i1p | Occupation number for oscillator 1 (ket) |
|
inline |
Inline for Matrix-free RHS to compute L2 dephasing coefficient for 1 oscillator.
| dephase0 | Dephasing rate for oscillator 0 |
| i0 | Occupation number (bra) |
| i0p | Occupation number (ket) |
|
inline |
Inline for Matrix-free RHS to compute tensor product index for 1 oscillator system.
| nlevels0 | Number of levels for oscillator 0 |
| i0 | Occupation number (bra) |
| i0p | Occupation number (ket) |
|
inline |
Inline for Matrix-free RHS, Computes tensor product index for 2 oscillator system.
| nlevels0 | Number of levels for oscillator 0 |
| nlevels1 | Number of levels for oscillator 1 |
| i0 | Occupation number for oscillator 0 (bra) |
| i1 | Occupation number for oscillator 1 (bra) |
| i0p | Occupation number for oscillator 0 (ket) |
| i1p | Occupation number for oscillator 1 (ket) |
|
inline |
|
inline |
|
inline |