首页 文章

ARPACK对于Hermitian矩阵的奇怪行为

提问于
浏览
0

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

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
它's a very strange problem, since this matrix that I am using (which comes from quantum mechanics) can be solved analitycally as well as using Mathematica, and with ARPACK in Python doesn'工作 . 有人知道为什么会这样,怎么解决?谢谢

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

1 回答

  • 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

相关问题