Skip to content

Commit

Permalink
Merge pull request #1601 from pyiron/Increase-lammps-parsing-robustness
Browse files Browse the repository at this point in the history
Increase lammps parsing robustness
  • Loading branch information
jan-janssen authored Nov 13, 2024
2 parents a4e3bbb + 9252df1 commit 745b602
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
16 changes: 11 additions & 5 deletions pyiron_atomistics/lammps/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import pandas
from pyiron_base import state
from pyiron_snippets.deprecate import deprecate
from pyiron_snippets.logger import logger

from pyiron_atomistics.atomistics.job.atomistic import AtomisticGenericJob
from pyiron_atomistics.lammps.control import LammpsControl
Expand Down Expand Up @@ -427,17 +428,22 @@ def save_output(
data_dict=output_dict,
group_name="output",
)
final_structure = self.structure.copy()
final_structure.indices = hdf_dict["output/generic/indices"][-1]
final_structure.positions = hdf_dict["output/generic/positions"][-1]
final_structure.cell = hdf_dict["output/generic/cells"][-1]
if final_structure is not None:
if len(self.structure) == len(hdf_dict["output/generic/indices"][-1]):
final_structure = self.structure.copy()
final_structure.indices = hdf_dict["output/generic/indices"][-1]
final_structure.positions = hdf_dict["output/generic/positions"][-1]
final_structure.cell = hdf_dict["output/generic/cells"][-1]
hdf_dict.update(
{
"output/structure/" + k: v
for k, v in final_structure.to_dict().items()
}
)
else:
logger.warning(
"The number of atoms changed during the simulation. This can be a sign of massive issues in your simulation.\n"
"Not storing 'output/structure' to HDF"
)
self.project_hdf5.write_dict_to_hdf(data_dict=hdf_dict)

def convergence_check(self):
Expand Down
9 changes: 8 additions & 1 deletion pyiron_atomistics/lammps/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import numpy as np
import pandas as pd
from pyiron_base import extract_data_from_file
from pyiron_snippets.logger import logger

from pyiron_atomistics.lammps.structure import UnfoldingPrism
from pyiron_atomistics.lammps.units import UnitConverter
Expand Down Expand Up @@ -75,7 +76,10 @@ def parse_lammps_output(

for k, v in dump_dict.items():
if len(v) > 0:
hdf_generic[k] = convert_units(np.array(v), label=k)
try:
hdf_generic[k] = convert_units(np.array(v), label=k)
except ValueError:
hdf_generic[k] = [convert_units(np.array(val), label=k) for val in v]

if df is not None and pressure_dict is not None and generic_keys_lst is not None:
for k, v in df.items():
Expand Down Expand Up @@ -328,6 +332,9 @@ def _collect_output_log(
if l.startswith("Loop") or l.startswith("ERROR"):
read_thermo = False
continue
elif l.startswith("WARNING:"):
logger.warning(f"A warning was found in the log:\n{l}")
continue
thermo_lines += l

if l.startswith("Step"):
Expand Down

0 comments on commit 745b602

Please sign in to comment.