start porting some LAMMPS python module examples to python3 with compatibility to python2

This commit is contained in:
Axel Kohlmeyer
2016-07-19 16:59:57 -04:00
parent ec9c9a235a
commit 21ea3ccfb7
18 changed files with 148 additions and 109 deletions

View File

@ -7,13 +7,14 @@
# Syntax: split.py in.lammps
# in.lammps = LAMMPS input script
from __future__ import print_function
import sys
# parse command line
argv = sys.argv
if len(argv) != 2:
print "Syntax: simple.py in.lammps"
print("Syntax: simple.py in.lammps")
sys.exit()
infile = sys.argv[1]
@ -57,12 +58,12 @@ if color == 0:
lmp.command("run 1");
f = lmp.extract_atom("f",3)
print "Force on 1 atom via extract_atom: ",f[0][0]
print("Force on 1 atom via extract_atom: ",f[0][0])
fx = lmp.extract_variable("fx","all",1)
print "Force on 1 atom via extract_variable:",fx[0]
print "Proc %d out of %d procs has" % (me,nprocs), lmp
print "Calculation on partition 0 complete"
print("Force on 1 atom via extract_variable:",fx[0])
print("Proc %d out of %d procs has" % (me,nprocs), lmp)
print("Calculation on partition 0 complete")
else:
# could run a 2nd calculation on second partition
@ -71,7 +72,7 @@ else:
import time
time.sleep(2)
print "Calculation on partition 1 complete"
print("Calculation on partition 1 complete")
# shutdown mpi4py