new MESSAGE package for client/server/coupling
This commit is contained in:
@ -10,6 +10,7 @@ See these sections of the LAMMPS manaul for details:
|
||||
|
||||
2.5 Building LAMMPS as a library (doc/Section_start.html#start_5)
|
||||
6.10 Coupling LAMMPS to other codes (doc/Section_howto.html#howto_10)
|
||||
6.29 Using LAMMPS in client/server mode (doc/Section_howto.html#howto_29)
|
||||
|
||||
In all of the examples included here, LAMMPS must first be built as a
|
||||
library. Basically, in the src dir you type one of
|
||||
@ -33,9 +34,11 @@ These are the sub-directories included in this directory:
|
||||
|
||||
simple simple example of driver code calling LAMMPS as a lib
|
||||
multiple example of driver code calling multiple instances of LAMMPS
|
||||
lammps_mc client/server coupling Monte Carlo with LAMMPS MD
|
||||
lammps_quest MD with quantum forces, coupling to Quest DFT code
|
||||
lammps_spparks grain-growth Monte Carlo with strain via MD,
|
||||
coupling to SPPARKS kinetic MC code
|
||||
lammps_vasp client/server coupling LAMMPS MD with VASP quantum DFT
|
||||
library collection of useful inter-code communication routines
|
||||
fortran a simple wrapper on the LAMMPS library API that
|
||||
can be called from Fortran
|
||||
|
||||
34
examples/COUPLE/lammps_mc/Makefile
Normal file
34
examples/COUPLE/lammps_mc/Makefile
Normal file
@ -0,0 +1,34 @@
|
||||
# Makefile for MC
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
SRC = mc.cpp random_park.cpp
|
||||
OBJ = $(SRC:.cpp=.o)
|
||||
|
||||
# change this line for your machine to path for CSlib src dir
|
||||
|
||||
CSLIB = /home/sjplimp/lammps/lib/message/cslib/src
|
||||
|
||||
# compiler/linker settings
|
||||
|
||||
CC = g++
|
||||
CCFLAGS = -g -O3 -I$(CSLIB)
|
||||
LINK = g++
|
||||
LINKFLAGS = -g -O -L$(CSLIB)
|
||||
|
||||
# targets
|
||||
|
||||
mc: $(OBJ)
|
||||
# this line if built the CSlib within lib/message with ZMQ support
|
||||
# note this is using the serial (no-mpi) version of the CSlib
|
||||
$(LINK) $(LINKFLAGS) $(OBJ) -lcsnompi -lzmq -o mc
|
||||
# this line if built the CSlib without ZMQ support
|
||||
# $(LINK) $(LINKFLAGS) $(OBJ) -lcsnompi -o mc
|
||||
|
||||
clean:
|
||||
@rm -f *.o mc
|
||||
|
||||
# rules
|
||||
|
||||
%.o:%.cpp
|
||||
$(CC) $(CCFLAGS) -c $<
|
||||
106
examples/COUPLE/lammps_mc/README
Normal file
106
examples/COUPLE/lammps_mc/README
Normal file
@ -0,0 +1,106 @@
|
||||
Sample Monte Carlo (MC) wrapper on LAMMPS via client/server coupling
|
||||
|
||||
See the MESSAGE package (doc/Section_messages.html#MESSAGE)
|
||||
and Section_howto.html#howto10 for more details on how
|
||||
client/server coupling works in LAMMPS.
|
||||
|
||||
In this dir, the mc.cpp/h files are a standalone "client" MC code. It
|
||||
should be run on a single processor, though it could become a parallel
|
||||
program at some point. LAMMPS is also run as a standalone executable
|
||||
as a "server" on as many processors as desired using its "server mc"
|
||||
command; see it's doc page for details.
|
||||
|
||||
Messages are exchanged between MC and LAMMPS via a client/server
|
||||
library (CSlib), which is included in the LAMMPS distribution in
|
||||
lib/message. As explained below you can choose to exchange data
|
||||
between the two programs either via files or sockets (ZMQ). If the MC
|
||||
program became parallel, data could also be exchanged via MPI.
|
||||
|
||||
The MC code makes simple MC moves, by displacing a single random atom
|
||||
by a small random amount. It uses LAMMPS to calculate the energy
|
||||
change, and to run dynamics between MC moves.
|
||||
|
||||
----------------
|
||||
|
||||
Build LAMMPS and the MC client code
|
||||
|
||||
First, build LAMMPS with its MESSAGE package installed:
|
||||
|
||||
cd lammps/lib/message
|
||||
python Install.py -m -z # build CSlib with MPI and ZMQ support
|
||||
cd lammps/src
|
||||
make yes-message
|
||||
make mpi
|
||||
|
||||
You can leave off the -z if you do not have ZMQ on your system.
|
||||
|
||||
Next build the MC client code:
|
||||
|
||||
First edit the Makefile in this dir. The CSLIB variable should be the
|
||||
path to where the LAMMPS lib/message dir is on your system. If you
|
||||
built the CSlib without ZMQ support you will also need to
|
||||
comment/uncomment two lines. Then you can just type "make" and you
|
||||
should get an "mc" executable.
|
||||
|
||||
----------------
|
||||
|
||||
To run in client/server mode:
|
||||
|
||||
Both the client (MC) and server (LAMMPS) must use the same messaging
|
||||
mode, namely file or zmq. This is an argument to the MC code; it can
|
||||
be selected by setting the "mode" variable when you run LAMMPS. The
|
||||
default mode = file.
|
||||
|
||||
Here we assume LAMMPS was built to run in parallel, and the MESSAGE
|
||||
package was installed with socket (ZMQ) support. This means either of
|
||||
the messaging modes can be used and LAMMPS can be run in serial or
|
||||
parallel. The MC code is always run in serial.
|
||||
|
||||
When you run, the server should print out thermodynamic info
|
||||
for every MD run it performs (between MC moves). The client
|
||||
will print nothing until the simulation ends, then it will
|
||||
print stats about the accepted MC moves.
|
||||
|
||||
The examples below are commands you should use in two different
|
||||
terminal windows. The order of the two commands (client or server
|
||||
launch) does not matter. You can run them both in the same window if
|
||||
you append a "&" character to the first one to run it in the
|
||||
background.
|
||||
|
||||
--------------
|
||||
|
||||
File mode of messaging:
|
||||
|
||||
% mpirun -np 1 mc in.mc file tmp.couple
|
||||
% mpirun -np 1 lmp_mpi -v mode file < in.mc.server
|
||||
|
||||
% mpirun -np 1 mc in.mc file tmp.couple
|
||||
% mpirun -np 4 lmp_mpi -v mode file < in.mc.server
|
||||
|
||||
ZMQ mode of messaging:
|
||||
|
||||
% mpirun -np 1 mc in.mc zmq localhost:5555
|
||||
% mpirun -np 1 lmp_mpi -v mode zmq < in.mc.server
|
||||
|
||||
% mpirun -np 1 mc in.mc zmq localhost:5555
|
||||
% mpirun -np 4 lmp_mpi -v mode zmq < in.mc.server
|
||||
|
||||
--------------
|
||||
|
||||
The input script for the MC program is in.mc. You can edit it to run
|
||||
longer simulations.
|
||||
|
||||
500 nsteps = total # of steps of MD
|
||||
100 ndynamics = # of MD steps between MC moves
|
||||
0.1 delta = displacement size of MC move
|
||||
1.0 temperature = used in MC Boltzman factor
|
||||
12345 seed = random number seed
|
||||
|
||||
--------------
|
||||
|
||||
The problem size that LAMMPS is computing the MC energy for and
|
||||
running dynamics on is set by the x,y,z variables in the LAMMPS
|
||||
in.mc.server script. The default size is 500 particles. You can
|
||||
adjust the size as follows:
|
||||
|
||||
lmp_mpi -v x 10 -v y 10 -v z 20 # 8000 particles
|
||||
7
examples/COUPLE/lammps_mc/in.mc
Normal file
7
examples/COUPLE/lammps_mc/in.mc
Normal file
@ -0,0 +1,7 @@
|
||||
# MC params
|
||||
|
||||
500 nsteps
|
||||
100 ndynamics
|
||||
0.1 delta
|
||||
1.0 temperature
|
||||
12345 seed
|
||||
36
examples/COUPLE/lammps_mc/in.mc.server
Normal file
36
examples/COUPLE/lammps_mc/in.mc.server
Normal file
@ -0,0 +1,36 @@
|
||||
# 3d Lennard-Jones Monte Carlo server script
|
||||
|
||||
variable mode index file
|
||||
|
||||
if "${mode} == file" then &
|
||||
"message server mc file tmp.couple" &
|
||||
elif "${mode} == zmq" &
|
||||
"message server mc zmq *:5555" &
|
||||
|
||||
variable x index 5
|
||||
variable y index 5
|
||||
variable z index 5
|
||||
|
||||
units lj
|
||||
atom_style atomic
|
||||
atom_modify map yes
|
||||
|
||||
lattice fcc 0.8442
|
||||
region box block 0 $x 0 $y 0 $z
|
||||
create_box 1 box
|
||||
create_atoms 1 box
|
||||
mass 1 1.0
|
||||
|
||||
pair_style lj/cut 2.5
|
||||
pair_coeff 1 1 1.0 1.0 2.5
|
||||
|
||||
neighbor 0.3 bin
|
||||
neigh_modify delay 0 every 20 check no
|
||||
|
||||
velocity all create 1.44 87287 loop geom
|
||||
|
||||
fix 1 all nve
|
||||
|
||||
thermo 50
|
||||
|
||||
server mc
|
||||
254
examples/COUPLE/lammps_mc/log.23Jul18.file.g++.1
Normal file
254
examples/COUPLE/lammps_mc/log.23Jul18.file.g++.1
Normal file
@ -0,0 +1,254 @@
|
||||
LAMMPS (16 Jul 2018)
|
||||
# 3d Lennard-Jones Monte Carlo server script
|
||||
|
||||
variable mode index file
|
||||
|
||||
if "${mode} == file" then "message server mc file tmp.couple" elif "${mode} == zmq" "message server mc zmq *:5555"
|
||||
message server mc file tmp.couple
|
||||
variable x index 5
|
||||
variable y index 5
|
||||
variable z index 5
|
||||
|
||||
units lj
|
||||
atom_style atomic
|
||||
atom_modify map yes
|
||||
|
||||
lattice fcc 0.8442
|
||||
Lattice spacing in x,y,z = 1.6796 1.6796 1.6796
|
||||
region box block 0 $x 0 $y 0 $z
|
||||
region box block 0 5 0 $y 0 $z
|
||||
region box block 0 5 0 5 0 $z
|
||||
region box block 0 5 0 5 0 5
|
||||
create_box 1 box
|
||||
Created orthogonal box = (0 0 0) to (8.39798 8.39798 8.39798)
|
||||
1 by 1 by 1 MPI processor grid
|
||||
create_atoms 1 box
|
||||
Created 500 atoms
|
||||
Time spent = 0.000633001 secs
|
||||
mass 1 1.0
|
||||
|
||||
pair_style lj/cut 2.5
|
||||
pair_coeff 1 1 1.0 1.0 2.5
|
||||
|
||||
neighbor 0.3 bin
|
||||
neigh_modify delay 0 every 20 check no
|
||||
|
||||
velocity all create 1.44 87287 loop geom
|
||||
|
||||
fix 1 all nve
|
||||
|
||||
thermo 50
|
||||
|
||||
server mc
|
||||
run 0
|
||||
Neighbor list info ...
|
||||
update every 20 steps, delay 0 steps, check no
|
||||
max neighbors/atom: 2000, page size: 100000
|
||||
master list distance cutoff = 2.8
|
||||
ghost atom cutoff = 2.8
|
||||
binsize = 1.4, bins = 6 6 6
|
||||
1 neighbor lists, perpetual/occasional/extra = 1 0 0
|
||||
(1) pair lj/cut, perpetual
|
||||
attributes: half, newton on
|
||||
pair build: half/bin/atomonly/newton
|
||||
stencil: half/bin/3d/newton
|
||||
bin: standard
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.658 | 2.658 | 2.658 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
0 1.44 -6.7733681 0 -4.6176881 -5.0221006
|
||||
Loop time of 1.90735e-06 on 1 procs for 0 steps with 500 atoms
|
||||
|
||||
52.4% CPU use with 1 MPI tasks x no OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Output | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Modify | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Other | | 1.907e-06 | | |100.00
|
||||
|
||||
Nlocal: 500 ave 500 max 500 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Nghost: 1956 ave 1956 max 1956 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Neighs: 19500 ave 19500 max 19500 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Total # of neighbors = 19500
|
||||
Ave neighs/atom = 39
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds not checked
|
||||
run 0
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.658 | 2.658 | 2.658 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
0 1.44 -6.7723127 0 -4.6166327 -5.015531
|
||||
Loop time of 2.14577e-06 on 1 procs for 0 steps with 500 atoms
|
||||
|
||||
46.6% CPU use with 1 MPI tasks x no OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Output | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Modify | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Other | | 2.146e-06 | | |100.00
|
||||
|
||||
Nlocal: 500 ave 500 max 500 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Nghost: 1956 ave 1956 max 1956 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Neighs: 19501 ave 19501 max 19501 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Total # of neighbors = 19501
|
||||
Ave neighs/atom = 39.002
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds not checked
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.658 | 2.658 | 2.658 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
0 1.44 -6.7723127 0 -4.6166327 -5.015531
|
||||
50 0.70239211 -5.6763152 0 -4.6248342 0.59544428
|
||||
100 0.7565013 -5.757431 0 -4.6249485 0.21982657
|
||||
run 0
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.658 | 2.658 | 2.658 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
100 0.7565013 -5.7565768 0 -4.6240944 0.22436405
|
||||
Loop time of 1.90735e-06 on 1 procs for 0 steps with 500 atoms
|
||||
|
||||
157.3% CPU use with 1 MPI tasks x no OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Output | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Modify | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Other | | 1.907e-06 | | |100.00
|
||||
|
||||
Nlocal: 500 ave 500 max 500 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Nghost: 1939 ave 1939 max 1939 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Neighs: 18757 ave 18757 max 18757 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Total # of neighbors = 18757
|
||||
Ave neighs/atom = 37.514
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds not checked
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.658 | 2.658 | 2.658 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
100 0.7565013 -5.757431 0 -4.6249485 0.21982657
|
||||
150 0.76110797 -5.7664315 0 -4.6270529 0.16005254
|
||||
200 0.73505651 -5.7266069 0 -4.6262273 0.34189744
|
||||
run 0
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.658 | 2.658 | 2.658 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
200 0.73505651 -5.7181381 0 -4.6177585 0.37629943
|
||||
Loop time of 9.53674e-07 on 1 procs for 0 steps with 500 atoms
|
||||
|
||||
209.7% CPU use with 1 MPI tasks x no OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Output | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Modify | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Other | | 9.537e-07 | | |100.00
|
||||
|
||||
Nlocal: 500 ave 500 max 500 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Nghost: 1899 ave 1899 max 1899 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Neighs: 18699 ave 18699 max 18699 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Total # of neighbors = 18699
|
||||
Ave neighs/atom = 37.398
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds not checked
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.658 | 2.658 | 2.658 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
200 0.73505651 -5.7266069 0 -4.6262273 0.34189744
|
||||
250 0.73052476 -5.7206316 0 -4.627036 0.39287516
|
||||
300 0.76300831 -5.7675007 0 -4.6252773 0.16312925
|
||||
run 0
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.658 | 2.658 | 2.658 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
300 0.76300831 -5.768304 0 -4.6260806 0.15954325
|
||||
Loop time of 9.53674e-07 on 1 procs for 0 steps with 500 atoms
|
||||
|
||||
314.6% CPU use with 1 MPI tasks x no OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Output | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Modify | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Other | | 9.537e-07 | | |100.00
|
||||
|
||||
Nlocal: 500 ave 500 max 500 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Nghost: 1903 ave 1903 max 1903 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Neighs: 18715 ave 18715 max 18715 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Total # of neighbors = 18715
|
||||
Ave neighs/atom = 37.43
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds not checked
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.658 | 2.658 | 2.658 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
300 0.76300831 -5.768304 0 -4.6260806 0.15954325
|
||||
350 0.72993309 -5.7193261 0 -4.6266162 0.3358374
|
||||
400 0.72469448 -5.713463 0 -4.6285954 0.44859547
|
||||
run 0
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.658 | 2.658 | 2.658 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
400 0.72469448 -5.7077332 0 -4.6228655 0.47669832
|
||||
Loop time of 9.53674e-07 on 1 procs for 0 steps with 500 atoms
|
||||
|
||||
314.6% CPU use with 1 MPI tasks x no OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Output | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Modify | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Other | | 9.537e-07 | | |100.00
|
||||
|
||||
Nlocal: 500 ave 500 max 500 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Nghost: 1899 ave 1899 max 1899 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Neighs: 18683 ave 18683 max 18683 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Total # of neighbors = 18683
|
||||
Ave neighs/atom = 37.366
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds not checked
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.658 | 2.658 | 2.658 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
400 0.72469448 -5.713463 0 -4.6285954 0.44859547
|
||||
450 0.75305735 -5.7518283 0 -4.6245015 0.34658587
|
||||
500 0.73092571 -5.7206337 0 -4.6264379 0.43715809
|
||||
Total wall time: 0:00:02
|
||||
254
examples/COUPLE/lammps_mc/log.23Jul18.file.g++.4
Normal file
254
examples/COUPLE/lammps_mc/log.23Jul18.file.g++.4
Normal file
@ -0,0 +1,254 @@
|
||||
LAMMPS (16 Jul 2018)
|
||||
# 3d Lennard-Jones Monte Carlo server script
|
||||
|
||||
variable mode index file
|
||||
|
||||
if "${mode} == file" then "message server mc file tmp.couple" elif "${mode} == zmq" "message server mc zmq *:5555"
|
||||
message server mc file tmp.couple
|
||||
variable x index 5
|
||||
variable y index 5
|
||||
variable z index 5
|
||||
|
||||
units lj
|
||||
atom_style atomic
|
||||
atom_modify map yes
|
||||
|
||||
lattice fcc 0.8442
|
||||
Lattice spacing in x,y,z = 1.6796 1.6796 1.6796
|
||||
region box block 0 $x 0 $y 0 $z
|
||||
region box block 0 5 0 $y 0 $z
|
||||
region box block 0 5 0 5 0 $z
|
||||
region box block 0 5 0 5 0 5
|
||||
create_box 1 box
|
||||
Created orthogonal box = (0 0 0) to (8.39798 8.39798 8.39798)
|
||||
1 by 2 by 2 MPI processor grid
|
||||
create_atoms 1 box
|
||||
Created 500 atoms
|
||||
Time spent = 0.000604868 secs
|
||||
mass 1 1.0
|
||||
|
||||
pair_style lj/cut 2.5
|
||||
pair_coeff 1 1 1.0 1.0 2.5
|
||||
|
||||
neighbor 0.3 bin
|
||||
neigh_modify delay 0 every 20 check no
|
||||
|
||||
velocity all create 1.44 87287 loop geom
|
||||
|
||||
fix 1 all nve
|
||||
|
||||
thermo 50
|
||||
|
||||
server mc
|
||||
run 0
|
||||
Neighbor list info ...
|
||||
update every 20 steps, delay 0 steps, check no
|
||||
max neighbors/atom: 2000, page size: 100000
|
||||
master list distance cutoff = 2.8
|
||||
ghost atom cutoff = 2.8
|
||||
binsize = 1.4, bins = 6 6 6
|
||||
1 neighbor lists, perpetual/occasional/extra = 1 0 0
|
||||
(1) pair lj/cut, perpetual
|
||||
attributes: half, newton on
|
||||
pair build: half/bin/atomonly/newton
|
||||
stencil: half/bin/3d/newton
|
||||
bin: standard
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.619 | 2.619 | 2.619 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
0 1.44 -6.7733681 0 -4.6176881 -5.0221006
|
||||
Loop time of 3.09944e-06 on 4 procs for 0 steps with 500 atoms
|
||||
|
||||
72.6% CPU use with 4 MPI tasks x no OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Output | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Modify | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Other | | 3.099e-06 | | |100.00
|
||||
|
||||
Nlocal: 125 ave 125 max 125 min
|
||||
Histogram: 4 0 0 0 0 0 0 0 0 0
|
||||
Nghost: 1099 ave 1099 max 1099 min
|
||||
Histogram: 4 0 0 0 0 0 0 0 0 0
|
||||
Neighs: 4875 ave 4875 max 4875 min
|
||||
Histogram: 4 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Total # of neighbors = 19500
|
||||
Ave neighs/atom = 39
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds not checked
|
||||
run 0
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.619 | 2.619 | 2.619 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
0 1.44 -6.7723127 0 -4.6166327 -5.015531
|
||||
Loop time of 3.33786e-06 on 4 procs for 0 steps with 500 atoms
|
||||
|
||||
119.8% CPU use with 4 MPI tasks x no OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Output | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Modify | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Other | | 3.338e-06 | | |100.00
|
||||
|
||||
Nlocal: 125 ave 125 max 125 min
|
||||
Histogram: 4 0 0 0 0 0 0 0 0 0
|
||||
Nghost: 1099 ave 1099 max 1099 min
|
||||
Histogram: 4 0 0 0 0 0 0 0 0 0
|
||||
Neighs: 4875.25 ave 4885 max 4866 min
|
||||
Histogram: 1 0 0 0 2 0 0 0 0 1
|
||||
|
||||
Total # of neighbors = 19501
|
||||
Ave neighs/atom = 39.002
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds not checked
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.619 | 2.619 | 2.619 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
0 1.44 -6.7723127 0 -4.6166327 -5.015531
|
||||
50 0.70210225 -5.6759068 0 -4.6248598 0.59609192
|
||||
100 0.75891559 -5.7611234 0 -4.6250267 0.20841608
|
||||
run 0
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.619 | 2.619 | 2.619 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
100 0.75891559 -5.7609392 0 -4.6248426 0.20981291
|
||||
Loop time of 3.51667e-06 on 4 procs for 0 steps with 500 atoms
|
||||
|
||||
113.7% CPU use with 4 MPI tasks x no OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Output | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Modify | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Other | | 3.517e-06 | | |100.00
|
||||
|
||||
Nlocal: 125 ave 126 max 124 min
|
||||
Histogram: 2 0 0 0 0 0 0 0 0 2
|
||||
Nghost: 1085.25 ave 1089 max 1079 min
|
||||
Histogram: 1 0 0 0 0 1 0 0 0 2
|
||||
Neighs: 4690.25 ave 4996 max 4401 min
|
||||
Histogram: 1 0 0 1 0 1 0 0 0 1
|
||||
|
||||
Total # of neighbors = 18761
|
||||
Ave neighs/atom = 37.522
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds not checked
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.619 | 2.619 | 2.619 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
100 0.75891559 -5.7609392 0 -4.6248426 0.20981291
|
||||
150 0.75437991 -5.7558622 0 -4.6265555 0.20681722
|
||||
200 0.73111257 -5.7193748 0 -4.6248993 0.35230715
|
||||
run 0
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.619 | 2.619 | 2.619 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
200 0.73111257 -5.7143906 0 -4.6199151 0.37126023
|
||||
Loop time of 2.92063e-06 on 4 procs for 0 steps with 500 atoms
|
||||
|
||||
119.8% CPU use with 4 MPI tasks x no OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Output | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Modify | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Other | | 2.921e-06 | | |100.00
|
||||
|
||||
Nlocal: 125 ave 126 max 123 min
|
||||
Histogram: 1 0 0 0 0 0 1 0 0 2
|
||||
Nghost: 1068.5 ave 1076 max 1063 min
|
||||
Histogram: 2 0 0 0 0 0 1 0 0 1
|
||||
Neighs: 4674.75 ave 4938 max 4419 min
|
||||
Histogram: 1 0 0 0 1 1 0 0 0 1
|
||||
|
||||
Total # of neighbors = 18699
|
||||
Ave neighs/atom = 37.398
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds not checked
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.619 | 2.619 | 2.619 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
200 0.73111257 -5.7193748 0 -4.6248993 0.35230715
|
||||
250 0.73873144 -5.7312505 0 -4.6253696 0.33061033
|
||||
300 0.76392796 -5.7719207 0 -4.6283206 0.18197874
|
||||
run 0
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.619 | 2.619 | 2.619 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
300 0.76392796 -5.7725589 0 -4.6289588 0.17994628
|
||||
Loop time of 3.39746e-06 on 4 procs for 0 steps with 500 atoms
|
||||
|
||||
117.7% CPU use with 4 MPI tasks x no OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Output | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Modify | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Other | | 3.397e-06 | | |100.00
|
||||
|
||||
Nlocal: 125 ave 128 max 121 min
|
||||
Histogram: 1 0 0 0 0 1 0 1 0 1
|
||||
Nghost: 1069 ave 1080 max 1055 min
|
||||
Histogram: 1 0 0 0 0 0 2 0 0 1
|
||||
Neighs: 4672 ave 4803 max 4600 min
|
||||
Histogram: 2 0 0 1 0 0 0 0 0 1
|
||||
|
||||
Total # of neighbors = 18688
|
||||
Ave neighs/atom = 37.376
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds not checked
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.619 | 2.619 | 2.619 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
300 0.76392796 -5.7725589 0 -4.6289588 0.17994628
|
||||
350 0.71953041 -5.7041632 0 -4.6270261 0.44866153
|
||||
400 0.7319047 -5.7216051 0 -4.6259438 0.46321355
|
||||
run 0
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.619 | 2.619 | 2.619 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
400 0.7319047 -5.7158168 0 -4.6201554 0.49192039
|
||||
Loop time of 3.39746e-06 on 4 procs for 0 steps with 500 atoms
|
||||
|
||||
117.7% CPU use with 4 MPI tasks x no OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Output | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Modify | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Other | | 3.397e-06 | | |100.00
|
||||
|
||||
Nlocal: 125 ave 132 max 118 min
|
||||
Histogram: 1 0 0 0 0 2 0 0 0 1
|
||||
Nghost: 1057.5 ave 1068 max 1049 min
|
||||
Histogram: 1 0 0 1 1 0 0 0 0 1
|
||||
Neighs: 4685.75 ave 5045 max 4229 min
|
||||
Histogram: 1 0 0 1 0 0 0 0 0 2
|
||||
|
||||
Total # of neighbors = 18743
|
||||
Ave neighs/atom = 37.486
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds not checked
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.619 | 2.619 | 2.619 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
400 0.7319047 -5.7216051 0 -4.6259438 0.46321355
|
||||
450 0.74503154 -5.7405318 0 -4.6252196 0.33211879
|
||||
500 0.70570501 -5.6824439 0 -4.6260035 0.62020788
|
||||
Total wall time: 0:00:02
|
||||
254
examples/COUPLE/lammps_mc/log.23Jul18.zmq.g++.1
Normal file
254
examples/COUPLE/lammps_mc/log.23Jul18.zmq.g++.1
Normal file
@ -0,0 +1,254 @@
|
||||
LAMMPS (16 Jul 2018)
|
||||
# 3d Lennard-Jones Monte Carlo server script
|
||||
|
||||
variable mode index file
|
||||
|
||||
if "${mode} == file" then "message server mc file tmp.couple" elif "${mode} == zmq" "message server mc zmq *:5555"
|
||||
message server mc zmq *:5555
|
||||
variable x index 5
|
||||
variable y index 5
|
||||
variable z index 5
|
||||
|
||||
units lj
|
||||
atom_style atomic
|
||||
atom_modify map yes
|
||||
|
||||
lattice fcc 0.8442
|
||||
Lattice spacing in x,y,z = 1.6796 1.6796 1.6796
|
||||
region box block 0 $x 0 $y 0 $z
|
||||
region box block 0 5 0 $y 0 $z
|
||||
region box block 0 5 0 5 0 $z
|
||||
region box block 0 5 0 5 0 5
|
||||
create_box 1 box
|
||||
Created orthogonal box = (0 0 0) to (8.39798 8.39798 8.39798)
|
||||
1 by 1 by 1 MPI processor grid
|
||||
create_atoms 1 box
|
||||
Created 500 atoms
|
||||
Time spent = 0.000612974 secs
|
||||
mass 1 1.0
|
||||
|
||||
pair_style lj/cut 2.5
|
||||
pair_coeff 1 1 1.0 1.0 2.5
|
||||
|
||||
neighbor 0.3 bin
|
||||
neigh_modify delay 0 every 20 check no
|
||||
|
||||
velocity all create 1.44 87287 loop geom
|
||||
|
||||
fix 1 all nve
|
||||
|
||||
thermo 50
|
||||
|
||||
server mc
|
||||
run 0
|
||||
Neighbor list info ...
|
||||
update every 20 steps, delay 0 steps, check no
|
||||
max neighbors/atom: 2000, page size: 100000
|
||||
master list distance cutoff = 2.8
|
||||
ghost atom cutoff = 2.8
|
||||
binsize = 1.4, bins = 6 6 6
|
||||
1 neighbor lists, perpetual/occasional/extra = 1 0 0
|
||||
(1) pair lj/cut, perpetual
|
||||
attributes: half, newton on
|
||||
pair build: half/bin/atomonly/newton
|
||||
stencil: half/bin/3d/newton
|
||||
bin: standard
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.658 | 2.658 | 2.658 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
0 1.44 -6.7733681 0 -4.6176881 -5.0221006
|
||||
Loop time of 2.14577e-06 on 1 procs for 0 steps with 500 atoms
|
||||
|
||||
46.6% CPU use with 1 MPI tasks x no OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Output | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Modify | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Other | | 2.146e-06 | | |100.00
|
||||
|
||||
Nlocal: 500 ave 500 max 500 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Nghost: 1956 ave 1956 max 1956 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Neighs: 19500 ave 19500 max 19500 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Total # of neighbors = 19500
|
||||
Ave neighs/atom = 39
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds not checked
|
||||
run 0
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.658 | 2.658 | 2.658 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
0 1.44 -6.7723127 0 -4.6166327 -5.015531
|
||||
Loop time of 1.90735e-06 on 1 procs for 0 steps with 500 atoms
|
||||
|
||||
157.3% CPU use with 1 MPI tasks x no OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Output | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Modify | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Other | | 1.907e-06 | | |100.00
|
||||
|
||||
Nlocal: 500 ave 500 max 500 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Nghost: 1956 ave 1956 max 1956 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Neighs: 19501 ave 19501 max 19501 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Total # of neighbors = 19501
|
||||
Ave neighs/atom = 39.002
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds not checked
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.658 | 2.658 | 2.658 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
0 1.44 -6.7723127 0 -4.6166327 -5.015531
|
||||
50 0.70239211 -5.6763152 0 -4.6248342 0.59544428
|
||||
100 0.7565013 -5.757431 0 -4.6249485 0.21982657
|
||||
run 0
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.658 | 2.658 | 2.658 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
100 0.7565013 -5.7565768 0 -4.6240944 0.22436405
|
||||
Loop time of 9.53674e-07 on 1 procs for 0 steps with 500 atoms
|
||||
|
||||
209.7% CPU use with 1 MPI tasks x no OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Output | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Modify | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Other | | 9.537e-07 | | |100.00
|
||||
|
||||
Nlocal: 500 ave 500 max 500 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Nghost: 1939 ave 1939 max 1939 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Neighs: 18757 ave 18757 max 18757 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Total # of neighbors = 18757
|
||||
Ave neighs/atom = 37.514
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds not checked
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.658 | 2.658 | 2.658 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
100 0.7565013 -5.757431 0 -4.6249485 0.21982657
|
||||
150 0.76110797 -5.7664315 0 -4.6270529 0.16005254
|
||||
200 0.73505651 -5.7266069 0 -4.6262273 0.34189744
|
||||
run 0
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.658 | 2.658 | 2.658 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
200 0.73505651 -5.7181381 0 -4.6177585 0.37629943
|
||||
Loop time of 9.53674e-07 on 1 procs for 0 steps with 500 atoms
|
||||
|
||||
209.7% CPU use with 1 MPI tasks x no OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Output | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Modify | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Other | | 9.537e-07 | | |100.00
|
||||
|
||||
Nlocal: 500 ave 500 max 500 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Nghost: 1899 ave 1899 max 1899 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Neighs: 18699 ave 18699 max 18699 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Total # of neighbors = 18699
|
||||
Ave neighs/atom = 37.398
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds not checked
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.658 | 2.658 | 2.658 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
200 0.73505651 -5.7266069 0 -4.6262273 0.34189744
|
||||
250 0.73052476 -5.7206316 0 -4.627036 0.39287516
|
||||
300 0.76300831 -5.7675007 0 -4.6252773 0.16312925
|
||||
run 0
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.658 | 2.658 | 2.658 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
300 0.76300831 -5.768304 0 -4.6260806 0.15954325
|
||||
Loop time of 0 on 1 procs for 0 steps with 500 atoms
|
||||
|
||||
0.0% CPU use with 1 MPI tasks x no OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Output | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Modify | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Other | | 0 | | | 0.00
|
||||
|
||||
Nlocal: 500 ave 500 max 500 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Nghost: 1903 ave 1903 max 1903 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Neighs: 18715 ave 18715 max 18715 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Total # of neighbors = 18715
|
||||
Ave neighs/atom = 37.43
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds not checked
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.658 | 2.658 | 2.658 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
300 0.76300831 -5.768304 0 -4.6260806 0.15954325
|
||||
350 0.72993309 -5.7193261 0 -4.6266162 0.3358374
|
||||
400 0.72469448 -5.713463 0 -4.6285954 0.44859547
|
||||
run 0
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.658 | 2.658 | 2.658 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
400 0.72469448 -5.7077332 0 -4.6228655 0.47669832
|
||||
Loop time of 0 on 1 procs for 0 steps with 500 atoms
|
||||
|
||||
0.0% CPU use with 1 MPI tasks x no OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Output | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Modify | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Other | | 0 | | | 0.00
|
||||
|
||||
Nlocal: 500 ave 500 max 500 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Nghost: 1899 ave 1899 max 1899 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Neighs: 18683 ave 18683 max 18683 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Total # of neighbors = 18683
|
||||
Ave neighs/atom = 37.366
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds not checked
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.658 | 2.658 | 2.658 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
400 0.72469448 -5.713463 0 -4.6285954 0.44859547
|
||||
450 0.75305735 -5.7518283 0 -4.6245015 0.34658587
|
||||
500 0.73092571 -5.7206337 0 -4.6264379 0.43715809
|
||||
Total wall time: 0:00:00
|
||||
254
examples/COUPLE/lammps_mc/log.23Jul18.zmq.g++.4
Normal file
254
examples/COUPLE/lammps_mc/log.23Jul18.zmq.g++.4
Normal file
@ -0,0 +1,254 @@
|
||||
LAMMPS (16 Jul 2018)
|
||||
# 3d Lennard-Jones Monte Carlo server script
|
||||
|
||||
variable mode index file
|
||||
|
||||
if "${mode} == file" then "message server mc file tmp.couple" elif "${mode} == zmq" "message server mc zmq *:5555"
|
||||
message server mc zmq *:5555
|
||||
variable x index 5
|
||||
variable y index 5
|
||||
variable z index 5
|
||||
|
||||
units lj
|
||||
atom_style atomic
|
||||
atom_modify map yes
|
||||
|
||||
lattice fcc 0.8442
|
||||
Lattice spacing in x,y,z = 1.6796 1.6796 1.6796
|
||||
region box block 0 $x 0 $y 0 $z
|
||||
region box block 0 5 0 $y 0 $z
|
||||
region box block 0 5 0 5 0 $z
|
||||
region box block 0 5 0 5 0 5
|
||||
create_box 1 box
|
||||
Created orthogonal box = (0 0 0) to (8.39798 8.39798 8.39798)
|
||||
1 by 2 by 2 MPI processor grid
|
||||
create_atoms 1 box
|
||||
Created 500 atoms
|
||||
Time spent = 0.000566006 secs
|
||||
mass 1 1.0
|
||||
|
||||
pair_style lj/cut 2.5
|
||||
pair_coeff 1 1 1.0 1.0 2.5
|
||||
|
||||
neighbor 0.3 bin
|
||||
neigh_modify delay 0 every 20 check no
|
||||
|
||||
velocity all create 1.44 87287 loop geom
|
||||
|
||||
fix 1 all nve
|
||||
|
||||
thermo 50
|
||||
|
||||
server mc
|
||||
run 0
|
||||
Neighbor list info ...
|
||||
update every 20 steps, delay 0 steps, check no
|
||||
max neighbors/atom: 2000, page size: 100000
|
||||
master list distance cutoff = 2.8
|
||||
ghost atom cutoff = 2.8
|
||||
binsize = 1.4, bins = 6 6 6
|
||||
1 neighbor lists, perpetual/occasional/extra = 1 0 0
|
||||
(1) pair lj/cut, perpetual
|
||||
attributes: half, newton on
|
||||
pair build: half/bin/atomonly/newton
|
||||
stencil: half/bin/3d/newton
|
||||
bin: standard
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.619 | 2.619 | 2.619 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
0 1.44 -6.7733681 0 -4.6176881 -5.0221006
|
||||
Loop time of 4.29153e-06 on 4 procs for 0 steps with 500 atoms
|
||||
|
||||
99.0% CPU use with 4 MPI tasks x no OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Output | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Modify | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Other | | 4.292e-06 | | |100.00
|
||||
|
||||
Nlocal: 125 ave 125 max 125 min
|
||||
Histogram: 4 0 0 0 0 0 0 0 0 0
|
||||
Nghost: 1099 ave 1099 max 1099 min
|
||||
Histogram: 4 0 0 0 0 0 0 0 0 0
|
||||
Neighs: 4875 ave 4875 max 4875 min
|
||||
Histogram: 4 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Total # of neighbors = 19500
|
||||
Ave neighs/atom = 39
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds not checked
|
||||
run 0
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.619 | 2.619 | 2.619 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
0 1.44 -6.7723127 0 -4.6166327 -5.015531
|
||||
Loop time of 3.57628e-06 on 4 procs for 0 steps with 500 atoms
|
||||
|
||||
97.9% CPU use with 4 MPI tasks x no OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Output | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Modify | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Other | | 3.576e-06 | | |100.00
|
||||
|
||||
Nlocal: 125 ave 125 max 125 min
|
||||
Histogram: 4 0 0 0 0 0 0 0 0 0
|
||||
Nghost: 1099 ave 1099 max 1099 min
|
||||
Histogram: 4 0 0 0 0 0 0 0 0 0
|
||||
Neighs: 4875.25 ave 4885 max 4866 min
|
||||
Histogram: 1 0 0 0 2 0 0 0 0 1
|
||||
|
||||
Total # of neighbors = 19501
|
||||
Ave neighs/atom = 39.002
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds not checked
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.619 | 2.619 | 2.619 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
0 1.44 -6.7723127 0 -4.6166327 -5.015531
|
||||
50 0.70210225 -5.6759068 0 -4.6248598 0.59609192
|
||||
100 0.75891559 -5.7611234 0 -4.6250267 0.20841608
|
||||
run 0
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.619 | 2.619 | 2.619 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
100 0.75891559 -5.7609392 0 -4.6248426 0.20981291
|
||||
Loop time of 3.09944e-06 on 4 procs for 0 steps with 500 atoms
|
||||
|
||||
121.0% CPU use with 4 MPI tasks x no OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Output | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Modify | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Other | | 3.099e-06 | | |100.00
|
||||
|
||||
Nlocal: 125 ave 126 max 124 min
|
||||
Histogram: 2 0 0 0 0 0 0 0 0 2
|
||||
Nghost: 1085.25 ave 1089 max 1079 min
|
||||
Histogram: 1 0 0 0 0 1 0 0 0 2
|
||||
Neighs: 4690.25 ave 4996 max 4401 min
|
||||
Histogram: 1 0 0 1 0 1 0 0 0 1
|
||||
|
||||
Total # of neighbors = 18761
|
||||
Ave neighs/atom = 37.522
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds not checked
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.619 | 2.619 | 2.619 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
100 0.75891559 -5.7609392 0 -4.6248426 0.20981291
|
||||
150 0.75437991 -5.7558622 0 -4.6265555 0.20681722
|
||||
200 0.73111257 -5.7193748 0 -4.6248993 0.35230715
|
||||
run 0
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.619 | 2.619 | 2.619 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
200 0.73111257 -5.7143906 0 -4.6199151 0.37126023
|
||||
Loop time of 2.14577e-06 on 4 procs for 0 steps with 500 atoms
|
||||
|
||||
139.8% CPU use with 4 MPI tasks x no OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Output | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Modify | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Other | | 2.146e-06 | | |100.00
|
||||
|
||||
Nlocal: 125 ave 126 max 123 min
|
||||
Histogram: 1 0 0 0 0 0 1 0 0 2
|
||||
Nghost: 1068.5 ave 1076 max 1063 min
|
||||
Histogram: 2 0 0 0 0 0 1 0 0 1
|
||||
Neighs: 4674.75 ave 4938 max 4419 min
|
||||
Histogram: 1 0 0 0 1 1 0 0 0 1
|
||||
|
||||
Total # of neighbors = 18699
|
||||
Ave neighs/atom = 37.398
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds not checked
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.619 | 2.619 | 2.619 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
200 0.73111257 -5.7193748 0 -4.6248993 0.35230715
|
||||
250 0.73873144 -5.7312505 0 -4.6253696 0.33061033
|
||||
300 0.76392796 -5.7719207 0 -4.6283206 0.18197874
|
||||
run 0
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.619 | 2.619 | 2.619 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
300 0.76392796 -5.7725589 0 -4.6289588 0.17994628
|
||||
Loop time of 1.90735e-06 on 4 procs for 0 steps with 500 atoms
|
||||
|
||||
157.3% CPU use with 4 MPI tasks x no OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Output | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Modify | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Other | | 1.907e-06 | | |100.00
|
||||
|
||||
Nlocal: 125 ave 128 max 121 min
|
||||
Histogram: 1 0 0 0 0 1 0 1 0 1
|
||||
Nghost: 1069 ave 1080 max 1055 min
|
||||
Histogram: 1 0 0 0 0 0 2 0 0 1
|
||||
Neighs: 4672 ave 4803 max 4600 min
|
||||
Histogram: 2 0 0 1 0 0 0 0 0 1
|
||||
|
||||
Total # of neighbors = 18688
|
||||
Ave neighs/atom = 37.376
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds not checked
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.619 | 2.619 | 2.619 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
300 0.76392796 -5.7725589 0 -4.6289588 0.17994628
|
||||
350 0.71953041 -5.7041632 0 -4.6270261 0.44866153
|
||||
400 0.7319047 -5.7216051 0 -4.6259438 0.46321355
|
||||
run 0
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.619 | 2.619 | 2.619 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
400 0.7319047 -5.7158168 0 -4.6201554 0.49192039
|
||||
Loop time of 2.14577e-06 on 4 procs for 0 steps with 500 atoms
|
||||
|
||||
151.5% CPU use with 4 MPI tasks x no OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Output | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Modify | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Other | | 2.146e-06 | | |100.00
|
||||
|
||||
Nlocal: 125 ave 132 max 118 min
|
||||
Histogram: 1 0 0 0 0 2 0 0 0 1
|
||||
Nghost: 1057.5 ave 1068 max 1049 min
|
||||
Histogram: 1 0 0 1 1 0 0 0 0 1
|
||||
Neighs: 4685.75 ave 5045 max 4229 min
|
||||
Histogram: 1 0 0 1 0 0 0 0 0 2
|
||||
|
||||
Total # of neighbors = 18743
|
||||
Ave neighs/atom = 37.486
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds not checked
|
||||
Per MPI rank memory allocation (min/avg/max) = 2.619 | 2.619 | 2.619 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
400 0.7319047 -5.7216051 0 -4.6259438 0.46321355
|
||||
450 0.74503154 -5.7405318 0 -4.6252196 0.33211879
|
||||
500 0.70570501 -5.6824439 0 -4.6260035 0.62020788
|
||||
Total wall time: 0:00:00
|
||||
261
examples/COUPLE/lammps_mc/mc.cpp
Normal file
261
examples/COUPLE/lammps_mc/mc.cpp
Normal file
@ -0,0 +1,261 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
// MC code used with LAMMPS in client/server mode
|
||||
// MC is the client, LAMMPS is the server
|
||||
|
||||
// Syntax: mc infile mode modearg
|
||||
// mode = file, zmq
|
||||
// modearg = filename for file, localhost:5555 for zmq
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "cslib.h"
|
||||
using namespace CSLIB_NS;
|
||||
|
||||
#include "mc.h"
|
||||
#include "random_park.h"
|
||||
|
||||
void error(const char *);
|
||||
CSlib *cs_create(char *, char *);
|
||||
|
||||
#define MAXLINE 256
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
// main program
|
||||
|
||||
int main(int narg, char **arg)
|
||||
{
|
||||
if (narg != 4) {
|
||||
error("Syntax: mc infile mode modearg");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// initialize CSlib
|
||||
|
||||
CSlib *cs = cs_create(arg[2],arg[3]);
|
||||
|
||||
// create MC class and perform run
|
||||
|
||||
MC *mc = new MC(arg[1],cs);
|
||||
mc->run();
|
||||
|
||||
// final MC stats
|
||||
|
||||
int naccept = mc->naccept;
|
||||
int nattempt = mc->nattempt;
|
||||
|
||||
printf("------ MC stats ------\n");
|
||||
printf("MC attempts = %d\n",nattempt);
|
||||
printf("MC accepts = %d\n",naccept);
|
||||
printf("Acceptance ratio = %g\n",1.0*naccept/nattempt);
|
||||
|
||||
// clean up
|
||||
|
||||
delete cs;
|
||||
delete mc;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void error(const char *str)
|
||||
{
|
||||
printf("ERROR: %s\n",str);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
CSlib *cs_create(char *mode, char *arg)
|
||||
{
|
||||
CSlib *cs = new CSlib(0,mode,arg,NULL);
|
||||
|
||||
// initial handshake to agree on protocol
|
||||
|
||||
cs->send(0,1);
|
||||
cs->pack_string(1,(char *) "mc");
|
||||
|
||||
int msgID,nfield;
|
||||
int *fieldID,*fieldtype,*fieldlen;
|
||||
msgID = cs->recv(nfield,fieldID,fieldtype,fieldlen);
|
||||
|
||||
return cs;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// MC class
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
MC::MC(char *mcfile, CSlib *cs_caller)
|
||||
{
|
||||
cs = cs_caller;
|
||||
|
||||
// setup MC params
|
||||
|
||||
options(mcfile);
|
||||
|
||||
// random # generator
|
||||
|
||||
random = new RanPark(seed);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
MC::~MC()
|
||||
{
|
||||
free(x);
|
||||
delete random;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void MC::run()
|
||||
{
|
||||
int iatom,accept,msgID,nfield;
|
||||
double pe_initial,pe_final,edelta;
|
||||
double dx,dy,dz;
|
||||
double xold[3],xnew[3];
|
||||
int *fieldID,*fieldtype,*fieldlen;
|
||||
|
||||
enum{NATOMS=1,EINIT,DISPLACE,ACCEPT,RUN};
|
||||
|
||||
// one-time request for atom count from MD
|
||||
// allocate 1d coord buffer
|
||||
|
||||
cs->send(NATOMS,0);
|
||||
|
||||
msgID = cs->recv(nfield,fieldID,fieldtype,fieldlen);
|
||||
natoms = cs->unpack_int(1);
|
||||
|
||||
x = (double *) malloc(3*natoms*sizeof(double));
|
||||
|
||||
// loop over MC moves
|
||||
|
||||
naccept = nattempt = 0;
|
||||
|
||||
for (int iloop = 0; iloop < nloop; iloop++) {
|
||||
|
||||
// request current energy from MD
|
||||
// recv energy, coords from MD
|
||||
|
||||
cs->send(EINIT,0);
|
||||
|
||||
msgID = cs->recv(nfield,fieldID,fieldtype,fieldlen);
|
||||
pe_initial = cs->unpack_double(1);
|
||||
double *x = (double *) cs->unpack(2);
|
||||
|
||||
// perform simple MC event
|
||||
// displace a single atom by random amount
|
||||
|
||||
iatom = (int) natoms*random->uniform();
|
||||
xold[0] = x[3*iatom+0];
|
||||
xold[1] = x[3*iatom+1];
|
||||
xold[2] = x[3*iatom+2];
|
||||
|
||||
dx = 2.0*delta*random->uniform() - delta;
|
||||
dy = 2.0*delta*random->uniform() - delta;
|
||||
dz = 2.0*delta*random->uniform() - delta;
|
||||
|
||||
xnew[0] = xold[0] + dx;
|
||||
xnew[1] = xold[1] + dx;
|
||||
xnew[2] = xold[2] + dx;
|
||||
|
||||
// send atom ID and its new coords to MD
|
||||
// recv new energy
|
||||
|
||||
cs->send(DISPLACE,2);
|
||||
cs->pack_int(1,iatom+1);
|
||||
cs->pack(2,4,3,xnew);
|
||||
|
||||
msgID = cs->recv(nfield,fieldID,fieldtype,fieldlen);
|
||||
pe_final = cs->unpack_double(1);
|
||||
|
||||
// decide whether to accept/reject MC event
|
||||
|
||||
if (pe_final <= pe_initial) accept = 1;
|
||||
else if (temperature == 0.0) accept = 0;
|
||||
else if (random->uniform() >
|
||||
exp(natoms*(pe_initial-pe_final)/temperature)) accept = 0;
|
||||
else accept = 1;
|
||||
|
||||
nattempt++;
|
||||
if (accept) naccept++;
|
||||
|
||||
// send accept (1) or reject (0) flag to MD
|
||||
|
||||
cs->send(ACCEPT,1);
|
||||
cs->pack_int(1,accept);
|
||||
|
||||
msgID = cs->recv(nfield,fieldID,fieldtype,fieldlen);
|
||||
|
||||
// send dynamics timesteps
|
||||
|
||||
cs->send(RUN,1);
|
||||
cs->pack_int(1,ndynamics);
|
||||
|
||||
msgID = cs->recv(nfield,fieldID,fieldtype,fieldlen);
|
||||
}
|
||||
|
||||
// send exit message to MD
|
||||
|
||||
cs->send(-1,0);
|
||||
msgID = cs->recv(nfield,fieldID,fieldtype,fieldlen);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void MC::options(char *filename)
|
||||
{
|
||||
// default params
|
||||
|
||||
nsteps = 0;
|
||||
ndynamics = 100;
|
||||
delta = 0.1;
|
||||
temperature = 1.0;
|
||||
seed = 12345;
|
||||
|
||||
// read and parse file
|
||||
|
||||
FILE *fp = fopen(filename,"r");
|
||||
if (fp == NULL) error("Could not open MC file");
|
||||
|
||||
char line[MAXLINE];
|
||||
char *keyword,*value;
|
||||
char *eof = fgets(line,MAXLINE,fp);
|
||||
|
||||
while (eof) {
|
||||
if (line[0] == '#') { // comment line
|
||||
eof = fgets(line,MAXLINE,fp);
|
||||
continue;
|
||||
}
|
||||
|
||||
value = strtok(line," \t\n\r\f");
|
||||
if (value == NULL) { // blank line
|
||||
eof = fgets(line,MAXLINE,fp);
|
||||
continue;
|
||||
}
|
||||
|
||||
keyword = strtok(NULL," \t\n\r\f");
|
||||
if (keyword == NULL) error("Missing keyword in MC file");
|
||||
|
||||
if (strcmp(keyword,"nsteps") == 0) nsteps = atoi(value);
|
||||
else if (strcmp(keyword,"ndynamics") == 0) ndynamics = atoi(value);
|
||||
else if (strcmp(keyword,"delta") == 0) delta = atof(value);
|
||||
else if (strcmp(keyword,"temperature") == 0) temperature = atof(value);
|
||||
else if (strcmp(keyword,"seed") == 0) seed = atoi(value);
|
||||
else error("Unknown param in MC file");
|
||||
|
||||
eof = fgets(line,MAXLINE,fp);
|
||||
}
|
||||
|
||||
// derived params
|
||||
|
||||
nloop = nsteps/ndynamics;
|
||||
}
|
||||
40
examples/COUPLE/lammps_mc/mc.h
Normal file
40
examples/COUPLE/lammps_mc/mc.h
Normal file
@ -0,0 +1,40 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef MC_H
|
||||
#define MC_H
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
class MC {
|
||||
public:
|
||||
int naccept; // # of accepted MC events
|
||||
int nattempt; // # of attempted MC events
|
||||
|
||||
MC(char *, class CSlib *);
|
||||
~MC();
|
||||
void run();
|
||||
|
||||
private:
|
||||
int nsteps; // total # of MD steps
|
||||
int ndynamics; // steps in one short dynamics run
|
||||
int nloop; // nsteps/ndynamics
|
||||
int natoms; // # of MD atoms
|
||||
|
||||
double delta; // MC displacement distance
|
||||
double temperature; // MC temperature for Boltzmann criterion
|
||||
double *x; // atom coords as 3N 1d vector
|
||||
double energy; // global potential energy
|
||||
|
||||
int seed; // RNG seed
|
||||
class RanPark *random;
|
||||
|
||||
class CSlib *cs; // messaging library
|
||||
|
||||
void options(char *);
|
||||
};
|
||||
|
||||
#endif
|
||||
72
examples/COUPLE/lammps_mc/random_park.cpp
Normal file
72
examples/COUPLE/lammps_mc/random_park.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
|
||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
certain rights in this software. This software is distributed under
|
||||
the GNU General Public License.
|
||||
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
// Park/Miller RNG
|
||||
|
||||
#include <math.h>
|
||||
#include "random_park.h"
|
||||
//#include "error.h"
|
||||
|
||||
#define IA 16807
|
||||
#define IM 2147483647
|
||||
#define AM (1.0/IM)
|
||||
#define IQ 127773
|
||||
#define IR 2836
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
RanPark::RanPark(int seed_init)
|
||||
{
|
||||
//if (seed_init <= 0)
|
||||
// error->one(FLERR,"Invalid seed for Park random # generator");
|
||||
seed = seed_init;
|
||||
save = 0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
uniform RN
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
double RanPark::uniform()
|
||||
{
|
||||
int k = seed/IQ;
|
||||
seed = IA*(seed-k*IQ) - IR*k;
|
||||
if (seed < 0) seed += IM;
|
||||
double ans = AM*seed;
|
||||
return ans;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
gaussian RN
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
double RanPark::gaussian()
|
||||
{
|
||||
double first,v1,v2,rsq,fac;
|
||||
|
||||
if (!save) {
|
||||
do {
|
||||
v1 = 2.0*uniform()-1.0;
|
||||
v2 = 2.0*uniform()-1.0;
|
||||
rsq = v1*v1 + v2*v2;
|
||||
} while ((rsq >= 1.0) || (rsq == 0.0));
|
||||
fac = sqrt(-2.0*log(rsq)/rsq);
|
||||
second = v1*fac;
|
||||
first = v2*fac;
|
||||
save = 1;
|
||||
} else {
|
||||
first = second;
|
||||
save = 0;
|
||||
}
|
||||
return first;
|
||||
}
|
||||
28
examples/COUPLE/lammps_mc/random_park.h
Normal file
28
examples/COUPLE/lammps_mc/random_park.h
Normal file
@ -0,0 +1,28 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
|
||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
certain rights in this software. This software is distributed under
|
||||
the GNU General Public License.
|
||||
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef RANPARK_H
|
||||
#define RANPARK_H
|
||||
|
||||
class RanPark {
|
||||
public:
|
||||
RanPark(int);
|
||||
double uniform();
|
||||
double gaussian();
|
||||
|
||||
private:
|
||||
int seed,save;
|
||||
double second;
|
||||
};
|
||||
|
||||
#endif
|
||||
53
examples/COUPLE/lammps_vasp/INCAR
Normal file
53
examples/COUPLE/lammps_vasp/INCAR
Normal file
@ -0,0 +1,53 @@
|
||||
# Startparameter for this run:
|
||||
NWRITE = 2 write-flag & timer
|
||||
PREC = normal normal or accurate (medium, high low for compatibility)
|
||||
ISTART = 0 job : 0-new 1-cont 2-samecut
|
||||
ICHARG = 2 charge: 1-file 2-atom 10-const
|
||||
ISPIN = 1 spin polarized calculation?
|
||||
LSORBIT = F spin-orbit coupling
|
||||
INIWAV = 1 electr: 0-lowe 1-rand 2-diag
|
||||
|
||||
# Electronic Relaxation 1
|
||||
ENCUT = 600.0 eV #Plane wave energy cutoff
|
||||
ENINI = 600.0 initial cutoff
|
||||
NELM = 100; NELMIN= 2; NELMDL= -5 # of ELM steps
|
||||
EDIFF = 0.1E-05 stopping-criterion for ELM
|
||||
# Ionic relaxation
|
||||
EDIFFG = 0.1E-02 stopping-criterion for IOM
|
||||
NSW = 0 number of steps for IOM
|
||||
NBLOCK = 1; KBLOCK = 1 inner block; outer block
|
||||
IBRION = -1 ionic relax: 0-MD 1-quasi-New 2-CG #No ion relaxation with -1
|
||||
NFREE = 0 steps in history (QN), initial steepest desc. (CG)
|
||||
ISIF = 2 stress and relaxation # 2: F-yes Sts-yes RlxIon-yes cellshape-no cellvol-no
|
||||
IWAVPR = 10 prediction: 0-non 1-charg 2-wave 3-comb # 10: TMPCAR stored in memory rather than file
|
||||
|
||||
POTIM = 0.5000 time-step for ionic-motion
|
||||
TEBEG = 3500.0; TEEND = 3500.0 temperature during run # Finite Temperature variables if AI-MD is on
|
||||
SMASS = -3.00 Nose mass-parameter (am)
|
||||
estimated Nose-frequenzy (Omega) = 0.10E-29 period in steps =****** mass= -0.366E-27a.u.
|
||||
PSTRESS= 0.0 pullay stress
|
||||
|
||||
# DOS related values:
|
||||
EMIN = 10.00; EMAX =-10.00 energy-range for DOS
|
||||
EFERMI = 0.00
|
||||
ISMEAR = 0; SIGMA = 0.10 broadening in eV -4-tet -1-fermi 0-gaus
|
||||
|
||||
# Electronic relaxation 2 (details)
|
||||
IALGO = 48 algorithm
|
||||
|
||||
# Write flags
|
||||
LWAVE = T write WAVECAR
|
||||
LCHARG = T write CHGCAR
|
||||
LVTOT = F write LOCPOT, total local potential
|
||||
LVHAR = F write LOCPOT, Hartree potential only
|
||||
LELF = F write electronic localiz. function (ELF)
|
||||
|
||||
# Dipole corrections
|
||||
LMONO = F monopole corrections only (constant potential shift)
|
||||
LDIPOL = F correct potential (dipole corrections)
|
||||
IDIPOL = 0 1-x, 2-y, 3-z, 4-all directions
|
||||
EPSILON= 1.0000000 bulk dielectric constant
|
||||
|
||||
# Exchange correlation treatment:
|
||||
GGA = -- GGA type
|
||||
|
||||
6
examples/COUPLE/lammps_vasp/KPOINTS
Normal file
6
examples/COUPLE/lammps_vasp/KPOINTS
Normal file
@ -0,0 +1,6 @@
|
||||
K-Points
|
||||
0
|
||||
Monkhorst Pack
|
||||
15 15 15
|
||||
0 0 0
|
||||
|
||||
11
examples/COUPLE/lammps_vasp/POSCAR_W
Normal file
11
examples/COUPLE/lammps_vasp/POSCAR_W
Normal file
@ -0,0 +1,11 @@
|
||||
W unit cell
|
||||
1.0
|
||||
3.16 0.00000000 0.00000000
|
||||
0.00000000 3.16 0.00000000
|
||||
0.00000000 0.00000000 3.16
|
||||
W
|
||||
2
|
||||
Direct
|
||||
0.00000000 0.00000000 0.00000000
|
||||
0.50000000 0.50000000 0.50000000
|
||||
|
||||
90
examples/COUPLE/lammps_vasp/README
Normal file
90
examples/COUPLE/lammps_vasp/README
Normal file
@ -0,0 +1,90 @@
|
||||
Sample LAMMPS MD wrapper on VASP quantum DFT via client/server
|
||||
coupling
|
||||
|
||||
See the MESSAGE package (doc/Section_messages.html#MESSAGE) and
|
||||
Section_howto.html#howto10 for more details on how client/server
|
||||
coupling works in LAMMPS.
|
||||
|
||||
In this dir, the vasp_warp.py is a wrapper on the VASP quantum DFT
|
||||
code so it can work as a "server" code which LAMMPS drives as a
|
||||
"client" code to perform ab initio MD. LAMMPS performs the MD
|
||||
timestepping, sends VASP a current set of coordinates each timestep,
|
||||
VASP computes forces and energy and virial and returns that info to
|
||||
LAMMPS.
|
||||
|
||||
Messages are exchanged between MC and LAMMPS via a client/server
|
||||
library (CSlib), which is included in the LAMMPS distribution in
|
||||
lib/message. As explained below you can choose to exchange data
|
||||
between the two programs either via files or sockets (ZMQ). If the
|
||||
vasp_wrap.py program became parallel, or the CSlib library calls were
|
||||
integrated into VASP directly, then data could also be exchanged via
|
||||
MPI.
|
||||
|
||||
----------------
|
||||
|
||||
Build LAMMPS with its MESSAGE package installed:
|
||||
|
||||
cd lammps/lib/message
|
||||
python Install.py -m -z # build CSlib with MPI and ZMQ support
|
||||
cd lammps/src
|
||||
make yes-message
|
||||
make mpi
|
||||
|
||||
You can leave off the -z if you do not have ZMQ on your system.
|
||||
|
||||
----------------
|
||||
|
||||
To run in client/server mode:
|
||||
|
||||
Both the client (LAMMPS) and server (vasp_wrap.py) must use the same
|
||||
messaging mode, namely file or zmq. This is an argument to the
|
||||
vasp_wrap.py code; it can be selected by setting the "mode" variable
|
||||
when you run LAMMPS. The default mode = file.
|
||||
|
||||
Here we assume LAMMPS was built to run in parallel, and the MESSAGE
|
||||
package was installed with socket (ZMQ) support. This means either of
|
||||
the messaging modes can be used and LAMMPS can be run in serial or
|
||||
parallel. The vasp_wrap.py code is always run in serial, but it
|
||||
launches VASP from Python via an mpirun command which can run VASP
|
||||
itself in parallel.
|
||||
|
||||
When you run, the server should print out thermodynamic info every
|
||||
timestep which corresponds to the forces and virial computed by VASP.
|
||||
VASP will also generate output files each timestep. The vasp_wrapper.py
|
||||
script could be generalized to archive these.
|
||||
|
||||
The examples below are commands you should use in two different
|
||||
terminal windows. The order of the two commands (client or server
|
||||
launch) does not matter. You can run them both in the same window if
|
||||
you append a "&" character to the first one to run it in the
|
||||
background.
|
||||
|
||||
--------------
|
||||
|
||||
File mode of messaging:
|
||||
|
||||
% mpirun -np 1 lmp_mpi -v mode file < in.client.W
|
||||
% python vasp_wrap.py file POSCAR_W
|
||||
|
||||
% mpirun -np 2 lmp_mpi -v mode file < in.client.W
|
||||
% python vasp_wrap.py file POSCAR_W
|
||||
|
||||
ZMQ mode of messaging:
|
||||
|
||||
% mpirun -np 1 lmp_mpi -v mode zmq < in.client.W
|
||||
% python vasp_wrap.py zmq POSCAR_W
|
||||
|
||||
% mpirun -np 2 lmp_mpi -v mode zmq < in.client.W
|
||||
% python vasp_wrap.py zmq POSCAR_W
|
||||
|
||||
--------------
|
||||
|
||||
The provided data.W file (for LAMMPS) and POSCAR_W file (for VASP) are
|
||||
for a simple 2-atom unit cell of bcc tungsten (W). You could
|
||||
replicate this with LAMMPS to create a larger system. The
|
||||
vasp_wrap.py script needs to be generalized to create an appropriate
|
||||
POSCAR_W file for a larger box.
|
||||
|
||||
VASP input file include the sample INCAR and KPOINTS files provided.
|
||||
A POTCAR file is also needed, which should come from your VASP package
|
||||
installation.
|
||||
15
examples/COUPLE/lammps_vasp/data.W
Normal file
15
examples/COUPLE/lammps_vasp/data.W
Normal file
@ -0,0 +1,15 @@
|
||||
LAMMPS W data file
|
||||
|
||||
2 atoms
|
||||
|
||||
1 atom types
|
||||
|
||||
0.0 3.16 xlo xhi
|
||||
0.0 3.16 ylo yhi
|
||||
0.0 3.16 zlo zhi
|
||||
|
||||
Atoms
|
||||
|
||||
1 1 0.000 0.000 0.000
|
||||
2 1 1.58 1.58 1.58
|
||||
|
||||
34
examples/COUPLE/lammps_vasp/in.client.W
Normal file
34
examples/COUPLE/lammps_vasp/in.client.W
Normal file
@ -0,0 +1,34 @@
|
||||
# small W unit cell for use with VASP
|
||||
|
||||
variable mode index file
|
||||
|
||||
if "${mode} == file" then &
|
||||
"message client md file tmp.couple" &
|
||||
elif "${mode} == zmq" &
|
||||
"message client md zmq localhost:5555" &
|
||||
|
||||
variable x index 1
|
||||
variable y index 1
|
||||
variable z index 1
|
||||
|
||||
units metal
|
||||
atom_style atomic
|
||||
atom_modify sort 0 0.0 map yes
|
||||
|
||||
read_data data.W
|
||||
mass 1 183.85
|
||||
|
||||
replicate $x $y $z
|
||||
|
||||
velocity all create 300.0 87287 loop geom
|
||||
|
||||
neighbor 0.3 bin
|
||||
neigh_modify delay 0 every 10 check no
|
||||
|
||||
fix 1 all nve
|
||||
fix 2 all client/md
|
||||
fix_modify 2 energy yes
|
||||
|
||||
thermo 1
|
||||
run 3
|
||||
|
||||
63
examples/COUPLE/lammps_vasp/log.client.output
Normal file
63
examples/COUPLE/lammps_vasp/log.client.output
Normal file
@ -0,0 +1,63 @@
|
||||
LAMMPS (20 Apr 2018)
|
||||
# small W unit cell for use with VASP
|
||||
|
||||
#message client aimd file tmp.couple
|
||||
message client aimd zmq localhost:5555
|
||||
#message client aimd mpi/two tmp.couple
|
||||
#message client aimd mpi/one tmp.couple
|
||||
|
||||
units real
|
||||
atom_style atomic
|
||||
atom_modify sort 0 0.0 map yes
|
||||
|
||||
read_data data.W
|
||||
orthogonal box = (0 0 0) to (3.16 3.16 3.16)
|
||||
1 by 1 by 1 MPI processor grid
|
||||
reading atoms ...
|
||||
2 atoms
|
||||
mass 1 1.0
|
||||
|
||||
#velocity all create 300.0 87287 loop geom
|
||||
|
||||
neighbor 0.3 bin
|
||||
neigh_modify delay 0 every 10 check no
|
||||
|
||||
fix 1 all nve
|
||||
fix 2 all message/aimd
|
||||
fix_modify 2 energy yes
|
||||
|
||||
thermo 1
|
||||
run 2
|
||||
Per MPI rank memory allocation (min/avg/max) = 1.8 | 1.8 | 1.8 Mbytes
|
||||
Step Temp E_pair E_mol TotEng Press
|
||||
0 0 0 0 -48.069571 -172694.2
|
||||
1 0.063865861 0 0 -48.069381 -172693.93
|
||||
2 0.25546344 0 0 -48.06881 -172693.1
|
||||
Loop time of 0.281842 on 1 procs for 2 steps with 2 atoms
|
||||
|
||||
Performance: 0.613 ns/day, 39.145 hours/ns, 7.096 timesteps/s
|
||||
0.0% CPU use with 1 MPI tasks x no OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 3.0994e-06 | 3.0994e-06 | 3.0994e-06 | 0.0 | 0.00
|
||||
Output | 8.9169e-05 | 8.9169e-05 | 8.9169e-05 | 0.0 | 0.03
|
||||
Modify | 0.28174 | 0.28174 | 0.28174 | 0.0 | 99.97
|
||||
Other | | 5.96e-06 | | | 0.00
|
||||
|
||||
Nlocal: 2 ave 2 max 2 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Nghost: 7 ave 7 max 7 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Neighs: 0 ave 0 max 0 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Total # of neighbors = 0
|
||||
Ave neighs/atom = 0
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds not checked
|
||||
|
||||
Total wall time: 0:00:06
|
||||
234
examples/COUPLE/lammps_vasp/vasp_wrap.py
Normal file
234
examples/COUPLE/lammps_vasp/vasp_wrap.py
Normal file
@ -0,0 +1,234 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
# http://lammps.sandia.gov, Sandia National Laboratories
|
||||
# Steve Plimpton, sjplimp@sandia.gov
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
# Syntax: vasp_wrap.py file/zmq POSCARfile
|
||||
|
||||
# wrapper on VASP to act as server program using CSlib
|
||||
# receives message with list of coords from client
|
||||
# creates VASP inputs
|
||||
# invokes VASP to calculate self-consistent energy of that config
|
||||
# reads VASP outputs
|
||||
# sends message with energy, forces, virial to client
|
||||
|
||||
# NOTES:
|
||||
# check to insure basic VASP input files are in place?
|
||||
# worry about archiving VASP input/output in special filenames or dirs?
|
||||
# how to get ordering (by type) of VASP atoms vs LAMMPS atoms
|
||||
# create one initial permutation vector?
|
||||
# could make syntax for launching VASP more flexible
|
||||
# e.g. command-line arg for # of procs
|
||||
|
||||
import sys
|
||||
import commands
|
||||
import xml.etree.ElementTree as ET
|
||||
from cslib import CSlib
|
||||
|
||||
vaspcmd = "srun -N 1 --ntasks-per-node=4 " + \
|
||||
"-n 4 /projects/vasp/2017-build/cts1/vasp5.4.4/vasp_tfermi/bin/vasp_std"
|
||||
|
||||
# enums matching FixClientMD class in LAMMPS
|
||||
|
||||
SETUP,STEP = range(1,2+1)
|
||||
UNITS,DIM,NATOMS,NTYPES,BOXLO,BOXHI,BOXTILT,TYPES,COORDS,CHARGE = range(1,10+1)
|
||||
FORCES,ENERGY,VIRIAL = range(1,3+1)
|
||||
|
||||
# -------------------------------------
|
||||
# functions
|
||||
|
||||
# error message and exit
|
||||
|
||||
def error(txt):
|
||||
print "ERROR:",txt
|
||||
sys.exit(1)
|
||||
|
||||
# -------------------------------------
|
||||
# read initial VASP POSCAR file to setup problem
|
||||
# return natoms,ntypes,box
|
||||
|
||||
def vasp_setup(poscar):
|
||||
|
||||
ps = open(poscar,'r').readlines()
|
||||
|
||||
# box size
|
||||
|
||||
words = ps[2].split()
|
||||
xbox = float(words[0])
|
||||
words = ps[3].split()
|
||||
ybox = float(words[1])
|
||||
words = ps[4].split()
|
||||
zbox = float(words[2])
|
||||
box = [xbox,ybox,zbox]
|
||||
|
||||
ntypes = 0
|
||||
natoms = 0
|
||||
words = ps[6].split()
|
||||
for word in words:
|
||||
if word == '#': break
|
||||
ntypes += 1
|
||||
natoms += int(word)
|
||||
|
||||
return natoms,ntypes,box
|
||||
|
||||
# -------------------------------------
|
||||
# write a new POSCAR file for VASP
|
||||
|
||||
def poscar_write(poscar,natoms,ntypes,types,coords,box):
|
||||
|
||||
psold = open(poscar,'r').readlines()
|
||||
psnew = open("POSCAR",'w')
|
||||
|
||||
# header, including box size
|
||||
|
||||
print >>psnew,psold[0],
|
||||
print >>psnew,psold[1],
|
||||
print >>psnew,"%g 0.0 0.0" % box[0]
|
||||
print >>psnew,"0.0 %g 0.0" % box[1]
|
||||
print >>psnew,"0.0 0.0 %g" % box[2]
|
||||
print >>psnew,psold[5],
|
||||
print >>psnew,psold[6],
|
||||
|
||||
# per-atom coords
|
||||
# grouped by types
|
||||
|
||||
print >>psnew,"Cartesian"
|
||||
|
||||
for itype in range(1,ntypes+1):
|
||||
for i in range(natoms):
|
||||
if types[i] != itype: continue
|
||||
x = coords[3*i+0]
|
||||
y = coords[3*i+1]
|
||||
z = coords[3*i+2]
|
||||
aline = " %g %g %g" % (x,y,z)
|
||||
print >>psnew,aline
|
||||
|
||||
psnew.close()
|
||||
|
||||
# -------------------------------------
|
||||
# read a VASP output vasprun.xml file
|
||||
# uses ElementTree module
|
||||
# see https://docs.python.org/2/library/xml.etree.elementtree.html
|
||||
|
||||
def vasprun_read():
|
||||
tree = ET.parse('vasprun.xml')
|
||||
root = tree.getroot()
|
||||
|
||||
#fp = open("vasprun.xml","r")
|
||||
#root = ET.parse(fp)
|
||||
|
||||
scsteps = root.findall('calculation/scstep')
|
||||
energy = scsteps[-1].find('energy')
|
||||
for child in energy:
|
||||
if child.attrib["name"] == "e_0_energy":
|
||||
eout = float(child.text)
|
||||
|
||||
fout = []
|
||||
sout = []
|
||||
|
||||
varrays = root.findall('calculation/varray')
|
||||
for varray in varrays:
|
||||
if varray.attrib["name"] == "forces":
|
||||
forces = varray.findall("v")
|
||||
for line in forces:
|
||||
fxyz = line.text.split()
|
||||
fxyz = [float(value) for value in fxyz]
|
||||
fout += fxyz
|
||||
if varray.attrib["name"] == "stress":
|
||||
tensor = varray.findall("v")
|
||||
stensor = []
|
||||
for line in tensor:
|
||||
sxyz = line.text.split()
|
||||
sxyz = [float(value) for value in sxyz]
|
||||
stensor.append(sxyz)
|
||||
sxx = stensor[0][0]
|
||||
syy = stensor[1][1]
|
||||
szz = stensor[2][2]
|
||||
sxy = 0.5 * (stensor[0][1] + stensor[1][0])
|
||||
sxz = 0.5 * (stensor[0][2] + stensor[2][0])
|
||||
syz = 0.5 * (stensor[1][2] + stensor[2][1])
|
||||
sout = [sxx,syy,szz,sxy,sxz,syz]
|
||||
|
||||
#fp.close()
|
||||
|
||||
return eout,fout,sout
|
||||
|
||||
# -------------------------------------
|
||||
# main program
|
||||
|
||||
# command-line args
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
print "Syntax: python vasp_wrap.py file/zmq POSCARfile"
|
||||
sys.exit(1)
|
||||
|
||||
mode = sys.argv[1]
|
||||
poscar_template = sys.argv[2]
|
||||
|
||||
if mode == "file": cs = CSlib(1,mode,"tmp.couple",None)
|
||||
elif mode == "zmq": cs = CSlib(1,mode,"*:5555",None)
|
||||
else:
|
||||
print "Syntax: python vasp_wrap.py file/zmq POSCARfile"
|
||||
sys.exit(1)
|
||||
|
||||
natoms,ntypes,box = vasp_setup(poscar_template)
|
||||
|
||||
# initial message for MD protocol
|
||||
|
||||
msgID,nfield,fieldID,fieldtype,fieldlen = cs.recv()
|
||||
if msgID != 0: error("Bad initial client/server handshake")
|
||||
protocol = cs.unpack_string(1)
|
||||
if protocol != "md": error("Mismatch in client/server protocol")
|
||||
cs.send(0,0)
|
||||
|
||||
# endless server loop
|
||||
|
||||
while 1:
|
||||
|
||||
# recv message from client
|
||||
# msgID = 0 = all-done message
|
||||
|
||||
msgID,nfield,fieldID,fieldtype,fieldlen = cs.recv()
|
||||
if msgID < 0: break
|
||||
|
||||
# could generalize this to be more like ServerMD class
|
||||
# allow for box size, atom types, natoms, etc
|
||||
|
||||
# unpack coords from client
|
||||
# create VASP input
|
||||
# NOTE: generalize this for general list of atom types
|
||||
|
||||
coords = cs.unpack(COORDS,1)
|
||||
#types = cs.unpack(2);
|
||||
types = 2*[1]
|
||||
|
||||
poscar_write(poscar_template,natoms,ntypes,types,coords,box)
|
||||
|
||||
# invoke VASP
|
||||
|
||||
print "Launching VASP ..."
|
||||
print vaspcmd
|
||||
out = commands.getoutput(vaspcmd)
|
||||
print out
|
||||
|
||||
# process VASP output
|
||||
|
||||
energy,forces,virial = vasprun_read()
|
||||
|
||||
# return forces, energy, virial to client
|
||||
|
||||
cs.send(msgID,3);
|
||||
cs.pack(FORCES,4,3*natoms,forces)
|
||||
cs.pack_double(ENERGY,energy)
|
||||
cs.pack(VIRIAL,4,6,virial)
|
||||
|
||||
# final reply to client
|
||||
|
||||
cs.send(0,0)
|
||||
|
||||
# clean-up
|
||||
|
||||
del cs
|
||||
Reference in New Issue
Block a user