ARPACK对于Hermitian矩阵的奇怪行为

时间:2017-08-30 15:54:57

标签: python scipy eigenvalue arpack

我想在数值上获得一些厄米特矩阵的基态能量(参见下面代码中该矩阵的定义),并根据矩阵参数“相位”绘制它。

import scipy.sparse as sparse
import scipy
import numpy
import numpy as np
import math
from scipy.special import binom
import cmath
import sympy
import matplotlib.pyplot as plt
import pylab
from copy import *
from numpy import linalg as LA



M=5#DIMENSION OF THE MATRIX


def tunneling(phase):#HAMILTONIAN MATRIX
    Matrix_hop = [[0 for x in range(M)] for y in range(M)]
    for i in range(M):
            if i+1==M:
                Matrix_hop[i][0] = -1.0
                Matrix_hop[i][i-1] = -1.0
        else:
                Matrix_hop[i][i+1] = -1.0
                Matrix_hop[i][i-1] = -1.0
    Matrix_hop[0][M-1]=-1.0*cmath.exp(1j*phase)
    Matrix_hop[M-1][0]=-1.0*cmath.exp(-1j*phase)
    return Matrix_hop 

def eigen_system(H):
    values, vectors = sparse.linalg.eigs(H,2,which='SR') #ARPACK!!
    energy_ground = values[0]
    return  vectors[:,0], energy_ground


init = 0.0
points = 1000  
final_value = 2*math.pi
steep = (final_value-init)/points
list_values_phase = np.arange(init,final_value,steep)
f1 = open("ground_state_energy.dat", "w")
for i in list_values_phase:
    phase = i
    f1.write(str(phase)+" ")
    H = np.asarray(tunneling(i))
    f1.write(str(np.real(eigen_system(H)[1]))+" ")
    f1.write("\n")
f1.close()



datalist = pylab.loadtxt("ground_state_energy.dat")
pylab.plot( datalist[:,0], datalist[:,1],label="ground state" )
pylab.legend()
pylab.xlabel("phase")
pylab.ylabel("Energy")
pylab.show()

我在Python中使用了ARPACK用于hermitian矩阵,这是使用sparse.linalg.eigs完成的。问题在于,如下图所示,基态能量未正确计算,存在大量峰值,这意味着未正确找到基态。实际上似乎对于这个峰值,ARPACK没有找到基态并且它获得了第一个激发态。 enter image description here 这是一个非常奇怪的问题,因为我正在使用的这个矩阵(来自量子力学)可以在使用Mathematica的情况下解决,并且在Python中使用ARPACK不起作用。有人知道为什么会这样,怎么解决?谢谢

我正在使用scipy 0.19.1的最后一个版本

1 个答案:

答案 0 :(得分:2)

在此功能中

def eigen_system(H):
    values, vectors = sparse.linalg.eigs(H,2,which='SR') #ARPACK!!
    energy_ground = values[0]
    return  vectors[:,0], energy_ground

你找到第一个两个特征值,然后取第一个。函数eigs不保证它找到的特征值是有序的,有时第一个特征值不是最小的。

为什么不找到最小的?

,而不是找到两个最小的?
    values, vectors = sparse.linalg.eigs(H, 1, which='SR')  # ARPACK!!

当我做出改变时,我得到了这个情节:

plot