<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 QuTiP example
Step1:  If your qutip version is lower than 4.4.1 please run the following cell
Step2:  Otherwise please run this cell
Step3:  Hamiltonian
Step4:  The non-adjacent interactions are broken into a series of adjacent ones by the program automatically.
Step5:  Circular Spin Chain Model Implementation
Step6:  The results obtained from the physical implementation agree with the ideal result.
Step7:  The gates are first convert to gates with adjacent interactions moving in the direction with the least number of qubits in between.
Step8:  They are then converted into the basis [ISWAP, RX, RZ]
Step9:  The time for each applied gate
Step10:  The pulse can be plotted as
Step11:  Linear Spin Chain Model Implementation
Step12:  The results obtained from the physical implementation agree with the ideal result.
Step13:  The gates are first convert to gates with adjacent interactions moving in the direction with the least number of qubits in between.
Step14:  They are then converted into the basis [ISWAP, RX, RZ]
Step15:  The time for each applied gate
Step16:  The pulse can be plotted as
Step17:  Numerical simulation
From QuTiP 4.5, we also add the possibility to allow numerical simulation of SpinChain-based quantum computing. One needs only to add an option analytical=False in run_state to use one of the QuTiP solvers to simulate the state evolution instead of direct matrix product. Under numerical simulation, one can go beyond simulation with perfect gate operations. All the noise defined for the class Processor can also be used for SpinChain here.
Step18:  As the control noise is coherent noise, the result of this noise is still a pure state. Therefore, we can visualize it on a Bloch sphere.
Step19:  Software versions
<ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from qutip.qip.circuit import QubitCircuit
from qutip.qip.operations import gate_sequence_product
import numpy as np
Explanation: QuTiP example: Physical implementation of Spin Chain Qubit model
Author: Anubhav Vardhan (anubhavvardhan@gmail.com)
Numerical simulation added by Boxi Li (etamin1201@gmail.com)
For more information about QuTiP see http://qutip.org
End of explanation
from qutip.qip.models.spinchain import CircularSpinChain
from qutip.qip.models.spinchain import LinearSpinChain
Explanation: If your qutip version is lower than 4.4.1 please run the following cell
End of explanation
from qutip.qip.device import CircularSpinChain, LinearSpinChain
from qutip.qip.noise import RandomNoise
Explanation: Otherwise please run this cell
End of explanation
N = 3
qc = QubitCircuit(N)
qc.add_gate("CNOT", targets=[0], controls=[2])
Explanation: Hamiltonian:
$\displaystyle H = - \frac{1}{2}\sum_n^N h_n \sigma_z(n) - \frac{1}{2} \sum_n^{N-1} [ J_x^{(n)} \sigma_x(n) \sigma_x(n+1) + J_y^{(n)} \sigma_y(n) \sigma_y(n+1) +J_z^{(n)} \sigma_z(n) \sigma_z(n+1)]$
The linear and circular spin chain models employing the nearest neighbor interaction can be implemented using the SpinChain class.
Circuit Setup
End of explanation
U_ideal = gate_sequence_product(qc.propagators())
U_ideal
Explanation: The non-adjacent interactions are broken into a series of adjacent ones by the program automatically.
End of explanation
p1 = CircularSpinChain(N, correct_global_phase=True)
U_list = p1.run(qc)
U_physical = gate_sequence_product(U_list)
U_physical.tidyup(atol=1e-5)
(U_ideal - U_physical).norm()
Explanation: Circular Spin Chain Model Implementation
End of explanation
p1.qc0.gates
Explanation: The results obtained from the physical implementation agree with the ideal result.
End of explanation
p1.qc1.gates
Explanation: The gates are first convert to gates with adjacent interactions moving in the direction with the least number of qubits in between.
End of explanation
p1.qc2.gates
Explanation: They are then converted into the basis [ISWAP, RX, RZ]
End of explanation
p1.get_full_tlist()
Explanation: The time for each applied gate:
End of explanation
p1.plot_pulses();
Explanation: The pulse can be plotted as:
End of explanation
p2 = LinearSpinChain(N, correct_global_phase=True)
U_list = p2.run(qc)
U_physical = gate_sequence_product(U_list)
U_physical.tidyup(atol=1e-5)
(U_ideal - U_physical).norm()
Explanation: Linear Spin Chain Model Implementation
End of explanation
p2.qc0.gates
Explanation: The results obtained from the physical implementation agree with the ideal result.
End of explanation
p2.qc1.gates
Explanation: The gates are first convert to gates with adjacent interactions moving in the direction with the least number of qubits in between.
End of explanation
p2.qc2.gates
Explanation: They are then converted into the basis [ISWAP, RX, RZ]
End of explanation
p2.get_full_tlist()
Explanation: The time for each applied gate:
End of explanation
p2.plot_pulses();
Explanation: The pulse can be plotted as:
End of explanation
from qutip import basis, fidelity
N = 1
plus_state = (basis(2,0) + basis(2,1)).unit()
qc = QubitCircuit(N=N)
qc.add_gate("SNOT", targets=0)
processor = LinearSpinChain(N=N)
processor.load_circuit(qc)
end_state = processor.run_state(init_state=basis(2, 0), analytical=False).states[-1]
fidelity(end_state, plus_state)
processor.add_noise(RandomNoise(rand_gen=np.random.normal, dt=0.1, loc=0.1, scale=0.2))
end_state = processor.run_state(init_state=basis(2, 0), analytical=False).states[-1]
fidelity(end_state, plus_state)
Explanation: Numerical simulation
From QuTiP 4.5, we also add the possibility to allow numerical simulation of SpinChain-based quantum computing. One needs only to add an option analytical=False in run_state to use one of the QuTiP solvers to simulate the state evolution instead of direct matrix product. Under numerical simulation, one can go beyond simulation with perfect gate operations. All the noise defined for the class Processor can also be used for SpinChain here.
End of explanation
from qutip.bloch import Bloch
b = Bloch()
b.add_states([end_state, plus_state])
b.make_sphere()
Explanation: As the control noise is coherent noise, the result of this noise is still a pure state. Therefore, we can visualize it on a Bloch sphere.
End of explanation
from qutip.ipynbtools import version_table
version_table()
Explanation: Software versions:
End of explanation
<END_TASK>