diff --git a/python/lammps/core.py b/python/lammps/core.py index 279b0a64dc..b3cdceb1a6 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -758,6 +758,8 @@ class lammps(object): 'sublo_lambda':3, 'subhi_lambda':3, 'periodicity':3 } if name in vec_dict: veclen = vec_dict[name] + elif name == 'respa_dt': + veclen = self.extract_global('respa_levels',LAMMPS_INT) else: veclen = 1 diff --git a/src/library.cpp b/src/library.cpp index 8de36a299f..6f08cffcc2 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -31,12 +31,14 @@ #include "group.h" #include "info.h" #include "input.h" +#include "integrate.h" #include "memory.h" #include "modify.h" #include "molecule.h" #include "neigh_list.h" #include "neighbor.h" #include "region.h" +#include "respa.h" #include "output.h" #include "thermo.h" #include "timer.h" @@ -984,12 +986,14 @@ to then decide how to cast the (void*) pointer and access the data. * \return integer constant encoding the data type of the property * or -1 if not found. */ -int lammps_extract_global_datatype(void *handle, const char *name) +int lammps_extract_global_datatype(void * /*handle*/, const char *name) { if (strcmp(name,"dt") == 0) return LAMMPS_DOUBLE; if (strcmp(name,"ntimestep") == 0) return LAMMPS_BIGINT; if (strcmp(name,"atime") == 0) return LAMMPS_DOUBLE; if (strcmp(name,"atimestep") == 0) return LAMMPS_BIGINT; + if (strcmp(name,"respa_levels") == 0) return LAMMPS_INT; + if (strcmp(name,"respa_dt") == 0) return LAMMPS_DOUBLE; if (strcmp(name,"boxlo") == 0) return LAMMPS_DOUBLE; if (strcmp(name,"boxhi") == 0) return LAMMPS_DOUBLE; @@ -1116,6 +1120,14 @@ report the "native" data type. The following tables are provided: - bigint - 1 - the number of the timestep when "atime" was last updated. + * - respa_levels + - int + - 1 + - number of r-RESPA levels. See :doc:`run_style`. + * - respa_dt + - double + - number of r-RESPA levels + - length of the time steps with r-RESPA. See :doc:`run_style`. .. _extract_box_settings: @@ -1366,6 +1378,11 @@ void *lammps_extract_global(void *handle, const char *name) if (strcmp(name,"atime") == 0) return (void *) &lmp->update->atime; if (strcmp(name,"atimestep") == 0) return (void *) &lmp->update->atimestep; + if (utils::strmatch(lmp->update->integrate_style,"^respa")) { + Respa *respa = (Respa *)lmp->update->integrate; + if (strcmp(name,"respa_levels") == 0) return (void *) &respa->nlevels; + if (strcmp(name,"respa_dt") == 0) return (void *) respa->step; + } if (strcmp(name,"boxlo") == 0) return (void *) lmp->domain->boxlo; if (strcmp(name,"boxhi") == 0) return (void *) lmp->domain->boxhi; if (strcmp(name,"sublo") == 0) return (void *) lmp->domain->sublo; diff --git a/unittest/python/python-commands.py b/unittest/python/python-commands.py index c1e4cecef5..3bcb785b74 100644 --- a/unittest/python/python-commands.py +++ b/unittest/python/python-commands.py @@ -274,6 +274,16 @@ create_atoms 1 single & self.assertEqual(self.lmp.extract_global("subhi"), [1.0, 2.0, 3.0]) self.assertEqual(self.lmp.extract_global("periodicity"), [1,1,1]) # only valid for triclinic box + self.assertEqual(self.lmp.extract_global("respa_levels"), None) + self.assertEqual(self.lmp.extract_global("respa_dt"), None) + + # set and initialize r-RESPA + self.lmp.command("run_style respa 3 5 2 pair 2 kspace 3") + self.lmp.command("mass * 1.0") + self.lmp.command("run 1 post no") + self.assertEqual(self.lmp.extract_global("ntimestep"), 1) + self.assertEqual(self.lmp.extract_global("respa_levels"), 3) + self.assertEqual(self.lmp.extract_global("respa_dt"), [0.0005, 0.0025, 0.005]) self.lmp.command("change_box all triclinic") self.assertEqual(self.lmp.extract_global("sublo_lambda"), [0.0, 0.0, 0.0]) self.assertEqual(self.lmp.extract_global("subhi_lambda"), [1.0, 1.0, 1.0])