Skip to content
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
2 changes: 1 addition & 1 deletion oqupy/bath.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(
self._coupling_operator = tmp_coupling_operator
self._unitary = np.identity(self._dimension)
else:
w, v = np.linalg.eig(tmp_coupling_operator)
w, v = np.linalg.eigh(tmp_coupling_operator)
self._coupling_operator = np.diag(w)
self._unitary = v
assert np.allclose(tmp_coupling_operator, \
Expand Down
21 changes: 20 additions & 1 deletion tests/coverage/bath_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

from oqupy.bath import Bath
from oqupy.bath_correlations import PowerLawSD
from oqupy import operators

def test_bath():
wc = 4.0
Expand Down Expand Up @@ -79,6 +78,26 @@ def test_bath():
assert np.array_equal(bath_C.west_degeneracy_map,[0,0,0,0])
assert np.array_equal(bath_C.north_degeneracy_map,[0,0,0,0])

# Checks that the diagonalisation of the bath also works for degenerate
# coupling operators (see issue #165)
def test_bath_degenerate_coupling_op():
degenerat_coupling_op = np.array(
[[0.+0.j, 1.+0.j, 1.+0.j, 0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
[1.+0.j, 0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j],
[1.+0.j, 0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j],
[0.+0.j, 1.+0.j, 1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j],
[1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j, 1.+0.j, 0.+0.j],
[0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j, 1.+0.j],
[0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j, 1.+0.j],
[0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j, 1.+0.j, 1.+0.j, 0.+0.j]])
correlations = PowerLawSD(
alpha=0.02,
zeta=1,
cutoff=0.5,
cutoff_type="exponential",
temperature=0.5)
Bath(degenerat_coupling_op, correlations) # this failed before PR #166

def test_bath_bad_input():
wc = 4.0
alpha = 0.3
Expand Down
Loading