forked from StefanoBarison/p-VQD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ansatze.py
71 lines (37 loc) · 1.05 KB
/
ansatze.py
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
## These file will contain all the ansatze used for variational quantum simulation
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
#=========================================
def hweff_ansatz(n_spins,depth,p):
circuit = QuantumCircuit(n_spins)
count = 0
for j in range(depth):
if(j%2 == 0):
# Rx - Rzz block
for i in range(n_spins):
circuit.rx(p[count],i)
count = count +1
circuit.barrier()
for i in range(n_spins-1):
circuit.rzz(p[count],i,i+1)
count = count +1
circuit.barrier()
if(j%2 == 1):
for i in range(n_spins):
circuit.ry(p[count],i)
count = count +1
circuit.barrier()
for i in range(n_spins-1):
circuit.rzz(p[count],i,i+1)
count = count +1
circuit.barrier()
# Final block to close the ansatz
if (depth%2 == 1):
for i in range(n_spins):
circuit.ry(p[count],i)
count = count +1
if (depth%2 == 0):
for i in range(n_spins):
circuit.rx(p[count],i)
count = count +1
return circuit
#==========================================