Issue with Accessing Thermo Data in Pylammps

Dear members of the LAMMPS mailing list,

I have been attempting to build and install the LAMMPS Python interface (Pylammps) to leverage the advantages of accessing thermos data. However, I am encountering the following error:

Based on my understanding from the documentation, if I set up a simulation with a single run using L.run(100) and have the thermo data outputted at each step, I should be able to access the thermo output of this run using L.runs[0]. This should result in a list of thermo data for the first run, containing the thermo data at each step.

However, when I use L.runs[0], I only get the thermo data at the last step of my run. For example, L.runs[0] outputs:

[Run(thermo=ThermoData(Step=[100], Time=[0.1], Temp=[300.01106304681286], PotEng=[-3466.4364575685695]))]

Here is the process I followed to build and install LAMMPS as a shared library:

Step 1: Download the LAMMPS source with git

git clone -b stable https://github.com/lammps/lammps.git lammps

Step 2: Create a virtual environment named Pylammps:

conda create --name Pylammps
conda activate Pylammps

Step 3 Build LAMMPS as a shared library:
. Return to the main LAMMPS directory


cd lammps
mkdir build-shared
cd build-shared
cmake ../cmake -DPKG_MOLECULE=yes -D PKG_MANYBODY=yes -DBUILD_LIB=yes -DBUILD_SHARED_LIBS=yes
make
make install-python

I am using LAMMPS VERSION: 20230802 lammps-gui-v1.2 on Linux Ubuntu 20.04 with CMake version 3.27.9. The build and installation were successful. However, upon initializing Pylammps, I see a warning:

LAMMPS (2 Aug 2023 - Update 1)
OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98)
using 1 OpenMP thread(s) per MPI task
LAMMPS output is captured by PyLammps wrapper
**WARNING: run thermo data not captured since PYTHON LAMMPS package is not enabled**

Does this warning have something to do with L.runs not displaying the thermos data as expected? How can I resolve this issue?

Thank you!

We do not recommend using PyLammps for production calculations. Rather you should use the LAMMPS python module (the one you get when you import “lammps” instead of “PyLammps”).
The former is rather fragile and not meant to be used for production calculations, but rather for demos and specifically in combination with Jupyter notebooks.

Yes.

You need to enable the PYTHON package when compiling LAMMPS from source. PyLammps uses it to access data.

Any alternative approach, that is also compatible with the regular “lammps” python module, is to use the “yaml” thermodynamic output format and use a YAML parser to read that data as shown here: 8.3.9. Output structured data from LAMMPS — LAMMPS documentation