[KeldyshGF-svncheckins] [svn commit /var/www/svn/KeldyshGF] r272 - trunk/kgf/exact_diagonalization

svn at fysik.dtu.dk svn at fysik.dtu.dk
Sat Nov 17 17:05:54 CET 2012


Author: strange
Date: 2012-11-17 17:05:54 +0100 (Sat, 17 Nov 2012)
New Revision: 272

Modified:
   trunk/kgf/exact_diagonalization/exactdsparse.py
Log:
add possibility to use itertive eigenvalue solver

Modified: trunk/kgf/exact_diagonalization/exactdsparse.py
===================================================================
--- trunk/kgf/exact_diagonalization/exactdsparse.py	2012-11-16 14:16:09 UTC (rev 271)
+++ trunk/kgf/exact_diagonalization/exactdsparse.py	2012-11-17 16:05:54 UTC (rev 272)
@@ -167,10 +167,14 @@
         val, vec = spla.eigsh(H)
         return val[0]
 
-    def get_expectation_values(self, H, indices):
+    def get_expectation_values(self, H, indices, iterative=True):
         h_nn = self.get_subspace(H, indices)
-        if 0:
-            val, vec = spla.eigsh(h_nn, k=h_nn.shape[0]-1)
+        if iterative:
+            k = 100
+            if h_nn.shape[0]<100:
+                k = h_nn.shape[0]-1
+
+            val, vec = spla.eigsh(h_nn, k=k)
         else:
             val, vec = npla.eig(h_nn.toarray())
             perm = val.argsort()
@@ -186,8 +190,9 @@
         s_n = -0.5 + np.sqrt(s2_n + 0.25)
         return e_n, sz_n, s_n, s2_n, n_n
 
-    def print_expectation_values(self, H, indices, nmax=5):
-        e_n, sz_n, s_n, s2_n, n_n = self.get_expectation_values(H, indices)
+    def print_expectation_values(self, H, indices, nmax=5, iterative=True):
+        e_n, sz_n, s_n, s2_n, n_n = self.get_expectation_values(H, indices,
+                                                                iterative)
         print '--------------------------------'
         print '  E     |  Sz   |  S    |   N'
         print '--------------------------------'



More information about the KeldyshGF-svncheckins mailing list