Running a LAMMPS script
The simplest way of running a LAMMPS script is through the pre-made sim
simulation object. A LAMMPS simulation with the script script.in
can then be launched using
from lammps_simulator import sim
sim.set_input_script("script.in")
sim.run(num_procs=4, lmp_exec="lmp")
Device object
Sometimes it can be useful to define a Device
object, especially when running various simulations with the same hardware specifications. Different devices can be found in lammps_simulator.device
:
from lammps_simulator.device import CPU
device = CPU(num_procs=4, lmp_exec="lmp")
sim.run(device=device)
Other devices include GPU
(run LAMMPS with the GPU
or KOKKOS
package), SlurmCPU
(submit LAMMPS CPU jobs to Slurm) and SlurmGPU
(submit LAMMPS GPU jobs to Slurm). The Slurm support is further described in the Slurm-section.
Activate virtual cores
In Open MPI version >= 3.0, oversubscription of slots is not allowed by default. One can overcome this by manually bumping up the number of slots. There are multiply ways of doing this, but arguably the easiest way is to make a host file:
$ cat hostfile
localhost slots=<new-number-of-slots>
and then pass it as an argument to mpirun
/mpiexec
:
mpirun -n 1 -hostfile hostfile ...
By doing this, a simulation can be run both on the physical and the virtual cores of a node, which may give a significant speed-up. In lammps-simulator
, oversubscribing is built-in with the argument activate_virtual
:
from lammps_simulator import sim
sim.set_input_script("script.in")
sim.run(num_procs=4, lmp_exec="lmp", activate_virtual=True)
For more information about MPI command line arguments, see Command line arguments.