forked from dwavesystems/dwave-pimc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
153 lines (137 loc) · 6.74 KB
/
main.cpp
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
Copyright 2020 D-Wave Systems Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Path Integral Monte Carlo code for analysis of a finite temperature transverse field Ising model,
Defined by partition function Z = Trace[exp(-H)], and scaled Hamiltonian
H = invTemp/2 sum_{i,j} J_{ij} \sigma^z_i \sigma^z_j + invTemp \sum_i [h_i \sigma^z_i - \Gamma\sigma^x_i]
Methods exploit either single qubit Swendsen-Wang updates, or multi-qubit Swendsen-Wang updates,
in the latter case specifically for regular and independent 1d ferromagnetic subsequences. These
match the methods explored in A King et al. https://arxiv.org/abs/1911.03446
Authors: Jack Raymond, Stephen Face
Copyright: D-Wave Systems
License: Apache 2
Last modification: March 20 2020
See also README.md localPIMC.cpp and localPIMC.hpp
*/
#include <ctime>
#include <iostream>
#include "localPIMC.hpp"
int main(int argc, char *argv[]) {
if (argc < 3) {
std::cerr << "Requires two arguments: experimentNo[0,1] initialCondition[-1,0,1]\n e.g. ./_demo 1 1\n";
return EXIT_FAILURE;
}
int experimentNo = atoi(argv[1]);
int initialCondition = atoi(argv[2]);
if (initialCondition < -1 || initialCondition > 1) {
std::cerr << "Second argument, initialCondition must be selected from {-1,0,1}";
return EXIT_FAILURE;
}
unsigned int seed = 0; // 0 = Use random device, otherwise reproducible
int Lperiodic = 24; // Largest lattice
int nSweeps = 32768;
switch (experimentNo) {
case 0: {
//[Figure 17 1911.03446v2] (convergence on triangular cylinder, single qubit move)
int qubitsPerChain = 1;
int qubitsPerUpdate = 1;
double invTempOverJ = 2;
double GammaOverJ = 0.6;
std::cout << "#24 by 15 Triangular lattice, T/J=0.5, Gamma/J=0.6, generate sample projected in "
"computational basis at "
<< nSweeps << " sweeps, from classical initial condition with winding number " << initialCondition
<< "\n";
localPIMC localpimc(Lperiodic, invTempOverJ, GammaOverJ, initialCondition, qubitsPerUpdate, qubitsPerChain,
seed);
auto tstart = std::clock();
localpimc.run(nSweeps);
auto tend = std::clock();
std::cout << "#Time required:" << (tend - tstart) / (double)CLOCKS_PER_SEC << " second(s)\n";
for (int x : localpimc.firstSlice) {
std::cout << x << " ";
}
break;
}
case 1: {
//[Figure 17 1911.03446v2] (convergence on triangular cylinder, single qubit move)
Lperiodic = 12;
int qubitsPerChain = 1;
int qubitsPerUpdate = 1;
double invTempOverJ = 2;
double GammaOverJ = 0.6;
std::cout << "#12 by 9 Triangular lattice, T/J=0.5, Gamma/J=0.6, generate sample projected in "
"computational basis at "
<< nSweeps << " sweeps, from classical initial condition with winding number " << initialCondition
<< "\n";
localPIMC localpimc(Lperiodic, invTempOverJ, GammaOverJ, initialCondition, qubitsPerUpdate, qubitsPerChain,
seed);
auto tstart = std::clock();
localpimc.run(nSweeps);
auto tend = std::clock();
std::cout << "#Time required:" << (tend - tstart) / (double)CLOCKS_PER_SEC << " second(s)\n";
for (int x : localpimc.firstSlice) {
std::cout << x << " ";
}
std::cout << "\n";
break;
}
case 2: {
//[Figure 15f and others, 1911.03446v2] (convergence on square octagonal lattice cylinder, four qubit move)
//[Various figures, 1911.03446v2] (convergence on square octagonal lattice cylinder, single qubit move)
int qubitsPerChain = 4;
int qubitsPerUpdate = 4;
double invTempOverJ = 1 / 0.244;
double GammaOverJ = 0.736;
std::cout << "#24 by 15 Square Octagonal lattice, T/J=0.244, Gamma/J=0.736, generate sample projected in "
"computational basis at "
<< nSweeps << " sweeps, from classical initial condition with winding number " << initialCondition
<< " (with 4-qubit spatially local moves)\n";
localPIMC localpimc(Lperiodic, invTempOverJ, GammaOverJ, initialCondition, qubitsPerUpdate, qubitsPerChain,
seed);
auto tstart = std::clock();
localpimc.run(nSweeps);
auto tend = std::clock();
std::cout << "#Time required:" << (tend - tstart) / (double)CLOCKS_PER_SEC << " second(s)\n";
for (int x : localpimc.firstSlice) {
std::cout << x << " ";
}
std::cout << "\n";
break;
}
case 3: {
//[Convergence on square octagonal lattice cylinder by less efficient single qubit move)
int qubitsPerChain = 4;
int qubitsPerUpdate = 1;
double invTempOverJ = 1 / 0.244;
double GammaOverJ = 0.736;
std::cout << "#24 by 15 Square Octagonal lattice, T/J=0.244, Gamma/J=0.736, generate sample projected in "
"computational basis at "
<< nSweeps << " sweeps, from classical initial condition with winding number " << initialCondition
<< " (with [more slowly converging] 1-qubit spatially local moves)\n";
localPIMC localpimc(Lperiodic, invTempOverJ, GammaOverJ, initialCondition, qubitsPerUpdate, qubitsPerChain,
seed);
auto tstart = std::clock();
localpimc.run(nSweeps);
auto tend = std::clock();
std::cout << "#Time required:" << (tend - tstart) / (double)CLOCKS_PER_SEC << " second(s)\n";
for (int x : localpimc.firstSlice) {
std::cout << x << " ";
}
std::cout << "\n";
break;
}
default:
std::cerr << "Unknown experimentNo";
return EXIT_FAILURE;
}
}