Skip to content

Commit

Permalink
add logic to treat multiple log steps
Browse files Browse the repository at this point in the history
  • Loading branch information
Leimeroth committed Nov 26, 2024
1 parent 24c7d19 commit 73c0b8a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pyiron_atomistics/lammps/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ def _collect_output_log(
general purpose routine to extract static from a lammps log file
"""
with open(file_name, "r") as f:
dfs = []
read_thermo = False
thermo_lines = ""
for l in f:
Expand All @@ -331,25 +332,36 @@ def _collect_output_log(
if read_thermo:
if l.startswith("Loop") or l.startswith("ERROR"):
read_thermo = False
dfs.append(
pd.read_csv(StringIO(thermo_lines), sep="\s+", engine="c")
)
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"):
read_thermo = True
thermo_lines += l

df = pd.read_csv(StringIO(thermo_lines), sep="\s+", engine="c")

h5_dict = {
"Step": "steps",
"Temp": "temperature",
"PotEng": "energy_pot",
"TotEng": "energy_tot",
"Volume": "volume",
}
if len(dfs) == 1:
df = dfs[0]
else:
h5_dict["LogStep"] = "LogStep"
for i in range(len(dfs)):
df = dfs[i]
df["LogStep"] = np.ones(len(df)) * i
df = pd.concat(dfs)

for key in df.columns[df.columns.str.startswith("f_mean")]:
h5_dict[key] = key.replace("f_", "")
Expand Down

0 comments on commit 73c0b8a

Please sign in to comment.