Created
March 23, 2018 23:19
-
-
Save leelasd/4fd84ee9873cba6ecb116fdeb802ee44 to your computer and use it in GitHub Desktop.
Make Every internal degree in Z-matrix a variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
import os | |
import sys | |
fname = sys.argv[1] | |
def ZmatRead(filename='OPLS_TMA.z'): | |
zmat_part = [] | |
add_bonds = [] | |
for line in open(filename).readlines(): | |
if 'Geometry Variations follow' in line: break | |
zmat_part.append(line) | |
rline = False | |
for line in open(filename).readlines(): | |
if 'Additional Bonds follow' in line: rline =True | |
elif 'Harmonic Constraints follow' in line: break | |
if rline: add_bonds.append(line) | |
add_bonds = add_bonds[1:] | |
return(zmat_part,add_bonds) | |
def PrinNewZmat(zmat,abonds,fname): | |
ofile = open('NEW_'+fname,'w') | |
for line in zmat: ofile.write('%s'%line) | |
ofile.write(''' Geometry Variations | |
Variable Bonds follow (I4)''') | |
ofile.write('\n0004-%04d\n'%(len(zmat)-1)) | |
ofile.write(' Additional Bonds follow (2I4)\n') | |
for line in abonds: ofile.write('%s'%line) | |
ofile.write(''' | |
Variable Bond Angles follow (I4) | |
0005-%04d | |
Additional Bond Angles follow (3I4) | |
AUTO | |
Variable Dihedrals follow (3I4,F12.6) | |
0006-%04d | |
Additional Dihedrals follow (6I4) | |
AUTO | |
Domain Definitions follow (4I4) | |
Final blank line'''%(len(zmat)-1,len(zmat)-1)) | |
ofile.close() | |
return None | |
zmat, abonds = ZmatRead(fname) | |
PrinNewZmat(zmat,abonds,fname) | |
#print(len(zmat),len(abonds)) | |
#print(ZmatRead(fname)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment