Merge remote-tracking branch 'github/master' into collected-small-changes
# Conflicts: # python/lammps/__init__.py # python/lammps/core.py
This commit is contained in:
1
python/.gitignore
vendored
1
python/.gitignore
vendored
@ -1 +1,2 @@
|
||||
/build
|
||||
/*.egg-info
|
||||
|
||||
@ -38,13 +38,14 @@ Once you have successfully wrapped LAMMPS, you can run the Python
|
||||
scripts in the examples sub-directory:
|
||||
|
||||
trivial.py read/run a LAMMPS input script thru Python
|
||||
demo.py invoke various LAMMPS library interface routines
|
||||
simple.py parallel example, mimicing examples/COUPLE/simple/simple.cpp
|
||||
demo.py invoke various LAMMPS library interface routines
|
||||
simple.py parallel example, mimicing examples/COUPLE/simple/simple.cpp
|
||||
split.py parallel example
|
||||
mc.py Monte Carlo energy relaxation wrapper on LAMMPS
|
||||
gui.py GUI go/stop/temperature-slider to control LAMMPS
|
||||
plot.py real-time temperature plot with GnuPlot via Pizza.py
|
||||
viz_tool.py real-time viz via some viz package
|
||||
gui.py GUI go/stop/temperature-slider to control LAMMPS
|
||||
plot.py real-time temperature plot with GnuPlot via Pizza.py
|
||||
matplotlib_plot.py real-time temperature plot with Matplotlib via Pizza.py
|
||||
viz_tool.py real-time viz via some viz package
|
||||
vizplotgui_tool.py combination of viz.py and plot.py and gui.py
|
||||
|
||||
For the viz_tool.py and vizplotgui_tool.py commands, replace "tool"
|
||||
@ -100,24 +101,24 @@ split.py in.simple # can run in parallel (see below)
|
||||
|
||||
gui.py in.gui 100
|
||||
plot.py in.plot 10 1000 thermo_temp
|
||||
matplotlib_plot.py in.plot 10 1000 thermo_temp
|
||||
viz_tool.py in.viz 100 5000
|
||||
vizplotgui_tool.py in.viz 100 thermo_temp
|
||||
|
||||
To run LAMMPS in parallel from Python, so something like this:
|
||||
|
||||
% mpirun -np 4 simple.py in.simple
|
||||
% mpirun -np 4 python split.py in.simple
|
||||
% mpirun -np P simple.py in.simple
|
||||
% mpirun -np P python split.py in.simple
|
||||
|
||||
If you run simple.py as-is, this will invoke P instances of a
|
||||
one-processor run, where both Python and LAMMPS will run on single
|
||||
processors. Each running job will read the same input file, and write
|
||||
to same log.lammps file, which isn't too useful.
|
||||
|
||||
However, if you have either the Pypar or mpi4py packages installed in
|
||||
your Python, and uncomment the Pypar or mpi4py code in simple.py, then
|
||||
the above commands will invoke 1 instance of a P-processor run. Both
|
||||
Python and LAMMPS will run on P processors. The job will read the
|
||||
input file and write a single log.lammps file.
|
||||
However, if you have the mpi4py Python package installed and uncomment mpi4py
|
||||
code in simple.py, then the above commands will invoke 1 instance of a
|
||||
P-processor run. Both Python and LAMMPS will run on P processors. The job will
|
||||
read the input file and write a single log.lammps file.
|
||||
|
||||
The split.py script can also be run in parallel. It uses mpi4py
|
||||
version 2.0.0 (or later), which makes it possible to pass a
|
||||
|
||||
1
python/examples/.gitignore
vendored
Normal file
1
python/examples/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/tmp*
|
||||
@ -7,8 +7,7 @@
|
||||
# in.lammps = LAMMPS input script
|
||||
# Nfreq = query GUI every this many steps
|
||||
|
||||
# IMPORTANT: this script cannot yet be run in parallel via Pypar,
|
||||
# because I can't seem to do a MPI-style broadcast in Pypar
|
||||
# IMPORTANT: this script cannot yet be run in parallel
|
||||
|
||||
from __future__ import print_function
|
||||
import sys,time
|
||||
@ -39,10 +38,6 @@ infile = sys.argv[1]
|
||||
nfreq = int(sys.argv[2])
|
||||
|
||||
me = 0
|
||||
# uncomment if running in parallel via Pypar
|
||||
#import pypar
|
||||
#me = pypar.rank()
|
||||
#nprocs = pypar.size()
|
||||
|
||||
from lammps import lammps
|
||||
lmp = lammps()
|
||||
@ -110,7 +105,3 @@ while 1:
|
||||
if runflag: running = 1
|
||||
else: running = 0
|
||||
time.sleep(0.01)
|
||||
|
||||
# uncomment if running in parallel via Pypar
|
||||
#print("Proc %d out of %d procs has" % (me,nprocs), lmp)
|
||||
#pypar.finalize()
|
||||
|
||||
@ -12,9 +12,6 @@
|
||||
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
sys.path.append("./pizza")
|
||||
import matplotlib
|
||||
matplotlib.use('tkagg')
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# parse command line
|
||||
@ -30,10 +27,10 @@ nsteps = int(sys.argv[3])
|
||||
compute = sys.argv[4]
|
||||
|
||||
me = 0
|
||||
# uncomment if running in parallel via Pypar
|
||||
#import pypar
|
||||
#me = pypar.rank()
|
||||
#nprocs = pypar.size()
|
||||
# uncomment this if running in parallel via mpi4py
|
||||
#from mpi4py import MPI
|
||||
#me = MPI.COMM_WORLD.Get_rank()
|
||||
#nprocs = MPI.COMM_WORLD.Get_size()
|
||||
|
||||
from lammps import lammps
|
||||
lmp = lammps()
|
||||
@ -79,15 +76,16 @@ while ntimestep < nsteps:
|
||||
ax = plt.gca()
|
||||
ax.relim()
|
||||
ax.autoscale_view(True, True, True)
|
||||
fig.canvas.draw()
|
||||
plt.pause(0.001)
|
||||
|
||||
|
||||
lmp.command("run 0 pre no post yes")
|
||||
|
||||
# uncomment if running in parallel via Pypar
|
||||
# uncomment if running in parallel via mpi4py
|
||||
#print("Proc %d out of %d procs has" % (me,nprocs), lmp)
|
||||
#pypar.finalize()
|
||||
|
||||
if sys.version_info[0] == 3:
|
||||
input("Press Enter to exit...")
|
||||
else:
|
||||
raw_input("Press Enter to exit...")
|
||||
if me == 0:
|
||||
if sys.version_info[0] == 3:
|
||||
input("Press Enter to exit...")
|
||||
else:
|
||||
raw_input("Press Enter to exit...")
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
#
|
||||
# Copyright (2005) Sandia Corporation. Under the terms of Contract
|
||||
# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
# certain rights in this software. This software is distributed under
|
||||
# certain rights in this software. This software is distributed under
|
||||
# the GNU General Public License.
|
||||
|
||||
# for python3 compatibility
|
||||
@ -35,7 +35,7 @@ time = d.next() read next snapshot from dump files
|
||||
d.map(1,"id",3,"x") assign names to atom columns (1-N)
|
||||
|
||||
not needed if dump file is self-describing
|
||||
|
||||
|
||||
d.tselect.all() select all timesteps
|
||||
d.tselect.one(N) select only timestep N
|
||||
d.tselect.none() deselect all timesteps
|
||||
@ -227,7 +227,7 @@ class dump:
|
||||
for word in words: self.flist += glob.glob(word)
|
||||
if len(self.flist) == 0 and len(list) == 1:
|
||||
raise Exception("no dump file specified")
|
||||
|
||||
|
||||
if len(list) == 1:
|
||||
self.increment = 0
|
||||
self.read_all()
|
||||
@ -270,12 +270,12 @@ class dump:
|
||||
self.tselect.all()
|
||||
|
||||
# set default names for atom columns if file wasn't self-describing
|
||||
|
||||
|
||||
if len(self.snaps) == 0:
|
||||
print("no column assignments made")
|
||||
elif len(self.names):
|
||||
print("assigned columns:",self.names2str())
|
||||
elif self.snaps[0].atoms == None:
|
||||
elif self.snaps[0].atoms is None:
|
||||
print("no column assignments made")
|
||||
elif len(self.snaps[0].atoms[0]) == 5:
|
||||
self.map(1,"id",2,"type",3,"x",4,"y",5,"z")
|
||||
@ -341,7 +341,7 @@ class dump:
|
||||
# return snapshot or 0 if failed
|
||||
# assign column names if not already done and file is self-describing
|
||||
# convert xs,xu to x
|
||||
|
||||
|
||||
def read_snapshot(self,f):
|
||||
try:
|
||||
snap = Snap()
|
||||
@ -414,7 +414,7 @@ class dump:
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# map atom column names
|
||||
|
||||
|
||||
def map(self,*pairs):
|
||||
if len(pairs) % 2 != 0:
|
||||
raise Exception("dump map() requires pairs of mappings")
|
||||
@ -492,7 +492,7 @@ class dump:
|
||||
atoms[:,x] = snap.xlo + atoms[:,x]*xprd
|
||||
atoms[:,y] = snap.ylo + atoms[:,y]*yprd
|
||||
atoms[:,z] = snap.zlo + atoms[:,z]*zprd
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# wrap coords from outside box to inside
|
||||
|
||||
@ -505,7 +505,7 @@ class dump:
|
||||
ix = self.names["ix"]
|
||||
iy = self.names["iy"]
|
||||
iz = self.names["iz"]
|
||||
|
||||
|
||||
for snap in self.snaps:
|
||||
xprd = snap.xhi - snap.xlo
|
||||
yprd = snap.yhi - snap.ylo
|
||||
@ -527,7 +527,7 @@ class dump:
|
||||
ix = self.names["ix"]
|
||||
iy = self.names["iy"]
|
||||
iz = self.names["iz"]
|
||||
|
||||
|
||||
for snap in self.snaps:
|
||||
xprd = snap.xhi - snap.xlo
|
||||
yprd = snap.yhi - snap.ylo
|
||||
@ -542,7 +542,7 @@ class dump:
|
||||
|
||||
def owrap(self,other):
|
||||
print("Wrapping to other ...")
|
||||
|
||||
|
||||
id = self.names["id"]
|
||||
x = self.names["x"]
|
||||
y = self.names["y"]
|
||||
@ -551,7 +551,7 @@ class dump:
|
||||
iy = self.names["iy"]
|
||||
iz = self.names["iz"]
|
||||
iother = self.names[other]
|
||||
|
||||
|
||||
for snap in self.snaps:
|
||||
xprd = snap.xhi - snap.xlo
|
||||
yprd = snap.yhi - snap.ylo
|
||||
@ -568,7 +568,7 @@ class dump:
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# convert column names assignment to a string, in column order
|
||||
|
||||
|
||||
def names2str(self):
|
||||
ncol = len(self.snaps[0].atoms[0])
|
||||
pairs = self.names.items()
|
||||
@ -631,7 +631,7 @@ class dump:
|
||||
print(snap.ylo,snap.yhi,file=f)
|
||||
print(snap.zlo,snap.zhi,file=f)
|
||||
print("ITEM: ATOMS",namestr,file=f)
|
||||
|
||||
|
||||
atoms = snap.atoms
|
||||
nvalues = len(atoms[0])
|
||||
for i in range(snap.natoms):
|
||||
@ -655,7 +655,7 @@ class dump:
|
||||
if not snap.tselect: continue
|
||||
print(snap.time,end='')
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
file = root + "." + str(snap.time)
|
||||
f = open(file,"w")
|
||||
print("ITEM: TIMESTEP",file=f)
|
||||
@ -667,7 +667,7 @@ class dump:
|
||||
print(snap.ylo,snap.yhi,file=f)
|
||||
print(snap.zlo,snap.zhi,file=f)
|
||||
print("ITEM: ATOMS",namestr,file=f)
|
||||
|
||||
|
||||
atoms = snap.atoms
|
||||
nvalues = len(atoms[0])
|
||||
for i in range(snap.natoms):
|
||||
@ -709,7 +709,7 @@ class dump:
|
||||
lhs = list[0][1:]
|
||||
if not self.names.has_key(lhs):
|
||||
self.newcolumn(lhs)
|
||||
|
||||
|
||||
for item in list:
|
||||
name = item[1:]
|
||||
column = self.names[name]
|
||||
@ -721,7 +721,7 @@ class dump:
|
||||
if not snap.tselect: continue
|
||||
for i in range(snap.natoms):
|
||||
if snap.aselect[i]: exec(ceq)
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# set a column value via an input vec for all selected snapshots/atoms
|
||||
|
||||
@ -741,7 +741,7 @@ class dump:
|
||||
if snap.aselect[i]:
|
||||
atoms[i][icol] = vec[m]
|
||||
m += 1
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# clone value in col across selected timesteps for atoms with same ID
|
||||
|
||||
@ -807,7 +807,7 @@ class dump:
|
||||
columns.append(self.names[name])
|
||||
values.append(self.nselect * [0])
|
||||
ncol = len(columns)
|
||||
|
||||
|
||||
id = self.names["id"]
|
||||
m = 0
|
||||
for snap in self.snaps:
|
||||
@ -823,13 +823,13 @@ class dump:
|
||||
|
||||
if len(list) == 1: return values[0]
|
||||
else: return values
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# extract vector(s) of values for selected atoms at chosen timestep
|
||||
|
||||
def vecs(self,n,*list):
|
||||
snap = self.snaps[self.findtime(n)]
|
||||
|
||||
|
||||
if len(list) == 0:
|
||||
raise Exception("no columns specified")
|
||||
columns = []
|
||||
@ -884,7 +884,7 @@ class dump:
|
||||
del self.snaps[i]
|
||||
else:
|
||||
i += 1
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# iterate over selected snapshots
|
||||
|
||||
@ -896,11 +896,11 @@ class dump:
|
||||
self.iterate = i
|
||||
return i,self.snaps[i].time,1
|
||||
return 0,0,-1
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# return list of atoms to viz for snapshot isnap
|
||||
# augment with bonds, tris, lines if extra() was invoked
|
||||
|
||||
|
||||
def viz(self,isnap):
|
||||
snap = self.snaps[isnap]
|
||||
|
||||
@ -914,7 +914,7 @@ class dump:
|
||||
|
||||
# create atom list needed by viz from id,type,x,y,z
|
||||
# need Numeric/Numpy mode here
|
||||
|
||||
|
||||
atoms = []
|
||||
for i in range(snap.natoms):
|
||||
if not snap.aselect[i]: continue
|
||||
@ -948,12 +948,12 @@ class dump:
|
||||
elif self.triflag == 2:
|
||||
timetmp,boxtmp,atomstmp,bondstmp, \
|
||||
tris,linestmp = self.triobj.viz(time,1)
|
||||
|
||||
|
||||
lines = []
|
||||
if self.lineflag: lines = self.linelist
|
||||
|
||||
return time,box,atoms,bonds,tris,lines
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def findtime(self,n):
|
||||
@ -969,12 +969,12 @@ class dump:
|
||||
xhi = yhi = zhi = None
|
||||
for snap in self.snaps:
|
||||
if not snap.tselect: continue
|
||||
if xlo == None or snap.xlo < xlo: xlo = snap.xlo
|
||||
if xhi == None or snap.xhi > xhi: xhi = snap.xhi
|
||||
if ylo == None or snap.ylo < ylo: ylo = snap.ylo
|
||||
if yhi == None or snap.yhi > yhi: yhi = snap.yhi
|
||||
if zlo == None or snap.zlo < zlo: zlo = snap.zlo
|
||||
if zhi == None or snap.zhi > zhi: zhi = snap.zhi
|
||||
if xlo is None or snap.xlo < xlo: xlo = snap.xlo
|
||||
if xhi is None or snap.xhi > xhi: xhi = snap.xhi
|
||||
if ylo is None or snap.ylo < ylo: ylo = snap.ylo
|
||||
if yhi is None or snap.yhi > yhi: yhi = snap.yhi
|
||||
if zlo is None or snap.zlo < zlo: zlo = snap.zlo
|
||||
if zhi is None or snap.zhi > zhi: zhi = snap.zhi
|
||||
return [xlo,ylo,zlo,xhi,yhi,zhi]
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
@ -997,7 +997,7 @@ class dump:
|
||||
def extra(self,arg):
|
||||
|
||||
# read bonds from bond dump file
|
||||
|
||||
|
||||
if type(arg) is types.StringType:
|
||||
try:
|
||||
f = open(arg,'r')
|
||||
@ -1017,7 +1017,7 @@ class dump:
|
||||
f.close()
|
||||
|
||||
# convert values to int and absolute value since can be negative types
|
||||
|
||||
|
||||
if oldnumeric: bondlist = np.zeros((nbonds,4),np.Int)
|
||||
else: bondlist = np.zeros((nbonds,4),np.int)
|
||||
ints = [abs(int(value)) for value in words]
|
||||
@ -1032,9 +1032,9 @@ class dump:
|
||||
self.bondlist = bondlist
|
||||
except:
|
||||
raise Exception("could not read from bond dump file")
|
||||
|
||||
|
||||
# request bonds from data object
|
||||
|
||||
|
||||
elif type(arg) is types.InstanceType and ".data" in str(arg.__class__):
|
||||
try:
|
||||
bondlist = []
|
||||
@ -1050,7 +1050,7 @@ class dump:
|
||||
raise Exception("could not extract bonds from data object")
|
||||
|
||||
# request tris/lines from cdata object
|
||||
|
||||
|
||||
elif type(arg) is types.InstanceType and ".cdata" in str(arg.__class__):
|
||||
try:
|
||||
tmp,tmp,tmp,tmp,tris,lines = arg.viz(0)
|
||||
@ -1064,7 +1064,7 @@ class dump:
|
||||
raise Exception("could not extract tris/lines from cdata object")
|
||||
|
||||
# request tris from mdump object
|
||||
|
||||
|
||||
elif type(arg) is types.InstanceType and ".mdump" in str(arg.__class__):
|
||||
try:
|
||||
self.triflag = 2
|
||||
@ -1074,7 +1074,7 @@ class dump:
|
||||
|
||||
else:
|
||||
raise Exception("unrecognized argument to dump.extra()")
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def compare_atom(self,a,b):
|
||||
@ -1083,7 +1083,7 @@ class dump:
|
||||
elif a[0] > b[0]:
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
return 0
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# one snapshot
|
||||
@ -1098,7 +1098,7 @@ class tselect:
|
||||
|
||||
def __init__(self,data):
|
||||
self.data = data
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def all(self):
|
||||
@ -1145,7 +1145,7 @@ class tselect:
|
||||
data.nselect -= 1
|
||||
data.aselect.all()
|
||||
print("%d snapshots selected out of %d" % (data.nselect,data.nsnaps))
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def test(self,teststr):
|
||||
@ -1191,7 +1191,7 @@ class aselect:
|
||||
data = self.data
|
||||
|
||||
# replace all $var with snap.atoms references and compile test string
|
||||
|
||||
|
||||
pattern = "\$\w*"
|
||||
list = re.findall(pattern,teststr)
|
||||
for item in list:
|
||||
|
||||
@ -851,7 +851,7 @@ class gl:
|
||||
ncolor = self.vizinfo.ntcolor
|
||||
for tri in self.tridraw:
|
||||
itype = int(tri[1])
|
||||
if itype > ncolor: raise StandardError("tri type too big")
|
||||
if itype > ncolor: raise Exception("tri type too big")
|
||||
red,green,blue = self.vizinfo.tcolor[itype]
|
||||
glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,[red,green,blue,1.0]);
|
||||
glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,self.shiny);
|
||||
@ -909,7 +909,7 @@ class gl:
|
||||
ymin >= ylo and ymax <= yhi and zmin >= zlo and zmax <= zhi:
|
||||
if bond[10] > bound: continue
|
||||
itype = int(bond[1])
|
||||
if itype > ncolor: raise StandardError("bond type too big")
|
||||
if itype > ncolor: raise Exception("bond type too big")
|
||||
red,green,blue = self.vizinfo.bcolor[itype]
|
||||
rad = self.vizinfo.brad[itype]
|
||||
glPushMatrix()
|
||||
@ -941,7 +941,7 @@ class gl:
|
||||
ymin >= ylo and ymax <= yhi and \
|
||||
zmin >= zlo and zmax <= zhi:
|
||||
itype = int(tri[1])
|
||||
if itype > ncolor: raise StandardError("tri type too big")
|
||||
if itype > ncolor: raise Exception("tri type too big")
|
||||
red,green,blue = self.vizinfo.tcolor[itype]
|
||||
glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,
|
||||
[red,green,blue,1.0]);
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
#
|
||||
# Copyright (2005) Sandia Corporation. Under the terms of Contract
|
||||
# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
# certain rights in this software. This software is distributed under
|
||||
# certain rights in this software. This software is distributed under
|
||||
# the GNU General Public License.
|
||||
|
||||
# for python3 compatibility
|
||||
@ -16,7 +16,7 @@ oneline = "Create plots via GnuPlot plotting program"
|
||||
docstr = """
|
||||
g = gnu() start up GnuPlot
|
||||
g.stop() shut down GnuPlot process
|
||||
|
||||
|
||||
g.plot(a) plot vector A against linear index
|
||||
g.plot(a,b) plot B against A
|
||||
g.plot(a,b,c,d,...) plot B against A, D against C, etc
|
||||
@ -35,14 +35,14 @@ g("plot 'file.dat' using 2:3 with lines") execute string in GnuPlot
|
||||
g.enter() enter GnuPlot shell
|
||||
gnuplot> plot sin(x) with lines type commands directly to GnuPlot
|
||||
gnuplot> exit, quit exit GnuPlot shell
|
||||
|
||||
|
||||
g.export("data",range(100),a,...) create file with columns of numbers
|
||||
|
||||
all vectors must be of equal length
|
||||
could plot from file with GnuPlot command: plot 'data' using 1:2 with lines
|
||||
|
||||
g.select(N) figure N becomes the current plot
|
||||
|
||||
|
||||
subsequent commands apply to this plot
|
||||
|
||||
g.hide(N) delete window for figure N
|
||||
@ -87,17 +87,18 @@ g.curve(N,'r') set color of curve N
|
||||
|
||||
# Imports and external programs
|
||||
|
||||
import types, os
|
||||
import os
|
||||
import sys
|
||||
|
||||
try: from DEFAULTS import PIZZA_GNUPLOT
|
||||
except: PIZZA_GNUPLOT = "gnuplot -p"
|
||||
except ImportError: PIZZA_GNUPLOT = "gnuplot -p"
|
||||
try: from DEFAULTS import PIZZA_GNUTERM
|
||||
except: PIZZA_GNUTERM = "x11"
|
||||
except ImportError: PIZZA_GNUTERM = "x11"
|
||||
|
||||
# Class definition
|
||||
|
||||
class gnu:
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def __init__(self):
|
||||
@ -105,7 +106,7 @@ class gnu:
|
||||
self.file = "tmp.gnu"
|
||||
self.figures = []
|
||||
self.select(1)
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def stop(self):
|
||||
@ -117,12 +118,15 @@ class gnu:
|
||||
def __call__(self,command):
|
||||
self.GNUPLOT.write(command + '\n')
|
||||
self.GNUPLOT.flush()
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def enter(self):
|
||||
while 1:
|
||||
command = raw_input("gnuplot> ")
|
||||
if sys.version_info[0] == 3:
|
||||
command = input("gnuplot> ")
|
||||
else:
|
||||
command = raw_input("gnuplot> ")
|
||||
if command == "quit" or command == "exit": return
|
||||
self.__call__(command)
|
||||
|
||||
@ -136,7 +140,7 @@ class gnu:
|
||||
self.export(file,linear,vectors[0])
|
||||
self.figures[self.current-1].ncurves = 1
|
||||
else:
|
||||
if len(vectors) % 2: raise StandardError("vectors must come in pairs")
|
||||
if len(vectors) % 2: raise Exception("vectors must come in pairs")
|
||||
for i in range(0,len(vectors),2):
|
||||
file = self.file + ".%d.%d" % (self.current,i/2+1)
|
||||
self.export(file,vectors[i],vectors[i+1])
|
||||
@ -155,7 +159,7 @@ class gnu:
|
||||
if i: partial_vecs.append(vec[:i])
|
||||
else: partial_vecs.append([0])
|
||||
self.plot(*partial_vecs)
|
||||
|
||||
|
||||
if n < 10: newfile = file + "000" + str(n)
|
||||
elif n < 100: newfile = file + "00" + str(n)
|
||||
elif n < 1000: newfile = file + "0" + str(n)
|
||||
@ -163,14 +167,14 @@ class gnu:
|
||||
|
||||
self.save(newfile)
|
||||
n += 1
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# write list of equal-length vectors to filename
|
||||
|
||||
def export(self,filename,*vectors):
|
||||
n = len(vectors[0])
|
||||
for vector in vectors:
|
||||
if len(vector) != n: raise StandardError("vectors must be same length")
|
||||
if len(vector) != n: raise Exception("vectors must be same length")
|
||||
f = open(filename,'w')
|
||||
nvec = len(vectors)
|
||||
for i in range(n):
|
||||
@ -204,7 +208,7 @@ class gnu:
|
||||
# do not continue until plot file is written out
|
||||
# else script could go forward and change data file
|
||||
# use tmp.done as semaphore to indicate plot is finished
|
||||
|
||||
|
||||
def save(self,file):
|
||||
self.__call__("set terminal postscript enhanced solid lw 2 color portrait")
|
||||
cmd = "set output '%s.eps'" % file
|
||||
@ -215,7 +219,7 @@ class gnu:
|
||||
while not os.path.exists("tmp.done"): continue
|
||||
self.__call__("set output")
|
||||
self.select(self.current)
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# restore default attributes by creating a new fig object
|
||||
|
||||
@ -224,7 +228,7 @@ class gnu:
|
||||
fig.ncurves = self.figures[self.current-1].ncurves
|
||||
self.figures[self.current-1] = fig
|
||||
self.draw()
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def aspect(self,value):
|
||||
@ -248,12 +252,12 @@ class gnu:
|
||||
else:
|
||||
self.figures[self.current-1].ylimit = (values[0],values[1])
|
||||
self.draw()
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def label(self,x,y,text):
|
||||
self.figures[self.current-1].labels.append((x,y,text))
|
||||
self.figures[self.current-1].nlabels += 1
|
||||
self.figures[self.current-1].nlabels += 1
|
||||
self.draw()
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
@ -262,7 +266,7 @@ class gnu:
|
||||
self.figures[self.current-1].nlabel = 0
|
||||
self.figures[self.current-1].labels = []
|
||||
self.draw()
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def title(self,*strings):
|
||||
@ -279,13 +283,13 @@ class gnu:
|
||||
def xtitle(self,label):
|
||||
self.figures[self.current-1].xtitle = label
|
||||
self.draw()
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def ytitle(self,label):
|
||||
self.figures[self.current-1].ytitle = label
|
||||
self.draw()
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def xlog(self):
|
||||
@ -294,7 +298,7 @@ class gnu:
|
||||
else:
|
||||
self.figures[self.current-1].xlog = 1
|
||||
self.draw()
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def ylog(self):
|
||||
@ -303,7 +307,7 @@ class gnu:
|
||||
else:
|
||||
self.figures[self.current-1].ylog = 1
|
||||
self.draw()
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def curve(self,num,color):
|
||||
@ -319,10 +323,10 @@ class gnu:
|
||||
def draw(self):
|
||||
fig = self.figures[self.current-1]
|
||||
if not fig.ncurves: return
|
||||
|
||||
|
||||
cmd = 'set size ratio ' + str(1.0/float(fig.aspect))
|
||||
self.__call__(cmd)
|
||||
|
||||
|
||||
cmd = 'set title ' + '"' + fig.title + '"'
|
||||
self.__call__(cmd)
|
||||
cmd = 'set xlabel ' + '"' + fig.xtitle + '"'
|
||||
@ -334,11 +338,11 @@ class gnu:
|
||||
else: self.__call__("unset logscale x")
|
||||
if fig.ylog: self.__call__("set logscale y")
|
||||
else: self.__call__("unset logscale y")
|
||||
if fig.xlimit:
|
||||
if fig.xlimit:
|
||||
cmd = 'set xr [' + str(fig.xlimit[0]) + ':' + str(fig.xlimit[1]) + ']'
|
||||
self.__call__(cmd)
|
||||
else: self.__call__("set xr [*:*]")
|
||||
if fig.ylimit:
|
||||
if fig.ylimit:
|
||||
cmd = 'set yr [' + str(fig.ylimit[0]) + ':' + str(fig.ylimit[1]) + ']'
|
||||
self.__call__(cmd)
|
||||
else: self.__call__("set yr [*:*]")
|
||||
@ -368,7 +372,7 @@ class figure:
|
||||
|
||||
def __init__(self):
|
||||
self.ncurves = 0
|
||||
self.colors = []
|
||||
self.colors = []
|
||||
self.title = ""
|
||||
self.xtitle = ""
|
||||
self.ytitle = ""
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
#
|
||||
# Copyright (2005) Sandia Corporation. Under the terms of Contract
|
||||
# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
# certain rights in this software. This software is distributed under
|
||||
# certain rights in this software. This software is distributed under
|
||||
# the GNU General Public License.
|
||||
|
||||
# for python3 compatibility
|
||||
@ -25,7 +25,7 @@ p = pdbfile("3CRO",d) read in single PDB file with snapshot data
|
||||
if only one 4-char file specified and it is not found,
|
||||
it will be downloaded from http://www.rcsb.org as 3CRO.pdb
|
||||
d arg is object with atom coordinates (dump, data)
|
||||
|
||||
|
||||
p.one() write all output as one big PDB file to tmp.pdb
|
||||
p.one("mine") write to mine.pdb
|
||||
p.many() write one PDB file per snapshot: tmp0000.pdb, ...
|
||||
@ -39,7 +39,7 @@ p.single(N,"new") write as new.pdb
|
||||
if one file in str arg and d: one new PDB file per snapshot
|
||||
using input PDB file as template
|
||||
multiple input PDB files with a d is not allowed
|
||||
|
||||
|
||||
index,time,flag = p.iterator(0)
|
||||
index,time,flag = p.iterator(1)
|
||||
|
||||
@ -68,7 +68,7 @@ index,time,flag = p.iterator(1)
|
||||
|
||||
# Imports and external programs
|
||||
|
||||
import sys, types, glob, urllib
|
||||
import sys, glob, urllib
|
||||
PY3 = sys.version_info[0] == 3
|
||||
|
||||
if PY3:
|
||||
@ -93,31 +93,31 @@ class pdbfile:
|
||||
elif len(args) == 2:
|
||||
filestr = args[0]
|
||||
self.data = args[1]
|
||||
else: raise StandardError("invalid args for pdb()")
|
||||
else: raise Exception("invalid args for pdb()")
|
||||
|
||||
# flist = full list of all PDB input file names
|
||||
# append .pdb if needed
|
||||
|
||||
|
||||
if filestr:
|
||||
list = filestr.split()
|
||||
flist = []
|
||||
for file in list:
|
||||
if '*' in file: flist += glob.glob(file)
|
||||
else: flist.append(file)
|
||||
for i in xrange(len(flist)):
|
||||
for i in range(len(flist)):
|
||||
if flist[i][-4:] != ".pdb": flist[i] += ".pdb"
|
||||
if len(flist) == 0:
|
||||
raise StandardError("no PDB file specified")
|
||||
raise Exception("no PDB file specified")
|
||||
self.files = flist
|
||||
else: self.files = []
|
||||
|
||||
if len(self.files) > 1 and self.data:
|
||||
raise StandardError("cannot use multiple PDB files with data object")
|
||||
raise Exception("cannot use multiple PDB files with data object")
|
||||
if len(self.files) == 0 and not self.data:
|
||||
raise StandardError("no input PDB file(s)")
|
||||
raise Exception("no input PDB file(s)")
|
||||
|
||||
# grab PDB file from http://rcsb.org if not a local file
|
||||
|
||||
|
||||
if len(self.files) == 1 and len(self.files[0]) == 8:
|
||||
try:
|
||||
open(self.files[0],'r').close()
|
||||
@ -127,7 +127,7 @@ class pdbfile:
|
||||
urllib.urlretrieve(fetchstr,self.files[0])
|
||||
|
||||
if self.data and len(self.files): self.read_template(self.files[0])
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# write a single large PDB file for concatenating all input data or files
|
||||
# if data exists:
|
||||
@ -145,7 +145,7 @@ class pdbfile:
|
||||
f = open(file,'w')
|
||||
|
||||
# use template PDB file with each snapshot
|
||||
|
||||
|
||||
if self.data:
|
||||
n = flag = 0
|
||||
while 1:
|
||||
@ -163,7 +163,7 @@ class pdbfile:
|
||||
print("END",file=f)
|
||||
print(file,end='')
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
f.close()
|
||||
print("\nwrote %d datasets to %s in PDB format" % (n,file))
|
||||
|
||||
@ -199,7 +199,7 @@ class pdbfile:
|
||||
f = open(file,'w')
|
||||
self.convert(f,which)
|
||||
f.close()
|
||||
|
||||
|
||||
print(time,end='')
|
||||
sys.stdout.flush()
|
||||
n += 1
|
||||
@ -216,13 +216,13 @@ class pdbfile:
|
||||
else:
|
||||
file = root + str(n)
|
||||
file += ".pdb"
|
||||
|
||||
|
||||
f = open(file,'w')
|
||||
f.write(open(infile,'r').read())
|
||||
f.close()
|
||||
print(file,end='')
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
n += 1
|
||||
|
||||
print("\nwrote %d datasets to %s*.pdb in PDB format" % (n,root))
|
||||
@ -249,7 +249,7 @@ class pdbfile:
|
||||
self.convert(f,which)
|
||||
else:
|
||||
f.write(open(self.files[time],'r').read())
|
||||
|
||||
|
||||
f.close()
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
@ -268,8 +268,8 @@ class pdbfile:
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# read a PDB file and store ATOM lines
|
||||
|
||||
def read_template(self,file):
|
||||
|
||||
def read_template(self,file):
|
||||
lines = open(file,'r').readlines()
|
||||
self.atomlines = {}
|
||||
for line in lines:
|
||||
|
||||
@ -79,7 +79,7 @@ class vizinfo:
|
||||
# if list of types has a 0, increment each type value
|
||||
|
||||
if 0 in ids:
|
||||
for i in xrange(len(ids)): ids[i] += 1
|
||||
for i in range(len(ids)): ids[i] += 1
|
||||
|
||||
# extend storage list if necessary
|
||||
# extend other arrays for same "which" so that gl::make_atom_calllist
|
||||
@ -109,7 +109,7 @@ class vizinfo:
|
||||
ntypes = len(ids)
|
||||
nrgbs = len(rgbs)
|
||||
|
||||
for i in xrange(ntypes):
|
||||
for i in range(ntypes):
|
||||
id = ids[i]
|
||||
|
||||
if rgbs[0] == "loop":
|
||||
@ -157,7 +157,7 @@ class vizinfo:
|
||||
# if list of types has a 0, increment each type value
|
||||
|
||||
if 0 in ids:
|
||||
for i in xrange(len(ids)): ids[i] += 1
|
||||
for i in range(len(ids)): ids[i] += 1
|
||||
|
||||
# extend storage list if necessary
|
||||
# extend other arrays for same "which" so that gl::make_atom_calllist
|
||||
@ -220,7 +220,7 @@ class vizinfo:
|
||||
# if list of types has a 0, increment each type value
|
||||
|
||||
if 0 in ids:
|
||||
for i in xrange(len(ids)): ids[i] += 1
|
||||
for i in range(len(ids)): ids[i] += 1
|
||||
|
||||
# extend storage list if necessary
|
||||
# extend other arrays for same "which" so that gl::make_atom_calllist
|
||||
@ -234,7 +234,7 @@ class vizinfo:
|
||||
# if list lengths match, set directly, else set types to 1st fill value
|
||||
|
||||
if len(fills) == len(ids):
|
||||
for i in xrange(len(ids)): self.tfill[ids[i]] = int(fills[i])
|
||||
for i in range(len(ids)): self.tfill[ids[i]] = int(fills[i])
|
||||
else:
|
||||
for id in ids: self.tfill[id] = int(fills[0])
|
||||
|
||||
|
||||
@ -45,17 +45,16 @@ v.debug([True|False]) display generated VMD script commands?
|
||||
|
||||
# Imports and external programs
|
||||
|
||||
import types, os
|
||||
import numpy
|
||||
import os
|
||||
|
||||
try: from DEFAULTS import PIZZA_VMDNAME
|
||||
except: PIZZA_VMDNAME = "vmd"
|
||||
except ImportError: PIZZA_VMDNAME = "vmd"
|
||||
try: from DEFAULTS import PIZZA_VMDDIR
|
||||
except: PIZZA_VMDDIR = "/usr/local/lib/vmd"
|
||||
except ImportError: PIZZA_VMDDIR = "/usr/local/lib/vmd"
|
||||
try: from DEFAULTS import PIZZA_VMDDEV
|
||||
except: PIZZA_VMDDEV = "win"
|
||||
except ImportError: PIZZA_VMDDEV = "win"
|
||||
try: from DEFAULTS import PIZZA_VMDARCH
|
||||
except: PIZZA_VMDARCH = "LINUXAMD64"
|
||||
except ImportError: PIZZA_VMDARCH = "LINUXAMD64"
|
||||
|
||||
# try these settings for a Mac
|
||||
#PIZZA_VMDNAME = "vmd"
|
||||
@ -64,7 +63,7 @@ except: PIZZA_VMDARCH = "LINUXAMD64"
|
||||
#PIZZA_VMDARCH = "MACOSXX86"
|
||||
|
||||
try: import pexpect
|
||||
except:
|
||||
except ImportError:
|
||||
print("pexpect from http://pypi.python.org/pypi/pexpect", \
|
||||
"is required for vmd tool")
|
||||
raise
|
||||
|
||||
@ -28,10 +28,10 @@ nsteps = int(sys.argv[3])
|
||||
compute = sys.argv[4]
|
||||
|
||||
me = 0
|
||||
# uncomment if running in parallel via Pypar
|
||||
#import pypar
|
||||
#me = pypar.rank()
|
||||
#nprocs = pypar.size()
|
||||
# uncomment this if running in parallel via mpi4py
|
||||
#from mpi4py import MPI
|
||||
#me = MPI.COMM_WORLD.Get_rank()
|
||||
#nprocs = MPI.COMM_WORLD.Get_size()
|
||||
|
||||
from lammps import lammps
|
||||
lmp = lammps()
|
||||
@ -57,7 +57,7 @@ if me == 0:
|
||||
gn = gnu()
|
||||
gn.plot(xaxis,yaxis)
|
||||
gn.xrange(0,nsteps)
|
||||
gn.title(compute,"Timestep","Temperature")
|
||||
gn.title(compute.replace('_', ' '),"Timestep","Temperature")
|
||||
|
||||
# run nfreq steps at a time w/out pre/post, query compute, refresh plot
|
||||
|
||||
@ -71,6 +71,5 @@ while ntimestep < nsteps:
|
||||
|
||||
lmp.command("run 0 pre no post yes")
|
||||
|
||||
# uncomment if running in parallel via Pypar
|
||||
# uncomment if running in parallel via mpi4py
|
||||
#print("Proc %d out of %d procs has" % (me,nprocs), lmp)
|
||||
#pypar.finalize()
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
|
||||
# Parallel syntax: mpirun -np 4 simple.py in.lammps
|
||||
# in.lammps = LAMMPS input script
|
||||
# also need to uncomment either Pypar or mpi4py sections below
|
||||
# also need to uncomment mpi4py sections below
|
||||
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
@ -27,11 +27,6 @@ infile = sys.argv[1]
|
||||
|
||||
me = 0
|
||||
|
||||
# uncomment this if running in parallel via Pypar
|
||||
#import pypar
|
||||
#me = pypar.rank()
|
||||
#nprocs = pypar.size()
|
||||
|
||||
# uncomment this if running in parallel via mpi4py
|
||||
#from mpi4py import MPI
|
||||
#me = MPI.COMM_WORLD.Get_rank()
|
||||
@ -133,8 +128,5 @@ lmp.reset_box([0,0,0],[10,10,8],0,0,0)
|
||||
boxlo,boxhi,xy,yz,xz,periodicity,box_change = lmp.extract_box()
|
||||
if me == 0: print("Box info",boxlo,boxhi,xy,yz,xz,periodicity,box_change)
|
||||
|
||||
# uncomment if running in parallel via Pypar
|
||||
#print("Proc %d out of %d procs has" % (me,nprocs), lmp)
|
||||
|
||||
# uncomment if running in parallel via mpi4py
|
||||
#print("Proc %d out of %d procs has" % (me,nprocs), lmp)
|
||||
|
||||
@ -28,10 +28,10 @@ nfreq = int(sys.argv[2])
|
||||
nsteps = int(sys.argv[3])
|
||||
|
||||
me = 0
|
||||
# uncomment if running in parallel via Pypar
|
||||
#import pypar
|
||||
#me = pypar.rank()
|
||||
#nprocs = pypar.size()
|
||||
# uncomment this if running in parallel via mpi4py
|
||||
#from mpi4py import MPI
|
||||
#me = MPI.COMM_WORLD.Get_rank()
|
||||
#nprocs = MPI.COMM_WORLD.Get_size()
|
||||
|
||||
from lammps import lammps
|
||||
lmp = lammps()
|
||||
@ -68,6 +68,5 @@ while ntimestep < nsteps:
|
||||
|
||||
lmp.command("run 0 pre no post yes")
|
||||
|
||||
# uncomment if running in parallel via Pypar
|
||||
# uncomment if running in parallel via mpi4py
|
||||
#print("Proc %d out of %d procs has" % (me,nprocs), lmp)
|
||||
#pypar.finalize()
|
||||
|
||||
@ -24,10 +24,10 @@ nfreq = int(sys.argv[2])
|
||||
nsteps = int(sys.argv[3])
|
||||
|
||||
me = 0
|
||||
# uncomment if running in parallel via Pypar
|
||||
#import pypar
|
||||
#me = pypar.rank()
|
||||
#nprocs = pypar.size()
|
||||
# uncomment this if running in parallel via mpi4py
|
||||
#from mpi4py import MPI
|
||||
#me = MPI.COMM_WORLD.Get_rank()
|
||||
#nprocs = MPI.COMM_WORLD.Get_size()
|
||||
|
||||
from lammps import lammps
|
||||
lmp = lammps()
|
||||
@ -83,6 +83,5 @@ while ntimestep < nsteps:
|
||||
|
||||
lmp.command("run 0 pre no post yes")
|
||||
|
||||
# uncomment if running in parallel via Pypar
|
||||
# uncomment if running in parallel via mpi4py
|
||||
#print("Proc %d out of %d procs has" % (me,nprocs), lmp)
|
||||
#pypar.finalize()
|
||||
|
||||
@ -24,10 +24,10 @@ nfreq = int(sys.argv[2])
|
||||
nsteps = int(sys.argv[3])
|
||||
|
||||
me = 0
|
||||
# uncomment if running in parallel via Pypar
|
||||
#import pypar
|
||||
#me = pypar.rank()
|
||||
#nprocs = pypar.size()
|
||||
# uncomment this if running in parallel via mpi4py
|
||||
#from mpi4py import MPI
|
||||
#me = MPI.COMM_WORLD.Get_rank()
|
||||
#nprocs = MPI.COMM_WORLD.Get_size()
|
||||
|
||||
from lammps import lammps
|
||||
lmp = lammps()
|
||||
@ -78,6 +78,5 @@ while ntimestep < nsteps:
|
||||
|
||||
lmp.command("run 0 pre no post yes")
|
||||
|
||||
# uncomment if running in parallel via Pypar
|
||||
# uncomment if running in parallel via mpi4py
|
||||
#print("Proc %d out of %d procs has" % (me,nprocs), lmp)
|
||||
#pypar.finalize()
|
||||
|
||||
@ -24,10 +24,10 @@ nfreq = int(sys.argv[2])
|
||||
nsteps = int(sys.argv[3])
|
||||
|
||||
me = 0
|
||||
# uncomment if running in parallel via Pypar
|
||||
#import pypar
|
||||
#me = pypar.rank()
|
||||
#nprocs = pypar.size()
|
||||
# uncomment this if running in parallel via mpi4py
|
||||
#from mpi4py import MPI
|
||||
#me = MPI.COMM_WORLD.Get_rank()
|
||||
#nprocs = MPI.COMM_WORLD.Get_size()
|
||||
|
||||
from lammps import lammps
|
||||
lmp = lammps()
|
||||
@ -87,6 +87,5 @@ if me == 0:
|
||||
#v.enter()
|
||||
#v.stop()
|
||||
|
||||
# uncomment if running in parallel via Pypar
|
||||
# uncomment if running in parallel via mpi4py
|
||||
#print("Proc %d out of %d procs has" % (me,nprocs), lmp)
|
||||
#pypar.finalize()
|
||||
|
||||
@ -9,9 +9,6 @@
|
||||
# compute-ID = ID of compute that calculates temperature
|
||||
# (or any other scalar quantity)
|
||||
|
||||
# IMPORTANT: this script cannot yet be run in parallel via Pypar,
|
||||
# because I can't seem to do a MPI-style broadcast in Pypar
|
||||
|
||||
from __future__ import print_function
|
||||
import sys,os,time
|
||||
sys.path.append("./pizza")
|
||||
@ -59,10 +56,6 @@ nfreq = int(sys.argv[2])
|
||||
compute = sys.argv[3]
|
||||
|
||||
me = 0
|
||||
# uncomment if running in parallel via Pypar
|
||||
#import pypar
|
||||
#me = pypar.rank()
|
||||
#nprocs = pypar.size()
|
||||
|
||||
from lammps import lammps
|
||||
lmp = lammps()
|
||||
@ -163,7 +156,3 @@ while 1:
|
||||
time.sleep(0.01)
|
||||
|
||||
lmp.command("run 0 pre no post yes")
|
||||
|
||||
# uncomment if running in parallel via Pypar
|
||||
#print("Proc %d out of %d procs has" % (me,nprocs), lmp)
|
||||
#pypar.finalize()
|
||||
|
||||
@ -9,9 +9,6 @@
|
||||
# compute-ID = ID of compute that calculates temperature
|
||||
# (or any other scalar quantity)
|
||||
|
||||
# IMPORTANT: this script cannot yet be run in parallel via Pypar,
|
||||
# because I can't seem to do a MPI-style broadcast in Pypar
|
||||
|
||||
from __future__ import print_function
|
||||
import sys,time
|
||||
sys.path.append("./pizza")
|
||||
@ -55,10 +52,6 @@ nfreq = int(sys.argv[2])
|
||||
compute = sys.argv[3]
|
||||
|
||||
me = 0
|
||||
# uncomment if running in parallel via Pypar
|
||||
#import pypar
|
||||
#me = pypar.rank()
|
||||
#nprocs = pypar.size()
|
||||
|
||||
from lammps import lammps
|
||||
lmp = lammps()
|
||||
@ -176,7 +169,3 @@ while 1:
|
||||
time.sleep(0.01)
|
||||
|
||||
lmp.command("run 0 pre no post yes")
|
||||
|
||||
# uncomment if running in parallel via Pypar
|
||||
#print("Proc %d out of %d procs has" % (me,nprocs), lmp)
|
||||
#pypar.finalize()
|
||||
|
||||
@ -9,9 +9,6 @@
|
||||
# compute-ID = ID of compute that calculates temperature
|
||||
# (or any other scalar quantity)
|
||||
|
||||
# IMPORTANT: this script cannot yet be run in parallel via Pypar,
|
||||
# because I can't seem to do a MPI-style broadcast in Pypar
|
||||
|
||||
from __future__ import print_function
|
||||
import sys,time
|
||||
sys.path.append("./pizza")
|
||||
@ -57,10 +54,6 @@ nfreq = int(sys.argv[2])
|
||||
compute = sys.argv[3]
|
||||
|
||||
me = 0
|
||||
# uncomment if running in parallel via Pypar
|
||||
#import pypar
|
||||
#me = pypar.rank()
|
||||
#nprocs = pypar.size()
|
||||
|
||||
from lammps import lammps
|
||||
lmp = lammps()
|
||||
@ -172,7 +165,3 @@ while 1:
|
||||
time.sleep(0.01)
|
||||
|
||||
lmp.command("run 0 pre no post yes")
|
||||
|
||||
# uncomment if running in parallel via Pypar
|
||||
#print("Proc %d out of %d procs has" % (me,nprocs), lmp)
|
||||
#pypar.finalize()
|
||||
|
||||
@ -9,9 +9,6 @@
|
||||
# compute-ID = ID of compute that calculates temperature
|
||||
# (or any other scalar quantity)
|
||||
|
||||
# IMPORTANT: this script cannot yet be run in parallel via Pypar,
|
||||
# because I can't seem to do a MPI-style broadcast in Pypar
|
||||
|
||||
from __future__ import print_function
|
||||
import sys,time
|
||||
sys.path.append("./pizza")
|
||||
@ -56,10 +53,6 @@ nfreq = int(sys.argv[2])
|
||||
compute = sys.argv[3]
|
||||
|
||||
me = 0
|
||||
# uncomment if running in parallel via Pypar
|
||||
#import pypar
|
||||
#me = pypar.rank()
|
||||
#nprocs = pypar.size()
|
||||
|
||||
from lammps import lammps
|
||||
lmp = lammps()
|
||||
@ -171,7 +164,3 @@ while 1:
|
||||
time.sleep(0.01)
|
||||
|
||||
lmp.command("run 0 pre no post yes")
|
||||
|
||||
# uncomment if running in parallel via Pypar
|
||||
#print("Proc %d out of %d procs has" % (me,nprocs), lmp)
|
||||
#pypar.finalize()
|
||||
|
||||
@ -25,18 +25,18 @@ def get_version_number():
|
||||
|
||||
vstring = None
|
||||
if version_info.major == 3 and version_info.minor >= 8:
|
||||
from importlib.metadata import version
|
||||
from importlib.metadata import version, PackageNotFoundError
|
||||
try:
|
||||
vstring = version('lammps')
|
||||
except: # lgtm [py/catch-base-exception]
|
||||
except PackageNotFoundError:
|
||||
# nothing to do, ignore
|
||||
pass
|
||||
|
||||
else:
|
||||
from pkg_resources import get_distribution
|
||||
from pkg_resources import get_distribution, DistributionNotFound
|
||||
try:
|
||||
vstring = get_distribution('lammps').version
|
||||
except: # lgtm [py/catch-base-exception]
|
||||
except DistributionNotFound:
|
||||
# nothing to do, ignore
|
||||
pass
|
||||
|
||||
|
||||
@ -11,8 +11,6 @@
|
||||
# See the README file in the top-level LAMMPS directory.
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
from ctypes import c_int, c_int32, c_int64
|
||||
|
||||
# various symbolic constants to be used
|
||||
# in certain calls to select data formats
|
||||
LAMMPS_AUTODETECT = None
|
||||
@ -42,6 +40,7 @@ LMP_VAR_ATOM = 1
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
def get_ctypes_int(size):
|
||||
from ctypes import c_int, c_int32, c_int64
|
||||
if size == 4:
|
||||
return c_int32
|
||||
elif size == 8:
|
||||
|
||||
@ -100,7 +100,7 @@ class lammps(object):
|
||||
|
||||
try:
|
||||
if ptr: self.lib = CDLL("",RTLD_GLOBAL)
|
||||
except: # lgtm [py/catch-base-exception]
|
||||
except OSError:
|
||||
self.lib = None
|
||||
|
||||
# load liblammps.so unless name is given
|
||||
@ -307,13 +307,12 @@ class lammps(object):
|
||||
from mpi4py import __version__ as mpi4py_version
|
||||
# tested to work with mpi4py versions 2 and 3
|
||||
self.has_mpi4py = mpi4py_version.split('.')[0] in ['2','3']
|
||||
except: # lgtm [py/catch-base-exception]
|
||||
except ImportError:
|
||||
# ignore failing import
|
||||
pass
|
||||
|
||||
# if no ptr provided, create an instance of LAMMPS
|
||||
# don't know how to pass an MPI communicator from PyPar
|
||||
# but we can pass an MPI communicator from mpi4py v2.0.0 and later
|
||||
# we can pass an MPI communicator from mpi4py v2.0.0 and later
|
||||
# no_mpi call lets LAMMPS use MPI_COMM_WORLD
|
||||
# cargs = array of C strings from args
|
||||
# if ptr, then are embedding Python in LAMMPS input script
|
||||
@ -1134,10 +1133,10 @@ class lammps(object):
|
||||
with ExceptionCheck(self):
|
||||
if dtype == 0:
|
||||
data = ((count*natoms)*c_int)()
|
||||
self.lib.lammps_gather_atoms(self.lmp,name,type,count,data)
|
||||
self.lib.lammps_gather_atoms(self.lmp,name,dtype,count,data)
|
||||
elif dtype == 1:
|
||||
data = ((count*natoms)*c_double)()
|
||||
self.lib.lammps_gather_atoms(self.lmp,name,type,count,data)
|
||||
self.lib.lammps_gather_atoms(self.lmp,name,dtype,count,data)
|
||||
else:
|
||||
return None
|
||||
return data
|
||||
@ -1150,10 +1149,10 @@ class lammps(object):
|
||||
with ExceptionCheck(self):
|
||||
if dtype == 0:
|
||||
data = ((count*natoms)*c_int)()
|
||||
self.lib.lammps_gather_atoms_concat(self.lmp,name,type,count,data)
|
||||
self.lib.lammps_gather_atoms_concat(self.lmp,name,dtype,count,data)
|
||||
elif dtype == 1:
|
||||
data = ((count*natoms)*c_double)()
|
||||
self.lib.lammps_gather_atoms_concat(self.lmp,name,type,count,data)
|
||||
self.lib.lammps_gather_atoms_concat(self.lmp,name,dtype,count,data)
|
||||
else:
|
||||
return None
|
||||
return data
|
||||
|
||||
@ -8,8 +8,14 @@ LAMMPS_PYTHON_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||
LAMMPS_DIR = os.path.dirname(LAMMPS_PYTHON_DIR)
|
||||
LAMMPS_SOURCE_DIR = os.path.join(LAMMPS_DIR, 'src')
|
||||
|
||||
if not os.path.exists(LAMMPS_SOURCE_DIR):
|
||||
# allows installing and building wheel from current directory
|
||||
LAMMPS_DIR = os.path.realpath(os.path.join(os.environ['PWD'], '..'))
|
||||
LAMMPS_SOURCE_DIR = os.path.join(LAMMPS_DIR, 'src')
|
||||
|
||||
def get_lammps_version():
|
||||
with open(os.path.join(LAMMPS_SOURCE_DIR, 'version.h'), 'r') as f:
|
||||
version_h_file = os.path.join(LAMMPS_SOURCE_DIR, 'version.h')
|
||||
with open(version_h_file, 'r') as f:
|
||||
line = f.readline()
|
||||
start_pos = line.find('"')+1
|
||||
end_pos = line.find('"', start_pos)
|
||||
|
||||
Reference in New Issue
Block a user