Mod:Hunt Research Group:restart symbolic zmat

From wiki
Jump to navigation Jump to search

create an input file

  • extract the final geometry from the optimisation log file first
extract_structure.py filename (on your log file with without the .log extension)
this will give you a file filename.xyz
copy this to filename.inp and add the following information to the top of the file
number of atoms
atom at 0,0,0
the following example has 22 atoms and is centered at atom 16, then the coordinates follow
22 
16
   7  -0.047020  -1.332546   0.137334 
   7  -1.252302   0.460618  -0.104654 
   6  -1.629750   1.865930  -0.321180 

run the job

pos_restartzmat.py file.inp
output will look something like this
input file is emim_yp50_opt.inp
symbolic z-matrix output file is emim_yp50_opt_1.com
YOU MUST UPDATE THE FIELD AND CHECK CHARGE
YOU MUST MAKE THE FIXED ATOM xyz CONSTANTS
total number of atoms 19
center at atom 16
this will produce a file_1.com
CHECK THIS FILE
change the field it is set to x+50 at the moment
change the multiplicity and charge
make constants the fixed atom and dummy atoms marking the axes

altering the script

you may want to edit the lines in the script for the optimisation

pos_restartzmat.py

#!/opt/local/bin/python3
#
# pos_restartzmat.py
#
# python script to take cartesian coords from an electric field run and 
# produce a file to continue the run, ie no re-orientation
# in a FIRST step you will need to extract the last set of coordinates from your optimisation job
# use extract_structure.py
# to run the script type python pos_restartzmat.py input_file_name (without extension)
# input file has extension .inp and format
# no of atoms
# x where we center at atom x
# atomic symbol and coordinates
#
import sys
import os
import numpy as np
dir=os.getcwd()
#
if len(sys.argv) == 1:
  print('to run the script please type: python symb_restartzmat.py input_file_name \(without extension\)')
  sys.exit()
else:
  base=str(sys.argv[1])
  file=base+'.inp'
  out1=base+'_1.com'
  s='directory is '
  print('{0:}{1:}'.format(s,dir))
  s='input file is '
  print('{0:}{1:}'.format(s,file))
  s='symbolic z-matrix output file is '
  print('{0:}{1:}'.format(s,out1))
  s='YOU MUST UPDATE THE FIELD AND CHECK CHARGE'
  print('{0:}'.format(s))
  s='YOU MUST MAKE THE FIXED ATOM xyz CONSTANTS'
  print('{0:}'.format(s))
#close if
#
# set some defaults
atomtotal=0
atomcenter=0
nz1=0
nz2=0
nz3=0
col_atom=[]
col_x=[]
col_y=[]
col_z=[]
p=4.0

# open file and read lines one by one
f=open(file,"r")

#total number of atoms
line =f.readline()
#print('{0:}'.format(line))
atomtotal=int(line.rstrip())
atomtotal=atomtotal-3
s='total number of atoms '
print('{0:}{1:}'.format(s,atomtotal))

#center at atom
line =f.readline()
#print('{0:}'.format(line))
atomcenter=int(line.rstrip())
s='center at atom '
print('{0:}{1:}'.format(s,atomcenter))

#read in atoms and coordinates
mx=np.zeros(atomtotal,dtype=float)
my=np.zeros(atomtotal,dtype=float)
mz=np.zeros(atomtotal,dtype=float)
n=0
while n < atomtotal :
  line =f.readline()
#  print('{0:}'.format(line))
  a1,b1,c1,d1=line.rstrip().split()
  col_atom.append(a1)
  col_x.append(float(b1))
  col_y.append(float(c1))
  col_z.append(float(d1))
  n=n+1
#close while
#turn list into a numpty array
mx=np.array(col_x)
my=np.array(col_y)
mz=np.array(col_z)
#print(ny)

# write to the _symb.xyz file
c=open(out1,"w")
s="%nprocshared=32\n%mem=58GB\n"
c.write('{0:}'.format(s))
s='%chk='+base+'_1.chk\n'
c.write('{0:}'.format(s))
s="#b3lyp/6-311+g(d,p) int=ultrafine scf=conver=10 empiricaldispersion=gd3bj \n "
c.write('{0:}'.format(s))
s1="opt=(z-matrix,notrust,maxstep=60) field=x+50 "
s2="nosymm pop=(full,nbo7,dipole,chelpg) prop \n \n "
c.write('{0:}{1:}'.format(s1,s2))
s="Title Card Required \n\n"
c.write('{0:}'.format(s))
charge=-1
multiplicity=1
c.write('{0:} {1:} \n'.format(charge,multiplicity))
#
#write out z-matrix
n=0
while n < atomtotal:
  m=n+1
  c.write('{0:}  0  x{1:<4} y{2:<4}  z{3:<4} \n'.format(col_atom[n],m,m,m))
  n=n+1
#close while
m=n+1
c.write('{0:}  0  x{1:<4} y{2:<4}  z{3:<4} \n'.format('Xx',m,m,m))
m=n+2
c.write('{0:}  0  x{1:<4} y{2:<4}  z{3:<4} \n'.format('Xy',m,m,m))
m=n+3
c.write('{0:}  0  x{1:<4} y{2:<4}  z{3:<4} \n'.format('Xz',m,m,m))
c.write('\n'.format())

#write out variables 
n=0
while n < atomtotal:
  m=n+1
  c.write('  x{0:<3}={1:>9.6f} \n  y{2:<3}={3:9.6f} \n  z{4:<3}={5:9.6f} \n'.format(m,mx[n],m,my[n],m,mz[n]))
  n=n + 1
#close while
c.write('\n'.format())
m=n+1
c.write('  x{0:<3}={1:>9.6f} \n  y{2:<3}={3:9.6f} \n  z{4:<3}={5:9.6f} \n'.format(m,p,m,0.0,m,0.0))
m=n+2
c.write('  x{0:<3}={1:>9.6f} \n  y{2:<3}={3:9.6f} \n  z{4:<3}={5:9.6f} \n'.format(m,0.0,m,p,m,0.0))
m=n+3
c.write('  x{0:<3}={1:>9.6f} \n  y{2:<3}={3:9.6f} \n  z{4:<3}={5:9.6f} \n'.format(m,0.0,m,0.0,m,p))
c.write('\n\n'.format())

# close all open files
f.close()
c.close()
#