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
from ising_kitaev import move_chain

zeeman_ferro = 0.01  # value of on-site magnetic field for ferromagnetic domain
zeeman_para = 10  # value of on-site magnetic field for paramagnetic domain
initial_config = np.array([zeeman_ferro, zeeman_ferro, zeeman_ferro, zeeman_para, zeeman_para, zeeman_para])
final_config = np.array([zeeman_para, zeeman_para, zeeman_para, zeeman_ferro, zeeman_ferro, zeeman_ferro])
qreg = QuantumRegister(6)
creg = ClassicalRegister(3)
qcirc = QuantumCircuit(qreg, creg)

initialize_chain(qcirc, qreg, initial_config, 'logical_zero')
qcirc.draw()
move_chain(qcirc, qreg, initial_config, final_config, 0, 0.25, 0.25, 2, 10, method = "both")
qcirc.depth()

rotate_to_measurement_basis(qcirc, qreg, [3, 4, 5])
add_measurement(qcirc, qreg, creg, [3, 4, 5])

from qiskit import Aer, execute
backend = Aer.get_backend('qasm_simulator')
job = execute(qcirc, backend, shots=2000)
job.status()
result = job.result()
result.get_counts()

