git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@5201 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2010-11-02 15:07:40 +00:00
parent b63b44e274
commit 453aba29e5
23 changed files with 5263 additions and 0 deletions

40
python/examples/trivial.py Executable file
View File

@ -0,0 +1,40 @@
#!/usr/local/bin/python -i
# preceeding line should have path for Python on your machine
# trivial.py
# Purpose: run a LAMMPS input script via Python
# Syntax: trivial.py in.lammps
# in.lammps = LAMMPS input script
import sys
# parse command line
argv = sys.argv
if len(argv) != 2:
print "Syntax: trivial.py in.lammps"
sys.exit()
infile = sys.argv[1]
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
lmp.file(infile)
# run infile one line at a time
#lines = open(infile,'r').readlines()
#for line in lines: lmp.command(line)
# uncomment if running in parallel via Pypar
#print "Proc %d out of %d procs has" % (me,nprocs), lmp
#pypar.finalize()