git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@4988 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -1,55 +0,0 @@
|
|||||||
#!/usr/local/bin/python
|
|
||||||
|
|
||||||
# combine multiple NEB dump files into 1 dump file
|
|
||||||
# Syntax: neb1.py dfinal itype dfile1 dfile2 ...
|
|
||||||
# dfinal = new combined dump file
|
|
||||||
# itype = atoms of this type are added to each snapshot
|
|
||||||
# dfile1, dfile2, ... = NEB output dump files from each replica
|
|
||||||
|
|
||||||
# assumes all N input files have same # of snapshots
|
|
||||||
# for each snapshot time:
|
|
||||||
# all dfile1 atoms are added to dfinal
|
|
||||||
# only atoms of itype in dfile2,...,dfileN are added to dfinal
|
|
||||||
|
|
||||||
import sys,os
|
|
||||||
path = os.environ["LAMMPS_PYTHON_TOOLS"]
|
|
||||||
sys.path.append(path)
|
|
||||||
from dump import dump
|
|
||||||
|
|
||||||
if len(sys.argv) < 5:
|
|
||||||
print "Syntax: neb1.py dfinal itype dfile1 dfile2 ..."
|
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
dfinal = sys.argv[1]
|
|
||||||
itype = int(sys.argv[2])
|
|
||||||
files = sys.argv[3:]
|
|
||||||
|
|
||||||
tstr = "$type == %d" % itype
|
|
||||||
|
|
||||||
ntotal = 0
|
|
||||||
d = []
|
|
||||||
for file in files:
|
|
||||||
one = dump(file)
|
|
||||||
one.sort()
|
|
||||||
if d:
|
|
||||||
one.aselect.test(tstr)
|
|
||||||
nnew = one.snaps[0].nselect
|
|
||||||
idvec = range(ntotal+1,ntotal+nnew+1)
|
|
||||||
one.setv("id",idvec)
|
|
||||||
ntotal += one.snaps[0].nselect
|
|
||||||
d.append(one)
|
|
||||||
|
|
||||||
if os.path.exists(dfinal): os.remove(dfinal)
|
|
||||||
|
|
||||||
times = d[0].time()
|
|
||||||
for time in times:
|
|
||||||
d[0].tselect.one(time)
|
|
||||||
i = d[0].findtime(time)
|
|
||||||
hold = d[0].snaps[i].nselect
|
|
||||||
d[0].snaps[i].nselect = ntotal
|
|
||||||
d[0].write(dfinal,1,1)
|
|
||||||
d[0].snaps[i].nselec = hold
|
|
||||||
for one in d[1:]:
|
|
||||||
one.tselect.one(time)
|
|
||||||
one.aselect.test(tstr)
|
|
||||||
one.write(dfinal,0,1)
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
#!/usr/local/bin/python
|
|
||||||
|
|
||||||
# combine final snapshots from multiple NEB dump files into 1 dump file
|
|
||||||
# Syntax: neb2.py dfinal dfile1 dfile2 ...
|
|
||||||
# dfinal = new combined dump file
|
|
||||||
# dfile1, dfile2, ... = NEB output dump files from each replica,
|
|
||||||
# in correct order
|
|
||||||
|
|
||||||
# for M replicas, final snapshots are renumbered in final file from 1 to M
|
|
||||||
|
|
||||||
import sys,os
|
|
||||||
path = os.environ["LAMMPS_PYTHON_TOOLS"]
|
|
||||||
sys.path.append(path)
|
|
||||||
from dump import dump
|
|
||||||
|
|
||||||
if len(sys.argv) < 5:
|
|
||||||
print "Syntax: neb2.py dfinal dfile1 dfile2 ..."
|
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
dfinal = sys.argv[1]
|
|
||||||
files = sys.argv[2:]
|
|
||||||
|
|
||||||
if os.path.exists(dfinal): os.remove(dfinal)
|
|
||||||
|
|
||||||
n = 1
|
|
||||||
for file in files:
|
|
||||||
one = dump(file)
|
|
||||||
t = one.time()
|
|
||||||
one.tselect.one(t[-1])
|
|
||||||
one.snaps[-1].time = n
|
|
||||||
one.write(dfinal,1,1)
|
|
||||||
n += 1
|
|
||||||
88
tools/python/neb_combine.py
Executable file
88
tools/python/neb_combine.py
Executable file
@ -0,0 +1,88 @@
|
|||||||
|
#!/usr/local/bin/python
|
||||||
|
|
||||||
|
# make new dump file by combining snapshots from multiple NEB replica dumps
|
||||||
|
# Syntax: neb_combine.py -switch arg(s) -switch arg(s) ...
|
||||||
|
# -o outfile = new dump file
|
||||||
|
# each snapshot has NEB atoms from all replicas
|
||||||
|
# -r dump1 dump2 ... = replica dump files of NEB atoms
|
||||||
|
# can be in any order
|
||||||
|
# -b dumpfile = background atoms (optional)
|
||||||
|
# first snapshot in this file used as static non-NEB atoms
|
||||||
|
|
||||||
|
import sys,os
|
||||||
|
path = os.environ["LAMMPS_PYTHON_TOOLS"]
|
||||||
|
sys.path.append(path)
|
||||||
|
from dump import dump
|
||||||
|
|
||||||
|
# parse args
|
||||||
|
|
||||||
|
outfile = ""
|
||||||
|
backfile = ""
|
||||||
|
rfiles = []
|
||||||
|
|
||||||
|
argv = sys.argv
|
||||||
|
iarg = 1
|
||||||
|
narg = len(argv)
|
||||||
|
while iarg < narg:
|
||||||
|
if argv[iarg] == "-o":
|
||||||
|
outfile = argv[iarg+1]
|
||||||
|
iarg += 2
|
||||||
|
elif argv[iarg] == "-b":
|
||||||
|
backfile = argv[iarg+1]
|
||||||
|
iarg += 2
|
||||||
|
elif argv[iarg] == "-r":
|
||||||
|
ilast = iarg + 1
|
||||||
|
while ilast < narg and argv[ilast][0] != '-': ilast += 1
|
||||||
|
rfiles = argv[iarg+1:ilast]
|
||||||
|
iarg = ilast
|
||||||
|
else: break
|
||||||
|
|
||||||
|
if iarg < narg or not outfile or not rfiles:
|
||||||
|
print "Syntax: neb_combine.py -o outfile -b backfile -r dump1 dump2 ..."
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
if os.path.exists(outfile): os.remove(outfile)
|
||||||
|
|
||||||
|
# ntotal = total atoms in each snapshot
|
||||||
|
# reset IDs of atoms in each NEB dump file
|
||||||
|
|
||||||
|
ntotal = 0
|
||||||
|
d = []
|
||||||
|
for file in rfiles:
|
||||||
|
one = dump(file)
|
||||||
|
nnew = one.snaps[0].nselect
|
||||||
|
idvec = range(ntotal+1,ntotal+nnew+1)
|
||||||
|
one.setv("id",idvec)
|
||||||
|
ntotal += nnew
|
||||||
|
d.append(one)
|
||||||
|
|
||||||
|
# nback = additional atoms in each snapshot
|
||||||
|
# reset IDs of atoms in background file
|
||||||
|
|
||||||
|
if backfile:
|
||||||
|
back = dump(backfile)
|
||||||
|
t = back.time()
|
||||||
|
back.tselect.one(t[0])
|
||||||
|
nback = back.snaps[0].nselect
|
||||||
|
idvec = range(ntotal+1,ntotal+nback+1)
|
||||||
|
back.setv("id",idvec)
|
||||||
|
else: nback = 0
|
||||||
|
ntotal += nback
|
||||||
|
|
||||||
|
# write out each snapshot
|
||||||
|
# natoms = ntotal, by overwriting nselect
|
||||||
|
# add background atoms if requested
|
||||||
|
|
||||||
|
times = d[0].time()
|
||||||
|
for time in times:
|
||||||
|
d[0].tselect.one(time)
|
||||||
|
i = d[0].findtime(time)
|
||||||
|
hold = d[0].snaps[i].nselect
|
||||||
|
d[0].snaps[i].nselect = ntotal
|
||||||
|
d[0].write(outfile,1,1)
|
||||||
|
d[0].snaps[i].nselect = hold
|
||||||
|
for one in d[1:]:
|
||||||
|
one.tselect.one(time)
|
||||||
|
one.write(outfile,0,1)
|
||||||
|
if backfile: back.write(outfile,0,1)
|
||||||
|
|
||||||
71
tools/python/neb_final.py
Executable file
71
tools/python/neb_final.py
Executable file
@ -0,0 +1,71 @@
|
|||||||
|
#!/usr/local/bin/python
|
||||||
|
|
||||||
|
# make new dump file from final snapshots from multiple NEB replica dumps
|
||||||
|
# Syntax: neb_final.py -switch arg(s) -switch arg(s) ...
|
||||||
|
# -o outfile = new dump file
|
||||||
|
# snapshots numbered 1 to M = # of replicas
|
||||||
|
# -r dump1 dump2 ... = replica dump files of NEB atoms
|
||||||
|
# must be in correct sequence
|
||||||
|
# -b dumpfile = background atoms (optional)
|
||||||
|
# last snapshot in this file used as static non-NEB atoms
|
||||||
|
|
||||||
|
import sys,os
|
||||||
|
path = os.environ["LAMMPS_PYTHON_TOOLS"]
|
||||||
|
sys.path.append(path)
|
||||||
|
from dump import dump
|
||||||
|
|
||||||
|
# parse args
|
||||||
|
|
||||||
|
outfile = ""
|
||||||
|
backfile = ""
|
||||||
|
rfiles = []
|
||||||
|
|
||||||
|
argv = sys.argv
|
||||||
|
iarg = 1
|
||||||
|
narg = len(argv)
|
||||||
|
while iarg < narg:
|
||||||
|
if argv[iarg] == "-o":
|
||||||
|
outfile = argv[iarg+1]
|
||||||
|
iarg += 2
|
||||||
|
elif argv[iarg] == "-b":
|
||||||
|
backfile = argv[iarg+1]
|
||||||
|
iarg += 2
|
||||||
|
elif argv[iarg] == "-r":
|
||||||
|
ilast = iarg + 1
|
||||||
|
while ilast < narg and argv[ilast][0] != '-': ilast += 1
|
||||||
|
rfiles = argv[iarg+1:ilast]
|
||||||
|
iarg = ilast
|
||||||
|
else: break
|
||||||
|
|
||||||
|
if iarg < narg or not outfile or not rfiles:
|
||||||
|
print "Syntax: neb_final.py -o outfile -b backfile -r dump1 dump2 ..."
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
if os.path.exists(outfile): os.remove(outfile)
|
||||||
|
|
||||||
|
# nback = additional atoms in each snapshot
|
||||||
|
|
||||||
|
if backfile:
|
||||||
|
back = dump(backfile)
|
||||||
|
t = back.time()
|
||||||
|
back.tselect.one(t[-1])
|
||||||
|
nback = back.snaps[-1].nselect
|
||||||
|
else: nback = 0
|
||||||
|
|
||||||
|
# write out each snapshot
|
||||||
|
# time = replica #
|
||||||
|
# natoms = ntotal, by overwriting nselect
|
||||||
|
# add background atoms if requested
|
||||||
|
|
||||||
|
n = 1
|
||||||
|
for file in rfiles:
|
||||||
|
neb = dump(file)
|
||||||
|
t = neb.time()
|
||||||
|
neb.tselect.one(t[-1])
|
||||||
|
hold = neb.snaps[-1].nselect
|
||||||
|
neb.snaps[-1].nselect = hold + nback
|
||||||
|
neb.snaps[-1].time = n
|
||||||
|
neb.write(outfile,1,1)
|
||||||
|
neb.snaps[-1].nselect = hold
|
||||||
|
if backfile: back.write(outfile,0,1)
|
||||||
|
n += 1
|
||||||
Reference in New Issue
Block a user