File: neb_final.py

package info (click to toggle)
lammps 20250204%2Bdfsg.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 474,368 kB
  • sloc: cpp: 1,060,070; python: 27,785; ansic: 8,956; f90: 7,254; sh: 6,044; perl: 4,171; fortran: 2,442; xml: 1,714; makefile: 1,352; objc: 238; lisp: 188; yacc: 58; csh: 16; awk: 14; tcl: 6; javascript: 2
file content (71 lines) | stat: -rwxr-xr-x 1,811 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env 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
# Author:  Steve Plimpton (Sandia), sjplimp at gmail.com

import sys,os
path = os.environ["LAMMPS_PYTHON_TOOLS"]
sys.path.insert(1,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:
  sys.exit("Syntax: neb_final.py -o outfile -b backfile -r dump1 dump2 ...")

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