I want to create two PyLammps objects, here is my code:
# MD setting
cmdargs = ["-log", "none", "-screen", "none"] # args: https://docs.lammps.org/latest/Run_options.html
lmp1 = PyLammps(cmdargs = cmdargs)
lmp2 = PyLammps(cmdargs = cmdargs)
basis_timestep = 0.1
ntimestep = 10
but the code report a error as follows:
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Cell In[8], line 5
2 cmdargs = ["-log", "none", "-screen", "none"] # args: https://docs.lammps.org/latest/Run_options.html
4 lmp1 = PyLammps(cmdargs = cmdargs)
----> 5 lmp2 = PyLammps(cmdargs = cmdargs)
6 basis_timestep = 0.1
7 ntimestep = 10
File ~/miniconda3/envs/lammps/lib/python3.11/site-packages/lammps/pylammps.py:453, in PyLammps.__init__(self, name, cmdargs, ptr, comm, verbose)
451 self.lmp = lammps(name=name,cmdargs=cmdargs,ptr=ptr,comm=comm)
452 else:
--> 453 self.lmp = lammps(name=name,cmdargs=cmdargs,ptr=None,comm=comm)
454 print("LAMMPS output is captured by PyLammps wrapper")
455 self._cmd_history = []
File ~/miniconda3/envs/lammps/lib/python3.11/site-packages/lammps/core.py:428, in lammps.__init__(self, name, cmdargs, ptr, comm)
426 # check if library initilialization failed
427 if not self.lmp:
--> 428 raise(RuntimeError("Failed to initialize LAMMPS object"))
430 # optional numpy support (lazy loading)
431 self._numpy = None
RuntimeError: Failed to initialize LAMMPS object
if i set the cmdargs
to None
in the code block, it works. what’s wrong with my code?