Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug for the wrong tlist in c_ops #107

Merged
merged 1 commit into from
Nov 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/qutip_qip/device/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,10 +781,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