diff --git a/test/lib_python/Makefile b/test/lib_python/Makefile index 54af3ffb6d..8bb33463a7 100644 --- a/test/lib_python/Makefile +++ b/test/lib_python/Makefile @@ -10,8 +10,8 @@ default: test: $(LIB) $(OUTPUTS) log.%-$(MACH)$(TAG): in.%.py $(LIB) - $(MPICMD) python $< $(LMPFLAGS) - mv log.lammps $@ + $(MPICMD) python $< $(LMPFLAGS) -log none -screen $@ -echo screen + test -f log.lammps && mv log.lammps $@ || true clean: -rm -f log.* lammps.py *.pyc liblammps*.so diff --git a/test/lib_python/in.simple-001.py b/test/lib_python/in.simple-001.py index b5d29c9429..a0133cb450 100755 --- a/test/lib_python/in.simple-001.py +++ b/test/lib_python/in.simple-001.py @@ -1,16 +1,10 @@ #!/usr/bin/env python -i -# preceeding line should have path for Python on your machine - -# simple.py -# Purpose: mimic operation of couple/simple/simple.cpp via Python -# Syntax: simple.py in.lammps -# in.lammps = LAMMPS input script infile = 'in.simple' me = 0 from lammps import lammps -lmp = lammps(cmdargs=['-echo','screen']) +lmp = lammps() # run infile one line at a time diff --git a/test/lib_python/in.simple-002.py b/test/lib_python/in.simple-002.py new file mode 100755 index 0000000000..b62cf20691 --- /dev/null +++ b/test/lib_python/in.simple-002.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python -i +# preceeding line should have path for Python on your machine + +# simple.py +# Purpose: mimic operation of couple/simple/simple.cpp via Python +# Syntax: simple.py in.lammps +# in.lammps = LAMMPS input script + +import sys + +infile = 'in.simple' +me = 0 + +from lammps import lammps +lmp = lammps(cmdargs=sys.argv[1:]) + +# run infile one line at a time + +lines = open(infile,'r').readlines() +for line in lines: lmp.command(line) + +lmp.command("run 10") +x = lmp.gather_atoms("x",1,3) +epsilon = 0.1 +x[0] += epsilon +lmp.scatter_atoms("x",1,3,x) +lmp.command("run 1"); + +f = lmp.extract_atom("f",3) +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] +