Log & Thermo File ReaderΒΆ

Read LAMMPS log files containing thermodynamic output from the thermo command.

The log file reader automatically:

  • Detects different thermodynamic output sections with varying columns

  • Handles (ignores) warnings and broken lines in the log

  • Skips non-numeric data

  • Supports multi-run simulations with different thermo_style commands

Relevant documentation: read_log_file() and extract_thermo_params()

plot log thermo file reader
Temperature range: 0.00 - 0.36
Final pressure: -0.170444

import os

import matplotlib.pyplot as plt

from pylimer_tools.io.read_lammps_output_file import read_log_file

# Read complete log file
log_file = os.path.join(
    os.getcwd(),
    "../..",
    "tests/pylimer_tools/fixtures/log.lammps",
)
thermo_data = read_log_file(log_file)

# Access thermodynamic properties
print(
    f"Temperature range: {thermo_data['Temp'].min():.2f} - {
        thermo_data['Temp'].max():.2f
    }"
)
print(f"Final pressure: {thermo_data['Press'].iloc[-1]:.6f}")

# Plot temperature evolution
plt.plot(thermo_data["Step"], thermo_data["Temp"])
plt.xlabel("Simulation Step")
plt.ylabel("Temperature [LJ-units]")
plt.show()
plt.ylabel("Temperature [LJ-units]")
plt.show()

Total running time of the script: (0 minutes 0.059 seconds)

Gallery generated by Sphinx-Gallery