diff --git a/doc/source/pre/whatsnew/1.1.rst b/doc/source/pre/whatsnew/1.1.rst new file mode 100644 index 0000000000000000000000000000000000000000..6e9a4fd90d11fa23bd69e8b9a2cb0d2630cd16e5 --- /dev/null +++ b/doc/source/pre/whatsnew/1.1.rst @@ -0,0 +1,12 @@ +What's new in Kwant 1.1 +======================= + +This article explains the user-visible changes in Kwant 1.1. + +Harmonize `~kwant.physics.Bands` with `~kwant.physics.modes` +------------------------------------------------------------ +Kwant's convention is that momenta are positive in the direction of +`~kwant.lattice.TranslationalSymmetry`. While the momenta returned by +`~kwant.physics.modes` did respect this convention, the momenta read off the +band structure as given by `~kwant.physics.Bands` had the wrong sign. This has +been fixed now. diff --git a/doc/source/pre/whatsnew/index.rst b/doc/source/pre/whatsnew/index.rst index fc007c32e55725aa702fd5ea76b00d728ba06ec7..b97a4f12591efd87862cbff78ae953d5a00721e2 100644 --- a/doc/source/pre/whatsnew/index.rst +++ b/doc/source/pre/whatsnew/index.rst @@ -2,5 +2,6 @@ What's new in Kwant =================== .. toctree:: + 1.1 1.0 0.2 diff --git a/kwant/physics/dispersion.py b/kwant/physics/dispersion.py index 1c8bb2042dafc62616a5e47a4f1b64842d58042c..312c07dfd995fbaab94a3a8487a3f77fec9df5c9 100644 --- a/kwant/physics/dispersion.py +++ b/kwant/physics/dispersion.py @@ -49,6 +49,8 @@ class Bands(object): self.hop[:, hop.shape[1]:] = 0 def __call__(self, k): - mat = self.hop * complex(math.cos(k), math.sin(k)) + # Note: Equation to solve is + # (V^\dagger e^{ik} + H + V e^{-ik}) \psi = E \psi + mat = self.hop * complex(math.cos(k), -math.sin(k)) mat += mat.conjugate().transpose() + self.ham return np.sort(np.linalg.eigvalsh(mat).real) diff --git a/kwant/physics/tests/test_dispersion.py b/kwant/physics/tests/test_dispersion.py index cf41d48c570bb51a48f2cca2c7d3e89b6318dc6a..e2d759525292e63a126af7570217a2a9825171be 100644 --- a/kwant/physics/tests/test_dispersion.py +++ b/kwant/physics/tests/test_dispersion.py @@ -6,9 +6,9 @@ # the AUTHORS file at the top-level directory of this distribution and at # http://kwant-project.org/authors. -from numpy.testing import assert_array_almost_equal +from numpy.testing import assert_array_almost_equal, assert_almost_equal import kwant -from math import pi, cos +from math import pi, cos, sin def test_band_energies(N=5): sys = kwant.Builder(kwant.TranslationalSymmetry((-1, 0))) @@ -23,3 +23,16 @@ def test_band_energies(N=5): energies = band_energies(k) assert_array_almost_equal(sorted(energies), sorted([2 - 2 * cos(k), 4 - 2 * cos(k)])) + +def test_same_as_lead(): + sys = kwant.Builder(kwant.TranslationalSymmetry((-1,))) + lat = kwant.lattice.chain() + sys[lat(0)] = 0 + sys[lat(0), lat(1)] = complex(cos(0.2), sin(0.2)) + + sys = sys.finalized() + momenta = sys.modes()[0].momenta + bands = kwant.physics.Bands(sys) + + for momentum in momenta: + assert_almost_equal(bands(momentum)[0], 0) diff --git a/kwant/system.py b/kwant/system.py index 8497b8111e013bd3720b74fd5f2ed42cfe571b7d..3d9f0b3ca7bdbb23a0e42ddd62d3672609e473c8 100644 --- a/kwant/system.py +++ b/kwant/system.py @@ -194,8 +194,8 @@ class InfiniteSystem(System): def inter_cell_hopping(self, args=(), sparse=False): """Hopping Hamiltonian between two cells of the infinite system.""" cell_sites = xrange(self.cell_size) - neighbor_sites = xrange(self.cell_size, self.graph.num_nodes) - return self.hamiltonian_submatrix(args, cell_sites, neighbor_sites, + interface_sites = xrange(self.cell_size, self.graph.num_nodes) + return self.hamiltonian_submatrix(args, cell_sites, interface_sites, sparse=sparse) def modes(self, energy=0, args=()):