From 57baf7a8112dffaebebf6fa26da1c1b940ba3151 Mon Sep 17 00:00:00 2001 From: srmnitc Date: Tue, 21 Dec 2021 19:39:44 +0100 Subject: [PATCH 1/2] add local option --- pylammpsmpi/lammps_wrapper.py | 1 + pylammpsmpi/utils/lammps.py | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pylammpsmpi/lammps_wrapper.py b/pylammpsmpi/lammps_wrapper.py index 57d48d70..cf744634 100644 --- a/pylammpsmpi/lammps_wrapper.py +++ b/pylammpsmpi/lammps_wrapper.py @@ -33,6 +33,7 @@ def __init__(self, cores=1, working_directory=".", client=None, mode="local"): LammpsBase, cores=self.cores, working_directory=self.working_directory, + local=False, actor=True, ) self.lmp = fut.result() diff --git a/pylammpsmpi/utils/lammps.py b/pylammpsmpi/utils/lammps.py index 4b54fe44..76002f67 100644 --- a/pylammpsmpi/utils/lammps.py +++ b/pylammpsmpi/utils/lammps.py @@ -20,17 +20,22 @@ class LammpsBase: - def __init__(self, cores=8, working_directory="."): + def __init__(self, cores=8, working_directory=".", local=True): self.cores = cores self.working_directory = working_directory self._process = None + self.local = local def start_process(self): executable = os.path.join( os.path.dirname(os.path.abspath(__file__)), "../mpi", "lmpmpi.py" ) + if self.local: + command_array = ["mpiexec", "-n", str(self.cores), "python", executable] + else: + command_array = ["mpiexec", "--oversubscribe", "-n", str(self.cores), "python", executable] self._process = subprocess.Popen( - ["mpiexec", "--oversubscribe", "-n", str(self.cores), "python", executable], + command_array, stdout=subprocess.PIPE, stderr=None, stdin=subprocess.PIPE, From 5d459ce67838731aabd59071430e20f04ad57c5f Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Fri, 4 Mar 2022 11:04:51 -0700 Subject: [PATCH 2/2] black --- pylammpsmpi/utils/lammps.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pylammpsmpi/utils/lammps.py b/pylammpsmpi/utils/lammps.py index 76002f67..2e844e02 100644 --- a/pylammpsmpi/utils/lammps.py +++ b/pylammpsmpi/utils/lammps.py @@ -33,7 +33,14 @@ def start_process(self): if self.local: command_array = ["mpiexec", "-n", str(self.cores), "python", executable] else: - command_array = ["mpiexec", "--oversubscribe", "-n", str(self.cores), "python", executable] + command_array = [ + "mpiexec", + "--oversubscribe", + "-n", + str(self.cores), + "python", + executable, + ] self._process = subprocess.Popen( command_array, stdout=subprocess.PIPE,