1#ifndef XPED_SPINBASE_HPP_
2#define XPED_SPINBASE_HPP_
21template <
typename Symmetry_, std::
size_t order = 0>
24 using Scalar = double;
30 using qType =
typename Symmetry::qType;
38 SpinBase(std::size_t L_input, std::size_t D_input);
41 inline std::size_t
dim()
const {
return N_states; }
44 inline std::size_t
orbitals()
const {
return N_orbitals; }
47 inline std::size_t
get_D()
const {
return this->
D; }
60 template <
class Dummy = Symmetry>
61 typename std::enable_if<!Dummy::IS_SPIN_SU2(),
OperatorType>::type
n(std::size_t orbital = 0)
const;
68 template <
class Dummy = Symmetry>
69 typename std::enable_if<Dummy::IS_SPIN_SU2(),
OperatorType>::type
S(std::size_t orbital = 0)
const;
75 template <
class Dummy = Symmetry>
76 typename std::enable_if<Dummy::IS_SPIN_SU2(),
OperatorType>::type
Sdag(std::size_t orbital = 0)
const;
78 template <
class Dummy = Symmetry>
79 typename std::enable_if<Dummy::IS_SPIN_SU2(),
OperatorType>::type
Q(std::size_t orbital = 0)
const;
81 template <
class Dummy = Symmetry>
82 typename std::enable_if<Dummy::IS_SPIN_SU2(),
OperatorType>::type
Qdag(std::size_t orbital = 0)
const;
84 template <
class Dummy = Symmetry>
85 typename std::enable_if<!Dummy::IS_SPIN_SU2(),
OperatorType>::type
Qz(std::size_t orbital = 0)
const;
87 template <
class Dummy = Symmetry>
88 typename std::enable_if<!Dummy::IS_SPIN_SU2(),
OperatorType>::type
Qp(std::size_t orbital = 0)
const;
90 template <
class Dummy = Symmetry>
91 typename std::enable_if<!Dummy::IS_SPIN_SU2(),
OperatorType>::type
Qm(std::size_t orbital = 0)
const;
93 template <
class Dummy = Symmetry>
94 typename std::enable_if<!Dummy::IS_SPIN_SU2(),
OperatorType>::type
Qpz(std::size_t orbital = 0)
const;
96 template <
class Dummy = Symmetry>
97 typename std::enable_if<!Dummy::IS_SPIN_SU2(),
OperatorType>::type
Qmz(std::size_t orbital = 0)
const;
99 template <
class Dummy = Symmetry>
100 typename std::enable_if<!Dummy::IS_SPIN_SU2(),
OperatorType>::type
Sz(std::size_t orbital = 0)
const;
102 template <
class Dummy = Symmetry>
103 typename std::enable_if<!Dummy::IS_SPIN_SU2(),
OperatorType>::type
Sp(std::size_t orbital = 0)
const;
105 template <
class Dummy = Symmetry>
106 typename std::enable_if<!Dummy::IS_SPIN_SU2(),
OperatorType>::type
Sm(std::size_t orbital = 0)
const;
108 template <
class Dummy = Symmetry>
109 typename std::enable_if<Dummy::NO_SPIN_SYM(),
OperatorType>::type
Sx(std::size_t orbital = 0)
const;
111 template <
class Dummy = Symmetry>
112 typename std::enable_if<Dummy::NO_SPIN_SYM(),
OperatorTypeC>::type
Sy(std::size_t orbital = 0)
const;
114 template <
class Dummy = Symmetry>
115 typename std::enable_if<Dummy::NO_SPIN_SYM(),
OperatorType>::type
iSy(std::size_t orbital = 0)
const;
117 template <
class Dummy = Symmetry>
118 typename std::enable_if<!Dummy::IS_SPIN_SU2(),
OperatorType>::type
Scomp(SPINOP_LABEL Sa,
int orbital = 0)
const
120 assert(Sa != SPINOP_LABEL::SY and Sa != SPINOP_LABEL::QP and Sa != SPINOP_LABEL::QM and Sa != SPINOP_LABEL::QPZ and Sa != SPINOP_LABEL::QMZ);
122 if constexpr(Dummy::NO_SPIN_SYM()) {
123 if(Sa == SPINOP_LABEL::SX) {
125 }
else if(Sa == SPINOP_LABEL::iSY) {
127 }
else if(Sa == SPINOP_LABEL::SZ) {
129 }
else if(Sa == SPINOP_LABEL::SP) {
131 }
else if(Sa == SPINOP_LABEL::SM) {
135 assert(Sa != SPINOP_LABEL::SX and Sa != SPINOP_LABEL::iSY);
136 if(Sa == SPINOP_LABEL::SZ) {
138 }
else if(Sa == SPINOP_LABEL::SP) {
140 }
else if(Sa == SPINOP_LABEL::SM) {
147 template <
class Dummy = Symmetry>
148 typename std::enable_if<!Dummy::IS_SPIN_SU2(),
OperatorType>::type
Qcomp(SPINOP_LABEL Sa,
int orbital = 0)
const
150 assert(Sa != SPINOP_LABEL::SX and Sa != SPINOP_LABEL::SY and Sa != SPINOP_LABEL::iSY and Sa != SPINOP_LABEL::SZ and Sa != SPINOP_LABEL::SP and
151 Sa != SPINOP_LABEL::SM);
153 if(Sa == SPINOP_LABEL::QZ) {
155 }
else if(Sa == SPINOP_LABEL::QP) {
157 }
else if(Sa == SPINOP_LABEL::QM) {
159 }
else if(Sa == SPINOP_LABEL::QPZ) {
161 }
else if(Sa == SPINOP_LABEL::QMZ) {
259 std::size_t N_orbitals;
260 std::size_t N_states;
265template <
typename Symmetry_, std::
size_t order>
268 , N_orbitals(L_input)
271 typename Symmetry::qType
Q = Symmetry::qvacuum();
272 Eigen::Index inner_dim = 1;
283 if(N_orbitals == 1) {
285 }
else if(N_orbitals == 0) {
286 TensorBasis = vacuum;
289 for(std::size_t o = 2; o < N_orbitals; o++) { TensorBasis = TensorBasis.
combine(this->
basis_1s()).forgetHistory(); }
292 N_states = TensorBasis.
dim();
295template <
typename Symmetry_, std::
size_t order>
299 if(N_orbitals == 1) {
304 OperatorType stringOp = this->Id_1s();
308 out = OperatorType::outerprod(Op_1s, this->Id_1s(), Op_1s.Q);
312 out = OperatorType::outerprod(stringOp, Op_1s, Op_1s.Q);
315 out = OperatorType::outerprod(stringOp, stringOp, Symmetry_::qvacuum());
318 for(std::size_t o = 2; o < N_orbitals; o++) {
320 out = OperatorType::outerprod(out, Op_1s, Op_1s.Q);
322 }
else if(TOGGLE ==
false) {
323 out = OperatorType::outerprod(out, stringOp, Symmetry_::qvacuum());
324 }
else if(TOGGLE ==
true) {
325 out = OperatorType::outerprod(out, this->Id_1s(), Op_1s.Q);
333template <
typename Symmetry_, std::
size_t order>
337 if(N_orbitals == 1) {
339 Oout.
label() =
"sign";
343 for(
int i = orb1; i < N_orbitals; ++i) { Oout = Oout * (2. * Sz(i)); }
344 for(
int i = 0; i < orb2; ++i) { Oout = Oout * (2. * Sz(i)); }
345 Oout.
label() =
"sign";
350template <
typename Symmetry_, std::
size_t order>
351template <
typename Dummy>
385template <
typename Symmetry_, std::
size_t order>
386template <
typename Dummy>
389 return make_operator(this->S_1s(), orbital,
"S");
392template <
typename Symmetry_, std::
size_t order>
393template <
typename Dummy>
396 return S(orbital).adjoint();
399template <
typename Symmetry_, std::
size_t order>
400template <
typename Dummy>
403 return make_operator(this->Q_1s(), orbital,
"Q");
406template <
typename Symmetry_, std::
size_t order>
407template <
typename Dummy>
410 return Q(orbital).adjoint();
413template <
typename Symmetry_, std::
size_t order>
414template <
typename Dummy>
417 return make_operator(this->Qz_1s(), orbital,
"Qz");
420template <
typename Symmetry_, std::
size_t order>
421template <
typename Dummy>
424 return make_operator(this->Qp_1s(), orbital,
"Qp");
427template <
typename Symmetry_, std::
size_t order>
428template <
typename Dummy>
431 return make_operator(this->Qm_1s(), orbital,
"Qm");
434template <
typename Symmetry_, std::
size_t order>
435template <
typename Dummy>
438 return make_operator(this->Qpz_1s(), orbital,
"Qpz");
441template <
typename Symmetry_, std::
size_t order>
442template <
typename Dummy>
445 return make_operator(this->Qmz_1s(), orbital,
"Qmz");
448template <
typename Symmetry_, std::
size_t order>
449template <
typename Dummy>
452 return make_operator(this->Sz_1s(), orbital,
"Sz");
455template <
typename Symmetry_, std::
size_t order>
456template <
typename Dummy>
459 return make_operator(this->Sp_1s(), orbital,
"Sp");
462template <
typename Symmetry_, std::
size_t order>
463template <
typename Dummy>
466 return make_operator(this->Sm_1s(), orbital,
"Sm");
469template <
typename Symmetry_, std::
size_t order>
470template <
typename Dummy>
478template <
typename Symmetry, std::
size_t order>
479template <
typename Dummy>
483 using namespace std::complex_literals;
489template <
typename Symmetry_, std::
size_t order>
490template <
typename Dummy>
498template <
typename Symmetry_, std::
size_t order>
501 return make_operator(this->Id_1s(), orbital,
"Id");
504template <
typename Symmetry_, std::
size_t order>
507 return make_operator(this->Zero_1s(), orbital,
"Zero");
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
Definition: SpinBase.hpp:23
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type Qp(std::size_t orbital=0) const
Definition: SpinBase.hpp:422
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type Qm(std::size_t orbital=0) const
Definition: SpinBase.hpp:429
std::enable_if< Dummy::IS_SPIN_SU2(), OperatorType >::type Q(std::size_t orbital=0) const
Definition: SpinBase.hpp:401
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type Qcomp(SPINOP_LABEL Sa, int orbital=0) const
Definition: SpinBase.hpp:148
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type Qz(std::size_t orbital=0) const
Definition: SpinBase.hpp:415
OperatorType Zero(std::size_t orbital=0) const
Definition: SpinBase.hpp:505
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type Scomp(SPINOP_LABEL Sa, int orbital=0) const
Definition: SpinBase.hpp:118
std::enable_if< Dummy::IS_SPIN_SU2(), OperatorType >::type S(std::size_t orbital=0) const
Definition: SpinBase.hpp:387
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type Sz(std::size_t orbital=0) const
Definition: SpinBase.hpp:450
std::size_t dim() const
Definition: SpinBase.hpp:41
std::size_t orbitals() const
Definition: SpinBase.hpp:44
std::size_t get_D() const
Definition: SpinBase.hpp:47
Symmetry_ Symmetry
Definition: SpinBase.hpp:27
std::enable_if< Dummy::IS_SPIN_SU2(), OperatorType >::type Qdag(std::size_t orbital=0) const
Definition: SpinBase.hpp:408
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type Qmz(std::size_t orbital=0) const
Definition: SpinBase.hpp:443
std::enable_if< Dummy::NO_SPIN_SYM(), OperatorTypeC >::type Sy(std::size_t orbital=0) const
Definition: SpinBase.hpp:481
typename Symmetry::qType qType
Definition: SpinBase.hpp:30
std::enable_if< Dummy::NO_SPIN_SYM(), OperatorType >::type iSy(std::size_t orbital=0) const
Definition: SpinBase.hpp:491
OperatorType Id(std::size_t orbital=0) const
Definition: SpinBase.hpp:499
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type Qpz(std::size_t orbital=0) const
Definition: SpinBase.hpp:436
std::enable_if< Dummy::NO_SPIN_SYM(), OperatorType >::type Sx(std::size_t orbital=0) const
Definition: SpinBase.hpp:471
OperatorType sign(std::size_t orb1=0, std::size_t orb2=0) const
Definition: SpinBase.hpp:334
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type Sp(std::size_t orbital=0) const
Definition: SpinBase.hpp:457
SiteOperator< Scalar, Symmetry > OperatorType
Definition: SpinBase.hpp:28
SpinBase(std::size_t L_input, std::size_t D_input)
Definition: SpinBase.hpp:266
Qbasis< Symmetry, 1 > get_basis() const
Definition: SpinBase.hpp:255
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type n(std::size_t orbital=0) const
Definition: SpinBase.hpp:352
std::enable_if< Dummy::IS_SPIN_SU2(), OperatorType >::type Sdag(std::size_t orbital=0) const
Definition: SpinBase.hpp:394
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type Sm(std::size_t orbital=0) const
Definition: SpinBase.hpp:464
Qbasis< Symmetry, 1 > basis_1s() const
Definition: Spin.hpp:48
std::size_t D
Definition: Spin.hpp:51
std::string & label()
Definition: SiteOperator.hpp:85