VMPS++
Loading...
Searching...
No Matches
TEBDPropagator.h
Go to the documentation of this file.
1#ifndef TEBD_PROPAGATOR
2#define TEBD_PROPAGATOR
3
5#include <cmath>
7
8const static tuple<int,double> optTEBDstep (double tmax, double dtmax, double tol_accu=0.05)
9{
10 double dt3 = pow(tol_accu/tmax,0.5);
11 double dt9 = pow(tol_accu/tmax,0.25);
12
13 dt3 = min(dt3,dtmax);
14 dt9 = min(dt9,dtmax);
15// cout << "dt3=" << dt3 << ", dt9=" << dt9 << endl;
16
17 double cost3 = tmax/dt3*3;
18 double cost9 = tmax/dt9*9;
19// cout << "cost3=" << cost3 << ", cost9=" << cost9 << endl;
20
21 tuple<int,double> out;
22 get<0>(out) = (cost9<cost3)? 9 : 3;
23 get<1>(out) = (cost9<cost3)? dt9 : dt3;
24 return out;
25}
26
28
29template<typename Hamiltonian, size_t Nq, typename TimeScalar, typename VectorType>
31{
32public:
33
35
51 void t_step (const Hamiltonian &H, const VectorType &Vin, VectorType &Vout, TimeScalar dt, double tol=1e-5, int Nexp=3, TEBD_EXCEPTION EX=NO_EXCEPTION);
52
53private:
54
55 TimeScalar tstep;
57
61
65
68};
69
70template<typename Hamiltonian, size_t Nq, typename TimeScalar, typename VectorType>
73:tstep(0.), CHOSEN_VERBOSITY(VERBOSITY)
74{}
75
76template<typename Hamiltonian, size_t Nq, typename TimeScalar, typename VectorType>
78t_step (const Hamiltonian &H, const VectorType &Vin, VectorType &Vout, TimeScalar dt, double tol, int Nexp, TEBD_EXCEPTION EX)
79{
80 assert(Nexp==2 or Nexp==3 or Nexp==5 or Nexp==9 or Nexp==11 and "Implemented orders: 2,3,5,9,11");
81
82 if (dt != tstep)
83 {
84 tstep = dt;
85 if (Nexp == 2)
86 {
87 // error O(dt^2)
88 GateEvn1 = H.BondPropagator(tstep,EVEN);
89 GateOdd1 = H.BondPropagator(tstep,ODD);
90 GateEvn1Double = H.BondPropagator(2.*tstep,EVEN);
91 GateOdd1Double = H.BondPropagator(2.*tstep,ODD);
92 }
93 if (Nexp == 3)
94 {
95 // leapfrog, error O(dt^3) 0.070
96 GateEvn1 = H.BondPropagator(0.5*tstep,EVEN);
97 GateOdd1 = H.BondPropagator(tstep,ODD);
98 GateEvn1Double = H.BondPropagator(tstep,EVEN);
99 }
100 else if (Nexp == 5)
101 {
102 // error O(dt^3) 0.026
103 double xOdd1 = 0.5;
104 double y = pow(2.*sqrt(326.)-36.,1./3.);
105 double xEvn1 = (y*y+6.*y-2.)/(12.*y);
106 double xEvn2 = 1.-2.*xEvn1;
107
108 GateEvn1 = H.BondPropagator(xEvn1*tstep,EVEN);
109 GateOdd1 = H.BondPropagator(xOdd1*tstep,ODD);
110 GateEvn2 = H.BondPropagator(xEvn2*tstep,EVEN);
111 GateEvn1Double = H.BondPropagator(2.*xEvn1*tstep,EVEN);
112 }
113 else if (Nexp == 9)
114 {
115 // error O(dt^5), 0.014
116 double xEvn1 = (642.+sqrt(471.))/3924.;
117 double xEvn2 = 121./3924.*(12.-sqrt(471.));
118 double xEvn3 = 1.-2.*(xEvn1+xEvn2);
119 double xOdd1 = 6./11.;
120 double xOdd2 = -1./22.;
121
122 GateEvn1 = H.BondPropagator(xEvn1*tstep,EVEN);
123 GateOdd1 = H.BondPropagator(xOdd1*tstep,ODD);
124 GateEvn2 = H.BondPropagator(xEvn2*tstep,EVEN);
125 GateOdd2 = H.BondPropagator(xOdd2*tstep,ODD);
126 GateEvn3 = H.BondPropagator(xEvn3*tstep,EVEN);
127 GateEvn1Double = H.BondPropagator(2.*xEvn1*tstep,EVEN);
128 }
129 else if (Nexp == 11)
130 {
131 // error O(dt^5), 0.0046
132// double x1 = 0.25 * pow(1.-pow(cbrt(2.),-4.),-1.);
133// double x2 = 1.-4.*x1;
134// GateEvn1 = H.BondPropagator(0.5*x1*tstep,EVEN);
135// GateOdd1 = H.BondPropagator(x1*tstep,ODD);
136// GateEvn2 = H.BondPropagator(x1*tstep,EVEN);
137// GateEvn3 = H.BondPropagator((0.5*(x1+x2))*tstep,EVEN);
138// GateOdd2 = H.BondPropagator(x2*tstep,ODD);
139
140 double xEvn1 = (14.-sqrt(19.))/108.;
141 double xEvn2 = (20.-7.*sqrt(19.))/108.;
142 double xEvn3 = 0.5-xEvn1-xEvn2;
143 double xOdd1 = 0.4;
144 double xOdd2 = -0.1;
145 double xOdd3 = 0.4;
146
147 GateEvn1 = H.BondPropagator(xEvn1*tstep,EVEN);
148 GateOdd1 = H.BondPropagator(xOdd1*tstep,ODD);
149 GateEvn2 = H.BondPropagator(xEvn2*tstep,EVEN);
150 GateOdd2 = H.BondPropagator(xOdd2*tstep,ODD);
151 GateEvn3 = H.BondPropagator(xEvn3*tstep,EVEN);
152 GateOdd3 = H.BondPropagator(xOdd3*tstep,ODD);
153 GateEvn1Double = H.BondPropagator(2.*xEvn1*tstep,EVEN);
154 }
155 }
156
157 Stopwatch<> Chronos;
158
159 MpsCompressor<Nq,complex<double>,complex<double> > Compadre(CHOSEN_VERBOSITY);
160 VectorType Vtmp1, Vtmp2;
161
162 auto apply_gate = [this,&Compadre,&tol,&Nexp] (const Mpo<Nq,TimeScalar> &Gate, const VectorType &Vin, VectorType &Vout, int i, PARITY P)
163 {
164 Compadre.varCompress(Gate, Vin, Vout, Vin.calc_Dmax(), tol);
165 if (CHOSEN_VERBOSITY != DMRG::VERBOSITY::SILENT)
166 {
167 string p = (P==EVEN)? "EVEN " : "ODD ";
168 lout << p << i+1 << "/" << Nexp << ": " << Compadre.info() << endl;
169 }
170 };
171
172 if (Nexp <= 2)
173 {
174 apply_gate(GateEvn1,Vin, Vtmp1, 0,EVEN);
175 apply_gate(GateOdd1,Vtmp1,Vout, 1,ODD);
176 }
177 if (Nexp == 3)
178 {
179 if (EX == NO_EXCEPTION or EX == DOUBLE_FIRST or EX == DOUBLE_LAST)
180 {
181 if (EX == NO_EXCEPTION or EX == DOUBLE_LAST) {apply_gate(GateEvn1,Vin, Vtmp1, 0,EVEN);}
182 else {apply_gate(GateEvn1Double,Vin, Vtmp1, 0,EVEN);}
183 apply_gate(GateOdd1,Vtmp1,Vtmp2, 1,ODD);
184 if (EX == NO_EXCEPTION or EX == DOUBLE_FIRST) {apply_gate(GateEvn1,Vtmp2,Vout, 2,EVEN);}
185 else {apply_gate(GateEvn1Double,Vtmp2, Vout, 2,EVEN);}
186 }
187 else if (EX == EXCEPT_FIRST)
188 {
189 apply_gate(GateOdd1,Vin,Vtmp1, 1,ODD);
190 apply_gate(GateEvn1,Vtmp1,Vout, 2,EVEN);
191 }
192 else if (EX == EXCEPT_LAST)
193 {
194 apply_gate(GateEvn1,Vin, Vtmp1, 1,EVEN);
195 apply_gate(GateOdd1,Vtmp1,Vout, 2,ODD);
196 }
197 }
198 else if (Nexp == 5)
199 {
200 apply_gate(GateEvn1,Vin, Vtmp1, 0,EVEN);
201 apply_gate(GateOdd1,Vtmp1,Vtmp2, 1,ODD);
202 apply_gate(GateEvn2,Vtmp2,Vtmp1, 2,EVEN);
203 apply_gate(GateOdd1,Vtmp1,Vtmp2, 3,ODD);
204 apply_gate(GateEvn1,Vtmp2,Vout, 4,EVEN);
205 }
206 else if (Nexp == 7)
207 {
208 apply_gate(GateEvn1,Vin, Vtmp1, 0,EVEN);
209 apply_gate(GateOdd1,Vtmp1,Vtmp2, 1,ODD);
210 apply_gate(GateEvn2,Vtmp2,Vtmp1, 2,EVEN);
211 apply_gate(GateOdd2,Vtmp1,Vtmp2, 3,ODD);
212 apply_gate(GateEvn2,Vtmp2,Vtmp1, 4,EVEN);
213 apply_gate(GateOdd1,Vtmp1,Vtmp2, 5,ODD);
214 apply_gate(GateEvn1,Vtmp2,Vout, 6,EVEN);
215 }
216 else if (Nexp == 9)
217 {
218 if (EX == NO_EXCEPTION or EX == DOUBLE_FIRST or EX == DOUBLE_LAST)
219 {
220 if (EX == NO_EXCEPTION or EX == DOUBLE_LAST) {apply_gate(GateEvn1,Vin, Vtmp1, 0,EVEN);}
221 else {apply_gate(GateEvn1Double,Vin, Vtmp1, 0,EVEN);}
222 apply_gate(GateOdd1,Vtmp1,Vtmp2, 1,ODD);
223 apply_gate(GateEvn2,Vtmp2,Vtmp1, 2,EVEN);
224 apply_gate(GateOdd2,Vtmp1,Vtmp2, 3,ODD);
225 apply_gate(GateEvn3,Vtmp2,Vtmp1, 4,EVEN);
226 apply_gate(GateOdd2,Vtmp1,Vtmp2, 5,ODD);
227 apply_gate(GateEvn2,Vtmp2,Vtmp1, 6,EVEN);
228 apply_gate(GateOdd1,Vtmp1,Vtmp2, 7,ODD);
229 if (EX == NO_EXCEPTION or EX == DOUBLE_FIRST) {apply_gate(GateEvn1,Vtmp2,Vout, 8,EVEN);}
230 else {apply_gate(GateEvn1Double,Vtmp2, Vout, 8,EVEN);}
231 }
232 else if (EX == EXCEPT_FIRST)
233 {
234 apply_gate(GateOdd1,Vin, Vtmp2, 1,ODD);
235 apply_gate(GateEvn2,Vtmp2,Vtmp1, 2,EVEN);
236 apply_gate(GateOdd2,Vtmp1,Vtmp2, 3,ODD);
237 apply_gate(GateEvn3,Vtmp2,Vtmp1, 4,EVEN);
238 apply_gate(GateOdd2,Vtmp1,Vtmp2, 5,ODD);
239 apply_gate(GateEvn2,Vtmp2,Vtmp1, 6,EVEN);
240 apply_gate(GateOdd1,Vtmp1,Vtmp2, 7,ODD);
241 apply_gate(GateEvn1,Vtmp2,Vout, 8,EVEN);
242 }
243 else if (EX == EXCEPT_LAST)
244 {
245 apply_gate(GateEvn1,Vin, Vtmp1, 1,EVEN);
246 apply_gate(GateOdd1,Vtmp1,Vtmp2, 2,ODD);
247 apply_gate(GateEvn2,Vtmp2,Vtmp1, 3,EVEN);
248 apply_gate(GateOdd2,Vtmp1,Vtmp2, 4,ODD);
249 apply_gate(GateEvn3,Vtmp2,Vtmp1, 5,EVEN);
250 apply_gate(GateOdd2,Vtmp1,Vtmp2, 6,ODD);
251 apply_gate(GateEvn2,Vtmp2,Vtmp1, 7,EVEN);
252 apply_gate(GateOdd1,Vtmp1,Vout, 8,ODD);
253 }
254
255 }
256 else if (Nexp == 11)
257 {
258// apply_gate(GateEvn1,Vin, Vtmp1, 0);
259// apply_gate(GateOdd1,Vtmp1,Vtmp2, 1);
260// apply_gate(GateEvn2,Vtmp2,Vtmp1, 2);
261// apply_gate(GateOdd1,Vtmp1,Vtmp2, 3);
262// apply_gate(GateEvn3,Vtmp2,Vtmp1, 4);
263// apply_gate(GateOdd2,Vtmp1,Vtmp2, 5);
264// apply_gate(GateEvn3,Vtmp2,Vtmp1, 6);
265// apply_gate(GateOdd1,Vtmp1,Vtmp2, 7);
266// apply_gate(GateEvn2,Vtmp2,Vtmp1, 8);
267// apply_gate(GateOdd1,Vtmp1,Vtmp2, 9);
268// apply_gate(GateEvn1,Vtmp2,Vout, 10);
269
270 apply_gate(GateEvn1,Vin, Vtmp1, 0,EVEN);
271 apply_gate(GateOdd1,Vtmp1,Vtmp2, 1,ODD);
272 apply_gate(GateEvn2,Vtmp2,Vtmp1, 2,EVEN);
273 apply_gate(GateOdd2,Vtmp1,Vtmp2, 3,ODD);
274 apply_gate(GateEvn3,Vtmp2,Vtmp1, 4,EVEN);
275 apply_gate(GateOdd3,Vtmp1,Vtmp2, 5,ODD);
276 apply_gate(GateEvn3,Vtmp2,Vtmp1, 6,EVEN);
277 apply_gate(GateOdd2,Vtmp1,Vtmp2, 7,ODD);
278 apply_gate(GateEvn2,Vtmp2,Vtmp1, 8,EVEN);
279 apply_gate(GateOdd1,Vtmp1,Vtmp2, 9,ODD);
280 apply_gate(GateEvn1,Vtmp2,Vout, 10,EVEN);
281 }
282
283 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::ON_EXIT)
284 {
285 lout << Chronos.info("exp(-i*H*dt)*V") << endl;
286 lout << "Vout: " << Vout.info() << endl;
287 lout << endl;
288 }
289}
290
291#endif
PARITY
Definition: DmrgTypedefs.h:128
@ EVEN
Definition: DmrgTypedefs.h:128
@ ODD
Definition: DmrgTypedefs.h:128
TEBD_EXCEPTION
@ EXCEPT_FIRST
@ EXCEPT_LAST
@ NO_EXCEPTION
@ DOUBLE_FIRST
@ DOUBLE_LAST
static const tuple< int, double > optTEBDstep(double tmax, double dtmax, double tol_accu=0.05)
Definition: TEBDPropagator.h:8
Definition: Mpo.h:40
string info() const
TEBDPropagator(DMRG::VERBOSITY::OPTION VERBOSITY=DMRG::VERBOSITY::SILENT)
Mpo< Nq, TimeScalar > GateEvn3
void t_step(const Hamiltonian &H, const VectorType &Vin, VectorType &Vout, TimeScalar dt, double tol=1e-5, int Nexp=3, TEBD_EXCEPTION EX=NO_EXCEPTION)
Mpo< Nq, TimeScalar > GateEvn1Double
Mpo< Nq, TimeScalar > GateOdd2
TimeScalar tstep
Mpo< Nq, TimeScalar > GateEvn1
Mpo< Nq, TimeScalar > GateOdd1Double
Mpo< Nq, TimeScalar > GateOdd3
Mpo< Nq, TimeScalar > GateOdd1
DMRG::VERBOSITY::OPTION CHOSEN_VERBOSITY
Mpo< Nq, TimeScalar > GateEvn2