1#ifndef KONDOONECKLACEBSERVABLES
2#define KONDOONECKLACEBSERVABLES
6#include "ParamHandler.h"
9template<
typename Symmetry>
23 template<
typename Dummy = Symmetry>
24 typename std::enable_if<Dummy::IS_SPIN_SU2(),
Mpo<Symmetry> >::type
Simp (
size_t locx,
size_t locy=0,
double factor=1.)
const;
25 template<
typename Dummy = Symmetry>
26 typename std::enable_if<Dummy::IS_SPIN_SU2(),
Mpo<Symmetry> >::type
Simpdag (
size_t locx,
size_t locy=0,
double factor=std::sqrt(3.))
const;
27 template<
typename Dummy = Symmetry>
28 typename std::enable_if<Dummy::IS_SPIN_SU2(),
Mpo<Symmetry> >::type
Ssub (
size_t locx,
size_t locy=0,
double factor=1.)
const;
29 template<
typename Dummy = Symmetry>
30 typename std::enable_if<Dummy::IS_SPIN_SU2(),
Mpo<Symmetry> >::type
Ssubdag (
size_t locx,
size_t locy=0,
double factor=std::sqrt(3.))
const;
31 template<
typename Dummy = Symmetry>
33 template<
typename Dummy = Symmetry>
36 template<
typename Dummy = Symmetry>
37 typename std::enable_if<Dummy::IS_SPIN_SU2(),
Mpo<Symmetry> >::type
S (
size_t locx,
size_t locy=0,
double factor=1.)
const
38 {
return Simp(locx,locy,factor);};
40 template<
typename Dummy = Symmetry>
42 {
return Simp(
SZ,locx,locy,factor);}
44 template<
typename Dummy = Symmetry>
45 typename std::enable_if<!Dummy::IS_SPIN_SU2(),
Mpo<Symmetry> >::type
Sz (
size_t locx,
size_t locy=0)
const {
return Simp(
SZ,locx,locy,1.);}
46 template<
typename Dummy = Symmetry>
48 template<
typename Dummy = Symmetry>
50 template<
typename Dummy = Symmetry>
52 template<
typename Dummy = Symmetry>
53 typename std::conditional<Dummy::IS_SPIN_SU2(),
Mpo<Symmetry>, vector<Mpo<Symmetry> > >::type
SimpdagSimp (
size_t locx1,
size_t locx2,
size_t locy1=0,
size_t locy2=0)
const;
54 template<
typename Dummy = Symmetry>
55 typename std::conditional<Dummy::IS_SPIN_SU2(),
Mpo<Symmetry>, vector<Mpo<Symmetry> > >::type
SsubdagSsub (
size_t locx1,
size_t locx2,
size_t locy1=0,
size_t locy2=0)
const;
56 template<
typename Dummy = Symmetry>
57 typename std::conditional<Dummy::IS_SPIN_SU2(),
Mpo<Symmetry>, vector<Mpo<Symmetry> > >::type
SimpdagSsub (
size_t locx1,
size_t locx2,
size_t locy1=0,
size_t locy2=0)
const;
58 template<
typename Dummy = Symmetry>
59 typename std::conditional<Dummy::IS_SPIN_SU2(),
Mpo<Symmetry>, vector<Mpo<Symmetry> > >::type
SdagS (
size_t locx1,
size_t locx2,
size_t locy1=0,
size_t locy2=0)
const {
return SimpdagSimp(locx1,locx2,locy1,locy2);}
64 template<
typename Dummy = Symmetry>
66 template<
typename Dummy = Symmetry>
84 bool HERMITIAN=
false)
const;
87 double factor,
bool HERMITIAN)
const;
90 make_FourierYSum (
KONDO_SUBSYSTEM SUBSYS,
string name,
const vector<OperatorType> &Ops,
double factor,
bool HERMITIAN,
const vector<complex<double> > &phases)
const;
94 vector<SpinBase<Symmetry> >
Bimp;
95 vector<SpinBase<Symmetry> >
Bsub;
98template<
typename Symmetry>
106template<
typename Symmetry>
110 ParamHandler P(params,defaults);
111 size_t Lcell = P.size();
112 Bimp.resize(L); Bsub.resize(L);
114 for (
size_t l=0; l<L; ++l)
116 Bsub[l] =
SpinBase<Symmetry>(P.get<
size_t>(
"Ly",l%Lcell), P.get<
size_t>(
"Dsub",l%Lcell));
117 Bimp[l] =
SpinBase<Symmetry>(P.get<
size_t>(
"Ly",l%Lcell), P.get<
size_t>(
"Dimp",l%Lcell));
123template<
typename Symmetry>
127 assert(locx<Bimp.size() and locy<Bimp[locx].dim());
130 ss << Op.
label() <<
"(" << locx <<
"," << locy;
131 if (factor != 1.) ss <<
",factor=" << factor;
135 for (
size_t l=0; l<Bimp.size(); ++l) {Mout.
setLocBasis(Bsub[l].get_basis().combine(Bimp[l].get_basis()).qloc(),l);}
143 else if (SUBSYS ==
IMP)
148 Mout.
setLocal(locx, (factor * OpExt).
template plain<double>());
152template<
typename Symmetry>
156 double factor,
bool HERMITIAN)
const
158 assert(locx1<Bimp.size() and locx2<Bimp.size() and locy1<Bimp[locx1].dim() and locy2<Bimp[locx2].dim());
160 ss << Op1.
label() <<
"(" << locx1 <<
"," << locy1 <<
")"
161 << Op2.
label() <<
"(" << locx2 <<
"," << locy2 <<
")";
164 for (
size_t l=0; l<Bimp.size(); ++l) {Mout.
setLocBasis(Bsub[l].get_basis().combine(Bimp[l].get_basis()).qloc(),l);}
174 else if (SUBSYS ==
IMP)
179 else if (SUBSYS ==
IMPSUB)
187 auto product = factor*OperatorType::prod(Op1Ext, Op2Ext, Qtot);
188 Mout.
setLocal(locx1, product.template plain<double>());
192 Mout.
setLocal({locx1, locx2}, {(factor*Op1Ext).
template plain<double>(), Op2Ext.template plain<double>()});
198template<
typename Symmetry>
201 double factor,
bool HERMITIAN,
const vector<complex<double> > &phases)
const
204 ss << name <<
"_ky(";
205 for (
int l=0; l<phases.size(); ++l)
208 if (l!=phases.size()-1) {ss <<
",";}
214 for (
size_t l=0; l<Bimp.size(); ++l) {Mout.
setLocBasis(Bsub[l].get_basis().combine(Bimp[l].get_basis()).qloc(),l);}
216 vector<complex<double> > phases_x_factor = phases;
217 for (
int l=0; l<phases.size(); ++l)
219 phases_x_factor[l] = phases[l] * factor;
222 vector<SiteOperator<Symmetry,complex<double> > > OpsPlain(Ops.size());
223 for (
int l=0; l<OpsPlain.size(); ++l)
227 OpsPlain[l] =
kroneckerProduct(Ops[l], Bimp[l].Id()).template plain<double>().template cast<complex<double> >();
229 else if (SUBSYS ==
IMP)
231 OpsPlain[l] =
kroneckerProduct(Bsub[l].Id(),Ops[l]).template plain<double>().template cast<complex<double> >();
239template<
typename Symmetry>
240template<
typename Dummy>
244 bool HERMITIAN = (Sa==
SX or Sa==
SZ)?
true:
false;
245 return make_local(
IMP,locx,locy, Bimp[locx].Scomp(Sa,locy), factor, HERMITIAN);
248template<
typename Symmetry>
249template<
typename Dummy>
253 bool HERMITIAN = (Sa==
SX or Sa==
SZ)?
true:
false;
254 return make_local(
SUB,locx,locy, Bsub[locx].Scomp(Sa,locy), factor, HERMITIAN);
257template<
typename Symmetry>
258template<
typename Dummy>
262 return make_corr(
IMP,locx1,locx2,locy1,locy2, Bimp[locx1].Scomp(Sa1,locy1), Bimp[locx2].Scomp(Sa2,locy2), getQ_ScompScomp(Sa1,Sa2), fac,
PROP::HERMITIAN);
265template<
typename Symmetry>
266template<
typename Dummy>
270 return make_corr(
SUB,locx1,locx2,locy1,locy2, Bsub[locx1].Scomp(Sa1,locy1), Bsub[locx2].Scomp(Sa2,locy2), getQ_ScompScomp(Sa1,Sa2), fac,
PROP::HERMITIAN);
273template<
typename Symmetry>
274template<
typename Dummy>
278 return make_corr(
IMPSUB,locx1,locx2,locy1,locy2, Bimp[locx1].Scomp(Sa1,locy1), Bsub[locx2].Scomp(Sa2,locy2), getQ_ScompScomp(Sa1,Sa2), fac,
PROP::HERMITIAN);
281template<
typename Symmetry>
282template<
typename Dummy>
284Simp (
size_t locx,
size_t locy,
double factor)
const
289template<
typename Symmetry>
290template<
typename Dummy>
292Simpdag (
size_t locx,
size_t locy,
double factor)
const
297template<
typename Symmetry>
298template<
typename Dummy>
300Ssub(
size_t locx,
size_t locy,
double factor)
const
305template<
typename Symmetry>
306template<
typename Dummy>
308Ssubdag (
size_t locx,
size_t locy,
double factor)
const
313template<
typename Symmetry>
314template<
typename Dummy>
316SimpdagSimp (
size_t locx1,
size_t locx2,
size_t locy1,
size_t locy2)
const
318 if constexpr (Symmetry::IS_SPIN_SU2())
320 return make_corr(
IMP,locx1, locx2, locy1, locy2, Bimp[locx1].Sdag(locy1), Bimp[locx2].S(locy2), Symmetry::qvacuum(), sqrt(3.),
PROP::HERMITIAN);
325 vector<Mpo<Symmetry> > out(3);
326 out[0] = SimpSimp(
SZ,
SZ,locx1,locx2,locy1,locy2);
327 out[1] = SimpSimp(
SP,
SM,locx1,locx2,locy1,locy2,0.5);
328 out[2] = SimpSimp(
SM,
SP,locx1,locx2,locy1,locy2,0.5);
333template<
typename Symmetry>
334template<
typename Dummy>
336SsubdagSsub (
size_t locx1,
size_t locx2,
size_t locy1,
size_t locy2)
const
338 if constexpr (Symmetry::IS_SPIN_SU2())
340 return make_corr(
SUB,locx1, locx2, locy1, locy2, Bsub[locx1].Sdag(locy1), Bsub[locx2].S(locy2), Symmetry::qvacuum(), sqrt(3.),
PROP::HERMITIAN);
345 vector<Mpo<Symmetry> > out(3);
346 out[0] = SsubSsub(
SZ,
SZ,locx1,locx2,locy1,locy2);
347 out[1] = SsubSsub(
SP,
SM,locx1,locx2,locy1,locy2,0.5);
348 out[2] = SsubSsub(
SM,
SP,locx1,locx2,locy1,locy2,0.5);
353template<
typename Symmetry>
354template<
typename Dummy>
356SimpdagSsub (
size_t locx1,
size_t locx2,
size_t locy1,
size_t locy2)
const
358 if constexpr (Symmetry::IS_SPIN_SU2())
360 return make_corr(
IMPSUB,locx1, locx2, locy1, locy2, Bimp[locx1].Sdag(locy1), Bsub[locx2].S(locy2), Symmetry::qvacuum(), sqrt(3.),
PROP::HERMITIAN);
365 vector<Mpo<Symmetry> > out(3);
366 out[0] = SimpSsub(
SZ,
SZ,locx1,locx2,locy1,locy2);
367 out[1] = SimpSsub(
SP,
SM,locx1,locx2,locy1,locy2,0.5);
368 out[2] = SimpSsub(
SM,
SP,locx1,locx2,locy1,locy2,0.5);
373template<
typename Symmetry>
374template<
typename Dummy>
376Simp_ky (vector<complex<double> > phases)
const
378 vector<OperatorType> Ops(Bimp.size());
379 for (
size_t l=0; l<Bimp.size(); ++l)
381 Ops[l] = Bimp[l].S(0);
383 return make_FourierYSum(
IMP,
"S", Ops, 1.,
false, phases);
386template<
typename Symmetry>
387template<
typename Dummy>
389Simpdag_ky (vector<complex<double> > phases,
double factor)
const
391 vector<OperatorType> Ops(Bimp.size());
392 for (
size_t l=0; l<Bimp.size(); ++l)
394 Ops[l] = Bimp[l].Sdag(0);
396 return make_FourierYSum(
IMP,
"S†", Ops, 1.,
false, phases);
399template<
typename Symmetry>
402 typename Symmetry::qType out;
403 if ( (Sa1 ==
SZ and Sa2 ==
SZ) or (Sa1 ==
SP and Sa2 ==
SM) or (Sa1 ==
SM and Sa2 ==
SP) or (Sa1 ==
SX or Sa1 ==
iSY) ) {out = Symmetry::qvacuum();}
404 else {assert(
false and
"Quantumnumber for the chosen ScompScomp is not computed. Add in KondoNecklaceObservables::getQ_ScompScomp");}
SiteOperator< Symmetry, Scalar_ > kroneckerProduct(const SiteOperator< Symmetry, Scalar_ > &O1, const SiteOperator< Symmetry, Scalar_ > &O2)
std::enable_if<!Dummy::IS_SPIN_SU2(), Mpo< Symmetry > >::type SimpSimp(SPINOP_LABEL Sa1, SPINOP_LABEL Sa2, size_t locx1, size_t locx2, size_t locy1=0, size_t locy2=0, double fac=1.) const
Mpo< Symmetry, complex< double > > make_FourierYSum(KONDO_SUBSYSTEM SUBSYS, string name, const vector< OperatorType > &Ops, double factor, bool HERMITIAN, const vector< complex< double > > &phases) const
std::enable_if< Dummy::IS_SPIN_SU2(), Mpo< Symmetry > >::type Ssub(size_t locx, size_t locy=0, double factor=1.) const
std::enable_if<!Dummy::IS_SPIN_SU2(), Mpo< Symmetry > >::type SsubSsub(SPINOP_LABEL Sa1, SPINOP_LABEL Sa2, size_t locx1, size_t locx2, size_t locy1=0, size_t locy2=0, double fac=1.) const
KondoNecklaceObservables(const size_t &L, const vector< Param > ¶ms, const map< string, any > &defaults)
std::enable_if< Dummy::IS_SPIN_SU2(), Mpo< Symmetry, complex< double > > >::type Simp_ky(vector< complex< double > > phases) const
std::conditional< Dummy::IS_SPIN_SU2(), Mpo< Symmetry >, vector< Mpo< Symmetry > > >::type SsubdagSsub(size_t locx1, size_t locx2, size_t locy1=0, size_t locy2=0) const
std::enable_if<!Dummy::IS_SPIN_SU2(), Mpo< Symmetry > >::type Scomp(SPINOP_LABEL Sa, size_t locx, size_t locy=0, double factor=1.) const
std::enable_if< Dummy::IS_SPIN_SU2(), Mpo< Symmetry > >::type S(size_t locx, size_t locy=0, double factor=1.) const
std::enable_if<!Dummy::IS_SPIN_SU2(), Mpo< Symmetry > >::type Sz(size_t locx, size_t locy=0) const
KondoNecklaceObservables(const size_t &L)
SiteOperatorQ< Symmetry, Eigen::MatrixXd > OperatorType
Mpo< Symmetry > make_corr(KONDO_SUBSYSTEM SUBSYS, size_t locx1, size_t locx2, size_t locy1, size_t locy2, const OperatorType &Op1, const OperatorType &Op2, qarray< Symmetry::Nq > Qtot, double factor, bool HERMITIAN) const
std::enable_if<!Dummy::IS_SPIN_SU2(), Mpo< Symmetry > >::type Simp(SPINOP_LABEL Sa, size_t locx, size_t locy=0, double factor=1.) const
vector< SpinBase< Symmetry > > Bsub
std::enable_if<!Dummy::IS_SPIN_SU2(), Mpo< Symmetry > >::type Ssub(SPINOP_LABEL Sa, size_t locx, size_t locy=0, double factor=1.) const
std::conditional< Dummy::IS_SPIN_SU2(), Mpo< Symmetry >, vector< Mpo< Symmetry > > >::type SimpdagSimp(size_t locx1, size_t locx2, size_t locy1=0, size_t locy2=0) const
std::enable_if<!Dummy::IS_SPIN_SU2(), Mpo< Symmetry > >::type SimpSsub(SPINOP_LABEL Sa1, SPINOP_LABEL Sa2, size_t locx1, size_t locx2, size_t locy1=0, size_t locy2=0, double fac=1.) const
Mpo< Symmetry > make_local(KONDO_SUBSYSTEM SUBSYS, size_t locx, size_t locy, const OperatorType &Op, double factor=1., bool HERMITIAN=false) const
not implemented
std::conditional< Dummy::IS_SPIN_SU2(), Mpo< Symmetry >, vector< Mpo< Symmetry > > >::type SimpdagSsub(size_t locx1, size_t locx2, size_t locy1=0, size_t locy2=0) const
std::enable_if< Dummy::IS_SPIN_SU2(), Mpo< Symmetry > >::type Simp(size_t locx, size_t locy=0, double factor=1.) const
vector< SpinBase< Symmetry > > Bimp
Symmetry::qType getQ_ScompScomp(SPINOP_LABEL Sa1, SPINOP_LABEL Sa2) const
std::enable_if< Dummy::IS_SPIN_SU2(), Mpo< Symmetry > >::type Simpdag(size_t locx, size_t locy=0, double factor=std::sqrt(3.)) const
std::enable_if< Dummy::IS_SPIN_SU2(), Mpo< Symmetry > >::type Ssubdag(size_t locx, size_t locy=0, double factor=std::sqrt(3.)) const
std::conditional< Dummy::IS_SPIN_SU2(), Mpo< Symmetry >, vector< Mpo< Symmetry > > >::type SdagS(size_t locx1, size_t locx2, size_t locy1=0, size_t locy2=0) const
std::enable_if< Dummy::IS_SPIN_SU2(), Mpo< Symmetry, complex< double > > >::type Simpdag_ky(vector< complex< double > > phases, double factor=sqrt(3.)) const
KondoNecklaceObservables()
void setLocBasis(const std::vector< std::vector< qType > > &q)
void setLocal(std::size_t loc, const OperatorType &op)
void setLocalSum(const OperatorType &op, Scalar(*f)(int)=localSumTrivial)