From 4699d60085d1927eca69ffad04f314301a4339f0 Mon Sep 17 00:00:00 2001
From: Joseph Weston <joseph@weston.cloud>
Date: Fri, 14 Dec 2018 18:58:00 +0100
Subject: [PATCH] transform hamiltonian to CSC format in tutorials

This avoids "sparse efficiency" warnings.
---
 doc/source/code/figure/closed_system.py.diff | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/doc/source/code/figure/closed_system.py.diff b/doc/source/code/figure/closed_system.py.diff
index 6b5d2b83..5f9cc101 100644
--- a/doc/source/code/figure/closed_system.py.diff
+++ b/doc/source/code/figure/closed_system.py.diff
@@ -71,7 +71,8 @@
          ham_mat = syst.hamiltonian_submatrix(args=[B], sparse=True)
  
          # we only calculate the 15 lowest eigenvalues
-         ev = sla.eigsh(ham_mat, k=15, sigma=0, return_eigenvectors=False)
+         ev = sla.eigsh(ham_mat.tocsc(), k=15, sigma=0,
+                        return_eigenvectors=False)
  
          energies.append(ev)
  
@@ -105,7 +106,7 @@
 +
      # Calculate the wave functions in the system.
      ham_mat = syst.hamiltonian_submatrix(sparse=True, args=[B])
-     evals, evecs = sorted_eigs(sla.eigsh(ham_mat, k=20, sigma=0))
+     evals, evecs = sorted_eigs(sla.eigsh(ham_mat.tocsc(), k=20, sigma=0))
  
      # Plot the probability density of the 10th eigenmode.
 -    kwant.plotter.map(syst, np.abs(evecs[:, 9])**2,
@@ -124,7 +125,7 @@
 +
      # Calculate the wave functions in the system.
      ham_mat = syst.hamiltonian_submatrix(sparse=True, args=[B])
-     evals, evecs = sorted_eigs(sla.eigsh(ham_mat, k=20, sigma=0))
+     evals, evecs = sorted_eigs(sla.eigsh(ham_mat.tocsc(), k=20, sigma=0))
  
      # Calculate and plot the local current of the 10th eigenmode.
      J = kwant.operator.Current(syst)
-- 
GitLab