Skip to content

Commit

Permalink
Merge branch 'main' into update_doc
Browse files Browse the repository at this point in the history
  • Loading branch information
litman90 authored Nov 15, 2024
2 parents 56d4449 + d3bdb50 commit 821aa7c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
4 changes: 2 additions & 2 deletions drivers/py/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def run_driver(
nat = recv_data(sock, np.int32())
if len(pos) == 0:
# shapes up the position array
pos.resize((nat, 3))
force.resize((nat, 3))
pos.resize((nat, 3), refcheck=False)
force.resize((nat, 3), refcheck=False)
else:
if len(pos) != nat:
raise RuntimeError("Atom number changed during i-PI run")
Expand Down
2 changes: 1 addition & 1 deletion examples/clients/elphmod/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ driver $(DRIVER): driver.py $(MODEL)
run $(RUN): input.xml $(DRIVER)
$(IPI) $< &
sleep 5
i-pi-driver-py -u -m elphmod -o $(word 2,$^)
i-pi-driver-py -u -m elphmod -o driver=driver.pickle
wait

run2: input.xml run.py $(DRIVER)
Expand Down
26 changes: 12 additions & 14 deletions ipi/pes/elphmod.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
"""Interface with [elphmod](https://github.com/janberges/elphmod) MD driver."""

import sys
import os
from .dummy import Dummy_driver

from ipi.utils.messages import verbosity, warning

__DRIVER_NAME__ = "elphmod"
__DRIVER_CLASS__ = "ModelIIIDriver"

Expand All @@ -13,21 +11,21 @@ class ModelIIIDriver(Dummy_driver):
"""Wrapper around elphmod MD driver.
A pickled driver instance is required (see elphmod.md.Driver.save).
Example: python3 driver.py -u -m elphmod -o driver.pickle
Example: python3 driver.py -u -m elphmod -o driver=driver.pickle
"""

def check_parameters(self):
"""Check arguments and load driver instance."""
warning(
"THIS PES HAS NOT BEEN TESTED FOLLOWING CONVERSION TO THE NEW PES API.",
verbosity.low,
)
def __init__(self, driver, *args, **kwargs):
import elphmod

if len(self.args) != 1:
sys.exit(self.__doc__)

self.driver = elphmod.md.Driver.load(self.args[0])
if not os.path.exists(driver):
raise ValueError(f"File '{driver}' does not exist.")
self.driver = elphmod.md.Driver.load(driver)
if self.driver is None:
raise ValueError(
f"Some error occured within `ModelIIIDriver.__init__` when trying to load the driver from file '{driver}'."
)
super().__init__(*args, **kwargs)
pass

def __call__(self, cell, pos):
"""Calculate energy and forces for given structure."""
Expand Down
7 changes: 5 additions & 2 deletions ipi/pes/spline.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
import numpy as np
import sys
from .dummy import Dummy_driver
from scipy import interpolate
import json

from ipi.utils.messages import verbosity, warning

try:
from scipy import interpolate
except ImportError:
raise ImportError("Could not import scipy. Please install to use this.")

"""Spline driver. This is not a serious interpolation, use it if you know what you are doing. """
factor_coord = 5
mass = 1836
Expand Down

0 comments on commit 821aa7c

Please sign in to comment.