Xped
Loading...
Searching...
No Matches
Kondo.hpp
Go to the documentation of this file.
1#ifndef XPED_KONDO_HPP_
2#define XPED_KONDO_HPP_
3
4#include <map>
5#include <memory>
6#include <string>
7#include <vector>
8
9#include <highfive/H5File.hpp>
10
11#include "Xped/Core/Tensor.hpp"
17#include "Xped/Util/Param.hpp"
18
19namespace Xped {
20
21template <typename Symmetry>
22class Kondo : public TwoSiteObservable<double, Symmetry>
23{
25
26public:
27 Kondo(std::map<std::string, Param>& params_in, const Pattern& pat_in, Opts::Bond bond = Opts::Bond::H | Opts::Bond::V)
28 : TwoSiteObservable<double, Symmetry>(pat_in, bond)
29 , params(params_in)
30 , pat(pat_in)
31 {
32 B = SpinBase<Symmetry>(1, 2);
34 Tensor<double, 2, 2, Symmetry> gate, gate2, local_gate;
35 if constexpr(Symmetry::Nq > 0 and Symmetry::ANY_NON_ABELIAN) {
36 if constexpr(Symmetry::IS_SPIN[0] and Symmetry::NON_ABELIAN[0] and Symmetry::ABELIAN[1]) {
37 used_params = {"t", "Jk", "I", "tprime", "Iprime"};
38 }
39 } else if constexpr(Symmetry::ALL_ABELIAN) {
40 used_params = {"t", "Jkxy", "Jkz", "Ixy", "Iz", "tprime", "Izprime", "Ixyprime"};
41 }
42 if constexpr(Symmetry::Nq > 0 and Symmetry::ANY_NON_ABELIAN) {
43 if constexpr(Symmetry::IS_SPIN[0] and Symmetry::NON_ABELIAN[0] and Symmetry::ABELIAN[1]) {
44 auto SS = (std::sqrt(3.) * tprod(Op::outerprod(F.Id(), B.Sdag()), Op::outerprod(F.Id(), B.S()))).eval();
45
46 auto hop = (std::sqrt(2.) * tprod(Op::outerprod(F.cdag(), B.Id()), Op::outerprod(F.c(), B.Id())) +
47 std::sqrt(2.) * tprod(Op::outerprod(F.c(), B.Id()), Op::outerprod(F.cdag(), B.Id())))
48 .eval();
49
50 auto IdxSs = tprod(Op::outerprod(F.Id(), B.Id()), std::sqrt(3.) * Op::outerprod(F.Sdag(), B.S(), Symmetry::qvacuum()));
51 auto SsxId = tprod(std::sqrt(3.) * Op::outerprod(F.Sdag(), B.S(), Symmetry::qvacuum()), Op::outerprod(F.Id(), B.Id()));
52 gate = -params["t"].get<double>() * hop + params["I"].get<double>() * SS;
53 gate2 = params["tprime"].get<double>() * hop + params["Iprime"].get<double>() * SS;
54 local_gate = gate + 0.25 * params["Jk"].get<double>() * (SsxId + IdxSs);
55 }
56 } else if constexpr(Symmetry::ALL_ABELIAN) {
57 auto SzSz = tprod(Op::outerprod(F.Id(), B.Sz()), Op::outerprod(F.Id(), B.Sz()));
58 auto SpSm = tprod(Op::outerprod(F.Id(), B.Sp()), Op::outerprod(F.Id(), B.Sm()));
59 auto SmSp = tprod(Op::outerprod(F.Id(), B.Sm()), Op::outerprod(F.Id(), B.Sp()));
60
61 auto IdxSzsz = tprod(Op::outerprod(F.Id(), B.Id()), Op::outerprod(F.Sz(), B.Sz()));
62 auto IdxSpsm = tprod(Op::outerprod(F.Id(), B.Id()), Op::outerprod(F.Sp(), B.Sm()));
63 auto IdxSmsp = tprod(Op::outerprod(F.Id(), B.Id()), Op::outerprod(F.Sm(), B.Sp()));
64
65 auto SzszxId = tprod(Op::outerprod(F.Sz(), B.Sz()), Op::outerprod(F.Id(), B.Id()));
66 auto SpsmxId = tprod(Op::outerprod(F.Sp(), B.Sm()), Op::outerprod(F.Id(), B.Id()));
67 auto SmspxId = tprod(Op::outerprod(F.Sm(), B.Sp()), Op::outerprod(F.Id(), B.Id()));
68
69 auto hop = (tprod(Op::outerprod(F.cdag(SPIN_INDEX::UP), B.Id()), Op::outerprod(F.c(SPIN_INDEX::UP), B.Id())) +
70 tprod(Op::outerprod(F.cdag(SPIN_INDEX::DN), B.Id()), Op::outerprod(F.c(SPIN_INDEX::DN), B.Id())) -
71 tprod(Op::outerprod(F.c(SPIN_INDEX::UP), B.Id()), Op::outerprod(F.cdag(SPIN_INDEX::UP), B.Id())) -
72 tprod(Op::outerprod(F.c(SPIN_INDEX::DN), B.Id()), Op::outerprod(F.cdag(SPIN_INDEX::DN), B.Id())))
73 .eval();
74
75 gate = -params["t"].get<double>() * hop + params["Iz"].get<double>() * SzSz + 0.5 * params["Ixy"].get<double>() * (SpSm + SmSp);
76 gate2 = params["tprime"].get<double>() * hop + params["Izprime"].get<double>() * SzSz +
77 0.5 * params["Ixyprime"].get<double>() * (SpSm + SmSp);
78 local_gate = gate + 0.25 * (params["Jkz"].get<double>() * (SzszxId + IdxSzsz) +
79 0.5 * params["Jkxy"].get<double>() * ((SpsmxId + IdxSpsm) + (SmspxId + IdxSmsp)));
80 } else {
81 assert(false and "Symmetry is not supported in Kondo model.");
82 }
83
85 for(auto& t : this->data_h) { t = local_gate; }
86 }
88 for(auto& t : this->data_v) { t = local_gate; }
89 }
91 for(auto& t : this->data_d1) { t = gate2; }
92 }
94 for(auto& t : this->data_d2) { t = gate2; }
95 }
96 }
97
98 virtual void setDefaultObs() override
99 {
100 if constexpr(Symmetry::Nq > 0 and Symmetry::ANY_NON_ABELIAN) {
101 if constexpr(Symmetry::IS_SPIN[0] and Symmetry::NON_ABELIAN[0] and Symmetry::ABELIAN[1]) {
102 auto Sdags = std::make_unique<OneSiteObservable<double, Symmetry>>(pat, "Sdags");
103 for(auto& t : Sdags->data) { t = std::sqrt(3.) * Op::outerprod(F.Sdag(), B.S(), Symmetry::qvacuum()).data.template trim<2>(); }
104 obs.push_back(std::move(Sdags));
105 auto cdagc = std::make_unique<TwoSiteObservable<double, Symmetry>>(pat, Opts::Bond::H | Opts::Bond::V, "cdagc");
106 for(auto& t : cdagc->data_h) {
107 t = (std::sqrt(2.) * tprod(Op::outerprod(F.cdag(), B.Id()), Op::outerprod(F.c(), B.Id())) +
108 std::sqrt(2.) * tprod(Op::outerprod(F.c(), B.Id()), Op::outerprod(F.cdag(), B.Id())))
109 .eval();
110 }
111 for(auto& t : cdagc->data_v) {
112 t = (std::sqrt(2.) * tprod(Op::outerprod(F.cdag(), B.Id()), Op::outerprod(F.c(), B.Id())) +
113 std::sqrt(2.) * tprod(Op::outerprod(F.c(), B.Id()), Op::outerprod(F.cdag(), B.Id())))
114 .eval();
115 }
116 for(auto& t : cdagc->data_d1) {
117 t = (-1. * (std::sqrt(2.) * tprod(Op::outerprod(F.cdag(), B.Id()), Op::outerprod(F.c(), B.Id())) +
118 std::sqrt(2.) * tprod(Op::outerprod(F.c(), B.Id()), Op::outerprod(F.cdag(), B.Id()))))
119 .eval();
120 }
121 for(auto& t : cdagc->data_d2) {
122 t = (-1. * (std::sqrt(2.) * tprod(Op::outerprod(F.cdag(), B.Id()), Op::outerprod(F.c(), B.Id())) +
123 std::sqrt(2.) * tprod(Op::outerprod(F.c(), B.Id()), Op::outerprod(F.cdag(), B.Id()))))
124 .eval();
125 }
126
127 auto SdagS = std::make_unique<TwoSiteObservable<double, Symmetry>>(pat, Opts::Bond::H | Opts::Bond::V, "SdagS");
128 for(auto& t : SdagS->data_h) { t = (std::sqrt(3.) * tprod(Op::outerprod(F.Id(), B.Sdag()), Op::outerprod(F.Id(), B.S()))).eval(); }
129 for(auto& t : SdagS->data_v) { t = (std::sqrt(3.) * tprod(Op::outerprod(F.Id(), B.Sdag()), Op::outerprod(F.Id(), B.S()))).eval(); }
130 for(auto& t : SdagS->data_d1) { t = (std::sqrt(3.) * tprod(Op::outerprod(F.Id(), B.Sdag()), Op::outerprod(F.Id(), B.S()))).eval(); }
131 for(auto& t : SdagS->data_d2) { t = (std::sqrt(3.) * tprod(Op::outerprod(F.Id(), B.Sdag()), Op::outerprod(F.Id(), B.S()))).eval(); }
132 obs.push_back(std::move(cdagc));
133 obs.push_back(std::move(SdagS));
134 }
135 } else if constexpr(Symmetry::ALL_ABELIAN) {
136 auto Sz = std::make_unique<Xped::OneSiteObservable<double, Symmetry>>(pat, "Sz");
137 for(auto& t : Sz->data) { t = Op::outerprod(F.Id(), B.Sz(0)).data.template trim<2>(); }
138 auto sz = std::make_unique<Xped::OneSiteObservable<double, Symmetry>>(pat, "sz");
139 for(auto& t : sz->data) { t = Op::outerprod(F.Sz(0), B.Id()).data.template trim<2>(); }
140 auto nup = std::make_unique<Xped::OneSiteObservable<double, Symmetry>>(pat, "nup");
141 for(auto& t : nup->data) { t = Op::outerprod(F.n(Xped::SPIN_INDEX::UP), B.Id()).data.template trim<2>(); }
142 auto ndn = std::make_unique<Xped::OneSiteObservable<double, Symmetry>>(pat, "ndn");
143 for(auto& t : ndn->data) { t = Op::outerprod(F.n(Xped::SPIN_INDEX::DN), B.Id()).data.template trim<2>(); }
144 auto n = std::make_unique<Xped::OneSiteObservable<double, Symmetry>>(pat, "n");
145 for(auto& t : n->data) { t = Op::outerprod(F.n(), B.Id()).data.template trim<2>(); }
146 auto d = std::make_unique<Xped::OneSiteObservable<double, Symmetry>>(pat, "d");
147 for(auto& t : d->data) { t = Op::outerprod(F.d(), B.Id()).data.template trim<2>(); }
148 obs.push_back(std::move(nup));
149 obs.push_back(std::move(ndn));
150 obs.push_back(std::move(n));
151 obs.push_back(std::move(d));
152 obs.push_back(std::move(Sz));
153 obs.push_back(std::move(sz));
154 if constexpr(not Symmetry::ANY_IS_SPIN) {
155 auto Sx = std::make_unique<Xped::OneSiteObservable<double, Symmetry>>(pat, "Sx");
156 for(auto& t : Sx->data) { t = Op::outerprod(F.Id(), B.Sx(0)).data.template trim<2>(); }
157 auto sx = std::make_unique<Xped::OneSiteObservable<double, Symmetry>>(pat, "sx");
158 for(auto& t : sx->data) { t = Op::outerprod(F.Sx(0), B.Id()).data.template trim<2>(); }
159
160 obs.push_back(std::move(Sx));
161 obs.push_back(std::move(sx));
162 }
163 }
164 }
165
166 virtual std::string file_name() const override
167 {
168 return internal::create_filename(fmt::format("Kondo_Lx={}_Ly={}", pat.Lx, pat.Ly), params, used_params);
169 }
170
171 virtual std::string format() const override
172 {
173 return internal::format_params(fmt::format("Kondo[sym={}]", Symmetry::name()), params, used_params);
174 }
175
176 virtual void computeObs(XPED_CONST CTM<double, Symmetry, 2, false, Opts::CTMCheckpoint{}>& env) override
177 {
178 for(auto& ob : obs) {
179 if(auto* one = dynamic_cast<OneSiteObservable<double, Symmetry>*>(ob.get()); one != nullptr) { avg(env, *one); }
180 if(auto* two = dynamic_cast<TwoSiteObservable<double, Symmetry>*>(ob.get()); two != nullptr) { avg(env, *two); }
181 }
182 }
183
184 virtual void computeObs(XPED_CONST CTM<std::complex<double>, Symmetry, 2, false, Opts::CTMCheckpoint{}>& env) override
185 {
186 for(auto& ob : obs) {
187 if(auto* one = dynamic_cast<OneSiteObservable<double, Symmetry>*>(ob.get()); one != nullptr) { avg(env, *one); }
188 if(auto* two = dynamic_cast<TwoSiteObservable<double, Symmetry>*>(ob.get()); two != nullptr) { avg(env, *two); }
189 }
190 }
191
192 virtual void computeObs(XPED_CONST CTM<double, Symmetry, 1, false, Opts::CTMCheckpoint{}>& env) override
193 {
194 for(auto& ob : obs) {
195 if(auto* one = dynamic_cast<OneSiteObservable<double, Symmetry>*>(ob.get()); one != nullptr) { avg(env, *one); }
196 if(auto* two = dynamic_cast<TwoSiteObservable<double, Symmetry>*>(ob.get()); two != nullptr) { avg(env, *two); }
197 }
198 }
199
200 virtual std::string getObsString(const std::string& offset) const override
201 {
202 std::string out;
203 for(const auto& ob : obs) {
204 out.append(ob->getResString(offset));
205 if(&ob != &obs.back()) { out.push_back('\n'); }
206 }
207 return out;
208 }
209
210 virtual void obsToFile(HighFive::File& file, const std::string& root = "/") const override
211 {
212 for(const auto& ob : obs) { ob->toFile(file, root); }
213 }
214
215 std::map<std::string, Param> params;
217 std::vector<std::string> used_params;
220 std::vector<std::unique_ptr<ObservableBase>> obs;
221};
222
223} // namespace Xped
224#endif
Definition: CTM.hpp:62
Definition: FermionBase.hpp:25
std::enable_if< Dummy::IS_SPIN_SU2(), OperatorType >::type Sdag(std::size_t orbital=0) const
Definition: FermionBase.hpp:608
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::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_SPIN_SU2(), OperatorType >::type Sp(std::size_t orbital=0) const
Definition: FermionBase.hpp:622
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
std::enable_if<!Dummy::IS_SPIN_SU2(), OperatorType >::type Sm(std::size_t orbital=0) const
Definition: FermionBase.hpp:629
Definition: Kondo.hpp:23
virtual void computeObs(XPED_CONST CTM< double, Symmetry, 2, false, Opts::CTMCheckpoint{}> &env) override
Definition: Kondo.hpp:176
virtual void computeObs(XPED_CONST CTM< double, Symmetry, 1, false, Opts::CTMCheckpoint{}> &env) override
Definition: Kondo.hpp:192
virtual std::string format() const override
Definition: Kondo.hpp:171
SpinBase< Symmetry > B
Definition: Kondo.hpp:218
virtual std::string file_name() const override
Definition: Kondo.hpp:166
std::map< std::string, Param > params
Definition: Kondo.hpp:215
Pattern pat
Definition: Kondo.hpp:216
Kondo(std::map< std::string, Param > &params_in, const Pattern &pat_in, Opts::Bond bond=Opts::Bond::H|Opts::Bond::V)
Definition: Kondo.hpp:27
std::vector< std::string > used_params
Definition: Kondo.hpp:217
virtual void computeObs(XPED_CONST CTM< std::complex< double >, Symmetry, 2, false, Opts::CTMCheckpoint{}> &env) override
Definition: Kondo.hpp:184
FermionBase< Symmetry > F
Definition: Kondo.hpp:219
std::vector< std::unique_ptr< ObservableBase > > obs
Definition: Kondo.hpp:220
virtual void setDefaultObs() override
Definition: Kondo.hpp:98
virtual void obsToFile(HighFive::File &file, const std::string &root="/") const override
Definition: Kondo.hpp:210
virtual std::string getObsString(const std::string &offset) const override
Definition: Kondo.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::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 > &params, 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 > &params, const std::vector< std::string > &used_params)
Definition: Helpers.hpp:26
Definition: bench.cpp:62
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
Tensor< Scalar, 1, 2, Symmetry, false > data
Definition: SiteOperator.hpp:86
static SiteOperator< Scalar, Symmetry > outerprod(XPED_CONST SiteOperator< Scalar, Symmetry > &O1, XPED_CONST SiteOperator< Scalar, Symmetry > &O2, const qType &target)
Definition: SiteOperator.cpp:51
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