import numpy as np
from qiskit.circuit import QuantumCircuit, QuantumRegister, ClassicalRegister
from ising_kitaev import initialize_chain, braid_chain, rotate_to_measurement_basis, add_measurement, initialize_coupler

zeeman_ferro = 0.01
zeeman_para = 10

initial_config = np.array([zeeman_ferro]*3 + [zeeman_para]*9)

qreg = QuantumRegister(13)
creg = ClassicalRegister(3)
qcirc = QuantumCircuit(qreg, creg)

initialize_chain(qcirc, qreg, initial_config, 'up')
initialize_coupler(qcirc, qreg)
qcirc.draw()

braid_chain(qcirc, qreg, np.pi, 40, initial_config, 1.4, 0.25, 0.25, 2, 40, method='both')
qcirc.depth()

add_measurement(qcirc, qreg, creg, [0, 1, 2])

from qiskit import Aer, execute

backend = Aer.get_backend('qasm_simulator')
job = execute(qcirc, backend, shots=2000)

job.status()

result = job.result()
print(result.get_counts())