-
Notifications
You must be signed in to change notification settings - Fork 3
/
localmpoproj.h
118 lines (95 loc) · 2.66 KB
/
localmpoproj.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
//
// localmpoproj.hpp
//
//
// Created by Erich Mueller on 6/25/19.
// Edited by Shovan Dutta on 7/28/21
//
#ifndef localmpoproj_hpp
#define localmpoproj_hpp
#include <stdio.h>
#include "itensor/mps/localmpo.h"
namespace itensor
{
class LocalMPOproj
{
private:
MPO const *Op_ = nullptr; // Hamiltonian (H_c)
MPO const *Proj_ = nullptr; // Discontinuity op - positive semidefinite
LocalMPO lmpoH_;
LocalMPO lmpoProj_;
public:
Real weight_ = 1; // How much to weight penalty
LocalMPOproj() {}
LocalMPOproj(MPO const &Op,
MPO const &Proj,
Args const &args = Args::global());
//
// Sparse matrix methods
//
void
product(ITensor const &phi,
ITensor &phip) const;
Real
expect(ITensor const &phi) const // Energy with penalty
{
return lmpoH_.expect(phi) + weight_ * lmpoProj_.expect(phi);
}
Real
Hexpect(ITensor const &phi) const // Energy (E_c)
{
return lmpoH_.expect(phi);
}
Real
Projexpect(ITensor const &phi) const // Discontinuity measure
{
return lmpoProj_.expect(phi);
}
ITensor
deltaRho(ITensor const &AA,
ITensor const &comb,
Direction dir) const
{
return lmpoH_.deltaRho(AA, comb, dir) + lmpoProj_.deltaRho(AA, comb, dir);
}
// note no weight factor!!
// That was a design decision
// can re-evaluate
void
position(int b, MPS const &psi);
size_t
size() const { return lmpoH_.size(); }
explicit
operator bool() const { return (bool(Op_) and bool(Proj_)); }
Real
weight() const { return weight_; }
void
weight(Real val) { weight_ = val; } // Set weight
}; // end templates
// Constructors
inline LocalMPOproj::
LocalMPOproj(MPO const &Op,
MPO const &Proj,
Args const &args)
: Op_(&Op), Proj_(&Proj), weight_(args.getReal("Weight", 1))
{
lmpoH_ = LocalMPO(Op);
lmpoProj_ = LocalMPO(Proj);
}
void inline LocalMPOproj::
product(ITensor const &phi,
ITensor &phip) const
{
lmpoH_.product(phi, phip);
ITensor other;
lmpoProj_.product(phi, other);
phip += weight_ * other;
}
void inline LocalMPOproj::
position(int b, const MPS &psi)
{
lmpoH_.position(b, psi);
lmpoProj_.position(b, psi);
}
}
#endif /* localmpoproj_hpp */