-
Notifications
You must be signed in to change notification settings - Fork 170
Expand file tree
/
Copy pathExpIsing.h
More file actions
83 lines (63 loc) · 1.65 KB
/
ExpIsing.h
File metadata and controls
83 lines (63 loc) · 1.65 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
//
// Distributed under the ITensor Library License, Version 1.1.
// (See accompanying LICENSE file.)
//
#ifndef __EXP_ISING_H
#define __EXP_ISING_H
#include "itensor/mps/mpo.h"
namespace itensor {
class ExpIsing
{
SpinHalf const& sites_;
int N_ = 0;
Cplx tau_ = 0;
Real h_ = 0;
bool initted_ = false;
MPO H_;
public:
ExpIsing(SpinHalf const& sites,
Cplx tau,
Args const& args = Args::global());
operator MPO() { init_(); return H_; }
private:
void
init_();
}; //class ExpIsing
inline ExpIsing::
ExpIsing(SpinHalf const& sites,
Cplx tau,
Args const& args)
: sites_(sites),
tau_(tau),
initted_(false)
{
N_ = sites_.length();
h_ = args.getReal("h",0.);
}
void inline ExpIsing::
init_()
{
if(initted_) return;
H_ = MPO(sites_);
auto links = std::vector<Index>(N_+1);
for(int l = 0; l <= N_; ++l)
{
links.at(l) = Index(2,format("Link,l=%d",l));
}
for(int n = 1; n <= N_; ++n)
{
auto& W = H_.ref(n);
auto row = dag(links.at(n-1));
auto col = links.at(n);
W = ITensor(sites_(n),prime(sites_(n)),row,col);
W += sites_.op("Id",n) * setElt(row(1)) * setElt(col(1));
W += -tau_ * (-h_) * ITensor(sites_.op("Sx",n)) * setElt(row(1)) * setElt(col(1));
W += -tau_ * sites_.op("Sz",n) * setElt(row(1)) * setElt(col(2));
W += sites_.op("Sz",n) * setElt(row(2)) * setElt(col(1));
}
H_.ref(1) *= setElt(links.at(0)(1));
H_.ref(N_) *= setElt(links.at(N_)(1));
initted_ = true;
}
} //namespace itensor
#endif