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
|
|
|
|
|
|
|
# trivial.py
|
|
|
|
# Purpose: run a LAMMPS input script via Python
|
|
|
|
# Syntax: trivial.py in.lammps
|
|
|
|
# in.lammps = LAMMPS input script
|
|
|
|
|
2016-07-23 06:57:54 +08:00
|
|
|
from __future__ import print_function
|
2010-11-02 23:07:40 +08:00
|
|
|
import sys
|
|
|
|
|
|
|
|
# parse command line
|
|
|
|
|
|
|
|
argv = sys.argv
|
|
|
|
if len(argv) != 2:
|
2016-07-23 06:57:54 +08:00
|
|
|
print("Syntax: trivial.py in.lammps")
|
2010-11-02 23:07:40 +08:00
|
|
|
sys.exit()
|
|
|
|
|
|
|
|
infile = sys.argv[1]
|
|
|
|
|
|
|
|
from lammps import lammps
|
|
|
|
lmp = lammps()
|
|
|
|
|
|
|
|
# run infile all at once
|
|
|
|
|
|
|
|
lmp.file(infile)
|
|
|
|
|
2015-12-10 05:09:50 +08:00
|
|
|
# or run infile one line at a time
|
2010-11-02 23:07:40 +08:00
|
|
|
|
|
|
|
#lines = open(infile,'r').readlines()
|
|
|
|
#for line in lines: lmp.command(line)
|