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

This commit is contained in:
sjplimp
2016-07-22 22:57:54 +00:00
parent 2f936d5e56
commit 778f4d338c
22 changed files with 694 additions and 246 deletions

View File

@ -6,13 +6,14 @@
# Syntax: demo.py
# uses in.demo as LAMMPS input script
from __future__ import print_function
import sys
# parse command line
argv = sys.argv
if len(argv) != 1:
print "Syntax: demo.py"
print("Syntax: demo.py")
sys.exit()
from lammps import lammps
@ -22,29 +23,32 @@ lmp = lammps()
lmp.file("in.demo")
print "\nPython output:"
print("\nPython output:")
natoms = lmp.extract_global("natoms",0)
mass = lmp.extract_atom("mass",2)
x = lmp.extract_atom("x",3)
print "Natoms, mass, x[0][0] coord =",natoms,mass[1],x[0][0]
print("Natoms, mass, x[0][0] coord =",natoms,mass[1],x[0][0])
temp = lmp.extract_compute("thermo_temp",0,0)
print "Temperature from compute =",temp
print("Temperature from compute =",temp)
eng = lmp.extract_variable("eng",None,0)
print "Energy from equal-style variable =",eng
print("Energy from equal-style variable =",eng)
vy = lmp.extract_variable("vy","all",1)
print "Velocity component from atom-style variable =",vy[1]
print("Velocity component from atom-style variable =",vy[1])
vol = lmp.get_thermo("vol")
print("Volume from get_thermo = ",vol)
natoms = lmp.get_natoms()
print "Natoms from get_natoms =",natoms
print("Natoms from get_natoms =",natoms)
xc = lmp.gather_atoms("x",1,3)
print "Global coords from gather_atoms =",xc[0],xc[1],xc[31]
print("Global coords from gather_atoms =",xc[0],xc[1],xc[31])
xc[0] = xc[0] + 1.0
lmp.scatter_atoms("x",1,3,xc)
print "Changed x[0][0] via scatter_atoms =",x[0][0]
print("Changed x[0][0] via scatter_atoms =",x[0][0])