Skip to content

Commit

Permalink
rename force_key to force_db_name in MD driver for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
shinkle-lanl committed Aug 27, 2024
1 parent dfc2d50 commit 4314140
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion examples/molecular_dynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"coordinates": "position",
},
device=device,
updater=VelocityVerlet(force_key="force"),
updater=VelocityVerlet(force_db_name="force"),
)

# Define species and cell Variables
Expand Down
2 changes: 1 addition & 1 deletion hippynn/databases/ondisk.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class DirectoryDatabase(Database, Restartable):
"""
Database stored as NPY files in a diectory.
Database stored as NPY files in a directory.
:param directory: directory path where the files are stored
:param name: prefix for the arrays.
Expand Down
16 changes: 8 additions & 8 deletions hippynn/molecular_dynamics/md.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,14 @@ class VelocityVerlet(VariableUpdater):

def __init__(
self,
force_key: str,
force_db_name: str,
units_force: float = ase.units.eV,
units_acc: float = ase.units.Ang / (1.0**2),
):
"""
Parameters
----------
force_key : str
force_db_name : str
key which will correspond to the force on the modified Variable
in the HIPNN model output dictionary
units_force : float, optional
Expand All @@ -231,7 +231,7 @@ def __init__(
amount of Ang/fs^2 equal to one in the units used for acceleration
in the corresponding Variable, by default units.Ang/(1.0 ** 2) = 1
"""
self.force_key = force_key
self.force_db_name = force_db_name
self.force_factor = units_force / units_acc

def pre_step(self, dt):
Expand Down Expand Up @@ -261,7 +261,7 @@ def post_step(self, dt, model_outputs):
model_outputs : dict
dictionary of HIPNN model outputs
"""
self.variable.data["force"] = model_outputs[self.force_key].to(self.variable.device)
self.variable.data["force"] = model_outputs[self.force_db_name].to(self.variable.device)
if len(self.variable.data["force"].shape) == len(self.variable.data["mass"].shape):
self.variable.data["acceleration"] = self.variable.data["force"].detach() / self.variable.data["mass"] * self.force_factor
else:
Expand All @@ -280,7 +280,7 @@ class LangevinDynamics(VariableUpdater):

def __init__(
self,
force_key: str,
force_db_name: str,
temperature: float,
frix: float,
units_force=ase.units.eV,
Expand All @@ -290,7 +290,7 @@ def __init__(
"""
Parameters
----------
force_key : str
force_db_name : str
key which will correspond to the force on the modified Variable
in the HIPNN model output dictionary
temperature : float
Expand All @@ -309,7 +309,7 @@ def __init__(
used to set seed for reproducibility, by default None
"""

self.force_key = force_key
self.force_db_name = force_db_name
self.force_factor = units_force / units_acc
self.temperature = temperature
self.frix = frix
Expand Down Expand Up @@ -346,7 +346,7 @@ def post_step(self, dt, model_outputs):
model_outputs : dict
dictionary of HIPNN model outputs
"""
self.variable.data["force"] = model_outputs[self.force_key].to(self.variable.device)
self.variable.data["force"] = model_outputs[self.force_db_name].to(self.variable.device)

if len(self.variable.data["force"].shape) != len(self.variable.data["mass"].shape):
self.variable.data["mass"] = self.variable.data["mass"][..., None]
Expand Down

0 comments on commit 4314140

Please sign in to comment.