-
Notifications
You must be signed in to change notification settings - Fork 6
/
TStateObserver.h
79 lines (61 loc) · 1.58 KB
/
TStateObserver.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//
// Distributed under the ITensor Library License, Version 1.0.
// (See accompanying LICENSE file.)
//
#ifndef __ITENSOR_TSTATEOBSERVER_H
#define __ITENSOR_TSTATEOBSERVER_H
#include "itensor/mps/TEvolObserver.h"
//
// Class for monitoring time evolution calculations.
// The measure and checkDone methods are virtual
// so that behavior can be customized in a
// derived class.
//
namespace itensor {
template<class Tensor>
class TStateObserver : public TEvolObserver
{
public:
using MPST = MPSt<Tensor>;
TStateObserver(const MPST& psi,
const Args& args = Global::args());
virtual ~TStateObserver() { }
void virtual
measure(const Args& args = Global::args());
private:
/////////////
//
// Data Members
const MPST& psi_;
bool show_maxm_;
//
/////////////
}; // class TStateObserver
template<class Tensor>
inline TStateObserver<Tensor>::
TStateObserver(const MPST& psi,
const Args& args)
:
psi_(psi)
{
show_maxm_ = args.getBool("ShowMaxm",true);
}
template<class Tensor>
void inline TStateObserver<Tensor>::
measure(const Args& args)
{
const auto t = args.getReal("Time");
if(show_maxm_)
{
const auto ttotal = args.getReal("TotalTime");
const Real percentdone = (100.*t)/ttotal;
long maxm = 0;
for(int b = 1; b < psi_.N(); ++b)
{
maxm = std::max(maxm,linkInd(psi_,b).m());
}
printfln("%2.f%%:%d ",percentdone,maxm);
}
}
}
#endif // __ITENSOR_TSTATEOBSERVER_H