From 19a83135786765fecca1af73238bc359cfe29ac0 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 18 Jun 2024 21:13:14 -0400 Subject: [PATCH] switch proc_grid to procgrid with backward compatibility for PyLammps --- python/lammps/core.py | 2 +- python/lammps/pylammps.py | 2 +- src/library.cpp | 9 ++++----- unittest/python/python-commands.py | 4 ++-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/python/lammps/core.py b/python/lammps/core.py index 497d8efc20..8966a77440 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -891,7 +891,7 @@ class lammps(object): # set length of vector for items that are not a scalar vec_dict = { 'boxlo':3, 'boxhi':3, 'sublo':3, 'subhi':3, 'sublo_lambda':3, 'subhi_lambda':3, 'periodicity':3, - 'special_lj':4, 'special_coul':4, 'proc_grid':3 } + 'special_lj':4, 'special_coul':4, 'procgrid':3 } if name in vec_dict: veclen = vec_dict[name] elif name == 'respa_dt': diff --git a/python/lammps/pylammps.py b/python/lammps/pylammps.py index 519b1e323c..96384255c2 100644 --- a/python/lammps/pylammps.py +++ b/python/lammps/pylammps.py @@ -796,7 +796,7 @@ class PyLammps(object): comm = {} comm['nprocs'] = self.lmp.extract_setting("world_size") comm['nthreads'] = self.lmp.extract_setting("nthreads") - comm['proc_grid'] = self.lmp.extract_global("proc_grid") + comm['proc_grid'] = comm['procgrid'] = self.lmp.extract_global("procgrid") idx = self.lmp.extract_setting("comm_style") comm['comm_style'] = ('brick', 'tiled')[idx] idx = self.lmp.extract_setting("comm_style") diff --git a/src/library.cpp b/src/library.cpp index 4fbfbe332b..71cf01eff2 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -1407,7 +1407,7 @@ int lammps_extract_global_datatype(void * /*handle*/, const char *name) if (strcmp(name,"xy") == 0) return LAMMPS_DOUBLE; if (strcmp(name,"xz") == 0) return LAMMPS_DOUBLE; if (strcmp(name,"yz") == 0) return LAMMPS_DOUBLE; - if (strcmp(name,"proc_grid") == 0) return LAMMPS_INT; + if (strcmp(name,"procgrid") == 0) return LAMMPS_INT; if (strcmp(name,"natoms") == 0) return LAMMPS_BIGINT; if (strcmp(name,"nbonds") == 0) return LAMMPS_BIGINT; @@ -1626,7 +1626,7 @@ report the "native" data type. The following tables are provided: - double - 1 - triclinic tilt factor. See :doc:`Howto_triclinic`. - * - proc_grid + * - procgrid - int - 3 - processor count assigned to each dimension of 3d grid. See :doc:`processors`. @@ -1887,9 +1887,8 @@ void *lammps_extract_global(void *handle, const char *name) if (strcmp(name,"xy") == 0) return (void *) &lmp->domain->xy; if (strcmp(name,"xz") == 0) return (void *) &lmp->domain->xz; if (strcmp(name,"yz") == 0) return (void *) &lmp->domain->yz; - if ((lmp->comm->layout == Comm::LAYOUT_UNIFORM || - lmp->comm->layout == Comm::LAYOUT_NONUNIFORM) && - (strcmp(name,"proc_grid") == 0)) + if (((lmp->comm->layout == Comm::LAYOUT_UNIFORM) || + (lmp->comm->layout == Comm::LAYOUT_NONUNIFORM)) && (strcmp(name,"procgrid") == 0)) return (void *) &lmp->comm->procgrid; if (strcmp(name,"natoms") == 0) return (void *) &lmp->atom->natoms; diff --git a/unittest/python/python-commands.py b/unittest/python/python-commands.py index c007cc8014..3a222dde5a 100644 --- a/unittest/python/python-commands.py +++ b/unittest/python/python-commands.py @@ -660,11 +660,11 @@ create_atoms 1 single & self.assertEqual(self.lmp.extract_global("subhi_lambda"), [1.0, 1.0, 1.0]) # processor grid - self.assertEqual(self.lmp.extract_global("proc_grid"), [1,1,1]) + self.assertEqual(self.lmp.extract_global("procgrid"), [1,1,1]) self.lmp.command("comm_style tiled") self.lmp.command("run 0 post no") self.lmp.command("balance 0.1 rcb") - self.assertEqual(self.lmp.extract_global("proc_grid"), None) + self.assertEqual(self.lmp.extract_global("procgrid"), None) def test_create_atoms(self): self.lmp.command("boundary f p m")