Get mpi distribiuted box dimensions through python interface

Hi,

I am running lammps through the python interface across multiple nodes and would like to extract the local box dimensions of the distributed grid for each mpi rank in python. When I print the result of lmp.extract_box() to the terminal, each rank displays my original global box that I set in the input file. Is there some other way to get the distributed box dimensions?

Thanks!
Josh

You can use lmp.extract_global('sublo') and lmp.extract_global('subhi') to get the lower corner and upper corner coordinates of the subdomain box for the individual MPI rank.

Here is a minimal example to demonstrate:

from lammps import lammps

lmp = lammps(cmdargs=['-in','none'])
lmp.command('region box block 0 1 0 1 0 1')
lmp.command('create_box 1 box')

me = lmp.extract_setting('world_rank')
sublo = lmp.extract_global('sublo')
subhi = lmp.extract_global('subhi')
boxlo, boxhi, *rest = lmp.extract_box()

print('me = ', me, '  boxlo: ', boxlo, '  boxhi: ', boxhi, \
      '  sublo: ', sublo, '  subhi: ', subhi)
lmp.close()

Which produces the following output:

$ mpirun -np 8 python subbox.py 
LAMMPS (28 Mar 2023 - Development)
  using 1 OpenMP thread(s) per MPI task
Created orthogonal box = (0 0 0) to (1 1 1)
  2 by 2 by 2 MPI processor grid
Total wall time: 0:00:00
me =  1   boxlo:  [0.0, 0.0, 0.0]   boxhi:  [1.0, 1.0, 1.0]   sublo:  [0.0, 0.0, 0.5]   subhi:  [0.5, 0.5, 1.0]
me =  2   boxlo:  [0.0, 0.0, 0.0]   boxhi:  [1.0, 1.0, 1.0]   sublo:  [0.0, 0.5, 0.0]   subhi:  [0.5, 1.0, 0.5]
me =  3   boxlo:  [0.0, 0.0, 0.0]   boxhi:  [1.0, 1.0, 1.0]   sublo:  [0.0, 0.5, 0.5]   subhi:  [0.5, 1.0, 1.0]
me =  4   boxlo:  [0.0, 0.0, 0.0]   boxhi:  [1.0, 1.0, 1.0]   sublo:  [0.5, 0.0, 0.0]   subhi:  [1.0, 0.5, 0.5]
me =  5   boxlo:  [0.0, 0.0, 0.0]   boxhi:  [1.0, 1.0, 1.0]   sublo:  [0.5, 0.0, 0.5]   subhi:  [1.0, 0.5, 1.0]
me =  7   boxlo:  [0.0, 0.0, 0.0]   boxhi:  [1.0, 1.0, 1.0]   sublo:  [0.5, 0.5, 0.5]   subhi:  [1.0, 1.0, 1.0]
me =  6   boxlo:  [0.0, 0.0, 0.0]   boxhi:  [1.0, 1.0, 1.0]   sublo:  [0.5, 0.5, 0.0]   subhi:  [1.0, 1.0, 0.5]
me =  0   boxlo:  [0.0, 0.0, 0.0]   boxhi:  [1.0, 1.0, 1.0]   sublo:  [0.0, 0.0, 0.0]   subhi:  [0.5, 0.5, 0.5]

Fantastic! Thanks Axel!