VMPS++
Loading...
Searching...
No Matches
DmrgJanitor.h
Go to the documentation of this file.
1#ifndef DMRGJANITOR
2#define DMRGJANITOR
3
4#include "DmrgTypedefs.h"
5
7void turnaround (int pivot, size_t L, DMRG::DIRECTION::OPTION &DIR)
8{
9 if (pivot == L-1 and
11 {
13 }
14 if (pivot == 0 and
16 {
18 }
19}
20
27template<typename PivotMatrixType>
29{
30public:
31
33 DmrgJanitor(size_t L_input);
34
36
42 void sweep (size_t loc, DMRG::BROOM::OPTION TOOL, PivotMatrixType *H = NULL);
43
51 void skim (DMRG::DIRECTION::OPTION DIR, DMRG::BROOM::OPTION TOOL, PivotMatrixType *H = NULL);
52
59 void skim (DMRG::BROOM::OPTION TOOL, PivotMatrixType *H = NULL);
60
64
66
69 void sweepStep (DMRG::DIRECTION::OPTION DIR, size_t loc, DMRG::BROOM::OPTION TOOL, PivotMatrixType *H = NULL, bool DISCARD_U_or_V=false);
70
78 virtual void rightSweepStep (size_t loc, DMRG::BROOM::OPTION TOOL, PivotMatrixType *H = NULL, bool DISCARD_V=false){};
79
87 virtual void leftSweepStep (size_t loc, DMRG::BROOM::OPTION TOOL, PivotMatrixType *H = NULL, bool DISCARD_U=false){};
89
91
92 inline size_t length() const {return N_sites;}
94
96
101
103
104 void set_pivot (int pivot_input) {pivot = pivot_input;};
105
106protected:
107
109
110 int pivot = -1;
112 size_t N_sites;
114};
115
116template<typename PivotMatrixType>
119{
120 set_defaultCutoffs();
121}
122
123template<typename PivotMatrixType>
125DmrgJanitor (size_t L_input)
126:N_sites(L_input)
127{
129}
130
131template<typename PivotMatrixType>
134{
136 eps_truncWeight = DMRG::CONTROL::DEFAULT::eps_truncWeight(0);
141}
142
143template<typename PivotMatrixType>
145skim (DMRG::DIRECTION::OPTION DIR, DMRG::BROOM::OPTION TOOL, PivotMatrixType *H)
146{
147 if (DIR == DMRG::DIRECTION::LEFT)
148 {
149 assert(pivot == N_sites-1 or pivot == -1);
150 for (size_t l=N_sites-1; l>0; --l) {sweepStep(DMRG::DIRECTION::LEFT,l,TOOL,H);}
151 }
152 else
153 {
154 assert(pivot == 0 or pivot == -1);
155 for (size_t l=0; l<N_sites-1; ++l) {sweepStep(DMRG::DIRECTION::RIGHT,l,TOOL,H);}
156 }
157}
158
159template<typename PivotMatrixType>
161skim (DMRG::BROOM::OPTION TOOL, PivotMatrixType *H)
162{
163 assert(pivot == 0 or pivot == N_sites-1);
164
165 if (pivot == 0)
166 {
167 skim(DMRG::DIRECTION::RIGHT,TOOL,H);
168 }
169 else
170 {
171 skim(DMRG::DIRECTION::LEFT,TOOL,H);
172 }
173}
174
175template<typename PivotMatrixType>
178{
179 //double eps_svd_bak = eps_svd;
180 double eps_truncWeight_bak = eps_truncWeight;
181 eps_truncWeight = 0.;
182
183 if (pivot == 0)
184 {
186 }
187 else
188 {
190 }
191
192 //eps_svd = eps_svd_bak;
193 eps_truncWeight = eps_truncWeight_bak;
194}
195
196template<typename PivotMatrixType>
198sweep (size_t loc, DMRG::BROOM::OPTION TOOL, PivotMatrixType *H)
199{
200 assert(loc<N_sites);
201 if (pivot == -1)
202 {
203 skim(DMRG::DIRECTION::LEFT,TOOL,H);
204 for (size_t l=0; l<loc; ++l) {sweepStep(DMRG::DIRECTION::RIGHT,l,TOOL,H);}
205 }
206 else if (pivot!=-1 and pivot<loc)
207 {
208 for (size_t l=pivot; l<loc; ++l) {sweepStep(DMRG::DIRECTION::RIGHT,l,TOOL,H);}
209 }
210 else if (pivot!=-1 and pivot>loc)
211 {
212 for (size_t l=pivot; l>loc; --l) {sweepStep(DMRG::DIRECTION::LEFT,l,TOOL,H);}
213 }
214}
215
216template<typename PivotMatrixType>
218sweepStep (DMRG::DIRECTION::OPTION DIR, size_t loc, DMRG::BROOM::OPTION TOOL, PivotMatrixType *H, bool DISCARD_U_or_V)
219{
220 (DIR==DMRG::DIRECTION::LEFT)? leftSweepStep(loc,TOOL,H,DISCARD_U_or_V) : rightSweepStep(loc,TOOL,H,DISCARD_U_or_V);
221}
222
223#endif
void turnaround(int pivot, size_t L, DMRG::DIRECTION::OPTION &DIR)
Flips the sweep direction when the edge is reached.
Definition: DmrgJanitor.h:7
Base class for all the sweeping stuff. Needs to know PivotMatrixType because sweeps using DMRG::BROOM...
Definition: DmrgJanitor.h:29
double eps_truncWeight
Definition: DmrgJanitor.h:97
void skim(DMRG::DIRECTION::OPTION DIR, DMRG::BROOM::OPTION TOOL, PivotMatrixType *H=NULL)
Definition: DmrgJanitor.h:145
void sweepStep(DMRG::DIRECTION::OPTION DIR, size_t loc, DMRG::BROOM::OPTION TOOL, PivotMatrixType *H=NULL, bool DISCARD_U_or_V=false)
Definition: DmrgJanitor.h:218
void set_defaultCutoffs()
Definition: DmrgJanitor.h:133
void sweep(size_t loc, DMRG::BROOM::OPTION TOOL, PivotMatrixType *H=NULL)
Definition: DmrgJanitor.h:198
void skim(DMRG::BROOM::OPTION TOOL, PivotMatrixType *H=NULL)
Definition: DmrgJanitor.h:161
void set_pivot(int pivot_input)
Definition: DmrgJanitor.h:104
virtual void rightSweepStep(size_t loc, DMRG::BROOM::OPTION TOOL, PivotMatrixType *H=NULL, bool DISCARD_V=false)
Definition: DmrgJanitor.h:78
virtual void leftSweepStep(size_t loc, DMRG::BROOM::OPTION TOOL, PivotMatrixType *H=NULL, bool DISCARD_U=false)
Definition: DmrgJanitor.h:87
size_t N_sites
Definition: DmrgJanitor.h:112
DmrgJanitor(size_t L_input)
Definition: DmrgJanitor.h:125
void entropy_skim()
Definition: DmrgJanitor.h:177
double eps_svd
Definition: DmrgJanitor.h:97
size_t max_Nsv
Definition: DmrgJanitor.h:98
size_t length() const
Definition: DmrgJanitor.h:92
size_t min_Nsv
Definition: DmrgJanitor.h:98
double alpha_rsvd
Definition: DmrgJanitor.h:97
static double eps_svd(size_t i)
Definition: DmrgTypedefs.h:359
static double max_alpha_rsvd(size_t i)
Definition: DmrgTypedefs.h:357
static constexpr size_t Mlimit
Definition: DmrgTypedefs.h:341
static double eps_truncWeight(size_t i)
Definition: DmrgTypedefs.h:360
static size_t min_Nsv(size_t i)
Definition: DmrgTypedefs.h:364
static int max_Nrich(size_t i)
Definition: DmrgTypedefs.h:365