Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

100 cont errors from pyiron lammps log #102

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions atomisticparsers/gromacs/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ def to_float(string):
return value


def to_int(string):
try:
value = int(string)
except ValueError:
value = None
return value


class GromacsLogParser(TextParser):
def __init__(self):
super().__init__(None)
Expand Down Expand Up @@ -1106,6 +1114,22 @@ def parse_method(self):
rcoulomb = input_parameters.get("rcoulomb", None)
sec_force_calculations.coulomb_cutoff = to_float(rcoulomb)

def get_initialization_parameters(self):
initialization_parameters = {"velocity_distribution": "gaussian"}
gen_vel = self.input_parameters.get("gen-vel", "no").lower()
if gen_vel == "no":
return {}
gen_temp = self.input_parameters.get("gen-temp", None)
if isinstance(gen_temp, str):
gen_temp = to_float(gen_temp)
initialization_parameters["temperature"] = gen_temp
gen_seed = self.input_parameters.get("gen-seed", None)
if isinstance(gen_seed, str):
gen_seed = to_int(gen_seed)
initialization_parameters["velocity_distribution_seed"] = gen_seed

return initialization_parameters

def get_thermostat_parameters(self, integrator: str = ""):
thermostat = self.input_parameters.get("tcoupl", "no").lower()
thermostat_map = {
Expand Down Expand Up @@ -1389,6 +1413,8 @@ def parse_workflow(self):
timestep * ureg.picosecond if timestep else None
)

initialization_parameters = self.get_initialization_parameters()
method["initialization_parameters"] = [initialization_parameters]
thermostat_parameters = self.get_thermostat_parameters(integrator)
method["thermostat_parameters"] = [thermostat_parameters]
barostat_parameters = self.get_barostat_parameters()
Expand Down
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
Loading