Ejemplo n.º 1
0
def h2_pyscf_equil_test():
    jobs = []

    xyz = open('structures/h2_equil.xyz', 'r')
    xyz.readline()  # Remove headers.
    xyz.readline()

    scfman = PySCFManager(name='scf',
                          path='test_h2eq_py',
                          writer=PySCFWriter({
                              'spin': 0,
                              'xyz': xyz.read()
                          }),
                          runner=PySCFRunnerPBS(queue='secondary',
                                                nn=1,
                                                np=16,
                                                walltime='0:01:00'))
    jobs.append(scfman)

    var = QWalkManager(name='var',
                       path=scfman.path,
                       writer=VarianceWriter(),
                       reader=VarianceReader(),
                       runner=RunnerPBS(nn=1,
                                        np=16,
                                        queue='secondary',
                                        walltime='0:05:00'),
                       trialfunc=SlaterJastrow(scfman, kpoint=0))

    jobs.append(var)

    lin = QWalkManager(name='linear',
                       path=scfman.path,
                       writer=LinearWriter(),
                       reader=LinearReader(),
                       runner=RunnerPBS(nn=1,
                                        np=16,
                                        queue='secondary',
                                        walltime='0:10:00'),
                       trialfunc=SlaterJastrow(slatman=scfman,
                                               jastman=var,
                                               kpoint=0))

    jobs.append(lin)

    dmc = QWalkManager(name='dmc',
                       path=scfman.path,
                       writer=DMCWriter(),
                       reader=DMCReader(),
                       runner=RunnerPBS(
                           nn=1,
                           np=16,
                           queue='secondary',
                           walltime='0:10:00',
                       ),
                       trialfunc=SlaterJastrow(slatman=scfman, jastman=lin))
    jobs.append(dmc)

    return jobs
Ejemplo n.º 2
0
def si_pyscf_test():
  ''' Simple tests that check PBC is working Crystal, and that QMC can be performed on the result.'''
  jobs=[]

  pwriter=PySCFPBCWriter({
      'gmesh':[16,16,16],
      'cif':open('si.cif','r').read()
    })
  pman=PySCFManager(
      name='scf',
      path='sipyscf',
      writer=pwriter,
      runner=PySCFRunnerPBS(
          queue='secondary',
          nn=1,
          np=16,
          walltime='4:00:00'
        )
    )
  jobs.append(pman)

  var=QWalkManager(
      name='var',
      path=pman.path,
      writer=VarianceWriter(),
      reader=VarianceReader(),
      runner=RunnerPBS(
          nn=1,queue='secondary',walltime='0:10:00'
        ),
      trialfunc=SlaterJastrow(pman,kpoint=0)
    )
  jobs.append(var)

  lin=QWalkManager(
      name='lin',
      path=pman.path,
      writer=LinearWriter(),
      reader=LinearReader(),
      runner=RunnerPBS(
          nn=1,queue='secondary',walltime='0:30:00'
        ),
      trialfunc=SlaterJastrow(slatman=pman,jastman=var,kpoint=0)
    )
  jobs.append(lin)

  return jobs
Ejemplo n.º 3
0
def si_crystal_test():
  ''' Simple tests that check PBC is working Crystal, and that QMC can be performed on the result.'''
  jobs=[]

  cwriter=CrystalWriter({
      'xml_name':'../BFD_Library.xml',
      'cutoff':0.2,
      'kmesh':(4,4,4),
    })
  cwriter.set_struct_fromcif(open('si.cif','r').read(),primitive=True)
  cwriter.set_options({})

  cman=CrystalManager(
      name='crys',
      path='sicrys',
      writer=cwriter,
      runner=RunnerPBS(
          queue='secondary',
          nn=1,
          walltime='0:10:00'
        )
    )
  jobs.append(cman)

  var=QWalkManager(
      name='var',
      path=cman.path,
      writer=VarianceWriter(),
      reader=VarianceReader(),
      runner=RunnerPBS(
          nn=1,queue='secondary',walltime='0:10:00'
        ),
      trialfunc=SlaterJastrow(cman,kpoint=0)
    )

  jobs.append(var)

  lin=QWalkManager(
      name='linear',
      path=cman.path,
      writer=LinearWriter(),
      reader=LinearReader(),
      runner=RunnerPBS(
          nn=1,queue='secondary',walltime='1:00:00'
        ),
      trialfunc=SlaterJastrow(slatman=cman,jastman=var,kpoint=0)
    )

  jobs.append(lin)

  for kidx in cman.qwfiles['kpoints']:
    kpt=cman.qwfiles['kpoints'][kidx]
    dmc=QWalkManager(
        name='dmc_%d'%kidx,
        path=cman.path,
        writer=DMCWriter(),
        reader=DMCReader(),
        runner=RunnerPBS(
            nn=1,queue='secondary',walltime='1:00:00',
          ),
        trialfunc=SlaterJastrow(slatman=cman,jastman=lin,kpoint=kidx)
      )
    jobs.append(dmc)

  return jobs
Ejemplo n.º 4
0
def mno_test():
  ''' Test spinful calculations in PBC and real kpoint sampling. Also test trialfunc dependency. '''
  jobs=[]
  cwriter=CrystalWriter({
      'xml_name':'../BFD_Library.xml',
      'cutoff':0.2,
      'kmesh':(4,4,4),
      'total_spin':4
    })
  cwriter.set_struct_fromcif(open('mno.cif','r').read(),primitive=True)
  cwriter.set_options({})

  cman=CrystalManager(
      name='crys',
      path='mnocrys',
      writer=cwriter,
      runner=RunnerPBS(
          queue='secondary',
          nn=1,
          walltime='1:00:00'
        )
    )
  jobs+=[cman]

  var=QWalkManager(
      name='var',
      path=cman.path,
      writer=VarianceWriter(),
      reader=VarianceReader(),
      runner=RunnerPBS(
          nn=1,queue='secondary',walltime='0:10:00'
        ),
      trialfunc=SlaterJastrow(cman,kpoint=(0,0,0))
    )

  lin=QWalkManager(
      name='linear',
      path=cman.path,
      writer=LinearWriter(),
      reader=LinearReader(),
      runner=RunnerPBS(
          nn=1,queue='secondary',walltime='1:00:00'
        ),
      trialfunc=SlaterJastrow(slatman=cman,jastman=var,kpoint=(0,0,0))
    )

  for kidx in cman.qwfiles['kpoints']:
    kpt=cman.qwfiles['kpoints'][kidx]
    if not sum(np.array(kpt)%(np.array(cman.kmesh)/2))<1e-14:
      print("complex kpt %d%d%d skipped"%kpt)
      continue
    dmc=QWalkManager(
        name='dmc_%d'%kidx,
        path=cman.path,
        writer=DMCWriter(),
        reader=DMCReader(),
        runner=RunnerPBS(
            nn=1,queue='secondary',walltime='1:00:00',
          ),
        trialfunc=SlaterJastrow(slatman=cman,jastman=lin,kpoint=kidx)
      )
    jobs.append(dmc)
  return jobs
Ejemplo n.º 5
0
def mno_crystal_test():
    ''' Test spinful calculations in PBC and real kpoint sampling. Also test trialfunc dependency. '''
    cwriter = CrystalWriter({
        'xml_name': '../../BFD_Library.xml',
        'cutoff': 0.2,
        'kmesh': (3, 3, 3),
        'initial_spins': [1, 0],
        'total_spin': 5
    })
    cwriter.set_struct_fromcif(open('structures/mno.cif', 'r').read(),
                               primitive=True)
    cwriter.set_options({})

    cman = CrystalManager(name='crys',
                          path='test_mno_crys',
                          writer=cwriter,
                          runner=RunnerPBS(queue='secondary',
                                           nn=1,
                                           np=20,
                                           walltime='2:00:00'))

    var = QWalkManager(name='var',
                       path=cman.path,
                       writer=VarianceWriter(),
                       reader=VarianceReader(),
                       runner=RunnerPBS(nn=1,
                                        np=20,
                                        queue='secondary',
                                        walltime='0:10:00'),
                       trialfunc=SlaterJastrow(cman, kpoint=0))

    lin = QWalkManager(name='linear',
                       path=cman.path,
                       writer=LinearWriter(),
                       reader=LinearReader(),
                       runner=RunnerPBS(nn=1,
                                        np=20,
                                        queue='secondary',
                                        walltime='1:00:00'),
                       trialfunc=SlaterJastrow(slatman=cman,
                                               jastman=var,
                                               kpoint=0))

    jobs = [cman, var, lin]
    for kidx in cman.qwfiles['kpoints']:
        kpt = cman.qwfiles['kpoints'][kidx]
        dmc = QWalkManager(name='dmc_%d' % kidx,
                           path=cman.path,
                           writer=DMCWriter(),
                           reader=DMCReader(),
                           runner=RunnerPBS(
                               nn=1,
                               np=16,
                               queue='secondary',
                               walltime='1:00:00',
                           ),
                           trialfunc=SlaterJastrow(slatman=cman,
                                                   jastman=lin,
                                                   kpoint=kidx))
        jobs.append(dmc)
    return jobs
