我正在尝试实现一些移动粒子的代码,然后计算移动的接受/拒绝,但我陷入了困境。这是我的 Python 代码:
def VMC(WF,numSteps):
seed=5 ### my random number seed
EnergyList=[]
R=numpy.zeros((2,3),float)
movesAttempted=0.0
movesAccepted=0.0
print "num-steps: ",numSteps
for i in range(numSteps):
OldPos= R.copy()
oldWfc= WF.WaveFunction(R)
for ptcl in xrange(0,len(R)):
R[ptcl] = numpy.add( R[ptcl], (numpy.random.rand(3) - 0.5)*3.0 )
newWfc= WF.WaveFunction(R)
ratio = (newWfc**2/oldWfc**2)
rander = numpy.random.rand(1)
if ratio > rander:
Eloc = WF.LocalEnergy(R)
EnergyList.append(Eloc)
movesAttempted+=1
movesAccepted+=1
else:
movesAttempted+=1
R = OldPos
print "movesAcepted: ",movesAccepted
print " movesAttempted: ", movesAttempted
print "Acceptance Ratio", movesAccepted/movesAttempted
return EnergyList
这是更多代码的pastebin:http: //pastebin.com/7nTLDesy 我得到了一个荒谬的接受率值,这让我觉得我没有得到电子应该如何移动的概念全部。
具体来说:当我运行此代码时,我得到 0.478 的接受率,而对于 VMC 计算,在长度为 1.5 的盒子中(在每个方向上)围绕其当前位置(在 3d 中移动)移动一个粒子,接受率应该是0.323。
我的问题主要是要知道原子在 VMC 计算中应该如何移动,以及我是如何做到的
我在 Fortran(大都会)中看到了一个实现,我想知道我的有多么不同以及如何纠正它以提供更好的结果。