VMC template.py

From PIMC++

Jump to: navigation, search
from VMCHelp import *
import numpy
import random
import CalcStatistics


class H2Class:
  def SetParams(self,params):
     self.params=copy(params)
  def SetIons(self,ions):
     self.ions=ions.copy()
  def SetBondLength(self,BondLength):
     self.BondLength=BondLength
     TempIon=numpy.zeros((2,3),float)
     TempIon[0][0]=-BondLength/2.0
     TempIon[1][0]=BondLength/2.0
     self.SetIons(TempIon)
  def WaveFunction(self,R):
     alpha=self.params[0]
     # write code to evaluate your wavefunction here
     return 0.0 # you will return something other then 0
  def LocalEnergy(self,R):
   KE=-0.5*LaplacianPsiOverPsi(R,self.WaveFunction)
   V=0.0 #change this to actually calculate V
   return V+KE


def VMC(WF,numSteps):
    EnergyList=[]
   #pseudoCode:
   #Looping over steps:
      #choose new cooridinates
      #evaluate the wave function on these new cooridinates
      #if (newWaveFunction^2/oldWaveFunction^2>random_number):
         #accept the move making sure coords and oldWaveFunction has the up to date information
      #else:
         #reject the move making sure coords and oldWaveFunction has the up to date information
    return EnergyList


def Optimize(H2):
   optimizeList=[]
   #add things here to loop over alpha and do optimization
   return (optimizeList,bestAlpha)


def BondLength(H2):
   bondList=[]
   # add things here to loop over bondlengths
   return (bondList,bestBond)



class H2JastrowClass:
  def SetParams(self,params):
     self.params=copy(params)
     self.alpha = params[0]
     self.beta  = params[1]
     self.a_ee = 0.5
     self.a_ep = 1.0
     self.b_ee = sqrt(self.a_ee/self.beta)
     self.b_ep = sqrt(self.a_ep/self.beta)
  def SetIons(self,ions):
     self.ions=ions.copy()
  def LocalEnergy(self,R):
   KE=-0.5*LaplacianPsiOverPsi(R,self.WaveFunction)
  def WaveFunction(self, R):
     return 0.0

def OptimizeJastrow(H2):
  #fill this in


Personal tools