diff --git a/examples/USER/mdi/README b/examples/USER/mdi/README new file mode 100644 index 0000000000..ba8ddc3c5b --- /dev/null +++ b/examples/USER/mdi/README @@ -0,0 +1,29 @@ +This dir contains scripts that demonstrate how to use LAMMPS as an +MDI engine. LAMMPS as an engine performs the MD timestepping. +The driver is a simple Python script. Every timestep the driver +sends one or more commands to LAMMPS. + +See the MDI package documentation Build_extras.html#mdi and +Build_extras.html#mdi for more details on how the LAMMPS MDI +implementation works. + +-------------- + +NOTE: the Script.sh file has comands to perform all the +runs listed below. + +-------------- + +File or ZMQ or mpi/two modes of messaging: + +% mpirun -np 1 lmp_mpi -v mode file -log log.client -in in.message.client & +% mpirun -np 2 lmp_mpi -v mode file -log log.server -in in.message.server + +% mpirun -np 4 lmp_mpi -v mode zmq -log log.client -in in.message.client & +% mpirun -np 1 lmp_mpi -v mode zmq -log log.server -in in.message.server + +% mpirun -np 2 lmp_mpi -v mode mpitwo -log log.client -in in.message.client & +% mpirun -np 4 lmp_mpi -v mode mpitwo -log log.server -in in.message.server + +Or run with in.message.tilt.client/server. +Don't run the tilt files with the "file" mode; they run too slow. diff --git a/examples/USER/mdi/Script.sh b/examples/USER/mdi/Script.sh new file mode 100644 index 0000000000..4894f82e2a --- /dev/null +++ b/examples/USER/mdi/Script.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# sample launch scripts + +# TCP, running LAMMPS on one proc + +python driver.py -mdi "-name driver -role DRIVER -method TCP -port 8021" & +../../../src/lmp_mdi -mdi "-name LAMMPS -role ENGINE -method TCP -port 8021 -hostname localhost" -in lammps.in > lammps.out & +wait + + +# MPI, running LAMMPS on one proc + +mpirun -n 1 python driver.py -mdi "-name driver -role DRIVER -method MPI" : -n 1 ../../../src/lmp_mdi -mdi "-name LAMMPS -role ENGINE -method MPI" diff --git a/examples/USER/mdi/driver.py b/examples/USER/mdi/driver.py new file mode 100644 index 0000000000..fd478b92b7 --- /dev/null +++ b/examples/USER/mdi/driver.py @@ -0,0 +1,17 @@ +import sys +import mdi + +# Initialize the MDI Library +mdi.MDI_Init(sys.argv[2]) + +# Connect to the engine +comm = mdi.MDI_Accept_communicator() + +# Determine the name of the engine +mdi.MDI_Send_Command("