# how to move particles in a variational monte carlo simulation

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

-
Your question is missing many of the parts that would make it simpler for people to help you. For example, there is nothing we can get from your question without actually running the code. You say you're getting a "ridiculous value", but what is it? What do you observe? How many steps do you run? Etc. Without this you're really asking us to do all the work while doing none yourself. See also here: dealii.sourceforge.net/index.php/… – Wolfgang Bangerth Sep 28 '12 at 12:51
@mike What is the size of the physical domain, and how does that relate to 0.5 * 3.0? Have you plotted traces of the energies and particle locations so see if they look "reasonable"? Are you throwing away some burn in samples? How many? – Matthew Emmett Sep 28 '12 at 20:57
The particles are supposed to move is a box of size 1.5, that is why i chose 0.5*3.0, i havent plotted traces of the particle positions and if i understand you right, i have plotted the energy vs sample and it looks quite spiky, – mike Sep 28 '12 at 21:21
From glancing at your code it doesn't look like the particles are constrained, so they'll escape your box (but perhaps I misunderstood your comment). – Matthew Emmett Sep 29 '12 at 2:04
@MatthewEmmett The motion i meant is the sense described here: physics.princeton.edu/~bclark/Tutorials/VMCIntroTutorial/… about a third of the way down there's as section on building monte carlo code, you will see a description of moving a particle by 1.5 in each direction, thats what i'm trying to do. – mike Sep 29 '12 at 12:01