1#ifndef XPED_KONDO_NECKLACE_HPP_
2#define XPED_KONDO_NECKLACE_HPP_
9#include <highfive/H5File.hpp>
20template <
typename Symmetry>
31 if constexpr(std::is_same_v<Symmetry, Sym::SU2<Sym::SpinSU2>>) {
34 used_params = {
"Jxy",
"Jz",
"Jkxy",
"Jkz",
"Ixy",
"Iz"};
37 if constexpr(std::is_same_v<Symmetry, Sym::SU2<Sym::SpinSU2>>) {
38 auto SS = (std::sqrt(3.) *
tprod(
B.
Sdag(0),
B.
S(0))).eval();
40 auto ss = (std::sqrt(3.) *
tprod(
B.
Sdag(1),
B.
S(1))).eval();
46 gate =
params[
"J"].get<
double>() * ss +
params[
"I"].get<double>() * SS;
47 local_gate = gate + 0.25 *
params[
"Jk"].get<
double>() * (SsxId + IdxSs);
48 }
else if constexpr(Symmetry::ALL_ABELIAN) {
64 gate =
params[
"Jz"].get<
double>() * szsz + 0.5 *
params[
"Jxy"].get<double>() * (spsm + smsp);
65 gate = gate +
params[
"Iz"].get<
double>() * SzSz + 0.5 *
params[
"Ixy"].get<double>() * (SpSm + SmSp);
66 local_gate = gate + 0.25 * (
params[
"Jkz"].get<
double>() * (SzszxId + IdxSzsz) +
67 0.5 *
params[
"Jkxy"].get<
double>() * ((SpsmxId + IdxSpsm) + (SmspxId + IdxSmsp)));
69 assert(
false and
"Symmetry is not supported in KondoNecklace model.");
73 for(
auto& t : this->
data_h) { t = local_gate; }
76 for(
auto& t : this->
data_v) { t = local_gate; }
79 for(
auto& t : this->
data_d1) { t = gate; }
82 for(
auto& t : this->
data_d2) { t = gate; }
88 if constexpr(std::is_same_v<Symmetry, Sym::SU2<Sym::SpinSU2>>) {
89 }
else if constexpr(Symmetry::ALL_ABELIAN) {
90 auto Sz = std::make_unique<Xped::OneSiteObservable<double, Symmetry>>(
pat,
"Sz");
91 for(
auto& t : Sz->data) { t =
B.
Sz(0).data.template trim<2>(); }
92 auto sz = std::make_unique<Xped::OneSiteObservable<double, Symmetry>>(
pat,
"sz");
93 for(
auto& t : sz->data) { t =
B.
Sz(1).data.template trim<2>(); }
94 auto Szsz = std::make_unique<Xped::OneSiteObservable<double, Symmetry>>(
pat,
"Szsz");
95 for(
auto& t : Szsz->data) { t = (
B.
Sz(0) *
B.
Sz(1)).data.template trim<2>(); }
96 auto Spsm = std::make_unique<Xped::OneSiteObservable<double, Symmetry>>(
pat,
"Spsm");
97 for(
auto& t : Spsm->data) { t = (
B.
Sp(0) *
B.
Sm(1)).data.template trim<2>(); }
98 auto Smsp = std::make_unique<Xped::OneSiteObservable<double, Symmetry>>(
pat,
"Smsp");
99 for(
auto& t : Smsp->data) { t = (
B.
Sm(0) *
B.
Sp(1)).data.template trim<2>(); }
100 obs.push_back(std::move(Sz));
101 obs.push_back(std::move(sz));
102 obs.push_back(std::move(Szsz));
103 obs.push_back(std::move(Spsm));
104 obs.push_back(std::move(Smsp));
106 auto szsz = std::make_unique<Xped::TwoSiteObservable<double, Symmetry>>(
112 auto spsm = std::make_unique<Xped::TwoSiteObservable<double, Symmetry>>(
118 auto smsp = std::make_unique<Xped::TwoSiteObservable<double, Symmetry>>(
124 auto SzSz = std::make_unique<Xped::TwoSiteObservable<double, Symmetry>>(
130 auto SpSm = std::make_unique<Xped::TwoSiteObservable<double, Symmetry>>(
136 auto SmSp = std::make_unique<Xped::TwoSiteObservable<double, Symmetry>>(
142 obs.push_back(std::move(szsz));
143 obs.push_back(std::move(spsm));
144 obs.push_back(std::move(smsp));
145 obs.push_back(std::move(SzSz));
146 obs.push_back(std::move(SpSm));
147 obs.push_back(std::move(SmSp));
153 virtual std::string
format()
const override
160 for(
auto& ob :
obs) {
162 if(
auto* two =
dynamic_cast<TwoSiteObservable<double, Symmetry>*
>(ob.get()); two !=
nullptr) {
avg(env, *two); }
168 for(
auto& ob :
obs) {
170 if(
auto* two =
dynamic_cast<TwoSiteObservable<double, Symmetry>*
>(ob.get()); two !=
nullptr) {
avg(env, *two); }
176 for(
auto& ob :
obs) {
178 if(
auto* two =
dynamic_cast<TwoSiteObservable<double, Symmetry>*
>(ob.get()); two !=
nullptr) {
avg(env, *two); }
182 virtual std::string
getObsString(
const std::string& offset)
const override
185 for(
const auto& ob :
obs) {
186 out.append(ob->getResString(offset));
187 if(&ob != &
obs.back()) { out.push_back(
'\n'); }
192 virtual void obsToFile(HighFive::File& file,
const std::string& root =
"/")
const override
194 for(
const auto& ob :
obs) { ob->toFile(file, root); }
201 std::vector<std::unique_ptr<ObservableBase>>
obs;
Definition: KondoNecklace.hpp:22
std::vector< std::unique_ptr< ObservableBase > > obs
Definition: KondoNecklace.hpp:201
virtual void computeObs(XPED_CONST CTM< double, Symmetry, 1, false, Opts::CTMCheckpoint{}> &env) override
Definition: KondoNecklace.hpp:174
virtual std::string file_name() const override
Definition: KondoNecklace.hpp:151
virtual void obsToFile(HighFive::File &file, const std::string &root="/") const override
Definition: KondoNecklace.hpp:192
Pattern pat
Definition: KondoNecklace.hpp:198
virtual void computeObs(XPED_CONST CTM< double, Symmetry, 2, false, Opts::CTMCheckpoint{}> &env) override
Definition: KondoNecklace.hpp:158
virtual std::string format() const override
Definition: KondoNecklace.hpp:153
std::vector< std::string > used_params
Definition: KondoNecklace.hpp:199
virtual void setDefaultObs() override
Definition: KondoNecklace.hpp:86
KondoNecklace(std::map< std::string, Param > ¶ms_in, const Pattern &pat_in, Opts::Bond bond=Opts::Bond::H|Opts::Bond::V)
Definition: KondoNecklace.hpp:24
virtual std::string getObsString(const std::string &offset) const override
Definition: KondoNecklace.hpp:182
virtual void computeObs(XPED_CONST CTM< std::complex< double >, Symmetry, 2, false, Opts::CTMCheckpoint{}> &env) override
Definition: KondoNecklace.hpp:166
std::map< std::string, Param > params
Definition: KondoNecklace.hpp:197
SpinBase< Symmetry > B
Definition: KondoNecklace.hpp:200
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
OperatorType Id(std::size_t orbital=0) const
Definition: SpinBase.hpp:499
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: SiteOperator.hpp:10
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