1#ifndef XPED_HUBBARD_HPP_
2#define XPED_HUBBARD_HPP_
7#include <highfive/H5File.hpp>
23template <
typename Symmetry>
35 if constexpr(Symmetry::Nq == 2 and Symmetry::ANY_NON_ABELIAN) {
36 if constexpr(Symmetry::IS_SPIN[0] and Symmetry::NON_ABELIAN[0] and Symmetry::ABELIAN[1]) {
41 for(
auto& t : this->
data_h) {
42 t = -
params[
"t"].get<
double>() * hopping +
params[
"U"].get<double>() * hubbard -
params[
"mu"].get<
double>() * occ;
46 for(
auto& t : this->
data_v) {
47 t = -
params[
"t"].get<
double>() * hopping +
params[
"U"].get<double>() * hubbard -
params[
"mu"].get<
double>() * occ;
52 for(
auto& t : this->
data_d1) { t = +
params[
"tprime"].get<
double>() * hopping; }
56 for(
auto& t : this->
data_d2) { t = +
params[
"tprime"].get<
double>() * hopping; }
59 }
else if constexpr(std::is_same_v<Symmetry,
72 for(
auto& t : this->
data_h) {
73 t = -
params[
"t"].get<
double>() * hopping + 0.5 *
params[
"U"].get<double>() * hubbard -
74 (
params[
"mu"].get<
double>() + 1.5 *
params[
"U"].get<double>()) * occ;
78 for(
auto& t : this->
data_v) {
79 t = -
params[
"t"].get<
double>() * hopping + 0.5 *
params[
"U"].get<double>() * hubbard -
80 (
params[
"mu"].get<
double>() + 1.5 *
params[
"U"].get<double>()) * occ;
84 for(
auto& t : this->
data_d1) { t = -
params[
"tprime"].get<
double>() * hopping; }
87 for(
auto& t : this->
data_d2) { t = -
params[
"tprime"].get<
double>() * hopping; }
89 }
else if constexpr(Symmetry::ALL_ABELIAN) {
102 for(
auto& t : this->
data_h) {
103 t = -
params[
"t"].get<
double>() * hopping +
params[
"U"].get<double>() * hubbard -
params[
"mu"].get<
double>() * occ;
108 for(
auto& t : this->
data_v) {
109 t = -
params[
"t"].get<
double>() * hopping +
params[
"U"].get<double>() * hubbard -
params[
"mu"].get<
double>() * occ;
116 t = +
params[
"tprime"].get<
double>() * hopping;
122 t = +
params[
"tprime"].get<
double>() * hopping;
126 assert(
false and
"Symmetry is not supported in Hubbard model.");
133 if constexpr(Symmetry::Nq == 2 and Symmetry::ANY_NON_ABELIAN) {
134 if constexpr(Symmetry::IS_SPIN[0] and Symmetry::NON_ABELIAN[0] and Symmetry::ABELIAN[1]) {
135 auto n = std::make_unique<Xped::OneSiteObservable<double, Symmetry>>(
pat,
"n");
136 for(
auto& t : n->data) { t =
F.
n().data.template trim<2>(); }
137 obs.push_back(std::move(n));
138 auto d = std::make_unique<Xped::OneSiteObservable<double, Symmetry>>(
pat,
"d");
139 for(
auto& t : d->data) { t =
F.
d().data.template trim<2>(); }
140 obs.push_back(std::move(d));
142 auto cdagc = std::make_unique<TwoSiteObservable<double, Symmetry>>(
144 for(
auto& t : cdagc->data_h) { t = hopping; }
145 for(
auto& t : cdagc->data_v) { t = hopping; }
146 for(
auto& t : cdagc->data_d1) { t = -1. * hopping; }
147 for(
auto& t : cdagc->data_d2) { t = -1. * hopping; }
148 obs.push_back(std::move(cdagc));
150 }
else if constexpr(std::is_same_v<Symmetry,
155 auto n = std::make_unique<Xped::OneSiteObservable<double, Symmetry>>(
pat,
"n");
156 for(
auto& t : n->data) { t =
F.
n().data.template trim<2>(); }
157 obs.push_back(std::move(n));
158 }
else if constexpr(Symmetry::ALL_ABELIAN) {
159 auto nup = std::make_unique<Xped::OneSiteObservable<double, Symmetry>>(
pat,
"nup");
160 for(
auto& t : nup->data) { t =
F.
n(Xped::SPIN_INDEX::UP).data.template trim<2>(); }
161 auto ndn = std::make_unique<Xped::OneSiteObservable<double, Symmetry>>(
pat,
"ndn");
162 for(
auto& t : ndn->data) { t =
F.
n(Xped::SPIN_INDEX::DN).data.template trim<2>(); }
163 auto n = std::make_unique<Xped::OneSiteObservable<double, Symmetry>>(
pat,
"n");
164 for(
auto& t : n->data) { t =
F.
n().data.template trim<2>(); }
165 auto d = std::make_unique<Xped::OneSiteObservable<double, Symmetry>>(
pat,
"d");
166 for(
auto& t : d->data) { t =
F.
d().data.template trim<2>(); }
167 auto Sz = std::make_unique<Xped::OneSiteObservable<double, Symmetry>>(
pat,
"Sz");
168 for(
auto& t : Sz->data) { t =
F.
Sz().data.template trim<2>(); }
169 obs.push_back(std::move(nup));
170 obs.push_back(std::move(ndn));
171 obs.push_back(std::move(n));
172 obs.push_back(std::move(d));
173 obs.push_back(std::move(Sz));
174 auto hopping = (
tprod(
F.
cdag(SPIN_INDEX::UP),
F.
c(SPIN_INDEX::UP)) +
tprod(
F.
cdag(SPIN_INDEX::DN),
F.
c(SPIN_INDEX::DN)) -
179 for(
auto& t : cdagc->data_h) { t = hopping; }
180 for(
auto& t : cdagc->data_v) { t = hopping; }
181 for(
auto& t : cdagc->data_d1) { t = -1. * hopping; }
182 for(
auto& t : cdagc->data_d2) { t = -1. * hopping; }
186 for(
auto& t : SzSz->data_h) { t =
tprod(
F.
Sz(),
F.
Sz()); }
187 for(
auto& t : SzSz->data_v) { t =
tprod(
F.
Sz(),
F.
Sz()); }
188 for(
auto& t : SzSz->data_d1) { t =
tprod(
F.
Sz(),
F.
Sz()); }
189 for(
auto& t : SzSz->data_d2) { t =
tprod(
F.
Sz(),
F.
Sz()); }
191 obs.push_back(std::move(cdagc));
192 obs.push_back(std::move(SzSz));
193 if constexpr(not Symmetry::ANY_IS_SPIN) {
194 auto Sx = std::make_unique<Xped::OneSiteObservable<double, Symmetry>>(
pat,
"Sx");
195 for(
auto& t : Sx->data) { t =
F.
Sx().data.template trim<2>(); }
196 auto SxSx = std::make_unique<TwoSiteObservable<double, Symmetry>>(
198 for(
auto& t : SxSx->data_h) { t =
tprod(
F.
Sx(),
F.
Sx()); }
199 for(
auto& t : SxSx->data_v) { t =
tprod(
F.
Sx(),
F.
Sx()); }
200 for(
auto& t : SxSx->data_d1) { t =
tprod(
F.
Sx(),
F.
Sx()); }
201 for(
auto& t : SxSx->data_d2) { t =
tprod(
F.
Sx(),
F.
Sx()); }
202 obs.push_back(std::move(Sx));
203 obs.push_back(std::move(SxSx));
204 auto Sy = std::make_unique<Xped::OneSiteObservable<std::complex<double>, Symmetry>>(
pat,
"Sy");
205 for(
auto& t : Sy->data) { t =
F.
Sy().data.template trim<2>(); }
206 obs.push_back(std::move(Sy));
216 virtual std::string
format()
const override
223 for(
auto& ob :
obs) {
225 if(
auto* one_c =
dynamic_cast<OneSiteObservable<std::complex<double>, Symmetry
>*>(ob.get()); one_c !=
nullptr) {
avg(env, *one_c); }
226 if(
auto* two =
dynamic_cast<TwoSiteObservable<double, Symmetry>*
>(ob.get()); two !=
nullptr) {
avg(env, *two); }
232 for(
auto& ob :
obs) {
234 if(
auto* one_c =
dynamic_cast<OneSiteObservable<std::complex<double>, Symmetry
>*>(ob.get()); one_c !=
nullptr) {
avg(env, *one_c); }
235 if(
auto* two =
dynamic_cast<TwoSiteObservable<double, Symmetry>*
>(ob.get()); two !=
nullptr) {
avg(env, *two); }
236 if(
auto* one =
dynamic_cast<OneSiteObservable<double, Symmetry, false>*
>(ob.get()); one !=
nullptr) {
avg(env, *one); }
237 if(
auto* one_c =
dynamic_cast<OneSiteObservable<std::complex<double>, Symmetry, false
>*>(ob.get()); one_c !=
nullptr) {
240 if(
auto* two =
dynamic_cast<TwoSiteObservable<double, Symmetry, false>*
>(ob.get()); two !=
nullptr) {
avg(env, *two); }
246 for(
auto& ob :
obs) {
248 if(
auto* one_c =
dynamic_cast<OneSiteObservable<std::complex<double>, Symmetry
>*>(ob.get()); one_c !=
nullptr) {
avg(env, *one_c); }
249 if(
auto* two =
dynamic_cast<TwoSiteObservable<double, Symmetry>*
>(ob.get()); two !=
nullptr) {
avg(env, *two); }
253 virtual std::string
getObsString(
const std::string& offset)
const override
256 for(
auto i = 0ul;
const auto& ob :
obs) {
257 out.append(ob->getResString(offset));
258 if(i++ <
obs.size() - 1) { out.push_back(
'\n'); }
263 virtual void obsToFile(HighFive::File& file,
const std::string& root =
"/")
const override
265 for(
const auto& ob :
obs) { ob->toFile(file, root); }
272 std::vector<std::unique_ptr<ObservableBase>>
obs;
Definition: FermionBase.hpp:25
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
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< true, OperatorType >::type n(std::size_t orbital=0) const
Definition: FermionBase.hpp:541
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_CHARGE_SU2(), OperatorType >::type d(std::size_t orbital=0) const
Definition: FermionBase.hpp:570
std::enable_if< Dummy::NO_SPIN_SYM(), OperatorType >::type Sx(std::size_t orbital=0) const
Definition: FermionBase.hpp:636
Definition: Hubbard.hpp:25
virtual void computeObs(XPED_CONST CTM< double, Symmetry, 1, false, Opts::CTMCheckpoint{}> &env) override
Definition: Hubbard.hpp:244
FermionBase< Symmetry > F
Definition: Hubbard.hpp:271
std::vector< std::unique_ptr< ObservableBase > > obs
Definition: Hubbard.hpp:272
std::vector< std::string > used_params
Definition: Hubbard.hpp:270
Pattern pat
Definition: Hubbard.hpp:269
Hubbard(std::map< std::string, Param > ¶ms_in, const Pattern &pat_in, Opts::Bond bond=Opts::Bond::H|Opts::Bond::V)
Definition: Hubbard.hpp:27
virtual void computeObs(XPED_CONST CTM< std::complex< double >, Symmetry, 2, false, Opts::CTMCheckpoint{}> &env) override
Definition: Hubbard.hpp:230
virtual void setDefaultObs() override
Definition: Hubbard.hpp:131
virtual std::string file_name() const override
Definition: Hubbard.hpp:211
virtual void computeObs(XPED_CONST CTM< double, Symmetry, 2, false, Opts::CTMCheckpoint{}> &env) override
Definition: Hubbard.hpp:221
std::map< std::string, Param > params
Definition: Hubbard.hpp:268
virtual void obsToFile(HighFive::File &file, const std::string &root="/") const override
Definition: Hubbard.hpp:263
virtual std::string format() const override
Definition: Hubbard.hpp:216
virtual std::string getObsString(const std::string &offset) const override
Definition: Hubbard.hpp:253
Definition: Tensor.hpp:40
Bond
Definition: Bonds.hpp:10
std::string format_params(const std::string &name, const std::map< std::string, Param > ¶ms, const std::vector< std::string > &used_params)
Definition: Helpers.hpp:12
std::string create_filename(const std::string &name, const std::map< std::string, Param > ¶ms, const std::vector< std::string > &used_params)
Definition: Helpers.hpp:26
TMatrix< std::conditional_t< ENABLE_AD, stan::math::var, typename OneSiteObservable< OpScalar, Symmetry, HERMITIAN >::ObsScalar > > avg(XPED_CONST CTM< Scalar, Symmetry, TRank, ENABLE_AD, CPOpts > &env, OneSiteObservable< OpScalar, Symmetry, HERMITIAN > &op)
Definition: LinearAlgebra.cpp:11
Tensor< Scalar, 2, 2, Symmetry, false > tprod(XPED_CONST SiteOperator< Scalar, Symmetry > &O1, XPED_CONST SiteOperator< Scalar, Symmetry > &O2, bool ADD_TWIST=false, bool REVERSE_ORDER=false)
Definition: SiteOperator.hpp:150
Definition: OneSiteObservable.hpp:21
Definition: CTMOpts.hpp:96
Definition: Pattern.hpp:18
std::size_t Ly
Definition: Pattern.hpp:72
std::size_t Lx
Definition: Pattern.hpp:72
Definition: CombSym.hpp:12
Definition: TwoSiteObservable.hpp:22
TMatrix< Tensor< double, 2, 2, Symmetry, false > > data_h
Definition: TwoSiteObservable.hpp:287
TMatrix< Tensor< double, 2, 2, Symmetry, false > > data_v
Definition: TwoSiteObservable.hpp:288
TMatrix< Tensor< double, 2, 2, Symmetry, false > > data_d1
Definition: TwoSiteObservable.hpp:289
Opts::Bond bond
Definition: TwoSiteObservable.hpp:295
TMatrix< Tensor< double, 2, 2, Symmetry, false > > data_d2
Definition: TwoSiteObservable.hpp:290