Skip to content
Snippets Groups Projects
Commit 79d994be authored by Michael Wimmer's avatar Michael Wimmer Committed by Christoph Groth
Browse files

fix ordering of modes and momenta

parent d685dc0d
No related branches found
No related tags found
No related merge requests found
......@@ -498,9 +498,10 @@ def make_proper_modes(lmbdainv, psi, extract, tol=1e6):
raise RuntimeError("Numbers of left- and right-propagating "
"modes differ, possibly due to a numerical "
"instability.")
momenta = np.angle(lmbdainv)
order = np.lexsort([np.sign(velocities), -np.sign(velocities) * momenta,
velocities])
momenta = -np.angle(lmbdainv)
order = np.lexsort([velocities, -np.sign(velocities) * momenta,
np.sign(velocities)])
# The following is necessary due to wrong numpy handling of zero length
# arrays, which is going to be fixed in numpy 1.8.
if not len(order):
......
......@@ -226,7 +226,7 @@ def test_modes():
assert stab.nmodes == 1
assert stab.sqrt_hop is None
np.testing.assert_almost_equal(prop.velocities, [-v, v])
np.testing.assert_almost_equal(prop.momenta, [-k, k])
np.testing.assert_almost_equal(prop.momenta, [k, -k])
# Test for normalization by current.
np.testing.assert_almost_equal(
2 * (stab.vecs[0] * stab.vecslmbdainv[0].conj()).imag, [1, -1])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment