Skip to content

Commit

Permalink
Development (#8)
Browse files Browse the repository at this point in the history
Closes #10
EmielSlootman authored Apr 20, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 043deae commit c54afd3
Showing 12 changed files with 111 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@

autodoc_mock_imports = [
'flare-pp',
'flare_pp',
'matplotlib'
]

2 changes: 2 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -2,3 +2,5 @@ ase==3.22.1
mir-flare==0.2.4
numpy==1.20.3
pydantic==1.9.0
periodictable==1.6.0
sgdml==0.4.10
15 changes: 15 additions & 0 deletions docs/source/qmcblip.gamess.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
qmcblip.gamess package
======================

.. automodule:: qmcblip.gamess
:members:
:undoc-members:
:show-inheritance:

Submodules
----------

.. toctree::
:maxdepth: 4

qmcblip.gamess.utils
7 changes: 7 additions & 0 deletions docs/source/qmcblip.gamess.utils.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
qmcblip.gamess.utils module
===========================

.. automodule:: qmcblip.gamess.utils
:members:
:undoc-members:
:show-inheritance:
1 change: 1 addition & 0 deletions docs/source/qmcblip.rst
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ Subpackages
:maxdepth: 4

qmcblip.flare
qmcblip.gamess
qmcblip.sgdml

Submodules
2 changes: 1 addition & 1 deletion qmcblip/flare/otf.py
Original file line number Diff line number Diff line change
@@ -384,7 +384,7 @@ def md_step(self, forces=None):
forces (List[float]): array containing the forces as calculated by CHAMP (or FLARE).
"""

if self.curr_step in self.update_settings and self.dtf_loc.name == "CHAMP":
if self.curr_step in self.update_settings and self.dft_loc.name == "CHAMP":
sets = self.dft_loc.parameters.settings
ind = np.where(self.update_settings == self.curr_step)[0][0]
changes = self.update_settings[ind][1]
2 changes: 1 addition & 1 deletion qmcblip/flare/utils.py
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ def get_data(self):
self.results['total energy'] = kinE[2:] + potE[1:-1]
self.results['temperature'] = temp[2:]

if max(self.dft) > max(self.nondft):
if max(self.dft) > max(self.nondft + [0]):
self.dft = self.dft[:-1]
else:
self.nondft = self.nondft[:-1]
6 changes: 6 additions & 0 deletions qmcblip/gamess/utils.py
Original file line number Diff line number Diff line change
@@ -112,6 +112,8 @@ def setup_rhf(self, **kwargs):
if isinstance(item, dict):
for key2, item2 in item.items():
calc.parameters[key][key2] = item2
elif key == "userscr":
calc.userscr = item
else:
calc.parameters[key] = item

@@ -155,6 +157,8 @@ def setup_cas(self, **kwargs):
if isinstance(item, dict):
for key2, item2 in item.items():
calc.parameters[key][key2] = item2
elif key == "userscr":
calc.userscr = item
else:
calc.parameters[key] = item

@@ -199,6 +203,8 @@ def setup_ci(self, **kwargs):
if isinstance(item, dict):
for key2, item2 in item.items():
calc.parameters[key][key2] = item2
elif key == "userscr":
calc.userscr = item
else:
calc.parameters[key] = item

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -29,5 +29,5 @@
test_suite='tests',
packages=setuptools.find_packages(),
install_requires=dependencies,
python_requires="3.9",
python_requires=">=3.9, <3.10",
)
27 changes: 26 additions & 1 deletion tests/flare/test_flare.py
Original file line number Diff line number Diff line change
@@ -10,12 +10,13 @@
from qmcblip.champ import CHAMP
from qmcblip.flare.quicksim import OTFSettings, quicksim
from qmcblip.flare.utils import Analyze
from qmcblip.tools import otf_to_db

found_champ = pytest.mark.skipif(
not Path.home().joinpath(Path('software/champ')).is_dir(), reason="CHAMP not found."
)

class TestChamp(unittest.TestCase):
class TestFlare(unittest.TestCase):

def setUp(self):
os.mkdir("tests/test_data/temp")
@@ -43,6 +44,30 @@ def test_quicksim_C2(self):
res.get_data()
self.assertAlmostEqual(res.results['total energy'][-1], -292.466862)

@found_champ
def test_quicksim_C2_changes(self):
shutil.copytree("../C2_champ/pool", "pool")
shutil.copyfile("../C2_champ/vmc.inp", "vmc.inp")

atoms = Atoms('C2', [(0,0,-0.61385), (0,0,0.61385)])
atoms.cell = Cell.fromcellpar([50, 50, 50, 90, 90, 90])
atoms.pbc=[True, True, True]

settings = OTFSettings(theory=OTFSettings.FLARE())
settings.std_tolerance_factor = 0.5

calc = CHAMP(champ_loc=str(Path.home().joinpath('software/champ'))+"/bin/vmc.mov1")

changes = [(2, {'optwf': {'nopt_iter': 3}})]

quicksim(atoms, 0.5, 5, calc, settings, changes = changes)

res = Analyze('OTF.out')
res.to_xyz()
res.get_data()
otf_to_db('OTF.out', 'OTF.db')
self.assertAlmostEqual(res.results['total energy'][-1], -293.967875)

@found_champ
def test_quicksim_Thio(self):
shutil.copytree("../Thio_champ/pool", "pool")
Empty file added tests/gamess/__init__.py
Empty file.
50 changes: 50 additions & 0 deletions tests/gamess/test_gamess.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import os
import shutil
import unittest
from pathlib import Path

import pytest
from ase import Atoms
from qmcblip.champ import CHAMP
from qmcblip.champio import Settings
from qmcblip.gamess.utils import WavefunctionCreator

found_champ = pytest.mark.skipif(
not Path.home().joinpath(Path('software/champ')).is_dir(), reason="CHAMP not found."
)
found_games = pytest.mark.skipif(
not Path.home().joinpath(Path('software/gamess')).is_dir(), reason="GAMESS not found."
)

class TestGamess(unittest.TestCase):

def setUp(self):
if Path.home().joinpath(Path('software/gamess')).is_dir():
shutil.rmtree(Path.home().joinpath(Path('software/gamess/restart')))
os.mkdir(Path.home().joinpath(Path('software/gamess/restart')))
os.mkdir("tests/test_data/temp")
os.chdir('tests/test_data/temp')

@found_champ
@found_games
def test_gamess(self):
atoms = Atoms('C2', [(0,0,-0.61385), (0,0,0.61385)])
wf = WavefunctionCreator(atoms, str(Path.home().joinpath('software/champ')))
wf.setup_rhf(userscr=str(Path.home().joinpath(Path('software/gamess/restart'))))
wf.setup_cas(system=dict(mwords=500), drt=dict(nmcc=2, ndoc=2, nval=2), userscr=str(Path.home().joinpath(Path('software/gamess/restart'))))
wf.setup_ci(system=dict(mwords=500), cidrt=dict(nfzc=2, ndoc=2, nval=2), userscr=str(Path.home().joinpath(Path('software/gamess/restart'))))
wf.convert_to_champ()
input = wf.create_champ_input()
input.optwf.nopt_iter = 10
input.write('vmc.inp')
atoms.calc = CHAMP(champ_loc=str(Path.home().joinpath('software/champ'))+"/bin/vmc.mov1", settings = input)

self.assertAlmostEqual(atoms.get_total_energy(), -297.5, places=0)

def tearDown(self):
os.chdir("../../..")
shutil.rmtree('tests/test_data/temp')


if __name__ == '__main__':
unittest.main()

0 comments on commit c54afd3

Please sign in to comment.