I'm attempting to implement some code that moves particles and then calculated the acceptance/rejection of the move, but i'm stuck in a rut, here is my python code:
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
here is a pastebin of more of the code: http://pastebin.com/7nTLDesy I'm getting a ridiculous value of the acceptance ratio, which makes me think im not getting the concept of how the electrons should be moved at all.
EDIT:
Here is what i have a problem with: When i run this code i get an acceptance ratio of 0.478, while for vmc calculations, moving a particle in a box of length 1.5 (in each direction) around its current position (moving in 3d) the acceptance ratio is supposed to be 0.323, i dont know what else i do need to provide, but i'd love to clarify. My problem is mainly to know how atoms are supposed to be moved in a vmc calculation and whether how i'm doing it is o.k. I'v seen an implemetation in fortran (metropolis), ad i was wondering how different mine is and how i can correct it to give better results http://scienze-como.uninsubria.it/bressanini/src/var/var.f thanks