Fix bug in AvgChunkReader and add docs

This commit is contained in:
Richard Berger
2021-02-25 16:56:19 -05:00
parent 3d96d0a674
commit f92089298d
4 changed files with 38 additions and 1 deletions

View File

@ -12,13 +12,25 @@
# -------------------------------------------------------------------------
################################################################################
# LAMMPS data formats
# LAMMPS output formats
# Written by Richard Berger <richard.berger@temple.edu>
################################################################################
import re
class LogFile:
"""Reads LAMMPS log files and extracts the thermo information
It supports both the default thermo output style (including custom) and multi.
:param filename: path to log file
:type filename: str
:ivar runs: List of LAMMPS runs in log file. Each run is a dictionary with
thermo fields as keys, storing the values over time
:ivar errors: List of error lines in log file
"""
STYLE_DEFAULT = 0
STYLE_MULTI = 1
@ -73,7 +85,17 @@ class LogFile:
else:
current_run[k].append(float(v))
class AvgChunkFile:
"""Reads files generated by fix ave/chunk
:param filename: path to ave/chunk file
:type filename: str
:ivar timesteps: List of timesteps stored in file
:ivar total_count: total count over time
:ivar chunks: List of chunks. Each chunk is a dictionary containing its ID, the coordinates, and the averaged quantities
"""
def __init__(self, filename):
with open(filename, 'rt') as f:
timestep = None
@ -121,6 +143,7 @@ class AvgChunkFile:
total_count = float(parts[2])
self.timesteps.append(timestep)
self.total_count.append(total_count)
for i in range(num_chunks):
self.chunks.append({