Add MDI example
This commit is contained in:
29
examples/USER/mdi/README
Normal file
29
examples/USER/mdi/README
Normal file
@ -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.
|
||||
13
examples/USER/mdi/Script.sh
Normal file
13
examples/USER/mdi/Script.sh
Normal file
@ -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"
|
||||
17
examples/USER/mdi/driver.py
Normal file
17
examples/USER/mdi/driver.py
Normal file
@ -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("<NAME", comm)
|
||||
name = mdi.MDI_Recv(mdi.MDI_NAME_LENGTH, mdi.MDI_CHAR, comm)
|
||||
|
||||
print("Engine name: " + str(name))
|
||||
|
||||
# Send the "EXIT" command to the engine
|
||||
mdi.MDI_Send_Command("EXIT", comm)
|
||||
92
examples/USER/mdi/lammps.data
Normal file
92
examples/USER/mdi/lammps.data
Normal file
@ -0,0 +1,92 @@
|
||||
LAMMPS data file for water
|
||||
|
||||
24 atoms
|
||||
16 bonds
|
||||
8 angles
|
||||
0 dihedrals
|
||||
0 impropers
|
||||
|
||||
2 atom types
|
||||
1 bond types
|
||||
1 angle types
|
||||
0 dihedral types
|
||||
0 improper types
|
||||
|
||||
0.0 4.9325 xlo xhi
|
||||
0.0 4.9325 ylo yhi
|
||||
0.0 4.9325 zlo zhi
|
||||
|
||||
Masses
|
||||
|
||||
1 15.9994
|
||||
2 1.008
|
||||
|
||||
Pair Coeffs
|
||||
|
||||
1 0.102 3.188
|
||||
2 0.000 0.000
|
||||
|
||||
Bond Coeffs
|
||||
|
||||
1 450 0.9572
|
||||
|
||||
Angle Coeffs
|
||||
|
||||
1 55.0 104.52
|
||||
|
||||
Atoms
|
||||
|
||||
1 0 1 -0.83400 2.17919 0.196156 4.15513
|
||||
2 0 2 0.41700 2.29785 4.8353 0.126003
|
||||
3 0 2 0.41700 1.82037 1.07996 4.23498
|
||||
4 0 1 -0.83400 4.65839 0.120414 0.305758
|
||||
5 0 2 0.41700 4.67446 -0.0220991 4.29186
|
||||
6 0 2 0.41700 4.28188 0.994196 0.410515
|
||||
7 0 1 -0.83400 3.65045 2.40907 0.344349
|
||||
8 0 2 0.41700 3.52052 2.1838 4.35565
|
||||
9 0 2 0.41700 4.26579 3.14208 0.327669
|
||||
10 0 1 -0.83400 1.21327 2.62177 4.15519
|
||||
11 0 2 0.41700 1.47452 3.53837 4.0667
|
||||
12 0 2 0.41700 1.20743 2.46396 0.16677
|
||||
13 0 1 -0.83400 4.45777 4.47325 2.74192
|
||||
14 0 2 0.41700 4.53396 4.49652 1.78804
|
||||
15 0 2 0.41700 4.21354 3.56943 2.94119
|
||||
16 0 1 -0.83400 2.04119 4.41585 1.64725
|
||||
17 0 2 0.41700 2.26934 4.77582 2.50434
|
||||
18 0 2 0.41700 1.69079 3.54574 1.83793
|
||||
19 0 1 -0.83400 3.73384 1.97964 2.81949
|
||||
20 0 2 0.41700 3.41083 2.22014 1.95113
|
||||
21 0 2 0.41700 3.91914 1.04272 2.75561
|
||||
22 0 1 -0.83400 1.20859 2.09853 1.68186
|
||||
23 0 2 0.41700 1.01865 2.25693 2.60655
|
||||
24 0 2 0.41700 1.16884 1.14674 1.58832
|
||||
|
||||
Bonds
|
||||
|
||||
1 1 1 2
|
||||
2 1 1 3
|
||||
3 1 4 5
|
||||
4 1 4 6
|
||||
5 1 7 8
|
||||
6 1 7 9
|
||||
7 1 10 11
|
||||
8 1 10 12
|
||||
9 1 13 14
|
||||
10 1 13 15
|
||||
11 1 16 17
|
||||
12 1 16 18
|
||||
13 1 19 20
|
||||
14 1 19 21
|
||||
15 1 22 23
|
||||
16 1 22 24
|
||||
|
||||
Angles
|
||||
|
||||
1 1 2 1 3
|
||||
2 1 5 4 6
|
||||
3 1 8 7 9
|
||||
4 1 11 10 12
|
||||
5 1 14 13 15
|
||||
6 1 17 16 18
|
||||
7 1 20 19 21
|
||||
8 1 23 22 24
|
||||
28
examples/USER/mdi/lammps.in
Normal file
28
examples/USER/mdi/lammps.in
Normal file
@ -0,0 +1,28 @@
|
||||
units real
|
||||
neigh_modify delay 0 every 1 check yes
|
||||
atom_style full
|
||||
bond_style harmonic
|
||||
angle_style harmonic
|
||||
pair_style lj/cut/coul/long 10.0
|
||||
pair_modify mix arithmetic
|
||||
kspace_style pppm 1e-4
|
||||
special_bonds amber
|
||||
|
||||
atom_modify sort 0 0
|
||||
|
||||
read_data lammps.data
|
||||
|
||||
timestep 1.0
|
||||
|
||||
dump 1 all custom 1 dump.lammpstrj id element xu yu zu
|
||||
dump 2 all custom 1 dump.force id element fx fy fz
|
||||
dump 3 all xyz 1 dump.xyz
|
||||
dump_modify 1 element O H
|
||||
dump_modify 2 element O H
|
||||
|
||||
thermo_style multi
|
||||
thermo 1
|
||||
|
||||
fix 1 all nvt temp 300.0 300.0 70.0
|
||||
|
||||
mdi_engine
|
||||
Reference in New Issue
Block a user