27 std::vector<double>
Jkl;
28 std::vector<double>
eta;
227 void compute_dRHS_dParams(
const double t,
const Vec x,
const Vec x_bar,
const double alpha, Vec grad);
250 void population(
const Vec x, std::vector<double> &population_com);
278void 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);
309inline double H_detune(
const double detuning0,
const int a) {
321 return - xi0 / 2.0 * a * (a-1);
332inline double L2(
const double dephase0,
const int i0,
const int i0p){
333 return dephase0 * ( i0*i0p - 1./2. * (i0*i0 + i0p*i0p) );
344inline double L1diag(
const double decay0,
const int i0,
const int i0p){
345 return - decay0 / 2.0 * ( i0 + i0p ) ;
357 return i0 + nlevels0 * i0p;
369inline double H_detune(
const double detuning0,
const double detuning1,
const int a,
const int b) {
370 return detuning0*a + detuning1*b;
382inline double H_selfkerr(
const double xi0,
const double xi1,
const int a,
const int b) {
383 return - xi0 / 2.0 * a * (a-1) - xi1 / 2.0 * b * (b-1);
394inline double H_crosskerr(
const double xi01,
const int a,
const int b) {
395 return - xi01 * a * b;
409inline double L2(
const double dephase0,
const double dephase1,
const int i0,
const int i1,
const int i0p,
const int i1p){
410 return dephase0 * ( i0*i0p - 1./2. * (i0*i0 + i0p*i0p) ) + dephase1 * ( i1*i1p - 1./2. * (i1*i1 + i1p*i1p) );
424inline double L1diag(
const double decay0,
const double decay1,
const int i0,
const int i1,
const int i0p,
const int i1p){
425 return - decay0 / 2.0 * ( i0 + i0p ) - decay1 / 2.0 * ( i1 + i1p );
439inline int TensorGetIndex(
const int nlevels0,
const int nlevels1,
const int i0,
const int i1,
const int i0p,
const int i1p){
440 return i0*nlevels1 + i1 + (nlevels0 * nlevels1) * ( i0p * nlevels1 + i1p);
446inline double H_detune(
const double detuning0,
const double detuning1,
const double detuning2,
const int i0,
const int i1,
const int i2) {
447 return detuning0*i0 + detuning1*i1 + detuning2*i2;
449inline double H_selfkerr(
const double xi0,
const double xi1,
const double xi2,
const int i0,
const int i1,
const int i2) {
450 return - xi0 / 2.0 * i0 * (i0-1) - xi1 / 2.0 * i1 * (i1-1) - xi2 / 2.0 * i2 * (i2-1);
452inline double H_crosskerr(
const double xi01,
const double xi02,
const double xi12,
const int i0,
const int i1,
const int i2) {
453 return - xi01 * i0 * i1 - xi02 * i0 * i2 - xi12 * i1 * i2;
455inline 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){
456 return dephase0 * ( i0*i0p - 1./2. * (i0*i0 + i0p*i0p) )
457 + dephase1 * ( i1*i1p - 1./2. * (i1*i1 + i1p*i1p) )
458 + dephase2 * ( i2*i2p - 1./2. * (i2*i2 + i2p*i2p) );
460inline 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){
461 return - decay0 / 2.0 * ( i0 + i0p )
462 - decay1 / 2.0 * ( i1 + i1p )
463 - decay2 / 2.0 * ( i2 + i2p );
465inline 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){
466 return i0*nlevels1*nlevels2 + i1*nlevels2 + i2 + (nlevels0 * nlevels1 * nlevels2) * ( i0p * nlevels1*nlevels2 + i1p*nlevels2 + i2p);
472inline 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) {
473 return detuning0*i0 + detuning1*i1 + detuning2*i2 + detuning3*i3;
475inline 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) {
476 return - xi0 / 2.0 * i0 * (i0-1) - xi1 / 2.0 * i1 * (i1-1) - xi2 / 2.0 * i2 * (i2-1) - xi3/2.0 * i3 * (i3-1);
478inline 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) {
479 return - xi01 * i0 * i1 - xi02 * i0 * i2 - xi03*i0*i3 - xi12 * i1 * i2 - xi13*i1*i3 - xi23*i2*i3;
481inline 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){
482 return dephase0 * ( i0*i0p - 1./2. * (i0*i0 + i0p*i0p) )
483 + dephase1 * ( i1*i1p - 1./2. * (i1*i1 + i1p*i1p) )
484 + dephase2 * ( i2*i2p - 1./2. * (i2*i2 + i2p*i2p) )
485 + dephase3 * ( i3*i3p - 1./2. * (i3*i3 + i3p*i3p) );
487inline 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){
488 return - decay0 / 2.0 * ( i0 + i0p )
489 - decay1 / 2.0 * ( i1 + i1p )
490 - decay2 / 2.0 * ( i2 + i2p )
491 - decay3 / 2.0 * ( i3 + i3p );
493inline 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){
494 return i0*nlevels1*nlevels2*nlevels3 + i1*nlevels2*nlevels3 + i2*nlevels3 + i3 + (nlevels0 * nlevels1 * nlevels2 * nlevels3) * ( i0p * nlevels1*nlevels2*nlevels3 + i1p*nlevels2*nlevels3 + i2p*nlevels3 + i3p);
499inline 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) {
500 return detuning0*i0 + detuning1*i1 + detuning2*i2 + detuning3*i3 + detuning4*i4;
502inline 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) {
503 return - xi0 / 2.0 * i0 * (i0-1) - xi1 / 2.0 * i1 * (i1-1) - xi2 / 2.0 * i2 * (i2-1) - xi3/2.0 * i3 * (i3-1) - xi4/2.0 * i4 * (i4-1);
505inline 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) {
506 return - xi01 * i0 * i1 - xi02 * i0 * i2 - xi03*i0*i3 - xi04*i0*i4 - xi12 * i1 * i2 - xi13*i1*i3 - xi14*i1*i4 - xi23*i2*i3 - xi24*i2*i4 - xi34*i3*i4;
508inline 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){
509 return dephase0 * ( i0*i0p - 1./2. * (i0*i0 + i0p*i0p) )
510 + dephase1 * ( i1*i1p - 1./2. * (i1*i1 + i1p*i1p) )
511 + dephase2 * ( i2*i2p - 1./2. * (i2*i2 + i2p*i2p) )
512 + dephase3 * ( i3*i3p - 1./2. * (i3*i3 + i3p*i3p) )
513 + dephase4 * ( i4*i4p - 1./2. * (i4*i4 + i4p*i4p) );
515inline 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){
516 return - decay0 / 2.0 * ( i0 + i0p )
517 - decay1 / 2.0 * ( i1 + i1p )
518 - decay2 / 2.0 * ( i2 + i2p )
519 - decay3 / 2.0 * ( i3 + i3p )
520 - decay4 / 2.0 * ( i4 + i4p );
522inline 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){
523 return i0*nlevels1*nlevels2*nlevels3*nlevels4 + i1*nlevels2*nlevels3*nlevels4 + i2*nlevels3*nlevels4 + i3*nlevels4 + i4 + (nlevels0 * nlevels1 * nlevels2 * nlevels3*nlevels4) * ( i0p * nlevels1*nlevels2*nlevels3*nlevels4 + i1p*nlevels2*nlevels3*nlevels4 + i2p*nlevels3*nlevels4+ i3p*nlevels4 + i4p);
546inline 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) {
555 int itx = it + stridei;
556 double xre = xptr[itx];
557 double xim = xptr[itx+dim];
558 double sq = sqrt(i + 1);
559 *res_p_re += sq * xim;
560 *res_p_im += - sq * xre;
561 *res_q_re += sq * xre;
562 *res_q_im += sq * xim;
566 int itx = it + strideip;
567 double xre = xptr[itx];
568 double xim = xptr[itx+dim];
569 double sq = sqrt(ip + 1);
570 *res_p_re += - sq * xim;
571 *res_p_im += + sq * xre;
572 *res_q_re += sq * xre;
573 *res_q_im += sq * xim;
577 int itx = it - stridei;
578 double xre = xptr[itx];
579 double xim = xptr[itx+dim];
581 *res_p_re += + sq * xim;
582 *res_p_im += - sq * xre;
583 *res_q_re += - sq * xre;
584 *res_q_im += - sq * xim;
588 int itx = it - strideip;
589 double xre = xptr[itx];
590 double xim = xptr[itx+dim];
591 double sq = sqrt(ip);
592 *res_p_re += - sq * xim;
593 *res_p_im += + sq * xre;
594 *res_q_re += - sq * xre;
595 *res_q_im += - sq * xim;
625inline 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) {
626 if (fabs(Jij)>1e-10) {
628 if (i > 0 && j < nj-1) {
629 int itx = it - stridei + stridej;
630 double xre = xptr[itx];
631 double xim = xptr[itx+dim];
632 double sq = sqrt(i * (j + 1));
634 *yre += Jij * sq * ( cosij * xim + sinij * xre);
635 *yim += Jij * sq * ( - cosij * xre + sinij * xim);
638 if (i < ni-1 && j > 0) {
639 int itx = it + stridei - stridej;
640 double xre = xptr[itx];
641 double xim = xptr[itx+dim];
642 double sq = sqrt(j * (i + 1));
644 *yre += Jij * sq * ( cosij * xim - sinij * xre);
645 *yim += Jij * sq * ( - cosij * xre - sinij * xim);
648 if (ip > 0 && jp < njp-1) {
649 int itx = it - strideip + stridejp;
650 double xre = xptr[itx];
651 double xim = xptr[itx+dim];
652 double sq = sqrt(ip * (jp + 1));
654 *yre += Jij * sq * ( - cosij * xim + sinij * xre);
655 *yim += Jij * sq * ( cosij * xre + sinij * xim);
658 if (ip < nip-1 && jp > 0) {
659 int itx = it + strideip - stridejp;
660 double xre = xptr[itx];
661 double xim = xptr[itx+dim];
662 double sq = sqrt(jp * (ip + 1));
664 *yre += Jij * sq * ( - cosij * xim - sinij * xre);
665 *yim += Jij * sq * ( cosij * xre - sinij * xim);
694inline 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) {
695 if (fabs(Jij)>1e-10) {
697 if (i < ni-1 && j > 0) {
698 int itx = it + stridei - stridej;
699 double xre = xptr[itx];
700 double xim = xptr[itx+dim];
701 double sq = sqrt(j * (i + 1));
702 *yre += Jij * sq * ( - cosij * xim + sinij * xre);
703 *yim += Jij * sq * ( + cosij * xre + sinij * xim);
706 if (i > 0 && j < nj-1) {
707 int itx = it - stridei + stridej;
708 double xre = xptr[itx];
709 double xim = xptr[itx+dim];
710 double sq = sqrt(i * (j + 1));
711 *yre += Jij * sq * ( - cosij * xim - sinij * xre);
712 *yim += Jij * sq * ( + cosij * xre - sinij * xim);
715 if (ip < nip-1 && jp > 0) {
716 int itx = it + strideip - stridejp;
717 double xre = xptr[itx];
718 double xim = xptr[itx+dim];
719 double sq = sqrt(jp * (ip + 1));
720 *yre += Jij * sq * ( cosij * xim + sinij * xre);
721 *yim += Jij * sq * ( - cosij * xre + sinij * xim);
724 if (ip > 0 && jp < njp-1) {
725 int itx = it - strideip + stridejp;
726 double xre = xptr[itx];
727 double xim = xptr[itx+dim];
728 double sq = sqrt(ip * (jp + 1));
729 *yre += Jij * sq * ( cosij * xim - sinij * xre);
730 *yim += Jij * sq * ( - cosij * xre - sinij * xim);
751inline 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){
752 if (fabs(decayi) > 1e-12) {
753 if (i < n-1 && ip < n-1) {
754 double l1off = decayi * sqrt((i+1)*(ip+1));
755 int itx = it + stridei + strideip;
756 double xre = xptr[itx];
757 double xim = xptr[itx+dim];
779inline 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){
780 if (fabs(decayi) > 1e-12) {
781 if (i > 0 && ip > 0) {
782 double l1off = decayi * sqrt(i*ip);
783 int itx = it - stridei - strideip;
784 double xre = xptr[itx];
785 double xim = xptr[itx+dim];
811inline 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){
814 int itx = it + stridei;
815 double xre = xptr[itx];
816 double xim = xptr[itx+dim];
817 double sq = sqrt(i + 1);
818 *yre += sq * ( pt * xim + qt * xre);
819 *yim += sq * ( - pt * xre + qt * xim);
823 int itx = it + strideip;
824 double xre = xptr[itx];
825 double xim = xptr[itx+dim];
826 double sq = sqrt(ip + 1);
827 *yre += sq * ( -pt * xim + qt * xre);
828 *yim += sq * ( pt * xre + qt * xim);
832 int itx = it - stridei;
833 double xre = xptr[itx];
834 double xim = xptr[itx+dim];
836 *yre += sq * ( pt * xim - qt * xre);
837 *yim += sq * (- pt * xre - qt * xim);
841 int itx = it - strideip;
842 double xre = xptr[itx];
843 double xim = xptr[itx+dim];
844 double sq = sqrt(ip);
845 *yre += sq * (- pt * xim - qt * xre);
846 *yim += sq * ( pt * xre - qt * xim);
868inline 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){
871 int itx = it - stridei;
872 double xre = xptr[itx];
873 double xim = xptr[itx+dim];
875 *yre += sq * ( - pt * xim + qt * xre);
876 *yim += sq * ( pt * xre + qt * xim);
880 int itx = it - strideip;
881 double xre = xptr[itx];
882 double xim = xptr[itx+dim];
883 double sq = sqrt(ip);
884 *yre += sq * ( pt * xim + qt * xre);
885 *yim += sq * ( -pt * xre + qt * xim);
889 int itx = it + stridei;
890 double xre = xptr[itx];
891 double xim = xptr[itx+dim];
892 double sq = sqrt(i+1);
893 *yre += sq * (- pt * xim - qt * xre);
894 *yim += sq * ( pt * xre - qt * xim);
898 int itx = it + strideip;
899 double xre = xptr[itx];
900 double xim = xptr[itx+dim];
901 double sq = sqrt(ip+1);
902 *yre += sq * (+ pt * xim - qt * xre);
903 *yim += sq * (- pt * xre - qt * xim);
Configuration class containing all validated settings.
Definition config.hpp:57
Implementation of the real-valued right-hand-side (RHS) system matrix of the quantum dynamical equati...
Definition mastereq.hpp:92
bool addT1
Definition mastereq.hpp:113
bool addT2
Flags for including T1 decay and T2 dephasing Lindblad operators.
Definition mastereq.hpp:113
std::vector< Mat > Ac_vec
Definition mastereq.hpp:104
DecoherenceType decoherence_type
Type of Lindblad operators to include (NONE means Schroedinger equation)
Definition mastereq.hpp:132
Mat getRHS()
Retrieves the right-hand-side system matrix.
Definition mastereq.cpp:694
std::vector< size_t > nlevels
Number of levels per oscillator.
Definition mastereq.hpp:129
int mpirank_petsc
Rank of PETSc's communicator.
Definition mastereq.hpp:116
MasterEq()
Definition mastereq.cpp:3
Mat Bd
Definition mastereq.hpp:106
bool usematfree
Flag for using matrix-free solver.
Definition mastereq.hpp:131
PetscInt dim_rho
Dimension of Hilbert space = N.
Definition mastereq.hpp:96
bool quietmode
Flag for quiet mode operation.
Definition mastereq.hpp:124
std::vector< size_t > nessential
Number of essential levels per oscillator.
Definition mastereq.hpp:130
std::vector< double > crosskerr
Cross-Kerr coefficients (rad/time) for ZZ-coupling .
Definition mastereq.hpp:110
IS isu
Definition mastereq.hpp:122
std::optional< std::string > hamiltonian_file_Hc
Filename if a custom control Hamiltonians are read from file.
Definition mastereq.hpp:126
IS isv
Vector strides for accessing real and imaginary parts u=Re(x), v=Im(x)
Definition mastereq.hpp:122
PetscInt localsize_u
Size of local sub vector u or v in state x=[u,v].
Definition mastereq.hpp:118
PetscInt getDim()
Retrieves the dimension of the vectorized system.
Definition mastereq.hpp:181
size_t getNOscillators()
Retrieves the number of oscillators in the system.
Definition mastereq.hpp:174
PetscInt getDimRho()
Retrieves the dimension of the density matrix.
Definition mastereq.hpp:195
MatShellCtx RHSctx
Context containing data for applying the RHS to a state.
Definition mastereq.hpp:102
Oscillator ** oscil_vec
Array of pointers to oscillator objects.
Definition mastereq.hpp:99
std::vector< Mat > Bd_vec
Definition mastereq.hpp:108
std::optional< std::string > hamiltonian_file_Hsys
Filename if a custom system Hamiltonian is read from file.
Definition mastereq.hpp:125
Mat Ad
Definition mastereq.hpp:106
Oscillator * getOscillator(const size_t i)
Retrieves the i-th oscillator.
Definition mastereq.hpp:167
std::vector< double > eta
Frequency differences in rotating frame (rad/time) for dipole-dipole coupling.
Definition mastereq.hpp:112
void population(const Vec x, std::vector< double > &population_com)
Computes population of the full composite system.
Definition mastereq.cpp:2950
void set_RHS_MatMult_operation()
Pass MatMult operations for applying the RHS to PETSc.
Definition mastereq.cpp:724
PetscInt ilow
First index of the local sub vector u,v.
Definition mastereq.hpp:119
int noscillators
Number of oscillators in the system.
Definition mastereq.hpp:98
void initSparseMatSolver()
Initializes matrices needed for the sparse matrix solver.
Definition mastereq.cpp:206
int assemble_RHS(const double t)
Assembles the real-valued system matrix (RHS) at time t.
Definition mastereq.cpp:671
double expectedEnergy(const Vec x)
Computes expected energy of the full composite system.
Definition mastereq.cpp:2911
std::vector< Mat > Ad_vec
Definition mastereq.hpp:107
Mat RHS
MatShell for real-valued, vectorized system matrix (size 2N^2 x 2N^2)
Definition mastereq.hpp:101
int mpisize_petsc
Size of PETSc's communicator.
Definition mastereq.hpp:117
std::vector< double > Jkl
Dipole-dipole coupling coefficients (rad/time), multiplies .
Definition mastereq.hpp:111
int mpirank_world
Rank of global MPI communicator.
Definition mastereq.hpp:115
Vec aux
Auxiliary vector for computations.
Definition mastereq.hpp:123
PetscInt dim
Dimension of full vectorized system: N^2 if Lindblad, N if Schroedinger.
Definition mastereq.hpp:95
PetscInt getDimEss()
Retrieves the dimension of the essential level system.
Definition mastereq.hpp:188
PetscInt dim_ess
Dimension of essential levels = N_e.
Definition mastereq.hpp:97
PetscInt iupp
Last index (+1) of the local sub vector u,v.
Definition mastereq.hpp:120
std::vector< Mat > Bc_vec
Definition mastereq.hpp:105
void setControlAmplitudes(const Vec x)
Pass control parameters from global design vector to each oscillator.
Definition mastereq.cpp:707
~MasterEq()
Definition mastereq.cpp:172
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.
Definition mastereq.cpp:697
Quantum oscillator (multi-level qubit) with control capabilities.
Definition oscillator.hpp:37
Core type definitions and enumerations for Quandary quantum optimal control.
DecoherenceType
Available Lindblad operator types for open quantum systems, or NONE for closed quantum systems.
Definition defs.hpp:31
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
Definition mastereq.cpp:939
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.
Definition mastereq.hpp:694
int applyRHS_sparsemat(Mat RHS, Vec x, Vec y)
Sparse matrix MatMult.
Definition mastereq.cpp:757
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
Definition mastereq.cpp:984
int applyRHS_matfree_1Osc(Mat RHS, Vec x, Vec y)
Matrix-vector products to apply the RHS system matrix to a state vector.
Definition mastereq.cpp:2991
double L2(const double dephase0, const int i0, const int i0p)
Inline for Matrix-free RHS to compute L2 dephasing coefficient for 1 oscillator.
Definition mastereq.hpp:332
int applyRHS_matfree_transpose_1Osc(Mat RHS, Vec x, Vec y)
Transpose matrix-free MatMult for 1 oscillator.
Definition mastereq.cpp:3020
int applyRHS_matfree_transpose_5Osc(Mat RHS, Vec x, Vec y)
Transpose matrix-free MatMult for 5 oscillators.
Definition mastereq.cpp:3232
int applyRHS_matfree_transpose_2Osc(Mat RHS, Vec x, Vec y)
Transpose matrix-free MatMult for 2 oscillators.
Definition mastereq.cpp:3077
int applyRHS_matfree_4Osc(Mat RHS, Vec x, Vec y)
Matrix-free MatMult for 4 oscillators.
Definition mastereq.cpp:3155
int applyRHS_matfree_3Osc(Mat RHS, Vec x, Vec y)
Matrix-free MatMult for 3 oscillators.
Definition mastereq.cpp:3105
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.
Definition mastereq.hpp:546
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.
Definition mastereq.hpp:625
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.
Definition mastereq.hpp:751
double H_crosskerr(const double xi01, const int a, const int b)
Inline for Matrix-free RHS, Computes cross-Kerr coupling between 2 oscillators.
Definition mastereq.hpp:394
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.
Definition mastereq.hpp:356
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.
Definition mastereq.hpp:811
int applyRHS_matfree_5Osc(Mat RHS, Vec x, Vec y)
Matrix-free MatMult for 5 oscillators.
Definition mastereq.cpp:3206
double H_selfkerr(const double xi0, const int a)
Inline for Matrix-free RHS to Compute self-Kerr coefficient for 1 oscillator.
Definition mastereq.hpp:320
int applyRHS_matfree_2Osc(Mat RHS, Vec x, Vec y)
Matrix-free MatMult for 2 oscillators.
Definition mastereq.cpp:3047
int applyRHS_matfree_transpose_4Osc(Mat RHS, Vec x, Vec y)
Transpose matrix-free MatMult for 4 oscillators.
Definition mastereq.cpp:3181
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.
Definition mastereq.hpp:868
double L1diag(const double decay0, const int i0, const int i0p)
Inline for Matrix-free RHS to compute L1 decay coefficient for 1 oscillator.
Definition mastereq.hpp:344
int applyRHS_matfree_transpose_3Osc(Mat RHS, Vec x, Vec y)
Transpose matrix-free MatMult for 3 oscillators.
Definition mastereq.cpp:3131
int applyRHS_sparsemat_transpose(Mat RHS, Vec x, Vec y)
Transpose sparse matrix MatMult.
Definition mastereq.cpp:848
double H_detune(const double detuning0, const int a)
Inline for Matrix-free RHS to Compute detuning for 1 oscillator.
Definition mastereq.hpp:309
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.
Definition mastereq.hpp:779
Matrix shell context containing data needed for applying the right-hand-side (RHS) system matrix to a...
Definition mastereq.hpp:21
std::vector< Mat > Ad_vec
Vector of real parts of dipole-dipole coupling system matrices.
Definition mastereq.hpp:37
Oscillator ** oscil_vec
Array of pointers to the oscillators.
Definition mastereq.hpp:25
Vec * aux
Auxiliary vector for computations.
Definition mastereq.hpp:41
std::vector< double > Jkl
Dipole-dipole coupling strength.
Definition mastereq.hpp:27
std::vector< double > eta
Frequency differences of the rotating frames.
Definition mastereq.hpp:28
std::vector< size_t > nlevels
Number of levels per oscillator.
Definition mastereq.hpp:23
std::vector< double > crosskerr
Cross-Kerr coupling coefficients.
Definition mastereq.hpp:26
double time
Current time.
Definition mastereq.hpp:42
Mat * Ad
Real parts of time-independent system matrix.
Definition mastereq.hpp:35
std::vector< double > control_Im
Imaginary parts of control pulse .
Definition mastereq.hpp:32
PetscInt dim
Dimension of full vectorized system: N^2 if Lindblad, N if Schroedinger.
Definition mastereq.hpp:22
std::vector< double > control_Re
Real parts of control pulse .
Definition mastereq.hpp:31
std::vector< double > Bd_coeffs
Definition mastereq.hpp:39
std::vector< Mat > Ac_vec
Vector of real parts of control matrices per oscillator.
Definition mastereq.hpp:33
IS * isu
Definition mastereq.hpp:24
Mat * Bd
Imaginary parts of time-independent system matrix.
Definition mastereq.hpp:36
std::vector< double > Ad_coeffs
Definition mastereq.hpp:40
DecoherenceType decoherence_type
Type of Lindblad operators to include.
Definition mastereq.hpp:29
bool addT1
Definition mastereq.hpp:30
std::vector< Mat > Bd_vec
Vector of imaginary parts of dipole-dipole coupling system matrices.
Definition mastereq.hpp:38
std::vector< Mat > Bc_vec
Vector of imaginary parts of control matrices per oscillator.
Definition mastereq.hpp:34