1#ifndef XPED_PEPS_HEISENBERG_HPP_
2#define XPED_PEPS_HEISENBERG_HPP_
7#include <highfive/H5File.hpp>
23template <
typename Symmetry>
32 if constexpr(std::is_same_v<Symmetry, Sym::SU2<Sym::SpinSU2>>) {
41 if constexpr(std::is_same_v<Symmetry, Sym::SU2<Sym::SpinSU2>>) {
43 }
else if constexpr(Symmetry::ALL_ABELIAN) {
47 assert(
false and
"Symmetry is not supported in Heisenberg model.");
51 for(
auto& t : this->
data_h) { t = gate; }
54 for(
auto& t : this->
data_v) { t = gate; }
57 for(
auto& t : this->
data_d1) { t =
params[
"J2"].get<
double>() * gate; }
60 for(
auto& t : this->
data_d2) { t =
params[
"J2"].get<
double>() * gate; }
66 if constexpr(std::is_same_v<Symmetry, Sym::SU2<Sym::SpinSU2>>) {
67 auto SS = std::make_unique<Xped::TwoSiteObservable<double, Symmetry>>(
73 obs.push_back(std::move(SS));
75 }
else if constexpr(Symmetry::ALL_ABELIAN) {
76 auto Sz = std::make_unique<Xped::OneSiteObservable<double, Symmetry>>(
pat,
"Sz");
77 for(
auto& t : Sz->data) { t =
B.
Sz().data.template trim<2>(); }
78 obs.push_back(std::move(Sz));
79 if constexpr(Symmetry::ALL_IS_TRIVIAL) {
80 auto Sx = std::make_unique<Xped::OneSiteObservable<double, Symmetry>>(
pat,
"Sx");
81 for(
auto& t : Sx->data) { t =
B.
Sx().data.template trim<2>(); }
82 obs.push_back(std::move(Sx));
84 auto SzSz = std::make_unique<Xped::TwoSiteObservable<double, Symmetry>>(
90 obs.push_back(std::move(SzSz));
91 if constexpr(not Symmetry::ANY_IS_SPIN) {
92 auto SxSx = std::make_unique<TwoSiteObservable<double, Symmetry>>(
94 for(
auto& t : SxSx->data_h) { t =
tprod(
B.
Sx(),
B.
Sx()); }
95 for(
auto& t : SxSx->data_v) { t =
tprod(
B.
Sx(),
B.
Sx()); }
96 for(
auto& t : SxSx->data_d1) { t =
tprod(
B.
Sx(),
B.
Sx()); }
97 for(
auto& t : SxSx->data_d2) { t =
tprod(
B.
Sx(),
B.
Sx()); }
98 obs.push_back(std::move(SxSx));
99 auto Sy = std::make_unique<Xped::OneSiteObservable<std::complex<double>, Symmetry>>(
pat,
"Sy");
100 for(
auto& t : Sy->data) { t =
B.
Sy().data.template trim<2>(); }
101 obs.push_back(std::move(Sy));
108 virtual std::string
format()
const override
115 for(
auto& ob :
obs) {
117 if(
auto* one_c =
dynamic_cast<OneSiteObservable<std::complex<double>, Symmetry
>*>(ob.get()); one_c !=
nullptr) {
avg(env, *one_c); }
118 if(
auto* two =
dynamic_cast<TwoSiteObservable<double, Symmetry>*
>(ob.get()); two !=
nullptr) {
avg(env, *two); }
124 for(
auto& ob :
obs) {
126 if(
auto* one_c =
dynamic_cast<OneSiteObservable<std::complex<double>, Symmetry
>*>(ob.get()); one_c !=
nullptr) {
avg(env, *one_c); }
127 if(
auto* two =
dynamic_cast<TwoSiteObservable<double, Symmetry>*
>(ob.get()); two !=
nullptr) {
avg(env, *two); }
133 for(
auto& ob :
obs) {
135 if(
auto* one_c =
dynamic_cast<OneSiteObservable<std::complex<double>, Symmetry
>*>(ob.get()); one_c !=
nullptr) {
avg(env, *one_c); }
136 if(
auto* two =
dynamic_cast<TwoSiteObservable<double, Symmetry>*
>(ob.get()); two !=
nullptr) {
avg(env, *two); }
140 virtual std::string
getObsString(
const std::string& offset)
const override
143 for(
const auto& ob :
obs) {
144 out.append(ob->getResString(offset));
145 if(&ob != &
obs.back()) { out.push_back(
'\n'); }
150 virtual void obsToFile(HighFive::File& file,
const std::string& root =
"/")
const override
152 for(
const auto& ob :
obs) { ob->toFile(file, root); }
159 std::vector<std::unique_ptr<ObservableBase>>
obs;
Definition: Heisenberg.hpp:25
Heisenberg(std::map< std::string, Param > ¶ms_in, const Pattern &pat_in, Opts::Bond bond=Opts::Bond::H|Opts::Bond::V)
Definition: Heisenberg.hpp:27
virtual void computeObs(XPED_CONST CTM< double, Symmetry, 1, false, Opts::CTMCheckpoint{}> &env) override
Definition: Heisenberg.hpp:131
virtual void computeObs(XPED_CONST CTM< double, Symmetry, 2, false, Opts::CTMCheckpoint{}> &env) override
Definition: Heisenberg.hpp:113
Pattern pat
Definition: Heisenberg.hpp:156
virtual std::string getObsString(const std::string &offset) const override
Definition: Heisenberg.hpp:140
virtual void obsToFile(HighFive::File &file, const std::string &root="/") const override
Definition: Heisenberg.hpp:150
SpinBase< Symmetry > B
Definition: Heisenberg.hpp:158
virtual void setDefaultObs() override
Definition: Heisenberg.hpp:64
virtual void computeObs(XPED_CONST CTM< std::complex< double >, Symmetry, 2, false, Opts::CTMCheckpoint{}> &env) override
Definition: Heisenberg.hpp:122
virtual std::string file_name() const override
Definition: Heisenberg.hpp:106
std::vector< std::string > used_params
Definition: Heisenberg.hpp:157
virtual std::string format() const override
Definition: Heisenberg.hpp:108
std::map< std::string, Param > params
Definition: Heisenberg.hpp:155
std::vector< std::unique_ptr< ObservableBase > > obs
Definition: Heisenberg.hpp:159
Definition: SpinBase.hpp:23
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::enable_if< Dummy::NO_SPIN_SYM(), OperatorTypeC >::type Sy(std::size_t orbital=0) const
Definition: SpinBase.hpp:481
std::enable_if< Dummy::NO_SPIN_SYM(), OperatorType >::type Sx(std::size_t orbital=0) const
Definition: SpinBase.hpp:471
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type Sp(std::size_t orbital=0) const
Definition: SpinBase.hpp:457
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
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
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