diff --git a/doc/source/reference/kwant.physics.rst b/doc/source/reference/kwant.physics.rst index 7b202da06aba3f9d78badfc4ba20796c34a52320..2c457f5617e405622f42602a9f01c60a945ea555 100644 --- a/doc/source/reference/kwant.physics.rst +++ b/doc/source/reference/kwant.physics.rst @@ -12,4 +12,5 @@ Leads modes selfenergy selfenergy_from_modes - ModesTuple + PropagatingModes + StabilizedModes diff --git a/doc/source/reference/kwant.system.rst b/doc/source/reference/kwant.system.rst index 00065e6a8f9b231a2a79c3ee9f88296351e0c60b..826eed55077cf1aa4596ac57c0c6e8fb400efebb 100644 --- a/doc/source/reference/kwant.system.rst +++ b/doc/source/reference/kwant.system.rst @@ -20,3 +20,4 @@ the interface defined here. System InfiniteSystem FiniteSystem + PrecalculatedLead diff --git a/doc/source/whatsnew/1.0.rst b/doc/source/whatsnew/1.0.rst index 13c8f574719f0f9d722c0604db9c0da3b59be286..597c3c9315d4fbb060bda7c71ddb9b2bd498aadb 100644 --- a/doc/source/whatsnew/1.0.rst +++ b/doc/source/whatsnew/1.0.rst @@ -159,6 +159,20 @@ solver, using the method `~kwant.system.FiniteSystem.precalculate`. This may save time, when the linear system has to be solved many times with the same lead parameters. +Change of the modes and lead_info format +---------------------------------------- +The `~kwant.physics.modes` now returns two objects: +`~kwant.physics.PropagatingModes` and `~kwant.physics.StabilizedModes`. The +first one contains the wave functions of all the propagating modes in real +space, as well as their velocities and momenta. All these quantities were +previously not directly available. The second object contains the propagating +and evanescent modes in the compressed format expected by the sparse solver +(previously this was the sole output of `~kwant.physics.modes`). Accordingly, +the `lead_info` attribute of `~kwant.solvers.default.BlockResult` contains the +real space information about the modes in the leads (a list of +`~kwant.physics.PropagatingModes` objects). + + Inclusion of contributed modules -------------------------------- kwant now contains a sub-package :mod:`kwant.contrib` that contains various diff --git a/kwant/builder.py b/kwant/builder.py index 14fbd3cb1d57821c55d9de1703d56b8d44d0935f..c53592e8ad20cc9127fc0aa98d6f396dce779709 100644 --- a/kwant/builder.py +++ b/kwant/builder.py @@ -471,10 +471,12 @@ class ModesLead(Lead): Parameters ---------- modes_func : function - Function which returns the modes of the lead in the format specified - in `~kwant.physics.ModesTuple` given the energy and optionally a list of - extra arguments. - interface : sequence of `Site` instances + Function which returns the modes of the lead as a tuple of + `~kwant.physics.PropagatingModes` and `~kwant.physics.StabilizedModes` + given the energy and optionally a list of extra arguments. + interface : + sequence of `Site` instances + """ def __init__(self, modes_func, interface): self._modes_func = modes_func diff --git a/kwant/physics/leads.py b/kwant/physics/leads.py index b9407f2cd45907ae47aed036ab43559b159cc0ff..313bd5a1fd38469573570b4d2b3fa5042563e078 100644 --- a/kwant/physics/leads.py +++ b/kwant/physics/leads.py @@ -31,13 +31,7 @@ class PropagatingModes(object): Instance variables ================== wave_functions : numpy array - The wave functions of the propagating modes. The first dimension - corresponds to sites in a unit cell, the second one to the number of - the mode. Each mode is normalized to carry unit current. If several - modes have the same momentum and velocity, an arbitrary orthonormal - basis in the subspace of these modes is chosed. The first half of the - modes are incoming (having negative velocity), the second half is - outgoing (having positive velocity). momenta : numpy array + The wave functions of the propagating modes. momenta : numpy array Momenta of the modes. velocities : numpy array @@ -49,6 +43,12 @@ class PropagatingModes(object): modes have negative velocity, the second half have positive velocity. The modes with negative velocity are ordered from larger to lower momenta, the modes with positive velocity vice versa. + + The first dimension of the `wave_functions` corresponds to sites in a unit + cell, the second one to the number of the mode. Each mode is normalized to + carry unit current. If several modes have the same momentum and velocity, + an arbitrary orthonormal basis in the subspace of these modes is + chosen. """ def __init__(self, wave_functions, velocities, momenta): kwargs = locals() diff --git a/kwant/system.py b/kwant/system.py index c6843a993c66bda409c68e20d90e0442312992a8..2057e39e2e72f4440897683c55dabfd2edea52b2 100644 --- a/kwant/system.py +++ b/kwant/system.py @@ -14,7 +14,6 @@ __all__ = ['System', 'FiniteSystem', 'InfiniteSystem'] import abc import types from copy import copy -import numpy as np from . import physics, _system @@ -73,12 +72,13 @@ class FiniteSystem(System): For lead ``n``, the method leads[n].selfenergy must return a square matrix whose size is ``sum(len(self.hamiltonian(site, site)) for site in - self.lead_interfaces[n])``. The output format for ``leads[n].modes`` has to - be as described in `~kwant.physics.ModesTuple`. + self.lead_interfaces[n])``. The output of ``leads[n].modes`` has to be a + tuple of `~kwant.physics.PropatatingModes, ~kwant.physics.StabilizedModes`. Often, the elements of `leads` will be instances of `InfiniteSystem`. If this is the case for lead ``n``, the sites ``lead_interfaces[n]`` match the first ``len(lead_interfaces[n])`` sites of the InfiniteSystem. + """ __metaclass__ = abc.ABCMeta @@ -194,8 +194,8 @@ class InfiniteSystem(System): def modes(self, energy=0, args=()): """Return mode decomposition of the lead - See documentation of `~kwant.physics.ModesTuple` for the return - format details. + See documentation of `~kwant.physics.PropagatingModes` and + `~kwant.physics.StabilizedModes` for the return format details. """ ham = self.cell_hamiltonian(args=args) shape = ham.shape @@ -209,8 +209,8 @@ class InfiniteSystem(System): """Return self-energy of a lead. The returned matrix has the shape (s, s), where s is - ``sum(len(self.hamiltonian(i, i)) - for i in range(self.graph.num_nodes - self.cell_size))``. + ``sum(len(self.hamiltonian(i, i)) for i in range(self.graph.num_nodes - + self.cell_size))``. """ ham = self.cell_hamiltonian(args=args) shape = ham.shape @@ -227,7 +227,7 @@ class PrecalculatedLead(object): Parameters ---------- - modes : kwant.physics.ModesTuple + modes : (kwant.physics.PropagatingModes, kwant.physics.StabilizedModes) Modes of the lead. selfenergy : numpy array Lead self-energy.