1#!/usr/bin/env python -i 2# preceeding line should have path for Python on your machine 3 4# viz_atomeye.py 5# Purpose: viz running LIGGGHTS simulation via AtomEye 6# Syntax: viz_atomeye.py in.liggghts Nfreq Nsteps 7# in.liggghts = LIGGGHTS input script 8# Nfreq = dump and viz shapshot every this many steps 9# Nsteps = run for this many steps 10 11import sys,os 12 13# set this to point to AtomEye version 3 executable 14# first line if want AtomEye output to screen, 2nd line to file 15#ATOMEYE3 = "/home/sjplimp/tools/atomeye3/A3.i686-20060530" 16ATOMEYE3 = "/home/sjplimp/tools/atomeye3/A3.i686-20060530 > atomeye.out" 17 18# parse command line 19 20argv = sys.argv 21if len(argv) != 4: 22 print "Syntax: viz_atomeye.py in.liggghts Nfreq Nsteps" 23 sys.exit() 24 25infile = sys.argv[1] 26nfreq = int(sys.argv[2]) 27nsteps = int(sys.argv[3]) 28 29me = 0 30# uncomment if running in parallel via Pypar 31#import pypar 32#me = pypar.rank() 33#nprocs = pypar.size() 34 35from liggghts import liggghts 36lmp = liggghts() 37 38# run infile all at once 39# assumed to have no run command in it 40# dump a file in extended CFG format for AtomEye 41 42lmp.file(infile) 43lmp.command("thermo %d" % nfreq) 44lmp.command("dump python all cfg %d tmp.cfg.* id type xs ys zs" % nfreq) 45 46# initial 0-step run to generate dump file and image 47 48lmp.command("run 0 pre yes post no") 49ntimestep = 0 50 51# wrapper on GL window via Pizza.py gl tool 52# just proc 0 handles reading of dump file and viz 53 54if me == 0: 55 a = os.popen(ATOMEYE3,'w') 56 a.write("load_config tmp.cfg.0\n") 57 a.flush() 58 59# run nfreq steps at a time w/out pre/post, read dump snapshot, display it 60 61while ntimestep < nsteps: 62 lmp.command("run %d pre no post no" % nfreq) 63 ntimestep += nfreq 64 if me == 0: 65 a.write("load_config tmp.cfg.%d\n" % ntimestep) 66 a.flush() 67 68lmp.command("run 0 pre no post yes") 69 70# uncomment if running in parallel via Pypar 71#print "Proc %d out of %d procs has" % (me,nprocs), lmp 72#pypar.finalize() 73