1#ifndef XPED_FERMIONSITE_HPP_
2#define XPED_FERMIONSITE_HPP_
4#include "fmt/ostream.h"
19template <
typename Symmetry_>
22 using Scalar = double;
23 using Symmetry = Symmetry_;
25 using qType =
typename Symmetry::qType;
29 Fermion(
bool REMOVE_DOUBLE,
bool REMOVE_EMPTY,
bool REMOVE_SINGLE,
bool CONSIDER_SPIN =
true,
bool CONSIDER_CHARGE =
true);
36 if(sigma == SPIN_INDEX::UP) {
return cup_1s_; }
41 if(sigma == SPIN_INDEX::UP) {
return cdagup_1s_; }
48 if(sigma == SPIN_INDEX::UP) {
return nup_1s_; }
66 void fill_basis(
bool REMOVE_DOUBLE,
bool REMOVE_EMPTY,
bool REMOVE_SINGLE);
67 void fill_SiteOps(
bool REMOVE_DOUBLE,
bool REMOVE_EMPTY,
bool REMOVE_SINGLE);
69 qType
getQ(SPIN_INDEX sigma,
int Delta)
const;
70 qType
getQ(SPINOP_LABEL Sa)
const;
73 std::unordered_map<std::string, std::pair<qType, std::size_t>>
labels;
104template <
typename Symmetry_>
109 for(std::size_t q = 0; q < Symmetry::Nq; ++q) {
110 if(Symmetry::IS_SPIN[q]) {
119 if(CONSIDER_CHARGE) {
120 for(std::size_t q = 0; q < Symmetry::Nq; ++q) {
121 if(Symmetry::IS_FERMIONIC[q] or Symmetry::IS_BOSONIC[q]) {
130 fill_basis(REMOVE_DOUBLE, REMOVE_EMPTY, REMOVE_SINGLE);
132 fill_SiteOps(REMOVE_DOUBLE, REMOVE_EMPTY, REMOVE_SINGLE);
135template <
typename Symmetry_>
139 Id_1s_ =
OperatorType(Symmetry::qvacuum(), basis_1s_, labels);
140 F_1s_ =
OperatorType(Symmetry::qvacuum(), basis_1s_, labels);
142 cup_1s_ =
OperatorType(getQ(SPIN_INDEX::UP, -1), basis_1s_, labels);
144 cdn_1s_ =
OperatorType(getQ(SPIN_INDEX::DN, -1), basis_1s_, labels);
147 cdagup_1s_ =
OperatorType(getQ(SPIN_INDEX::UP, +1), basis_1s_, labels);
148 cdagdn_1s_ =
OperatorType(getQ(SPIN_INDEX::DN, +1), basis_1s_, labels);
150 n_1s_ =
OperatorType(Symmetry::qvacuum(), basis_1s_, labels);
151 nup_1s_ =
OperatorType(Symmetry::qvacuum(), basis_1s_, labels);
152 ndn_1s_ =
OperatorType(Symmetry::qvacuum(), basis_1s_, labels);
153 d_1s_ =
OperatorType(Symmetry::qvacuum(), basis_1s_, labels);
155 Sz_1s_ =
OperatorType(getQ(SPINOP_LABEL::SZ), basis_1s_, labels);
157 Sp_1s_ =
OperatorType(getQ(SPINOP_LABEL::SP), basis_1s_, labels);
159 Sm_1s_ =
OperatorType(getQ(SPINOP_LABEL::SM), basis_1s_, labels);
162 cc_1s_ =
OperatorType(getQ(SPIN_INDEX::UPDN, -1), basis_1s_, labels);
163 cdagcdag_1s_ =
OperatorType(getQ(SPIN_INDEX::UPDN, +1), basis_1s_, labels);
165 Id_1s_.setIdentity();
169 if(!REMOVE_EMPTY) F_1s_(
"empty",
"empty") = 1.;
170 if(!REMOVE_DOUBLE) F_1s_(
"double",
"double") = 1.;
172 F_1s_(
"up",
"up") = -1.;
173 F_1s_(
"dn",
"dn") = -1.;
176 if(!REMOVE_EMPTY and !REMOVE_SINGLE) { cup_1s_(
"empty",
"up") = 1.; }
177 if(!REMOVE_DOUBLE and !REMOVE_SINGLE) { cup_1s_(
"dn",
"double") = 1.; }
179 if(!REMOVE_EMPTY and !REMOVE_SINGLE) { cdn_1s_(
"empty",
"dn") = 1.; }
180 if(!REMOVE_EMPTY and !REMOVE_SINGLE) { cdn_1s_(
"up",
"double") = -1.; }
182 cdagup_1s_ = cup_1s_.adjoint();
183 cdagdn_1s_ = cdn_1s_.adjoint();
190 nup_1s_ = cdagup_1s_ * cup_1s_;
191 ndn_1s_ = cdagdn_1s_ * cdn_1s_;
192 n_1s_ = nup_1s_ + ndn_1s_;
195 if(!REMOVE_DOUBLE) d_1s_(
"double",
"double") = 1.;
197 cc_1s_ = cdn_1s_ * cup_1s_;
198 cdagcdag_1s_ = cc_1s_.adjoint();
201 Sz_1s_ = 0.5 * (nup_1s_ - ndn_1s_);
202 Sp_1s_ = cup_1s_.adjoint() * cdn_1s_;
203 Sm_1s_ = Sp_1s_.adjoint();
207template <
typename Symmetry_>
210 if constexpr(Symmetry::ALL_IS_TRIVIAL)
212 qType Q = Symmetry::qvacuum();
214 if(not REMOVE_EMPTY) { labels.insert(std::make_pair(
"empty", std::make_pair(Q, dim++))); }
215 if(not REMOVE_SINGLE) {
216 labels.insert(std::make_pair(
"up", std::make_pair(Q, dim++)));
217 labels.insert(std::make_pair(
"dn", std::make_pair(Q, dim++)));
219 if(not REMOVE_DOUBLE) { labels.insert(std::make_pair(
"double", std::make_pair(Q, dim++))); }
220 this->basis_1s_.push_back(Q, dim);
223 if(not HAS_SPIN and HAS_CHARGE) {
224 qType Q = Symmetry::qvacuum();
225 if(not REMOVE_EMPTY) {
226 this->basis_1s_.push_back(Q, 1);
227 labels.insert(std::make_pair(
"empty", std::make_pair(Q, 0)));
229 if(not REMOVE_DOUBLE) {
230 std::size_t dim = (Symmetry::MOD_N[ch_index] == 2) ? 1 : 0;
232 this->basis_1s_.push_back(Q, 1);
233 labels.insert(std::make_pair(
"double", std::make_pair(Q, dim)));
235 if(not REMOVE_SINGLE) {
237 this->basis_1s_.push_back(Q, 2);
238 labels.insert(std::make_pair(
"up", std::make_pair(Q, 0)));
239 labels.insert(std::make_pair(
"dn", std::make_pair(Q, 1)));
241 }
else if(HAS_SPIN and not HAS_CHARGE) {
242 qType Q = Symmetry::qvacuum();
244 if(not REMOVE_EMPTY) { labels.insert(std::make_pair(
"empty", std::make_pair(Q, dim++))); }
245 if(not REMOVE_DOUBLE) { labels.insert(std::make_pair(
"double", std::make_pair(Q, dim++))); }
246 this->basis_1s_.push_back(Q, dim);
247 if(not REMOVE_SINGLE) {
249 this->basis_1s_.push_back(Q, 1);
250 labels.insert(std::make_pair(
"up", std::make_pair(Q, 0)));
251 Q[sp_index] = Symmetry::IS_MODULAR[sp_index] ?
util::constFct::posmod(-1, Symmetry::MOD_N[sp_index]) : -1;
252 this->basis_1s_.push_back(Q, 1);
253 labels.insert(std::make_pair(
"dn", std::make_pair(Q, 0)));
256 qType Q = Symmetry::qvacuum();
257 if(not REMOVE_EMPTY) {
258 this->basis_1s_.push_back(Q, 1);
259 labels.insert(std::make_pair(
"empty", std::make_pair(Q, 0)));
261 if(not REMOVE_DOUBLE) {
262 std::size_t dim = (Symmetry::MOD_N[ch_index] == 2) ? 1 : 0;
264 this->basis_1s_.push_back(Q, 1);
265 labels.insert(std::make_pair(
"double", std::make_pair(Q, dim)));
267 if(not REMOVE_SINGLE) {
270 this->basis_1s_.push_back(Q, 1);
271 labels.insert(std::make_pair(
"up", std::make_pair(Q, 0)));
272 Q[sp_index] = Symmetry::IS_MODULAR[sp_index] ?
util::constFct::posmod(-1, Symmetry::MOD_N[sp_index]) : -1;
273 this->basis_1s_.push_back(Q, 1);
274 labels.insert(std::make_pair(
"dn", std::make_pair(Q, 0)));
280template <
typename Symmetry_>
283 auto Q = Symmetry::qvacuum();
284 if constexpr(Symmetry::ALL_IS_TRIVIAL) {
287 if(not HAS_SPIN and HAS_CHARGE) {
288 if(sigma == SPIN_INDEX::UP or sigma == SPIN_INDEX::DN) {
289 Q[ch_index] = Symmetry::IS_MODULAR[ch_index] ?
util::constFct::posmod(Delta, Symmetry::MOD_N[ch_index]) : Delta;
292 if(sigma == SPIN_INDEX::UPDN) {
293 Q[ch_index] = Symmetry::IS_MODULAR[ch_index] ?
util::constFct::posmod(2 * Delta, Symmetry::MOD_N[ch_index]) : 2 * Delta;
297 }
else if(HAS_SPIN and not HAS_CHARGE) {
298 if(sigma == SPIN_INDEX::UP) {
299 Q[sp_index] = Symmetry::IS_MODULAR[sp_index] ?
util::constFct::posmod(Delta, Symmetry::MOD_N[sp_index]) : Delta;
302 if(sigma == SPIN_INDEX::DN) {
303 Q[sp_index] = Symmetry::IS_MODULAR[sp_index] ?
util::constFct::posmod(-Delta, Symmetry::MOD_N[sp_index]) : -Delta;
308 if(sigma == SPIN_INDEX::UP) {
309 Q[sp_index] = Symmetry::IS_MODULAR[sp_index] ?
util::constFct::posmod(Delta, Symmetry::MOD_N[sp_index]) : Delta;
310 Q[ch_index] = Symmetry::IS_MODULAR[ch_index] ?
util::constFct::posmod(Delta, Symmetry::MOD_N[ch_index]) : Delta;
313 if(sigma == SPIN_INDEX::DN) {
314 Q[sp_index] = Symmetry::IS_MODULAR[sp_index] ?
util::constFct::posmod(-Delta, Symmetry::MOD_N[sp_index]) : -Delta;
315 Q[ch_index] = Symmetry::IS_MODULAR[ch_index] ?
util::constFct::posmod(Delta, Symmetry::MOD_N[ch_index]) : Delta;
318 if(sigma == SPIN_INDEX::UPDN) {
319 Q[ch_index] = Symmetry::IS_MODULAR[ch_index] ?
util::constFct::posmod(2 * Delta, Symmetry::MOD_N[ch_index]) : 2 * Delta;
327template <
typename Symmetry_>
330 auto Q = Symmetry::qvacuum();
331 if constexpr(Symmetry::ALL_IS_TRIVIAL) {
335 assert(Sa != SPINOP_LABEL::SX and Sa != SPINOP_LABEL::iSY and
"Sx and Sy break the U1 spin symmetry.");
336 if(Sa == SPINOP_LABEL::SZ) {
338 }
else if(Sa == SPINOP_LABEL::SP) {
340 }
else if(Sa == SPINOP_LABEL::SM) {
341 Q[sp_index] = Symmetry::IS_MODULAR[sp_index] ?
util::constFct::posmod(-2, Symmetry::MOD_N[sp_index]) : -2;
Definition: Fermion.hpp:21
std::size_t sp_index
Definition: Fermion.hpp:75
OperatorType Sm_1s_
Definition: Fermion.hpp:97
OperatorType ns_1s() const
Definition: Fermion.hpp:51
std::size_t ch_index
Definition: Fermion.hpp:76
OperatorType d_1s_
Definition: Fermion.hpp:93
OperatorType Sz_1s_
Definition: Fermion.hpp:95
OperatorType cdagcdag_1s() const
Definition: Fermion.hpp:61
OperatorType cdagup_1s_
Definition: Fermion.hpp:87
OperatorType cup_1s_
Definition: Fermion.hpp:84
OperatorType n_1s_
Definition: Fermion.hpp:90
bool HAS_SPIN
Definition: Fermion.hpp:78
OperatorType Id_1s() const
Definition: Fermion.hpp:31
bool HAS_CHARGE
Definition: Fermion.hpp:79
Fermion()
Definition: Fermion.hpp:28
OperatorType cdagcdag_1s_
Definition: Fermion.hpp:101
qType getQ(SPIN_INDEX sigma, int Delta) const
Definition: Fermion.hpp:281
OperatorType n_1s(SPIN_INDEX sigma) const
Definition: Fermion.hpp:46
OperatorType Sm_1s() const
Definition: Fermion.hpp:57
OperatorType Id_1s_
Definition: Fermion.hpp:81
OperatorType Tz_1s_
Definition: Fermion.hpp:99
OperatorType c_1s(SPIN_INDEX sigma) const
Definition: Fermion.hpp:34
OperatorType Sz_1s() const
Definition: Fermion.hpp:55
OperatorType nh_1s() const
Definition: Fermion.hpp:52
OperatorType Sp_1s_
Definition: Fermion.hpp:96
OperatorType d_1s() const
Definition: Fermion.hpp:53
OperatorType cdagdn_1s_
Definition: Fermion.hpp:88
OperatorType Tz_1s() const
Definition: Fermion.hpp:59
OperatorType n_1s() const
Definition: Fermion.hpp:45
OperatorType Sp_1s() const
Definition: Fermion.hpp:56
Qbasis< Symmetry, 1 > basis_1s_
Definition: Fermion.hpp:72
qType getQ(SPINOP_LABEL Sa) const
Definition: Fermion.hpp:328
OperatorType ndn_1s_
Definition: Fermion.hpp:92
void fill_SiteOps(bool REMOVE_DOUBLE, bool REMOVE_EMPTY, bool REMOVE_SINGLE)
Definition: Fermion.hpp:136
std::unordered_map< std::string, std::pair< qType, std::size_t > > labels
Definition: Fermion.hpp:73
OperatorType F_1s() const
Definition: Fermion.hpp:32
OperatorType cc_1s() const
Definition: Fermion.hpp:60
void fill_basis(bool REMOVE_DOUBLE, bool REMOVE_EMPTY, bool REMOVE_SINGLE)
Definition: Fermion.hpp:208
OperatorType cdag_1s(SPIN_INDEX sigma) const
Definition: Fermion.hpp:39
Fermion(bool REMOVE_DOUBLE, bool REMOVE_EMPTY, bool REMOVE_SINGLE, bool CONSIDER_SPIN=true, bool CONSIDER_CHARGE=true)
Definition: Fermion.hpp:105
OperatorType cdn_1s_
Definition: Fermion.hpp:85
OperatorType F_1s_
Definition: Fermion.hpp:82
OperatorType cc_1s_
Definition: Fermion.hpp:100
OperatorType nup_1s_
Definition: Fermion.hpp:91
Qbasis< Symmetry, 1 > basis_1s() const
Definition: Fermion.hpp:63
Definition: Qbasis.hpp:39
constexpr int posmod(int x)
Definition: Constfct.hpp:46