Skip to content

Commit

Permalink
added vel init and tests to lammps
Browse files Browse the repository at this point in the history
  • Loading branch information
jrudz committed Mar 28, 2024
1 parent ceac9a7 commit a958b59
Show file tree
Hide file tree
Showing 5 changed files with 952 additions and 57 deletions.
54 changes: 54 additions & 0 deletions atomisticparsers/lammps/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,12 @@ def __init__(self):
"poteng": "potential",
}

def apply_unit(self, value, unit):
units = self.log_parser.units
if not hasattr(value, "units"):
value = value * units.get(unit, 1)
return value

def get_time_step(self):
time_unit = self.log_parser.units.get("time", None)
time_step = self.log_parser.get("timestep", [0], unit=time_unit)[0]
Expand Down Expand Up @@ -1162,6 +1168,54 @@ def parse_workflow(self):
integration_timestep = self.get_time_step()
method["integration_timestep"] = integration_timestep

val = self.log_parser.get("velocity", None)
try:
val = (
[val_i for val_i in val if val_i[1] == "create"]
if val is not None
else None
)
val = val[len(val) - 1] if val is not None else None
except Exception:
self.logger.warning("Velocity command/s missing expected parameters.")
val = None

if val is not None:
initialization_parameters = {}
if val[0] != "all":
self.logger.warning(
"Velocity generation was not performed for all particles, details not stored."
)
initialization_parameters["temperature"] = (
val[2] if len(val) > 1 else None
)
initialization_parameters["velocity_distribution_seed"] = (
val[3] if len(val) > 2 and isinstance(val[3], int) else None
)
for i_val in range(3, len(val)):
if val[i_val] == "dist":
initialization_parameters["velocity_distribution"] = val[
i_val + 1
]
if val[i_val + 1] == "uniform":
initialization_parameters["velocity_distribution_min"] = (
self.apply_unit(val[i_val + 2], "velocity")
if len(val) > i_val + 2
else None
)
initialization_parameters["velocity_distribution_max"] = (
self.apply_unit(val[i_val + 3], "velocity")
if len(val) > i_val + 3
else None
)
elif val[i_val + 1] == "exponential":
initialization_parameters["velocity_distribution_decay"] = (
val[i_val + 2] / self.apply_unit(1.0, "velocity")
if len(val) > i_val + 2
else None
)
method["initialization_parameters"] = initialization_parameters

thermostat_parameters, barostat_parameters = {}, {}
val = self.log_parser.get("fix", None)
if val is not None:
Expand Down
Loading

0 comments on commit a958b59

Please sign in to comment.