Skip to content

Commit

Permalink
Fix a bug for the wrong tlist in c_ops (#107)
Browse files Browse the repository at this point in the history
The get_full_tlist method only considers the tlist in the ideal pulse. If the Lindblad noise has a different time dependency, this will cause inconsistency. Use the tlist of the generated QobjEvo, which already includes all the time steps.
  • Loading branch information
BoxiLi committed Nov 20, 2021
1 parent 995f8e3 commit 54ab065
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/qutip_qip/device/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,10 +955,9 @@ def get_qobjevo(self, args=None, noisy=False):
final_qu.args.update(args)

# bring all c_ops to the same tlist, won't need it in QuTiP 5
full_tlist = self.get_full_tlist()
temp = []
for c_op in c_ops:
temp.append(_merge_qobjevo([c_op], full_tlist))
temp.append(_merge_qobjevo([c_op], final_qu.tlist))
c_ops = temp

if noisy:
Expand Down
20 changes: 18 additions & 2 deletions tests/test_noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

from qutip import (
tensor, qeye, sigmaz, sigmax, sigmay, destroy, identity, QobjEvo,
fidelity, basis
fidelity, basis, sigmam
)
from qutip_qip.device import Processor, SCQubits
from qutip_qip.device import Processor, SCQubits, LinearSpinChain
from qutip_qip.noise import (
RelaxationNoise, DecoherenceNoise, ControlAmpNoise, RandomNoise,
ZZCrossTalk, Noise)
Expand Down Expand Up @@ -50,6 +50,22 @@ def test_decoherence_noise(self):
assert_allclose(c_ops[0].tlist, tlist)
assert_allclose(c_ops[1].ops[0].qobj, tensor(qeye(2), sigmax()))

def test_collapse_with_different_tlist(self):
"""
Test if there are errors raised because of wrong tlist handling.
"""
qc = QubitCircuit(1)
qc.add_gate("X", 0)
proc = LinearSpinChain(1)
proc.load_circuit(qc)
tlist = np.linspace(0, 30., 100)
coeff = tlist * 0.1
noise = DecoherenceNoise(
sigmam(), targets=0,
coeff=coeff, tlist=tlist)
proc.add_noise(noise)
proc.run_state(basis(2, 0))

def test_relaxation_noise(self):
"""
Test for the relaxation noise
Expand Down

0 comments on commit 54ab065

Please sign in to comment.