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

zeeman_ferro = 0.01
zeeman_para = 10

initial_config = np.array([zeeman_ferro, zeeman_ferro, zeeman_ferro, zeeman_para])
final_config = np.array([zeeman_ferro, zeeman_ferro, zeeman_ferro, zeeman_ferro])

qreg = QuantumRegister(4)
creg = ClassicalRegister(4)
qcirc = QuantumCircuit(qreg, creg)

initialize_chain(qcirc, qreg, initial_config, 'logical_one')
qcirc.draw()

run_adiabatic_zeeman_change(qcirc, qreg, initial_config, final_config, 0, 0.25, 0.25, 1, 10)
qcirc.depth()

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

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())