import updated version of tinker2lmp from @sjplimp. fix whitespace.

This commit is contained in:
Axel Kohlmeyer
2022-07-29 19:11:25 -04:00
parent 3a7a941cd5
commit 0dc9b31620

View File

@ -28,18 +28,16 @@ DELTA = 0.001 # delta on LAMMPS shrink-wrap box size, in Angstroms
# print an error message and exit
def error(txt=""):
if not txt:
print("Syntax: tinker2lmp.py -switch args ...")
print(" -xyz file")
print(" -amoeba file")
print(" -hippo file")
print(" -data file")
print(" -bitorsion file")
print(" -nopbc")
print(" -pbc xhi yhi zhi")
else: print("ERROR:",txt)
#sys.exit()
def error(txt="""
Syntax: tinker2lmp.py -switch args ...
-xyz file
-amoeba file
-hippo file
-data file
-bitorsion file
-nopbc
-pbc xhi yhi zhi"""):
sys.exit("ERROR: " + txt)
# read and store values from a Tinker xyz file
@ -477,9 +475,9 @@ class PRMfile(object):
elif (class2,class1) in bdict:
lmp3 = bdict[(class2,class1)]
else:
error("1st bond in BondAngle term not found: %d %d %d" % \
(class1,class2,class3))
# NOTE: just for debugging
#error("1st bond in BondAngle term not found: %d %d %d" % \
# (class1,class2,class3))
lmp3 = 0.0
if (class2,class3) in bdict:
@ -487,9 +485,9 @@ class PRMfile(object):
elif (class3,class2) in bdict:
lmp4 = bdict[(class3,class2)]
else:
error("2nd bond in BondAngle term not found: %d %d %d" % \
(class1,class2,class3))
# NOTE: just for debugging
#error("2nd bond in BondAngle term not found: %d %d %d" % \
# (class1,class2,class3))
lmp4 = 0.0
params.append((class1,class2,class3,lmp1,lmp2,lmp3,lmp4))
@ -1097,36 +1095,38 @@ for i,one in enumerate(alist):
elif len(params[3]) == 2:
nbonds,hcount = xyz.angle_hbond_count(atom1,atom2,atom3,lmptype,lmpmass)
if nbonds != 3:
print("Center angle atom has wrong bond count")
print(" angle atom IDs:",atom1,atom2,atom3)
print(" angle atom classes:",c1,c2,c3)
print(" Tinker FF file param options:",len(params[3]))
print(" Nbonds and hydrogen count:",nbonds,hcount)
#sys.exit() NOTE: allow this for now
#if nbonds != 3:
#print("Center angle atom has wrong bond count")
#print(" angle atom IDs:",atom1,atom2,atom3)
#print(" angle atom classes:",c1,c2,c3)
#print(" Tinker FF file param options:",len(params[3]))
#print(" Nbonds and hydrogen count:",nbonds,hcount)
# NOTE: allow this for now
#sys.exit()
if hcount == 0: which = 1
elif hcount == 1:
which = 2
m += 1
print("3-bond angle")
print(" angle atom IDs:",atom1,atom2,atom3)
print(" angle atom classes:",c1,c2,c3)
print(" Tinker FF file param options:",len(params[3]))
print(" Nbonds and hydrogen count:",nbonds,hcount)
print(" which:",which,m)
#print("3-bond angle")
#print(" angle atom IDs:",atom1,atom2,atom3)
#print(" angle atom classes:",c1,c2,c3)
#print(" Tinker FF file param options:",len(params[3]))
#print(" Nbonds and hydrogen count:",nbonds,hcount)
#print(" which:",which,m)
elif len(params[3]) == 3:
nbonds,hcount = xyz.angle_hbond_count(atom1,atom2,atom3,lmptype,lmpmass)
if nbonds != 4:
print("Center angle atom has wrong bond count")
print(" angle atom IDs:",atom1,atom2,atom3)
print(" angle atom classes:",c1,c2,c3)
print(" Tinker FF file param options:",len(params[3]))
print(" Nbonds and hydrogen count:",nbonds,hcount)
#sys.exit() NOTE: allow this for now
#if nbonds != 4:
#print("Center angle atom has wrong bond count")
#print(" angle atom IDs:",atom1,atom2,atom3)
#print(" angle atom classes:",c1,c2,c3)
#print(" Tinker FF file param options:",len(params[3]))
#print(" Nbonds and hydrogen count:",nbonds,hcount)
# NOTE: allow this for now
#sys.exit()
if hcount == 0: which = 1
elif hcount == 1:
@ -1171,7 +1171,8 @@ for itype in range(len(aparams)):
elif (c3,c2,c1) in badict:
n1,n2,r1,r2 = badict[(c3,c2,c1)]
else:
print("Bond-stretch angle triplet not found: %d %d %d" % (c1,c2,c3))
# NOTE: just for debugging
#print("Bond-stretch angle triplet not found: %d %d %d" % (c1,c2,c3))
n1,n2,r1,r2 = 4*[0.0]
baparams.append((n1,n2,r1,r2))
@ -1629,7 +1630,7 @@ print("Natoms =",natoms)
print("Ntypes =",ntypes)
print("Tinker XYZ types =",len(tink2lmp))
print("Tinker PRM types =",prm.ntypes)
#print "Tinker groups =",ngroups
#print("Tinker groups =",ngroups)
print("Nmol =",nmol)
print("Nbonds =",nbonds)
print("Nangles =",nangles)