-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
56 lines (41 loc) · 1.11 KB
/
test.py
File metadata and controls
56 lines (41 loc) · 1.11 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
from qiskit import *
from numpy import pi
from qiskit.providers.aer import QasmSimulator
steps = 200
min = 10000000
best = -1
for i in range(steps):
theta = i * (2*pi/steps)
print('Simulating for theta:', theta)
for j in range(steps):
phi = j * (2*pi/steps)
#print('Simulating for theta:', theta, 'and phi:', phi)
qc = QuantumCircuit(2)
qc.h(0)
qc.h(1)
qc.z(0)
qc.x(0)
qc.z(0)
qc.x(0)
qc.cz(0, 1)
qc.cp(theta, 0, 1)
qc.h(0)
qc.h(1)
qc.x(0)
qc.x(1)
qc.cp(phi, 0, 1)
qc.x(0)
qc.x(1)
qc.h(0)
qc.h(1)
qc.save_statevector()
qc.measure_all()
backend = QasmSimulator()
backend_options = {'method': 'statevector'}
job = execute(qc, backend, backend_options=backend_options)
job_result = job.result()
wanted = job_result.get_statevector(qc)[3]
if abs(wanted) < min:
min = abs(wanted)
best = wanted
print(min)