#initialization
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
import math

# importing Qiskit
from qiskit import IBMQ, BasicAer
from qiskit.providers.ibmq import least_busy
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister, execute

# import basic plot tools
from qiskit.tools.visualization import plot_histogram

def ising_gate(circuit,qrj,qrl,Jt):
    circuit.cx(qrj,qrl)
    circuit.u1(-2*Jt,qrl)
    circuit.cx(qrj,qrl)  

def fieldx_gate(circuit,qrj,Bt):
    # We use rotation around x 
    circuit.rx(-2*Bt,qrj)

def fieldz_gate(circuit,qrj,Bt):
    circuit.rz(-2*Bt,qrj)

def initialize_qa(circuit,qr):
    circuit.h(qr)

qr = QuantumRegister(2)
cr = QuantumRegister(2)
circuit = QuantumCircuit(qr)
initialize_qa(circuit,qr)
ising_gate(circuit,qr[0],qr[1],1)
fieldx_gate(circuit,qr,1)

circuit.draw(output='mpl')