1#ifndef XPED_FERMIONBASE_HPP_
2#define XPED_FERMIONBASE_HPP_
23template <
typename Symmetry_>
26 using Scalar = double;
32 using qType =
typename Symmetry::qType;
39 FermionBase(std::size_t L_input,
bool REMOVE_DOUBLE =
false,
bool REMVOVE_EMPTY =
false,
bool REMOVE_SINGLE =
false);
42 inline std::size_t
dim()
const {
return N_states; }
45 inline std::size_t
orbitals()
const {
return N_orbitals; }
60 template <
class Dummy = Symmetry>
61 typename std::enable_if<Dummy::IS_SPIN_SU2() and !Dummy::IS_CHARGE_SU2(),
OperatorType>::type
c(std::
size_t orbital = 0) const;
64 typename std::enable_if<!Dummy::IS_SPIN_SU2() and !Dummy::IS_CHARGE_SU2(),
OperatorType>::type
c(SPIN_INDEX sigma, std::
size_t orbital = 0) const;
67 typename std::enable_if<Dummy::IS_CHARGE_SU2() and !Dummy::IS_SPIN_SU2(),
OperatorType>::type
71 typename std::enable_if<Dummy::IS_CHARGE_SU2() and Dummy::IS_SPIN_SU2(),
OperatorType>::type
c(
SUB_LATTICE G, std::
size_t orbital = 0) const;
87 typename std::enable_if<Dummy::IS_SPIN_SU2() and !Dummy::IS_CHARGE_SU2(),
OperatorType>::type
cdag(std::
size_t orbital = 0) const;
90 typename std::enable_if<!Dummy::IS_SPIN_SU2() and !Dummy::IS_CHARGE_SU2(),
OperatorType>::type
cdag(SPIN_INDEX sigma,
91 std::
size_t orbital = 0) const;
94 typename std::enable_if<Dummy::IS_CHARGE_SU2() and !Dummy::IS_SPIN_SU2(),
OperatorType>::type
98 typename std::enable_if<Dummy::IS_CHARGE_SU2() and Dummy::IS_SPIN_SU2(),
OperatorType>::type
cdag(
SUB_LATTICE G, std::
size_t orbital = 0) const;
118 typename std::enable_if<true,
OperatorType>::type
n(std::
size_t orbital = 0) const;
121 typename std::enable_if<!Dummy::IS_SPIN_SU2(),
OperatorType>::type
n(SPIN_INDEX sigma, std::
size_t orbital = 0) const;
128 typename std::enable_if<!Dummy::IS_CHARGE_SU2(),
OperatorType>::type
d(std::
size_t orbital = 0) const;
149 typename std::enable_if<Dummy::IS_SPIN_SU2(),
OperatorType>::type
S(std::
size_t orbital = 0) const;
156 typename std::enable_if<Dummy::IS_SPIN_SU2(),
OperatorType>::type
Sdag(std::
size_t orbital = 0) const;
159 typename std::enable_if<!Dummy::IS_SPIN_SU2(),
OperatorType>::type
Sz(std::
size_t orbital = 0) const;
162 typename std::enable_if<!Dummy::IS_SPIN_SU2(),
OperatorType>::type
Sp(std::
size_t orbital = 0) const;
165 typename std::enable_if<!Dummy::IS_SPIN_SU2(),
OperatorType>::type
Sm(std::
size_t orbital = 0) const;
168 typename std::enable_if<Dummy::NO_SPIN_SYM(),
OperatorType>::type
Sx(std::
size_t orbital = 0) const;
171 typename std::enable_if<Dummy::NO_SPIN_SYM(),
OperatorTypeC>::type
Sy(std::
size_t orbital = 0) const;
174 typename std::enable_if<Dummy::NO_SPIN_SYM(),
OperatorType>::type
iSy(std::
size_t orbital = 0) const;
177 typename std::enable_if<!Dummy::IS_SPIN_SU2(),
OperatorType>::type
Scomp(SPINOP_LABEL Sa,
int orbital)
const
179 assert(Sa != SPINOP_LABEL::SY);
181 if constexpr(Dummy::NO_SPIN_SYM()) {
182 if(Sa == SPINOP_LABEL::SX) {
184 }
else if(Sa == SPINOP_LABEL::iSY) {
186 }
else if(Sa == SPINOP_LABEL::SZ) {
188 }
else if(Sa == SPINOP_LABEL::SP) {
190 }
else if(Sa == SPINOP_LABEL::SM) {
194 if(Sa == SPINOP_LABEL::SZ) {
196 }
else if(Sa == SPINOP_LABEL::SP) {
198 }
else if(Sa == SPINOP_LABEL::SM) {
214 template <
class Dummy = Symmetry>
215 typename std::enable_if<Dummy::IS_CHARGE_SU2(),
OperatorType>::type
T(std::size_t orbital = 0)
const;
221 template <
class Dummy = Symmetry>
222 typename std::enable_if<Dummy::IS_CHARGE_SU2(),
OperatorType>::type
Tdag(std::size_t orbital = 0)
const;
228 template <
class Dummy = Symmetry>
229 typename std::enable_if<!Dummy::IS_CHARGE_SU2(),
OperatorType>::type
Tz(std::size_t orbital = 0)
const;
235 template <
class Dummy = Symmetry>
242 template <
class Dummy = Symmetry>
245 template <
class Dummy = Symmetry>
248 double factor =
static_cast<double>(
static_cast<int>(G));
249 return factor *
cc(orbital);
252 template <
class Dummy = Symmetry>
255 double factor =
static_cast<double>(
static_cast<int>(G));
264 template <
class Dummy = Symmetry>
265 typename std::enable_if<!Dummy::IS_CHARGE_SU2(),
OperatorType>::type
cc(std::size_t orbital = 0)
const;
271 template <
class Dummy = Symmetry>
357 OperatorType make_operator(
const OperatorType& Op_1s, std::size_t orbital = 0,
bool FERMIONIC =
false, std::string label =
"")
const;
358 std::size_t N_orbitals;
359 std::size_t N_states;
367template <
typename Symmetry>
370 , N_orbitals(L_input)
373 qType Q = Symmetry::qvacuum();
384 if(N_orbitals == 1) {
386 }
else if(N_orbitals == 0) {
387 TensorBasis = vacuum;
390 for(std::size_t o = 2; o < N_orbitals; o++) { TensorBasis = TensorBasis.
combine(this->
basis_1s()).forgetHistory(); }
393 N_states = TensorBasis.
dim();
396template <
typename Symmetry>
400 assert(orbital < N_orbitals);
402 if(N_orbitals == 1) {
406 }
else if(N_orbitals == 0) {
409 OperatorType stringOp;
411 stringOp = this->Id_1s();
413 stringOp = this->Id_1s();
417 out = OperatorType::outerprod(Op_1s, this->Id_1s(), Op_1s.Q);
421 out = OperatorType::outerprod(stringOp, Op_1s, Op_1s.Q);
424 out = OperatorType::outerprod(stringOp, stringOp, Symmetry::qvacuum());
427 for(std::size_t o = 2; o < N_orbitals; o++) {
429 out = OperatorType::outerprod(out, Op_1s, Op_1s.Q);
431 }
else if(TOGGLE ==
false) {
432 out = OperatorType::outerprod(out, stringOp, Symmetry::qvacuum());
433 }
else if(TOGGLE ==
true) {
434 out = OperatorType::outerprod(out, this->Id_1s(), Op_1s.Q);
442template <
typename Symmetry>
443template <
typename Dummy>
444typename std::enable_if<Dummy::IS_SPIN_SU2() and !Dummy::IS_CHARGE_SU2(), SiteOperator<
double, Symmetry>>::type
450template <
typename Symmetry>
451template <
typename Dummy>
452typename std::enable_if<Dummy::IS_SPIN_SU2() and !Dummy::IS_CHARGE_SU2(),
SiteOperator<
double, Symmetry>>::type
455 return c(orbital).adjoint();
458template <
typename Symmetry>
459template <
typename Dummy>
460typename std::enable_if<!Dummy::IS_SPIN_SU2() and !Dummy::IS_CHARGE_SU2(),
SiteOperator<
double, Symmetry>>::type
463 std::stringstream ss;
465 return make_operator(this->c_1s(sigma), orbital,
PROP::FERMIONIC, ss.str());
468template <
typename Symmetry>
469template <
typename Dummy>
470typename std::enable_if<!Dummy::IS_SPIN_SU2() and !Dummy::IS_CHARGE_SU2(),
SiteOperator<
double, Symmetry>>::type
474 std::stringstream ss;
475 ss <<
"c†" << sigma;
476 return make_operator(this->cdag_1s(sigma), orbital,
PROP::FERMIONIC, ss.str());
479template <
typename Symmetry>
480template <
typename Dummy>
481typename std::enable_if<Dummy::IS_CHARGE_SU2() and !Dummy::IS_SPIN_SU2(),
SiteOperator<
double, Symmetry>>::type
484 std::stringstream ss;
485 return make_operator(this->c_1s(sigma, G), orbital,
PROP::FERMIONIC, ss.str());
488template <
typename Symmetry>
489template <
typename Dummy>
490typename std::enable_if<Dummy::IS_CHARGE_SU2() and !Dummy::IS_SPIN_SU2(),
SiteOperator<
double, Symmetry>>::type
493 return c(sigma, G, orbital).adjoint();
496template <
typename Symmetry>
497template <
typename Dummy>
498typename std::enable_if<Dummy::IS_CHARGE_SU2() and Dummy::IS_SPIN_SU2(),
SiteOperator<
double, Symmetry>>::type
501 std::stringstream ss;
503 return make_operator(this->c_1s(G), orbital,
PROP::FERMIONIC, ss.str());
506template <
typename Symmetry>
507template <
typename Dummy>
508typename std::enable_if<Dummy::IS_CHARGE_SU2() and Dummy::IS_SPIN_SU2(),
SiteOperator<
double, Symmetry>>::type
511 return c(G, orbital).adjoint();
514template <
typename Symmetry>
520template <
typename Symmetry>
524 if(N_orbitals == 1) {
526 Oout.
label() =
"sign";
528 }
else if(N_orbitals == 0) {
532 for(
int i = orb1; i < N_orbitals; ++i) { Oout = Oout * (nh(i) - ns(i)); }
533 for(
int i = 0; i < orb2; ++i) { Oout = Oout * (nh(i) - ns(i)); }
534 Oout.
label() =
"sign";
539template <
typename Symmetry>
540template <
typename Dummy>
546template <
typename Symmetry>
547template <
typename Dummy>
549 std::size_t orbital)
const
551 std::stringstream ss;
556template <
typename Symmetry>
562template <
typename Symmetry>
568template <
typename Symmetry>
569template <
typename Dummy>
599template <
typename Symmetry>
600template <
typename Dummy>
606template <
typename Symmetry>
607template <
typename Dummy>
610 return S(orbital).adjoint();
613template <
typename Symmetry>
614template <
typename Dummy>
620template <
typename Symmetry>
621template <
typename Dummy>
627template <
typename Symmetry>
628template <
typename Dummy>
634template <
typename Symmetry>
635template <
typename Dummy>
643template <
typename Symmetry>
644template <
typename Dummy>
647 using namespace std::complex_literals;
653template <
typename Symmetry>
654template <
typename Dummy>
662template <
typename Symmetry>
663template <
typename Dummy>
669template <
typename Symmetry>
670template <
typename Dummy>
673 return T(orbital).adjoint();
676template <
typename Symmetry>
677template <
typename Dummy>
683template <
typename Symmetry>
684template <
typename Dummy>
703template <
typename Symmetry>
704template <
typename Dummy>
708 out.
label() =
"Tz=1/2*(n-Id)";
712template <
typename Symmetry>
713template <
typename Dummy>
717 OperatorType out = 0.5 * (Tp(orbital, G) + Tm(orbital, G));
722template <
typename Symmetry>
723template <
typename Dummy>
727 OperatorType out = 0.5 * (Tp(orbital, G) - Tm(orbital, G));
732template <
typename Symmetry>
Definition: FermionBase.hpp:25
std::enable_if< Dummy::NO_SPIN_SYM(), OperatorType >::type iSy(std::size_t orbital=0) const
Definition: FermionBase.hpp:655
std::enable_if< Dummy::IS_CHARGE_SU2(), OperatorType >::type Tdag(std::size_t orbital=0) const
Definition: FermionBase.hpp:671
SiteOperator< Scalar, Symmetry > OperatorType
Definition: FermionBase.hpp:30
std::size_t orbitals() const
Definition: FermionBase.hpp:45
std::enable_if< Dummy::IS_SPIN_SU2(), OperatorType >::type Sdag(std::size_t orbital=0) const
Definition: FermionBase.hpp:608
std::enable_if< Dummy::IS_SPIN_SU2(), OperatorType >::type S(std::size_t orbital=0) const
Definition: FermionBase.hpp:601
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type Scomp(SPINOP_LABEL Sa, int orbital) const
Definition: FermionBase.hpp:177
OperatorType Id(std::size_t orbital=0) const
Definition: FermionBase.hpp:733
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type Sz(std::size_t orbital=0) const
Definition: FermionBase.hpp:615
OperatorType ns(std::size_t orbital=0) const
Definition: FermionBase.hpp:557
std::enable_if<!Dummy::IS_CHARGE_SU2(), OperatorType >::type Tm(std::size_t orbital=0, SUB_LATTICE G=A) const
Definition: FermionBase.hpp:253
std::enable_if< Dummy::IS_SPIN_SU2() and!Dummy::IS_CHARGE_SU2(), OperatorType >::type cdag(std::size_t orbital=0) const
Definition: FermionBase.hpp:453
std::enable_if< Dummy::NO_CHARGE_SYM(), OperatorType >::type iTy(std::size_t orbital=0, SUB_LATTICE G=A) const
Definition: FermionBase.hpp:724
std::enable_if<!Dummy::IS_CHARGE_SU2(), OperatorType >::type cdagcdag(std::size_t orbital=0) const
Definition: FermionBase.hpp:685
std::enable_if< true, OperatorType >::type n(std::size_t orbital=0) const
Definition: FermionBase.hpp:541
std::enable_if< Dummy::IS_CHARGE_SU2(), OperatorType >::type T(std::size_t orbital=0) const
Definition: FermionBase.hpp:664
OperatorType sign(std::size_t orb1=0, std::size_t orb2=0) const
Definition: FermionBase.hpp:521
Symmetry_ Symmetry
Definition: FermionBase.hpp:29
std::enable_if< Dummy::NO_SPIN_SYM(), OperatorTypeC >::type Sy(std::size_t orbital=0) const
Definition: FermionBase.hpp:645
std::enable_if< Dummy::IS_SPIN_SU2() and!Dummy::IS_CHARGE_SU2(), OperatorType >::type c(std::size_t orbital=0) const
Definition: FermionBase.hpp:445
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type Sp(std::size_t orbital=0) const
Definition: FermionBase.hpp:622
std::enable_if<!Dummy::IS_CHARGE_SU2(), OperatorType >::type Tp(std::size_t orbital=0, SUB_LATTICE G=A) const
Definition: FermionBase.hpp:246
FermionBase(std::size_t L_input, bool REMOVE_DOUBLE=false, bool REMVOVE_EMPTY=false, bool REMOVE_SINGLE=false)
Definition: FermionBase.hpp:368
OperatorType nh(std::size_t orbital=0) const
Definition: FermionBase.hpp:563
OperatorType sign_local(std::size_t orbital=0) const
Definition: FermionBase.hpp:515
std::enable_if<!Dummy::IS_CHARGE_SU2(), OperatorType >::type d(std::size_t orbital=0) const
Definition: FermionBase.hpp:570
std::size_t dim() const
Definition: FermionBase.hpp:42
std::enable_if<!Dummy::IS_CHARGE_SU2(), OperatorType >::type Tz(std::size_t orbital=0) const
Definition: FermionBase.hpp:705
std::enable_if< Dummy::NO_SPIN_SYM(), OperatorType >::type Sx(std::size_t orbital=0) const
Definition: FermionBase.hpp:636
std::enable_if<!Dummy::IS_CHARGE_SU2(), OperatorType >::type cc(std::size_t orbital=0) const
Definition: FermionBase.hpp:678
Qbasis< Symmetry, 1 > get_basis() const
Definition: FermionBase.hpp:354
std::enable_if< Dummy::NO_CHARGE_SYM(), OperatorType >::type Tx(std::size_t orbital=0, SUB_LATTICE G=A) const
Definition: FermionBase.hpp:714
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type Sm(std::size_t orbital=0) const
Definition: FermionBase.hpp:629
typename Symmetry::qType qType
Definition: FermionBase.hpp:32
Definition: Fermion.hpp:21
Qbasis< Symmetry, 1 > basis_1s() const
Definition: Fermion.hpp:63
Definition: Qbasis.hpp:39
void push_back(const qType &q, const size_t &inner_dim)
Definition: Qbasis.cpp:32
Qbasis< Symmetry, depth+1, AllocationPolicy > combine(const Qbasis< Symmetry, 1, AllocationPolicy > &other, bool CONJ=false) const
Definition: Qbasis.cpp:439
std::size_t dim() const
Definition: Qbasis.hpp:75
constexpr bool FERMIONIC
Definition: Properties.hpp:10
constexpr bool NON_FERMIONIC
Definition: Properties.hpp:11
SUB_LATTICE
Definition: SubLattice.hpp:9
@ A
Definition: SubLattice.hpp:10
void setZero()
Definition: SiteOperator.hpp:62
std::string & label()
Definition: SiteOperator.hpp:85
void setIdentity()
Definition: SiteOperator.hpp:63