Ejemplo n.º 6
0
def h2_crystal_equil_test():
    jobs = []

    cwriter = CrystalWriter({
        'xml_name': '../../BFD_Library.xml',
        'cutoff': 0.2,
        'spin_polarized': False
    })
    cwriter.set_struct_fromxyz(open('structures/h2_equil.xyz', 'r').read())

    cman = CrystalManager(name='crys',
                          path='test_h2eq_crys',
                          writer=cwriter,
                          runner=RunnerPBS(queue='secondary',
                                           nn=1,
                                           np=16,
                                           walltime='0:01:00'))
    jobs.append(cman)

    var = QWalkManager(name='var',
                       path=cman.path,
                       writer=VarianceWriter(),
                       reader=VarianceReader(),
                       runner=RunnerPBS(nn=1,
                                        np=16,
                                        queue='secondary',
                                        walltime='0:05:00'),
                       trialfunc=SlaterJastrow(cman, kpoint=0))

    jobs.append(var)

    lin = QWalkManager(name='linear',
                       path=cman.path,
                       writer=LinearWriter(),
                       reader=LinearReader(),
                       runner=RunnerPBS(nn=1,
                                        np=16,
                                        queue='secondary',
                                        walltime='0:10:00'),
                       trialfunc=SlaterJastrow(slatman=cman,
                                               jastman=var,
                                               kpoint=0))

    jobs.append(lin)

    for kidx in cman.qwfiles['kpoints']:
        kpt = cman.qwfiles['kpoints'][kidx]
        dmc = QWalkManager(name='dmc_%d' % kidx,
                           path=cman.path,
                           writer=DMCWriter(),
                           reader=DMCReader(),
                           runner=RunnerPBS(
                               nn=1,
                               np=16,
                               queue='secondary',
                               walltime='0:10:00',
                           ),
                           trialfunc=SlaterJastrow(slatman=cman,
                                                   jastman=lin,
                                                   kpoint=kidx))
        jobs.append(dmc)

    return jobs
Ejemplo n.º 7
0
from trialfunc import SlaterJastrow
sj = SlaterJastrow(pyscf_manager)

# ### Setting up the QWalk run.
# Now we can set up the corresponding objects for QWalk.

# In[ ]:

from variance import VarianceWriter, VarianceReader
from autorunner import RunnerLocal
from qwalkmanager import QWalkManager
from imp import reload
import time

vopt_writer = VarianceWriter({'iterations': 6})

vopt_manager = QWalkManager(
    name='h2_vopt',
    path=path,
    writer=vopt_writer,
    runner=RunnerLocal(np=4),
    reader=VarianceReader(),
    trialfunc=sj  # This is new!
)
while not vopt_manager.completed:
    vopt_manager.nextstep()

print(vopt_manager.reader.output['sigma'])
import matplotlib.pyplot as plt
Ejemplo n.º 8
0
path = '00-scratch'

# A hydrogen molecule.
h2 = '\n'.join(['H 0.0 0.0 0.0 ', 'H 0.74 0.0 0.0 '])

# Input parameters for SCF calculation.
pyscf_writer = PySCFWriter({
    'xyz': h2,
    'dft': 'pbe,pbe',
    'spin': 0,
    'dm_generator': dm_set_spins([1, -1], []),
    'pyscf_path': sys.path
})

vmc_writer = VarianceWriter()

# Manage the PySCF job.
scfmanager = PySCFManager(name='h2_pbe',
                          path=path,
                          writer=pyscf_writer,
                          runner=PySCFRunnerLocal())

# Manage the VMC job.
voptmanager = QWalkManager(name='h2_vopt',
                           path=path,
                           writer=VarianceWriter(),
                           reader=VarianceReader(),
                           trialfunc=SlaterJastrow(scfmanager),
                           runner=RunnerLocal(np=4))