9#include <unsupported/Eigen/MatrixFunctions>
24template<
typename Symmetry_,
size_t order=0>
35 typedef typename Symmetry::qType
qType;
52 inline size_t get_D()
const {
return this->
D;}
59 OperatorType
sign (std::size_t orb1=0, std::size_t orb2=0)
const;
65 template<
class Dummy = Symmetry>
66 typename std::enable_if<!Dummy::IS_SPIN_SU2(),
OperatorType>::type
n (std::size_t
orbital=0)
const;
73 template<
class Dummy = Symmetry>
80 template<
class Dummy = Symmetry>
83 template<
class Dummy = Symmetry>
86 template<
class Dummy = Symmetry>
89 template<
class Dummy = Symmetry>
92 template<
class Dummy = Symmetry>
95 template<
class Dummy = Symmetry>
98 template<
class Dummy = Symmetry>
101 template<
class Dummy = Symmetry>
104 template<
class Dummy = Symmetry>
107 template<
class Dummy = Symmetry>
110 template<
class Dummy = Symmetry>
113 template<
class Dummy = Symmetry>
116 template<
class Dummy = Symmetry>
119 template<
class Dummy = Symmetry>
122 assert(Sa !=
SY and Sa !=
QP and Sa !=
QM and Sa !=
QPZ and Sa !=
QMZ);
124 if constexpr (Dummy::NO_SPIN_SYM())
134 assert(Sa !=
SX and Sa !=
iSY);
142 template<
class Dummy = Symmetry>
145 assert(Sa !=
SX and Sa !=
SY and Sa !=
iSY and Sa !=
SZ and Sa !=
SP and Sa !=
SM);
156 template<
class Dummy = Symmetry>
159 template<
class Dummy = Symmetry>
162 template<
class Dummy = Symmetry>
165 template<
class Dummy = Symmetry>
191 template<
typename Scalar_>
194 template<
typename Dummy = Symmetry>
196 const ArrayXd &Bz,
const ArrayXd &mu,
const ArrayXd &nu,
197 const ArrayXd &Kz)
const;
199 template<
typename Dummy = Symmetry>
213 template<
typename Dummy = Symmetry>
215 const ArrayXd &Bz,
const ArrayXd &Bx,
const ArrayXd &mu,
const ArrayXd &nu,
216 const ArrayXd &Kz,
const ArrayXd &Kx,
217 const ArrayXXd &Dy)
const;
225 template<
typename Dummy = Symmetry>
227 const std::array<ArrayXd,3> &
B,
228 const std::array<ArrayXd,3> &K,
229 const std::array<ArrayXXd,3> &
D)
const;
230 template<
typename Scalar_,
typename Dummy = Symmetry>
231 typename std::enable_if<Dummy::NO_SPIN_SYM(),
SiteOperatorQ<Symmetry_,Eigen::Matrix<Scalar_,-1,-1> >>::type
coupling_Bx (
const Array<double,Dynamic,1> &Bx)
const;
233 template<
typename Dummy = Symmetry>
247template <
typename Symmetry_,
size_t order>
249SpinBase (std::size_t L_input, std::size_t D_input,
int mfactor)
253 typename Symmetry::qType
Q=Symmetry::qvacuum();
254 Eigen::Index inner_dim = 1;
279template<
typename Symmetry_,
size_t order>
284 if (N_orbitals == 1) {out = Op_1s; out.
label() = label;
return out;}
289 if (
orbital == 0) {out = OperatorType::outerprod(Op_1s,this->Id_1s(),Op_1s.
Q()); TOGGLE=
true;}
292 if (
orbital == 1) {out = OperatorType::outerprod(stringOp,Op_1s,Op_1s.
Q()); TOGGLE=
true;}
293 else {out = OperatorType::outerprod(stringOp,stringOp,Symmetry_::qvacuum());}
295 for(std::size_t o=2; o<N_orbitals; o++)
297 if (
orbital == o) {out = OperatorType::outerprod(out,Op_1s,Op_1s.
Q()); TOGGLE=
true; }
298 else if (TOGGLE==
false) {out = OperatorType::outerprod(out,stringOp,Symmetry_::qvacuum());}
299 else if (TOGGLE==
true) {out = OperatorType::outerprod(out,this->Id_1s(),Op_1s.
Q());}
306template<
typename Symmetry_,
size_t order>
308sign (std::size_t orb1, std::size_t orb2)
const
311 if (N_orbitals == 1) {Oout = this->F_1s(); Oout.
label()=
"sign";
return Oout;}
315 for (
int i=orb1; i<N_orbitals; ++i)
317 Oout = Oout * (2.*Sz(i));
319 for (
int i=0; i<orb2; ++i)
321 Oout = Oout * (2.*Sz(i));
323 Oout.
label() =
"sign";
328template<
typename Symmetry_,
size_t order>
329template <
typename Dummy>
378template<
typename Symmetry_,
size_t order>
379template <
typename Dummy>
387 out = this->exp_i_pi_Sz(); out.
label() =
"exp(i*Ï€*Sz)";
396template<
typename Symmetry_,
size_t order>
397template <
typename Dummy>
401 return make_operator(this->S_1s(),
orbital,
"S");
404template<
typename Symmetry_,
size_t order>
405template <
typename Dummy>
412template<
typename Symmetry_,
size_t order>
413template <
typename Dummy>
417 return make_operator(this->Q_1s(),
orbital,
"Q");
420template<
typename Symmetry_,
size_t order>
421template <
typename Dummy>
428template<
typename Symmetry_,
size_t order>
429template <
typename Dummy>
433 return make_operator(this->Qz_1s(),
orbital,
"Qz");
436template<
typename Symmetry_,
size_t order>
437template <
typename Dummy>
441 return make_operator(this->Qp_1s(),
orbital,
"Qp");
444template<
typename Symmetry_,
size_t order>
445template <
typename Dummy>
449 return make_operator(this->Qm_1s(),
orbital,
"Qm");
452template<
typename Symmetry_,
size_t order>
453template <
typename Dummy>
457 return make_operator(this->Qpz_1s(),
orbital,
"Qpz");
460template<
typename Symmetry_,
size_t order>
461template <
typename Dummy>
465 return make_operator(this->Qmz_1s(),
orbital,
"Qmz");
468template<
typename Symmetry_,
size_t order>
469template <
typename Dummy>
473 return make_operator(this->Sz_1s(),
orbital,
"Sz");
476template<
typename Symmetry_,
size_t order>
477template <
typename Dummy>
481 return make_operator(this->Sp_1s(),
orbital,
"Sp");
484template<
typename Symmetry_,
size_t order>
485template <
typename Dummy>
489 return make_operator(this->Sm_1s(),
orbital,
"Sm");
492template<
typename Symmetry_,
size_t order>
493template <
typename Dummy>
502template<
typename Symmetry_,
size_t order>
503template <
typename Dummy>
512template<
typename Symmetry_,
size_t order>
516 return make_operator(this->Id_1s(),
orbital,
"Id");
519template<
typename Symmetry_,
size_t order>
523 return make_operator(this->Zero_1s(),
orbital,
"Zero");
526template<
typename Symmetry_,
size_t order>
527template<
typename Scalar_>
533 for (
int i=0; i<N_orbitals; ++i)
534 for (
int j=0; j<N_orbitals; ++j)
538 if constexpr (Symmetry::IS_SPIN_SU2())
540 Oout += J(i,j)*std::sqrt(3.) * (OperatorType::prod(Sdag(i),S(j),Symmetry::qvacuum())).
template cast<Scalar_>();
544 Oout += J(i,j) * (OperatorType::prod(Sz(i),Sz(j),Symmetry::qvacuum())).
template cast<Scalar_>();
545 Oout += 0.5*J(i,j) * (OperatorType::prod(Sp(i),Sm(j),Symmetry::qvacuum()) + OperatorType::prod(Sm(i),Sp(j),Symmetry::qvacuum())).
template cast<Scalar_>();
550 for (
int i=0; i<N_orbitals; ++i)
552 if (Offset(i) != 0.) {Oout += Offset(i) * Id(i);}
555 Oout.
label() =
"Hloc";
559template<
typename Symmetry_,
size_t order>
560template<
typename Dummy>
562HeisenbergHamiltonian (
const ArrayXXd &Jxy,
const ArrayXXd &Jz,
const ArrayXd &Bz,
const ArrayXd &mu,
const ArrayXd &nu,
const ArrayXd &Kz)
const
564 assert(Bz.rows() == N_orbitals and Kz.rows() == N_orbitals);
568 for (
int i=0; i<N_orbitals; ++i)
569 for (
int j=0; j<N_orbitals; ++j)
573 Mout += 0.5*Jxy(i,j) * (Scomp(
SP,i) * Scomp(
SM,j) + Scomp(
SM,i) * Scomp(
SP,j));
577 Mout += Jz(i,j) * Scomp(
SZ,i)*Scomp(
SZ,j);
581 for (
int i=0; i<N_orbitals; ++i)
583 if (Bz(i) != 0.) {Mout -= Bz(i) * Scomp(
SZ,i);}
585 for (
int i=0; i<N_orbitals; ++i)
587 if (mu(i) != 0.) {Mout += mu(i) * (Scomp(
SZ,i)-0.5*Id());}
589 for (
int i=0; i<N_orbitals; ++i)
591 if (nu(i) != 0.) {Mout += nu(i) * (Scomp(
SZ,i)+0.5*Id());}
593 for (
int i=0; i<N_orbitals; ++i)
595 if (Kz(i)!=0.) {Mout += Kz(i) * Scomp(
SZ,i) * Scomp(
SZ,i);}
597 Mout.
label() =
"Hloc";
601template<
typename Symmetry_,
size_t order>
602template<
typename Dummy>
608 for (
int i=0; i<N_orbitals; ++i)
609 for (
int j=0; j<N_orbitals; ++j)
611 if (abs(Jxy(i,j)) != 0.)
613 Mout += 0.5 * (Jxy(i,j) * Scomp(
SP,i) * Scomp(
SM,j) + conj(Jxy(i,j)) * Scomp(
SM,i) * Scomp(
SP,j));
615 if (abs(Jz(i,j)) != 0.)
617 Mout += Jz(i,j) * Scomp(
SZ,i) * Scomp(
SZ,j);
620 Mout.
label() =
"Hloc";
624template<
typename Symmetry_,
size_t order>
625template<
typename Dummy>
628 const ArrayXd &Bz,
const ArrayXd &Bx,
629 const ArrayXd &mu,
const ArrayXd &nu,
630 const ArrayXd &Kz,
const ArrayXd &Kx,
631 const ArrayXXd &Dy)
const
633 assert(Bz.rows() == N_orbitals and Bx.rows() == N_orbitals and Kz.rows() == N_orbitals and Kx.rows() == N_orbitals);
635 OperatorType Mout = HeisenbergHamiltonian(Jxy, Jz, Bz, mu, nu, Kz);
637 for (
int i=0; i<N_orbitals; ++i)
638 for (
int j=0; j<i; ++j)
640 if (Dy(i,j) != 0.) {Mout += Dy(i,j) * (Scomp(
SX,i)*Scomp(
SZ,j) - Scomp(
SZ,i)*Scomp(
SX,j));}
642 for (
int i=0; i<N_orbitals; ++i)
644 if (Bx(i) != 0.) {Mout -= Bx(i) * Scomp(
SX,i);}
646 for (
int i=0; i<N_orbitals; ++i)
648 if (Kx(i)!=0.) {Mout += Kx(i) * Scomp(
SX,i) * Scomp(
SX,i);}
654template<
typename Symmetry_,
size_t order>
655template<
typename Scalar_,
typename Dummy>
657coupling_Bx (
const Array<double,Dynamic,1> &Bx)
const
659 SiteOperatorQ<Symmetry_,Eigen::Matrix<Scalar_,-1,-1> > Mout(Symmetry::qvacuum(), TensorBasis);
660 for (
int i=0; i<N_orbitals; ++i)
664 Mout -= Bx(i) * Sx(i).template cast<Scalar_>();
670template<
typename Symmetry_,
size_t order>
671template<
typename Dummy>
673coupling_By (
const Array<double,Dynamic,1> &By)
const
676 for (
int i=0; i<N_orbitals; ++i)
680 Mout -= -1i*By(i) * iSy(i).template cast<complex<double> >();
686template<
typename Symmetry_,
size_t order>
687template<
typename Dummy>
689HeisenbergHamiltonian (
const std::array<ArrayXXd,3> &J,
const std::array<ArrayXd,3> &
B,
const std::array<ArrayXd,3> &K,
const std::array<ArrayXXd,3> &D)
const
692 for (
int i=0; i<N_orbitals; ++i)
693 for (
int j=0; j<N_orbitals; ++j)
696 if (J[0](i,j) != 0.) {Mout += J[0](i,j) * (Sx(i) * Sx(j)).
template cast<complex<double>>();}
697 if (J[1](i,j) != 0.) {Mout += -J[1](i,j) * (iSy(i) * iSy(j)).
template cast<complex<double>>();}
698 if (J[2](i,j) != 0.) {Mout += J[2](i,j) * (Sz(i) * Sz(j)).
template cast<complex<double>>();}
701 if (D[0](i,j) != 0.) {Mout += D[0](i,j) * (-1.i) * (iSy(i) * Sz(j) - Sz(i) * iSy(j)).
template cast<complex<double> >();}
702 if (D[1](i,j) != 0.) {Mout += D[1](i,j) * (Sx(i) * Sz(j) - Sz(i) * Sx(j)).
template cast<complex<double> >();}
703 if (D[2](i,j) != 0.) {Mout += D[2](i,j) * (-1.i) * (Sx(i) * iSy(j) - iSy(i) * Sx(j)).
template cast<complex<double> >();}
706 for (
int i=0; i<N_orbitals; ++i)
709 if (
B[0](i) != 0.) {Mout -=
B[0](i) * Sx(i).template cast<complex<double> >();}
710 if (
B[1](i) != 0.) {Mout -=
B[1](i) * (-1.i) * iSy(i).template cast<complex<double> >();}
711 if (
B[2](i) != 0.) {Mout -=
B[2](i) * Sz(i).template cast<complex<double> >();}
714 if (K[0](i) != 0.) {Mout += K[0](i) * ( Sx(i) * Sx(i)).
template cast<complex<double> >();}
715 if (K[1](i) != 0.) {Mout -= K[1](i) * (iSy(i) * iSy(i)).
template cast<complex<double> >();}
716 if (K[2](i) != 0.) {Mout += K[2](i) * ( Sz(i) * Sz(i)).
template cast<complex<double> >();}
718 Mout.
label() =
"Hloc";
void push_back(const std::tuple< qType, Eigen::Index, std::vector< std::string > > &state)
std::enable_if< Dummy::IS_SPIN_SU2(), OperatorType >::type Sdag(size_t orbital=0) const
SiteOperatorQ< Symmetry, Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > > OperatorType
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type Qpz(size_t orbital=0) const
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type Sm(size_t orbital=0) const
SiteOperatorQ< Symmetry_, Eigen::Matrix< Scalar_,-1,-1 > > HeisenbergHamiltonian(const Array< Scalar_, Dynamic, Dynamic > &J, const ArrayXd &Offset) const
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type Sp(size_t orbital=0) const
std::enable_if< Dummy::NO_SPIN_SYM(), SiteOperatorQ< Symmetry_, Eigen::Matrix< Scalar_,-1,-1 > > >::type coupling_Bx(const Array< double, Dynamic, 1 > &Bx) const
std::size_t orbitals() const
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type Qp(size_t orbital=0) const
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type Qm(size_t orbital=0) const
std::enable_if< Dummy::IS_SPIN_SU2(), OperatorType >::type bead(STRING STR, size_t orbital=0) const
SiteOperatorQ< Symmetry, Eigen::Matrix< complex< Scalar >, Eigen::Dynamic, Eigen::Dynamic > > ComplexOperatorType
OperatorType Zero(std::size_t orbital=0) const
Qbasis< Symmetry > get_basis() const
ArrayXXd ZeroHopping() const
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type bead(STRING STR, size_t orbital=0) const
std::enable_if< Dummy::IS_SPIN_SU2(), OperatorType >::type Qdag(size_t orbital=0) const
std::enable_if< Dummy::IS_SPIN_SU2(), OperatorType >::type Q(size_t orbital=0) const
OperatorType Id(std::size_t orbital=0) const
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type Qcomp(SPINOP_LABEL Sa, int orbital=0) const
OperatorType sign(std::size_t orb1=0, std::size_t orb2=0) const
Qbasis< Symmetry > TensorBasis
std::enable_if< Dummy::NO_SPIN_SYM(), OperatorType >::type Sx(size_t orbital=0) const
std::enable_if< Dummy::IS_SPIN_SU2(), OperatorType >::type S(size_t orbital=0) const
std::enable_if<!Dummy::IS_SPIN_SU2(), ComplexOperatorType >::type exp_ipiSz(size_t orbital=0) const
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type n(std::size_t orbital=0) const
std::enable_if< Dummy::NO_SPIN_SYM(), OperatorType >::type iSy(size_t orbital=0) const
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type Qmz(size_t orbital=0) const
ArrayXd ZeroField() const
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type Scomp(SPINOP_LABEL Sa, int orbital=0) const
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type Qz(size_t orbital=0) const
OperatorType make_operator(const OperatorType &Op_1s, size_t orbital=0, string label="") const
std::enable_if< Dummy::NO_SPIN_SYM(), SiteOperatorQ< Symmetry_, Eigen::Matrix< complex< double >,-1,-1 > > >::type coupling_By(const Array< double, Dynamic, 1 > &By) const
std::enable_if<!Dummy::IS_SPIN_SU2(), SiteOperatorQ< Symmetry, Eigen::MatrixXcd > >::type Rcomp(SPINOP_LABEL Sa, int orbital=0) const
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type Sz(size_t orbital=0) const
Qbasis< Symmetry > basis_1s() const