pylammps: make use of lammps_last_thermo

this now avoids parsing LAMMPS output to extract thermo data, but instead uses
the new lammps_last_thermo library function
This commit is contained in:
Richard Berger
2023-06-09 02:29:30 -06:00
parent ecf7c24e87
commit fe45b766c3
2 changed files with 31 additions and 53 deletions

View File

@ -746,6 +746,11 @@ class lammps(object):
return self.lib.lammps_get_thermo(self.lmp,name)
# -------------------------------------------------------------------------
@property
def last_thermo_step(self):
with ExceptionCheck(self):
ptr = self.lib.lammps_last_thermo(self.lmp, c_char_p("step".encode()), 0)
return cast(ptr, POINTER(self.c_bigint)).contents.value
def last_thermo(self):
"""Get a dictionary of the last thermodynamic output
@ -760,9 +765,7 @@ class lammps(object):
"""
rv = dict()
with ExceptionCheck(self):
ptr = self.lib.lammps_last_thermo(self.lmp, c_char_p("step".encode()), 0)
mystep = cast(ptr, POINTER(self.c_bigint)).contents.value
mystep = self.last_thermo_step
if mystep < 0:
return None