1#ifndef KONDONECKLACESU2_H_
2#define KONDONECKLACESU2_H_
14#include "Geometry2D.h"
28 typedef Eigen::Matrix<
double,Eigen::Dynamic,Eigen::Dynamic>
MatrixType;
59 static const std::map<string,std::any>
defaults;
85 {
"Jloc",1.}, {
"Jpara",1.}, {
"Jperp",0.}, {
"Jprime",1.},
86 {
"Dimp",2ul}, {
"Dsub",2ul}, {
"Ly",1ul},
87 {
"maxPower",2ul}, {
"CYLINDER",
false}
92 {
"max_alpha",100.}, {
"min_alpha",1e-11}, {
"lim_alpha",12ul}, {
"eps_svd",1e-7},
93 {
"Dincr_abs", 4ul}, {
"Dincr_per", 2ul}, {
"Dincr_rel", 1.1},
94 {
"min_Nsv",1ul}, {
"max_Nrich",-1},
95 {
"max_halfsweeps",100ul}, {
"min_halfsweeps",24ul},
96 {
"Dinit",5ul}, {
"Qinit",6ul}, {
"Dlimit",250ul},
97 {
"tol_eigval",1e-9}, {
"tol_state",1e-8},
108 std::size_t Lcell = P.size();
111 for (
size_t loc=0; loc<
N_sites; ++loc)
113 N_phys += P.get<
size_t>(
"Ly",loc%Lcell);
118 std::vector<std::vector<std::string>> labellist(
N_sites);
130 std::size_t Lcell = P.size();
132 for(std::size_t loc=0; loc<
N_sites; ++loc)
134 std::size_t orbitals =
Bsub[loc].orbitals();
135 std::size_t next_orbitals =
Bsub[(loc+1)%
N_sites].orbitals();
136 std::size_t nextn_orbitals =
Bsub[(loc+2)%
N_sites].orbitals();
140 std::stringstream ss1, ss2, ss3;
143 ss3 <<
"Ly=" << P.get<
size_t>(
"Ly",loc%Lcell);
144 labellist[loc].push_back(ss1.str());
145 labellist[loc].push_back(ss2.str());
146 labellist[loc].push_back(ss3.str());
150 param1d Jloc = P.fill_array1d<
double>(
"Jloc",
"Jloc_array", orbitals, loc%Lcell);
153 labellist[loc].push_back(Jloc.label);
154 for(
int alpha=0; alpha<orbitals; ++alpha)
156 double lambda = std::sqrt(3.)*Jloc.a(alpha);
157 std::vector<OperatorType> ops(1);
159 pushlist.push_back(std::make_tuple(loc, ops, lambda));
164 param2d Jperp = P.fill_array2d<
double>(
"Jrung",
"Jperp",
"Jperp_array", orbitals, loc%Lcell, P.get<
bool>(
"CYLINDER"));
165 if((Jperp.a != 0.).any())
167 labellist[loc].push_back(Jperp.label);
168 for(
int alpha=0; alpha<orbitals; ++alpha)
170 for(
int beta=0; beta<orbitals; ++beta)
172 double lambda = std::sqrt(3.)*Jperp.a(alpha,beta);
173 std::vector<OperatorType> ops(1);
175 pushlist.push_back(std::make_tuple(loc, ops, lambda));
180 auto push_full = [&
N_sites, &loc, &
Bimp, &
Bsub, &P, &pushlist, &labellist, &boundary] (
string xxxFull,
string label,
181 const vector<SiteOperatorQ<Symmetry,Eigen::MatrixXd> > &first,
182 const vector<vector<SiteOperatorQ<Symmetry,Eigen::MatrixXd> > > &last,
183 vector<double> factor) ->
void
185 ArrayXXd Full = P.get<Eigen::ArrayXXd>(xxxFull);
186 vector<vector<std::pair<size_t,double> > > R = Geometry2D::rangeFormat(Full);
188 if (
static_cast<bool>(boundary)) {assert(R.size() ==
N_sites and
"Use an (N_sites)x(N_sites) hopping matrix for open BC!");}
189 else {assert(R.size() >= 2*
N_sites and
"Use at least a (2*N_sites)x(N_sites) hopping matrix for infinite BC!");}
191 for (
size_t j=0; j<first.size(); j++)
192 for (
size_t h=0; h<R[loc].size(); ++h)
194 size_t range = R[loc][h].first;
195 double value = R[loc][h].second;
199 vector<SiteOperatorQ<Symmetry,Eigen::MatrixXd> > ops(range+1);
201 for (
size_t i=1; i<range; ++i)
205 ops[range] = last[j][(loc+range)%
N_sites];
206 pushlist.push_back(std::make_tuple(loc, ops, factor[j] * value));
211 ss <<
label <<
"(" << Geometry2D::hoppingInfo(Full) <<
")";
212 labellist[loc].push_back(ss.str());
220 vector<vector<SiteOperatorQ<Symmetry,Eigen::MatrixXd> > > last {S_ranges};
221 push_full(
"Jfull",
"Jᵢⱼ", first, last, {std::sqrt(3.)});
227 vector<vector<SiteOperatorQ<Symmetry,Eigen::MatrixXd> > > last {S_ranges};
228 push_full(
"Ifull",
"Iᵢⱼ", first, last, {std::sqrt(3.)});
230 if (P.HAS(
"Jfull") or P.HAS(
"Ifull")) {
continue;}
233 param2d Jpara = P.fill_array2d<
double>(
"Jpara",
"Jpara_array", {orbitals, next_orbitals}, loc%Lcell);
234 if((Jpara.a != 0.).any())
236 labellist[loc].push_back(Jpara.label);
237 if(loc <
N_sites-1 or boundary == BC::INFINITE)
239 for(
int alpha=0; alpha<orbitals; ++alpha)
241 for(
int beta=0; beta<next_orbitals; ++beta)
243 double lambda = std::sqrt(3.)*Jpara.a(alpha,beta);
244 std::vector<OperatorType> ops(2);
247 pushlist.push_back(std::make_tuple(loc, ops, lambda));
256 param2d Jprime = P.fill_array2d<
double>(
"Jprime",
"Jprime_array", {orbitals, nextn_orbitals}, loc%Lcell);
257 if((Jprime.a != 0.).any())
259 labellist[loc].push_back(Jprime.label);
262 for(
int alpha=0; alpha<orbitals; ++alpha)
264 for(
int beta=0; beta<nextn_orbitals; ++beta)
266 double lambda = std::sqrt(3.)*Jprime.a(alpha,beta);
267 std::vector<OperatorType> ops(3);
271 pushlist.push_back(std::make_tuple(loc, ops, lambda));
281 std::size_t last_orbitals =
Bsub[
N_sites-1].orbitals();
282 std::size_t first_orbitals =
Bsub[0].orbitals();
284 std::size_t next_orbitals =
Bsub[1%
N_sites].orbitals();
288 param2d Jpara = P.fill_array2d<
double>(
"Jpara",
"Jpara_array", {first_orbitals,first_orbitals}, 0);
289 if((Jpara.a != 0.).any())
291 labellist[0].push_back(Jpara.label);
292 for(
int alpha=0; alpha<last_orbitals; ++alpha)
294 for(
int beta=0; beta<first_orbitals; ++beta)
296 double lambda = std::sqrt(3.)*Jpara.a(alpha,beta);
297 std::vector<OperatorType> ops(1);
299 pushlist.push_back(std::make_tuple(0ul, ops, lambda));
304 param2d Jprime = P.fill_array2d<
double>(
"Jprime",
"Jprime_array", {first_orbitals, first_orbitals}, 0%Lcell);
305 if((Jprime.a != 0.).any())
307 labellist[0].push_back(Jprime.label);
308 for(
int alpha=0; alpha<first_orbitals; ++alpha)
310 for(
int beta=0; beta<first_orbitals; ++beta)
312 double lambda = std::sqrt(3.)*Jprime.a(alpha,beta);
313 std::vector<OperatorType> ops(1);
315 pushlist.push_back(std::make_tuple(0ul, ops, lambda));
322 param2d Jpara = P.fill_array2d<
double>(
"Jpara",
"Jpara_array", {last_orbitals,first_orbitals}, 1%Lcell);
323 if((Jpara.a != 0.).any())
325 labellist[1].push_back(Jpara.label);
326 for(
int alpha=0; alpha<last_orbitals; ++alpha)
328 for(
int beta=0; beta<first_orbitals; ++beta)
330 double lambda = std::sqrt(3.)*Jpara.a(alpha,beta);
331 std::vector<OperatorType> ops(2);
334 pushlist.push_back(std::make_tuple(0ul, ops, lambda));
339 param2d Jprime_prev_to_first = P.fill_array2d<
double>(
"Jprime",
"Jprime_array", {first_orbitals, first_orbitals}, 0%Lcell);
340 if((Jprime_prev_to_first.a != 0.).any())
342 labellist[0].push_back(Jprime_prev_to_first.label);
343 for(
int alpha=0; alpha<first_orbitals; ++alpha)
345 for(
int beta=0; beta<first_orbitals; ++beta)
347 double lambda = std::sqrt(3.)*Jprime_prev_to_first.a(alpha,beta);
348 std::vector<OperatorType> ops(1);
350 pushlist.push_back(std::make_tuple(0ul, ops, lambda));
355 param2d Jprime_last_to_next = P.fill_array2d<
double>(
"Jprime",
"Jprime_array", {last_orbitals, last_orbitals}, 1%Lcell);
356 if((Jprime_last_to_next.a != 0.).any())
358 labellist[1].push_back(Jprime_last_to_next.label);
359 for(
int alpha=0; alpha<last_orbitals; ++alpha)
361 for(
int beta=0; beta<last_orbitals; ++beta)
363 double lambda = std::sqrt(3.)*Jprime_last_to_next.a(alpha,beta);
364 std::vector<OperatorType> ops(1);
366 pushlist.push_back(std::make_tuple(1ul, ops, lambda));
373 param2d Jpara = P.fill_array2d<
double>(
"Jpara",
"Jpara_array", {last_orbitals,first_orbitals}, (
N_sites-1)%Lcell);
374 if((Jpara.a != 0.).any())
376 labellist[
N_sites-1].push_back(Jpara.label);
377 for(
int alpha=0; alpha<last_orbitals; ++alpha)
379 for(
int beta=0; beta<first_orbitals; ++beta)
381 double lambda = std::sqrt(3.)*Jpara.a(alpha,beta);
382 std::vector<OperatorType> ops(
N_sites);
384 for(std::size_t loc=1; loc<
N_sites-1; ++loc)
389 pushlist.push_back(std::make_tuple(0ul, ops, lambda));
394 param2d Jprime_prev_to_first = P.fill_array2d<
double>(
"Jprime",
"Jprime_array", {previous_orbitals, first_orbitals}, (
N_sites-2)%Lcell);
395 if((Jprime_prev_to_first.a != 0.).any())
397 labellist[
N_sites-2].push_back(Jprime_prev_to_first.label);
398 for(
int alpha=0; alpha<previous_orbitals; ++alpha)
400 for(
int beta=0; beta<first_orbitals; ++beta)
402 double lambda = std::sqrt(3.)*Jprime_prev_to_first.a(alpha,beta);
403 std::vector<OperatorType> ops(
N_sites-1);
405 for(std::size_t loc=1; loc<
N_sites-2; ++loc)
410 pushlist.push_back(std::make_tuple(0ul, ops, lambda));
415 param2d Jprime_last_to_next = P.fill_array2d<
double>(
"Jprime",
"Jprime_array", {last_orbitals, next_orbitals}, (
N_sites-1)%Lcell);
416 if((Jprime_last_to_next.a != 0.).any())
418 labellist[
N_sites-1].push_back(Jprime_last_to_next.label);
419 for(
int alpha=0; alpha<last_orbitals; ++alpha)
421 for(
int beta=0; beta<next_orbitals; ++beta)
423 double lambda = std::sqrt(3.)*Jprime_last_to_next.a(alpha,beta);
424 std::vector<OperatorType> ops(
N_sites-1);
426 for(std::size_t loc=2; loc<
N_sites-1; ++loc)
431 pushlist.push_back(std::make_tuple(1ul, ops, lambda));
441 auto add = [](std::set<std::size_t>& left, std::set<std::size_t>& right) ->
void
449 std::set<std::size_t> temp;
450 for(
auto l : left)
for(
auto r : right)
452 std::size_t min = std::abs((
static_cast<int>(l))-(
static_cast<int>(r)))+1;
453 std::size_t max = l+r-1;
454 for(std::size_t i=min; i<=max; i+=2ul) temp.insert(i);
459 std::vector<std::set<std::size_t>> local(
N_sites);
460 std::vector<std::set<std::size_t>> reachable(
N_sites);
461 for(std::size_t loc=0; loc<
N_sites; ++loc)
463 std::set<std::size_t> subspins;
464 if(
Bsub[loc].orbitals()%2 == 0) subspins.insert(1ul);
465 for(std::size_t i =
Bsub[loc].get_D(); i<=
Bsub[loc].orbitals()*(
Bsub[loc].get_D()-1)+1; i+=2ul) subspins.insert(i);
466 add(local[loc], subspins);
467 std::set<std::size_t> impspins;
468 if(
Bimp[loc].orbitals()%2 == 0) impspins.insert(1ul);
469 for(std::size_t i =
Bimp[loc].get_D(); i<=
Bimp[loc].orbitals()*(
Bimp[loc].get_D()-1)+1; i+=2ul) impspins.insert(i);
470 add(local[loc], impspins);
472 reachable[0] = local[0];
473 for(std::size_t loc=1; loc<
N_sites; ++loc)
475 reachable[loc] = local[loc];
476 add(reachable[loc], reachable[loc-1]);
479 auto it = find(reachable[
N_sites-1].begin(), reachable[
N_sites-1].end(), qnum[0]);
480 return it!=reachable[
N_sites-1].end();
boost::rational< int > frac
std::string print_frac_nice(frac r)
#define EIGEN_DEFAULT_SPARSE_INDEX_TYPE
SiteOperator< Symmetry, Scalar_ > kroneckerProduct(const SiteOperator< Symmetry, Scalar_ > &O1, const SiteOperator< Symmetry, Scalar_ > &O2)
std::enable_if< Dummy::IS_SPIN_SU2(), Mpo< Sym::SU2< Sym::SpinSU2 > > >::type S(size_t locx, size_t locy=0, double factor=1.) const
vector< SpinBase< Sym::SU2< Sym::SpinSU2 > > > Bsub
vector< SpinBase< Sym::SU2< Sym::SpinSU2 > > > Bimp
void finalize(const bool COMPRESS=true, const std::size_t power=1, const double tolerance=::mynumeric_limits< double >::epsilon())
void set_verbosity(const DMRG::VERBOSITY::OPTION VERB_in)
void setLocBasis(const std::vector< std::vector< qType > > &q)
DMRG::VERBOSITY::OPTION VERB
void add(const std::size_t loc, const OperatorType &op, const qType &qIn, const qType &qOut, const std::size_t IndexIn, const std::size_t IndexOut)
void precalc_TwoSiteData(bool FORCE=false)
void construct_from_pushlist(const PushType< OperatorType, CouplScalar > &pushlist, const std::vector< std::vector< std::string > > &labellist, size_t Lcell)
static SiteOperatorQ< Symmetry, MatrixType_ > prod(const SiteOperatorQ< Symmetry, MatrixType_ > &O1, const SiteOperatorQ< Symmetry, MatrixType_ > &O2, const qType &target)
static SiteOperatorQ< Symmetry, MatrixType_ > outerprod(const SiteOperatorQ< Symmetry, MatrixType_ > &O1, const SiteOperatorQ< Symmetry, MatrixType_ > &O2, const qType &target)
bool validate(qType qnum)
static void set_operators(const std::vector< SpinBase< Symmetry > > &Bsub, const std::vector< SpinBase< Symmetry > > &Bimp, const ParamHandler &P, PushType< SiteOperator< Symmetry, double >, double > &pushlist, std::vector< std::vector< std::string > > &labellist, const BC boundary)
static const std::map< string, std::any > defaults
static const std::map< string, std::any > sweep_defaults
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixType
Eigen::SparseMatrix< double, Eigen::ColMajor, EIGEN_DEFAULT_SPARSE_INDEX_TYPE > SparseMatrixType
static constexpr MODEL_FAMILY FAMILY
Sym::SU2< Sym::SpinSU2 > Symmetry
#define MAKE_TYPEDEFS(MODEL)