Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
ceriottm committed Nov 14, 2023
1 parent 3861466 commit 3000a8e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion drivers/py/pes/dummy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# this is how the driver will be referred to in the input files
__DRIVER_NAME__ = "dummy"
__DRIVER_NAME__ = "dummy"
__DRIVER_CLASS__ = "Dummy_driver"


Expand Down
2 changes: 1 addition & 1 deletion drivers/py/pes/harmonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys
from .dummy import Dummy_driver

__DRIVER_NAME__ = "harmonic"
__DRIVER_NAME__ = "harmonic"
__DRIVER_CLASS__ = "Harmonic_driver"


Expand Down
17 changes: 10 additions & 7 deletions drivers/py/pes/pet.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@
from ipi.utils.mathtools import det_ut3x3
from ipi.utils.units import unit_to_internal, unit_to_user

try:
from ase.io import read
try:
from ase.io import read
except:
raise ImportError("The PET driver has an ASE dependency")

try:
sys.path.append(os.getcwd()+'/pet/src')
sys.path.append(os.getcwd() + "/pet/src")
from single_struct_calculator import SingleStructCalculator as PETCalc
except:
PETCalc = None

__DRIVER_NAME__ = "pet"
__DRIVER_CLASS__ = "PET_driver"


class PET_driver(Dummy_driver):
def __init__(self, args=None):
self.error_msg = """
Expand Down Expand Up @@ -52,7 +53,7 @@ def check_arguments(self):
sys.exit(self.error_msg)

self.template_ase = read(self.template)
self.template_ase.arrays['forces']=np.zeros_like(self.template_ase.positions)
self.template_ase.arrays["forces"] = np.zeros_like(self.template_ase.positions)
self.pet_calc = PETCalc(self.model)

def __call__(self, cell, pos):
Expand All @@ -64,13 +65,15 @@ def __call__(self, cell, pos):
pet_structure = self.template_ase.copy()
pet_structure.positions = pos_pet
pet_structure.cell = cell_pet

# Do the actual calculation
pot, force = self.pet_calc.forward(pet_structure)
pot_ipi = np.asarray(unit_to_internal("energy", "electronvolt", pot), np.float64)
pot_ipi = np.asarray(
unit_to_internal("energy", "electronvolt", pot), np.float64
)
force_ipi = np.asarray(unit_to_internal("force", "ev/ang", force), np.float64)
# PET does not yet compute stress
vir_pet = 0*np.eye(3)
vir_pet = 0 * np.eye(3)
vir_ipi = unit_to_internal("energy", "electronvolt", vir_pet.T)
extras = ""
return pot_ipi, force_ipi, vir_ipi, extras

0 comments on commit 3000a8e

Please sign in to comment.