2013-06-10 23:01:35 +08:00
|
|
|
#!/usr/bin/env python -i
|
2017-03-07 13:57:23 +08:00
|
|
|
# preceding line should have path for Python on your machine
|
2010-11-02 23:07:40 +08:00
|
|
|
|
2010-11-25 04:40:51 +08:00
|
|
|
# viz_atomeye.py
|
|
|
|
# Purpose: viz running LAMMPS simulation via AtomEye
|
|
|
|
# Syntax: viz_atomeye.py in.lammps Nfreq Nsteps
|
2010-11-02 23:07:40 +08:00
|
|
|
# in.lammps = LAMMPS input script
|
|
|
|
# Nfreq = dump and viz shapshot every this many steps
|
|
|
|
# Nsteps = run for this many steps
|
|
|
|
|
2016-07-23 06:57:54 +08:00
|
|
|
from __future__ import print_function
|
2010-11-09 05:04:35 +08:00
|
|
|
import sys,os
|
|
|
|
|
|
|
|
# set this to point to AtomEye version 3 executable
|
2010-11-25 05:27:39 +08:00
|
|
|
# first line if want AtomEye output to screen, 2nd line to file
|
|
|
|
#ATOMEYE3 = "/home/sjplimp/tools/atomeye3/A3.i686-20060530"
|
|
|
|
ATOMEYE3 = "/home/sjplimp/tools/atomeye3/A3.i686-20060530 > atomeye.out"
|
2010-11-02 23:07:40 +08:00
|
|
|
|
|
|
|
# parse command line
|
|
|
|
|
|
|
|
argv = sys.argv
|
|
|
|
if len(argv) != 4:
|
2016-07-23 06:57:54 +08:00
|
|
|
print("Syntax: viz_atomeye.py in.lammps Nfreq Nsteps")
|
2010-11-02 23:07:40 +08:00
|
|
|
sys.exit()
|
|
|
|
|
|
|
|
infile = sys.argv[1]
|
|
|
|
nfreq = int(sys.argv[2])
|
|
|
|
nsteps = int(sys.argv[3])
|
|
|
|
|
|
|
|
me = 0
|
|
|
|
# uncomment if running in parallel via Pypar
|
|
|
|
#import pypar
|
|
|
|
#me = pypar.rank()
|
|
|
|
#nprocs = pypar.size()
|
|
|
|
|
|
|
|
from lammps import lammps
|
|
|
|
lmp = lammps()
|
|
|
|
|
|
|
|
# run infile all at once
|
|
|
|
# assumed to have no run command in it
|
2010-11-09 05:04:35 +08:00
|
|
|
# dump a file in extended CFG format for AtomEye
|
2010-11-02 23:07:40 +08:00
|
|
|
|
|
|
|
lmp.file(infile)
|
|
|
|
lmp.command("thermo %d" % nfreq)
|
2017-03-16 10:31:14 +08:00
|
|
|
lmp.command("dump python all cfg %d tmp.cfg.* mass type xs ys zs id" % nfreq)
|
2010-11-02 23:07:40 +08:00
|
|
|
|
|
|
|
# initial 0-step run to generate dump file and image
|
|
|
|
|
|
|
|
lmp.command("run 0 pre yes post no")
|
|
|
|
ntimestep = 0
|
|
|
|
|
|
|
|
# wrapper on GL window via Pizza.py gl tool
|
|
|
|
# just proc 0 handles reading of dump file and viz
|
|
|
|
|
|
|
|
if me == 0:
|
2010-11-09 05:04:35 +08:00
|
|
|
a = os.popen(ATOMEYE3,'w')
|
|
|
|
a.write("load_config tmp.cfg.0\n")
|
|
|
|
a.flush()
|
2010-11-02 23:07:40 +08:00
|
|
|
|
|
|
|
# run nfreq steps at a time w/out pre/post, read dump snapshot, display it
|
|
|
|
|
|
|
|
while ntimestep < nsteps:
|
|
|
|
lmp.command("run %d pre no post no" % nfreq)
|
|
|
|
ntimestep += nfreq
|
|
|
|
if me == 0:
|
2010-11-09 05:04:35 +08:00
|
|
|
a.write("load_config tmp.cfg.%d\n" % ntimestep)
|
|
|
|
a.flush()
|
2010-11-02 23:07:40 +08:00
|
|
|
|
|
|
|
lmp.command("run 0 pre no post yes")
|
|
|
|
|
|
|
|
# uncomment if running in parallel via Pypar
|
2016-07-23 06:57:54 +08:00
|
|
|
#print("Proc %d out of %d procs has" % (me,nprocs), lmp)
|
2010-11-02 23:07:40 +08:00
|
|
|
#pypar.finalize()
|