-
Notifications
You must be signed in to change notification settings - Fork 170
Expand file tree
/
Copy pathHeisenberg.h
More file actions
120 lines (92 loc) · 2.64 KB
/
Heisenberg.h
File metadata and controls
120 lines (92 loc) · 2.64 KB
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
119
120
//
// Distributed under the ITensor Library License, Version 1.1.
// (See accompanying LICENSE file.)
//
#ifndef __ITENSOR_HAMS_HEISENBERG_H
#define __ITENSOR_HAMS_HEISENBERG_H
#include "itensor/mps/mpo.h"
namespace itensor {
class Heisenberg
{
public:
Heisenberg(SiteSet const& sites,
Args const& args = Args::global());
operator MPO() { init_(); return H; }
private:
//////////////////
//
// Data Members
SiteSet const& sites_;
int N_;
Real J_,
Jz_;
bool initted_,
infinite_;
MPO H;
//
//////////////////
void
init_();
}; //class Heisenberg
inline Heisenberg::
Heisenberg(SiteSet const& sites,
Args const& args)
: sites_(sites),
initted_(false)
{
N_ = sites_.length();
J_ = args.getReal("J",1.);
Jz_ = args.getReal("Jz",J_);
infinite_ = args.getBool("Infinite",false);
}
void inline Heisenberg::
init_()
{
if(initted_) return;
H = MPO(sites_);
std::vector<Index> links(N_+1);
for(int l = 0; l <= N_; ++l)
{
auto ts = format("Link,l=%d",l);
links.at(l) = Index(QN({"Sz", 0}),3,
QN({"Sz",-2}),1,
QN({"Sz",+2}),1,
Out,
ts);
}
Index const& last = (infinite_ ? links.at(0) : links.at(N_));
for(int n = 1; n <= N_; ++n)
{
auto& W = H.ref(n);
auto row = dag(links.at(n-1));
auto col = (n==N_ ? last : links.at(n));
W = ITensor(dag(sites_(n)),prime(sites_(n)),row,col);
W += sites_.op("Id",n) * setElt(row(1)) * setElt(col(1)); //ending state
W += sites_.op("Id",n) * setElt(row(2)) * setElt(col(2)); //starting state
W += sites_.op("Sz",n) * setElt(row(3)) * setElt(col(1));
W += sites_.op("Sz",n) * setElt(row(2)) * setElt(col(3)) * Jz_;
W += sites_.op("Sm",n) * setElt(row(4)) * setElt(col(1));
W += sites_.op("Sp",n) * setElt(row(2)) * setElt(col(4)) * J_/2;
W += sites_.op("Sp",n) * setElt(row(5)) * setElt(col(1));
W += sites_.op("Sm",n) * setElt(row(2)) * setElt(col(5)) * J_/2;
}
auto LH = setElt(links.at(0)(2));
auto RH = setElt(dag(last)(1));
if(not infinite_)
{
//Multiply first and last
//MPO tensor by edge vectors
H.ref(1) *= LH;
H.ref(N_) *= RH;
}
else
{
//Store edge vectors just before
//and after first and last sites
H.ref(0) = LH;
H.ref(N_+1) = RH;
}
initted_ = true;
}
} //namespace itensor
#endif