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