WorkDir = os.getcwd().strip() HomeDir = os.getenv('HOME') if os.getenv('IGOR_MODULES_PATH'): # STRING, private module DIR ModuDir = os.getenv('IGOR_MODULES_PATH') sys.path.append(ModuDir) # Append it into "sys.path" import gaussian_manage as gaum # Import private modules else: print('\n'+\ 'Error in getting grobal environment '+\ '\"$IGOR_MODULES_PATH\" which is the direction to private modules') os.exit() IOut = file('test.out', 'w') TmpGau = gaum.GauIO(IOut, fn=None, bugctrl=1) Form = '%5s%16.8f%16.8f%16.8f' counter = 0 for line in file(sys.argv[1]): counter += 1 if counter == 1 or counter == 2: pass else: tmpList = line.split() geomList = map(float, tmpList[1:]) geomList = [parse_atom_name(tmpList[0].lower())] + geomList TmpGau.GeomList.append(Form % tuple(geomList)) TmpGau.Charge = 0 TmpGau.Spin = 1 TmpGau.CartesianFlag = True
#!/usr/bin/python2.7 import gaussian_manage output = open("Output", "w") ff = gaussian_manage.GauIO(output, "NH3-force.gjf") ff.get_MachAndOpt() print(ff.MachineList) print(ff.OptionList) ff.get_TCSGR() print(ff.TitleList) print("Spin of this system is %5i" % ff.Spin) print("Charge of this system is %5i" % ff.Charge) for xx in ff.GeomList: print(xx) print(ff.RestList) ff.form_Inp()
import cp2k_manage as cp2k from my_io import print_Error from my_io import print_List from my_io import print_String else: print '\n'+\ 'Error in getting grobal environment '+\ '\"$IGOR_MODULES_PATH\" which is the direction to private modules' sys.exit(1) lf = file('../chage.log','w') p1 = re.compile(' *\d+[ \t]+[\d]+ *\n') os.listdir('%s' %WorkDir) for inp in os.listdir('./'): name, postfix = os.path.splitext(inp) tmpGau = gaum.GauIO(lf,inp,bugctrl=1) tmpGau.get_MachAndOpt() tmpGau.ctrl_Option() tmpGau.get_TCSGR() tmpCP2K = cp2k.CP2KIO(lf,fn=None,bugctrl=1) tmpCP2K.JobName = name tmpCP2K.InpuDict={} tmpCP2K.InpuDict['force_eval'] = dict(index=['force_eval'],content=[],rest='') ProjName = 'PROJECT %s' % name tmpCP2K.InpuDict['global'] = dict(index=['global'], content=[ProjName],rest='') Spin = 'MULTIPLICITY %i' % tmpGau.Spin Charge = 'CHARGE %i' % tmpGau.Charge tmpCP2K.InpuDict['dft'] = dict(index=['force_eval','dft'], content=[Spin,Charge],rest='')
def run_xDH(argv=None): from os import remove from os.path import isfile import sys import gaussian_manage as gaum # Import private modules import xDH_module as xDH # Import private modules from gaussian_manage import print_Error from gaussian_manage import print_List from gaussian_manage import print_String if argv is None: argv = sys.argv FileName = argv[-1] Path, FileName = os.path.split(os.path.abspath(FileName)) Name, Extension = os.path.splitext(FileName) __info__ = prepare_Info(__version__) if isfile('%s.xDH' % Name): # Open the output file iout = open('%s.xDH' % Name, 'a') else: iout = open('%s.xDH' % Name, 'w') print_List(iout, __info__, 2, '%s' % '-' * 76 + '==') # Writing the package info. print_String( iout, 'Start the job of "%s" using the Gaussian %02i package' % (FileName, __gaussian__), 2) MainIO = gaum.GauIO(iout, '%s%s' % (Name, extension), iprint) MainIO.KickOptionList = ['extraoverlay', 'oniom', 'opt'] # Disable options for xDH MainIO.get_MachAndOpt() MainIO.ctrl_Option() MainIO.get_TCSGR() OptClass = gaum.OptHandle(iout, MainIO, iprint) R5Class = xDH.xDH(iout, MainIO, OptClass, iprint, __gaussian__, syncinterval) #if not MainIO.CartesianFlag: # MainIO.collect_Geom() #DFTDClass = gaum.DFTD(iout,MainIO,OptClass,iprint) #if DFTDClass.PureDisp: # DFTDClass.DispClass.get_EngyReal() # Get classical disp. engy. # return iout.flush() # Flush the output if R5Class.TurnOn: #R5Class.gen_OptionList() EngyPos = iout.tell() iout.write('%s\n' % (' ' * 640)) print_String( iout, 'The following is the output for preparing KS orbitals and density ::', 2) iout.flush() # Flush the output R5Class.run_Job(sync=True) R5Class.collect_EngyReal(EngyPos) # Bring energy print to front if not OptClass.Opt: if iprint >= 1: print_String(iout, 'Job Type :: Single-Point Calculation', 1) else: os.remove('Job_%s.log' % MainIO.JobName) iout.write('=' * 80 + '\n') iout.write('**%s**\n' % (' ' * 76)) iout.write('** THE JOB OF \"%s\" IS DONE%s**\n' % (Name, (' ' * (54 - len(Name))))) iout.write('**%s**\n' % (' ' * 76)) iout.write('=' * 80 + '\n') #del DFTDClass del R5Class del OptClass del MainIO return else: print_Error(iout,'Geom. optimization is not supported'\ +' in this version') else: print_Error(iout, 'Normal Gaussian job does not need the xDH4Gau package') return