From cb8540823ddde113dd924245665b1d9fc4fccd61 Mon Sep 17 00:00:00 2001
From: Anton Akhmerov <anton.akhmerov@gmail.com>
Date: Sat, 20 Jul 2013 12:43:13 +0200
Subject: [PATCH] update docs, add whatsnew entry

---
 doc/source/reference/kwant.physics.rst |  3 ++-
 doc/source/reference/kwant.system.rst  |  1 +
 doc/source/whatsnew/1.0.rst            | 14 ++++++++++++++
 kwant/builder.py                       | 10 ++++++----
 kwant/physics/leads.py                 | 14 +++++++-------
 kwant/system.py                        | 16 ++++++++--------
 6 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/doc/source/reference/kwant.physics.rst b/doc/source/reference/kwant.physics.rst
index 7b202da0..2c457f56 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 00065e6a..826eed55 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 13c8f574..597c3c93 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 14fbd3cb..c53592e8 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 b9407f2c..313bd5a1 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 c6843a99..2057e39e 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.
-- 
GitLab