Beispiel #1
0
#!/usr/bin/python

#import argparse - only available in version 2.7
import sys
import theo_header, lib_struc

theo_header.print_header('Openbabel wrapper - conversion of coordinate files')

print("""\
Usage: molecular structure conversion based on the openbabel package
     - increased support for Columbus (col) and Tinker (txyz2) formats
     - velocity conversion Newton-X (vnx) and Tinker (vtxyz)
     
Syntax: babel.py <intype> <infile> <outtype> <outfile>
       e.g. babel.py tmol coord xyz coord.xyz
""")

if len(sys.argv) < 4+1:
    print("""  Supported file types:
    col -- Columbus and Newton-X format
    colr -- Columbus format, atoms reordered
    txyz2 -- Tinker format with reading possibility (verify the atom types in the output)
    vnx -- veloctiy (Newton-X format)
    ntxyz -- velocity (Tinker format)
  additionally all formats from openbabel are included
    type 'babel -H' for a complete list""")
    
    print('\nFour arguments required.')
    sys.exit()
    
(intype,infile,outtype,outfile) = sys.argv[1:]
Beispiel #2
0
#!/usr/bin/python
"""
Driver script for analyzing a set of NO files.
"""

import theo_header, lib_sden, input_options
import sys

theo_header.print_header('NO file analysis')


def ihelp():
    print(" analyze_NOs.py <MO_file> [<NO_file_ref> <NO_file2> ...]\n")
    print(" Command line options:")
    print("  -h, -H, -help: print this help")
    print("  -ifile [dens_ana.in]: name of the input file")
    exit(0)


#--------------------------------------------------------------------------#
# Input options
#--------------------------------------------------------------------------#

tmp = sys.argv.pop(0)

no_files = []
ifile = 'dens_ana.in'
while len(sys.argv) > 0:
    arg = sys.argv.pop(0)
    if arg in ["-h", "-H", "-help"]:
        ihelp()
Beispiel #3
0
        if xunit.lower() == 'ev':
            xlist = self.en
            pylab.xlabel('Energy (eV)')
            xfac = 0.
        elif xunit.lower() == 'nm':
            xlist = self.lam
            #pylab.xlabel(r'$\lambda$') not working ...
            pylab.xlabel('Wavelength (nm)')
            xfac = units.energy['nm'] * units.energy['eV']
        else:
            raise error_handler.ElseError(xunit, 'xunit')
        pylab.ylabel('Absorption (norm.)')

        pylab.plot(xlist, self.spec, 'k-')

        for A, x0 in self.sticks:
            pylab.plot([xfac / x0, xfac / x0], [0., A], 'r-')

        pylab.savefig(pname)

        if lvprt >= 1:
            print("Spectrum file %s created." % pname)


if __name__ == '__main__':
    theo_header.print_header('Create a convoluted spectrum')

    sopt = spec_options('spectrum.in')
    sopt.spec_input()

    sopt.make_spec()
Beispiel #4
0
        elif jopt['spec'] == 'frontier':
            moc = mocollf(jopt['en_ind'], mldfile)
        elif jopt['spec'] == 'occ':
            moc = mocoll_occ(jopt['occmin'], jopt['occmax'], mldfile)
        else:
            raise error_handler.ElseError(self['spec'], 'spec')
        
        moout = mo_output_jmol(moc, jopt)
        moout.output(jo)
        
        moh = mo_output_html(moc, jopt)
        moh.output(ho)
        
        mol = mo_output_tex(moc, jopt)
        mol.output(lo)
            
    jo.post(lvprt=1)
    if mldfiles == [""]:
        print("  -> Open the Molden-file in jmol and execute the commands contained in this file.")
    else:
        print("  -> Now simply run \"jmol -n %s\" to plot all the orbitals.\n"%jo.name)
    ho.post(lvprt=1)
    print("  -> View in browser.")
    lo.post(lvprt=1)
    print("  -> Compile with pdflatex (or adjust first).")

if __name__=='__main__':
    import sys

    theo_header.print_header('Orbital plotting in Jmol')
    run()
Beispiel #5
0
            pylab.colorbar()

        pylab.axis('off')
        pylab.savefig('axes.%s' % self['output_format'], dpi=self['plot_dpi'])

        tel = '<img src="axes.%s", border="1" width="200">\n' % self[
            'output_format']
        tel += '<br>Axes / Scale'
        htable.add_el(tel)

        hfile.write(htable.ret_table())
        hfile.post()

        print(
            " HTML file %s containing the electron-hole correlation plots written."
            % hfname)


def run_plot():
    Oopt = OmFrag_options('plot.in')
    Oopt.read_OmFrag()

    Oopt.OmFrag_input()

    Oopt.plot()


if __name__ == '__main__':
    theo_header.print_header('Plot Omega matrices')

    run_plot()
Beispiel #6
0
#!/usr/bin/python
"""
Check if a file can be read by cclib and if all the required information is available.
"""

import theo_header, cclib_interface, input_options, error_handler
import sys

theo_header.print_header('Check cclib')

print("cc_check.py <logfile>")
print("Check if a logfile can be parsed with cclib")

try:
    logfile = sys.argv[1]
except IndexError:
    raise error_handler.MsgError("Please enter the name of the logfile!")

ioptions = input_options.dens_ana_options(ifile=None, check_init=False)
ioptions['rtype'] = 'cclib'
ioptions['rfile'] = logfile

ccparser = cclib_interface.file_parser_cclib(ioptions)
errcode = ccparser.check()

if errcode <= 1:
    print("\n %s can be parsed by using rtype='cclib' in dens_ana.in." %
          logfile)
    if errcode == 0:
        print(" Conversion to Molden format also possible")
    else:
Beispiel #7
0
#!/usr/bin/python
"""
Driver script for transition density matrix analysis.
"""

import theo_header, lib_tden, lib_exciton, input_options, error_handler
import os, sys, time

theo_header.print_header('Transition density matrix analysis')
(tc, tt) = (time.clock(), time.time())

def ihelp():
    print(" analyze_tden.py")
    print(" Command line options:")
    print("  -h, -H, -help: print this help")
    print("  -ifile, -f [dens_ana.in]: name of the input file")
    exit(0)

#--------------------------------------------------------------------------#        
# Parsing and computations
#--------------------------------------------------------------------------# 

ifile = 'dens_ana.in'

arg=sys.argv.pop(0)
while len(sys.argv)>0:
    arg = sys.argv.pop(0)
    if arg in ["-h", "-H", "-help"]:
        ihelp()
    elif arg == '-ifile' or arg == '-f':
        ifile = sys.argv.pop(0)
Beispiel #8
0
#!/usr/bin/python

import os, sys
import numpy
import theo_header, lib_mo, error_handler

theo_header.print_header('Extract molden files')

print("""\
usage: Extract the hole/particle components out of a molden file
syntax: extract_molden.py <mo_file1> [<mo_file2> ...]
options: -ene          - interpret energies as occupations
         -thresh=0.001 - threshold for print-out
""")

class extract_mld:
    def __init__(self, thresh=0.001, rd_ene=False, decompose=True):
        self.thresh = thresh # threshold for print-out into output file
        self.rd_ene = rd_ene # interpret energies as occupations
        self.decompose = decompose # decompose (for NDOs or NTOs)
        
        self.stdir = os.getcwd()
        
    def extract(self, mo_file):
        print("Extracting %s ..."%mo_file)
        os.chdir(self.stdir)
        
        mos = lib_mo.MO_set_molden(file=mo_file)
        mos.read()
        
        orb_dir = "%s.dir"%mo_file
Beispiel #9
0
#!/usr/bin/python
"""
Driver script for transition density matrix analysis.
"""

import theo_header, lib_tden, lib_exciton, input_options, error_handler
import os, sys, time

theo_header.print_header('Transition density matrix analysis')
(tc, tt) = (time.clock(), time.time())


def ihelp():
    print(" analyze_tden.py")
    print(" Command line options:")
    print("  -h, -H, -help: print this help")
    print("  -ifile, -f [dens_ana.in]: name of the input file")
    exit(0)


#--------------------------------------------------------------------------#
# Parsing and computations
#--------------------------------------------------------------------------#

ifile = 'dens_ana.in'

arg = sys.argv.pop(0)
while len(sys.argv) > 0:
    arg = sys.argv.pop(0)
    if arg in ["-h", "-H", "-help"]:
        ihelp()
Beispiel #10
0
#            pylab.figure(figsize=(2,2))
            
            pylab.pcolor(numpy.zeros([1, 1]), cmap=pylab.get_cmap(name=self['cmap']), vmin=0., vmax=self.maxOm)
            
            pylab.colorbar()
            
        pylab.axis('off')            
        pylab.savefig('axes.%s'%self['output_format'], dpi=self['plot_dpi'])
            
        tel  = '<img src="axes.%s", border="1" width="200">\n'%self['output_format']
        tel += '<br>Axes / Scale'
        htable.add_el(tel)
            
        hfile.write(htable.ret_table())    
        hfile.post()
        
        print(" HTML file %s containing the electron-hole correlation plots written."%hfname)

def run_plot():
    Oopt = OmFrag_options('plot.in')        
    Oopt.read_OmFrag()
    
    Oopt.OmFrag_input()
    
    Oopt.plot()
    
    
if __name__ == '__main__':
    theo_header.print_header('Plot Omega matrices')

    run_plot()
Beispiel #11
0
                
        if xunit.lower() == 'ev':
            xlist = self.en
            pylab.xlabel('Energy (eV)')
            xfac = 0.
        elif xunit.lower() == 'nm':
            xlist = self.lam
            #pylab.xlabel(r'$\lambda$') not working ...
            pylab.xlabel('Wavelength (nm)')
            xfac = units.energy['nm'] * units.energy['eV']
        else:
            raise error_handler.ElseError(xunit, 'xunit')
        pylab.ylabel('Absorption (norm.)')
        
        pylab.plot(xlist, self.spec, 'k-')
        
        for A,x0 in self.sticks:
            pylab.plot([xfac/x0, xfac/x0], [0., A], 'r-')
        
        pylab.savefig(pname)
        
        if lvprt >= 1:
            print("Spectrum file %s created."%pname)
    
if __name__ == '__main__':
    theo_header.print_header('Create a convoluted spectrum')
    
    sopt = spec_options('spectrum.in')
    sopt.spec_input()
    
    sopt.make_spec()
Beispiel #12
0
#!/usr/bin/python

#import argparse - only available in version 2.7
import sys
import theo_header, lib_struc

theo_header.print_header('Openbabel wrapper - conversion of coordinate files')

print("""\
Usage: molecular structure conversion based on the openbabel package
     - increased support for Columbus (col) and Tinker (txyz2) formats
     - velocity conversion Newton-X (vnx) and Tinker (vtxyz)
     
Syntax: babel.py <intype> <infile> <outtype> <outfile>
       e.g. babel.py tmol coord xyz coord.xyz
""")

if len(sys.argv) < 4 + 1:
    print("""  Supported file types:
    col -- Columbus and Newton-X format
    colr -- Columbus format, atoms reordered
    txyz2 -- Tinker format with reading possibility (verify the atom types in the output)
    vnx -- veloctiy (Newton-X format)
    ntxyz -- velocity (Tinker format)
  additionally all formats from openbabel are included
    type 'babel -H' for a complete list""")

    print('\nFour arguments required.')
    sys.exit()

(intype, infile, outtype, outfile) = sys.argv[1:]
Beispiel #13
0
                
    if (not dotden) and (wopt['rtype'] in ['nos', 'colmcscf', 'rassi']):
        if wopt.ret_yn('Analysis of state density matrices?', True):
            wopt.read_yn('Print out Mulliken populations?', 'pop_ana', True)
            if wopt['rtype'] in ['nos']:
                if wopt.read_yn('Compute number of unpaired electrons?', 'unpaired_ana', True):
                    wopt['prop_list'] += ['nu', 'nunl']
            wopt.AD_ana()
            wopt.BO_ana()
            wopt.ddm_parse()
            
    wopt.write_prop_list()
    
    # Program specific input
    if wopt['rtype'] in ['colmrci']:
        wopt.get_ncore()
    elif wopt['rtype'] in ['rassi']:
        wopt.get_rassi_list()
    
    wopt.output_options()
    
    wopt.flush(lvprt=1, choose_file=True)
    
    if wopt['rtype'] == 'colmcscf':
        print("\nNow, please run write_den.bash to prepare the MCSCF density matrices!")
    
if __name__ == '__main__':
    theo_header.print_header('Input generation')

    run_theoinp()
Beispiel #14
0
        self['fformat'] = '%.2f'


def run_table():
    infilen = 'table.in'

    topt = write_table_options(infilen)
    ropt = read_table_options(infilen, False)

    if ropt.init == 0:
        copy = topt.ret_yn(
            'Found %s. Use this file directly rather than performing an interactive input?'
            % infilen, True)
    else:
        copy = False

    if copy:
        topt.copy(ropt)
    else:
        topt.table_input()

    topt.write_table()

    if not copy:
        topt.flush()


if __name__ == '__main__':
    theo_header.print_header('Table conversion')

    run_table()
Beispiel #15
0
        self['doplots']=True
        self['dotxt']=True
        
def run_plot():
    infilen = 'graph.in'
    
    popt = write_plot_options(infilen)
    ropt = read_plot_options(infilen, False)

    if ropt.init == 0:
        copy = popt.ret_yn('Found %s. Use this file directly rather than performing an interactive input?'%infilen, True)
    else:
        copy = False    
    
    if copy:
        popt.copy(ropt)
    else:        
        popt.plot_input()
    
    popt.read_data()
    
    if popt['doplots']: popt.plot()
    if popt['dotxt']:   popt.txt_files()
    
    if not copy:
        popt.flush()
    
if __name__ == '__main__':
    theo_header.print_header('Graph plotting')
    
    run_plot()
Beispiel #16
0
def run_plot():
    infilen = 'graph.in'

    popt = write_plot_options(infilen)
    ropt = read_plot_options(infilen, False)

    if ropt.init == 0:
        copy = popt.ret_yn(
            'Found %s. Use this file directly rather than performing an interactive input?'
            % infilen, True)
    else:
        copy = False

    if copy:
        popt.copy(ropt)
    else:
        popt.plot_input()

    popt.read_data()

    if popt['doplots']: popt.plot()
    if popt['dotxt']: popt.txt_files()

    if not copy:
        popt.flush()


if __name__ == '__main__':
    theo_header.print_header('Graph plotting')

    run_plot()
Beispiel #17
0
        self['output_format'] = 'latex'
        self['lformula'] = False
        self['prop_list'] = []
        self['fname'] = None
        self['fformat'] = '%.2f'

def run_table():
    infilen = 'table.in'
    
    topt = write_table_options(infilen)    
    ropt = read_table_options(infilen, False)
    
    if ropt.init == 0:
        copy = topt.ret_yn('Found %s. Use this file directly rather than performing an interactive input?'%infilen, True)
    else:
        copy = False    
    
    if copy:
        topt.copy(ropt)
    else:
        topt.table_input()    
    
    topt.write_table()
    
    if not copy:
        topt.flush()

if __name__ == '__main__':
    theo_header.print_header('Table conversion')
    
    run_table()
Beispiel #18
0
#!/usr/bin/python
"""
Driver script for analyzing a set of NO files.
"""

import theo_header, lib_sden, input_options
import os, sys

theo_header.print_header('State density matrix analysis')


def ihelp():
    print(" analyze_sden.py\n")
    print(" Command line options:")
    print("  -h, -H, -help: print this help")
    print("  -ifile, -f  [dens_ana.in]: name of the input file")
    exit(0)


#--------------------------------------------------------------------------#
# Input options
#--------------------------------------------------------------------------#

tmp = sys.argv.pop(0)

ifile = 'dens_ana.in'
while len(sys.argv) > 0:
    arg = sys.argv.pop(0)
    if arg in ["-h", "-H", "-help"]:
        ihelp()
    elif arg == '-ifile' or arg == '-f':
Beispiel #19
0
#!/usr/bin/python
"""
Driver script for analyzing a set of NO files.
"""

import theo_header, lib_sden, input_options
import os, sys

theo_header.print_header('State density matrix analysis')

def ihelp():
    print(" analyze_sden.py\n")
    print(" Command line options:")
    print("  -h, -H, -help: print this help")
    print("  -ifile, -f  [dens_ana.in]: name of the input file")
    exit(0)

#--------------------------------------------------------------------------#        
# Input options
#--------------------------------------------------------------------------# 

tmp = sys.argv.pop(0)

ifile = 'dens_ana.in'
while len(sys.argv)>0:
    arg = sys.argv.pop(0)
    if arg in ["-h", "-H", "-help"]:
        ihelp()
    elif arg == '-ifile' or arg == '-f':
        ifile = sys.argv.pop(0)
Beispiel #20
0
#!/usr/bin/python
"""
Convert a log-file to Molden format with the help of cclib.
"""

import theo_header, cclib_interface, input_options, error_handler, lib_mo
import sys

theo_header.print_header('cc2molden')

print("cc2molden.py <logfile>")
print("Convert a log-file to Molden format with the help of cclib.")

try:
    logfile = sys.argv[1]
except IndexError:
    raise error_handler.MsgError("Please enter the name of the logfile!")

ioptions = input_options.dens_ana_options(ifile=None, check_init=False)
ioptions['rtype'] = 'cclib'
ioptions['rfile'] = logfile

ccparser = cclib_interface.file_parser_cclib(ioptions)

errcode = ccparser.check()
if errcode > 0:
    print(" Conversion to Molden format not possible!")
    print(" %s does not contain all required information"%logfile)
else:
    mos = ccparser.read_mos()
    mos.write_molden_file(fname="cc.mld")
Beispiel #21
0
#!/usr/bin/python
"""
Check if a file can be read by cclib and if all the required information is available.
"""

import theo_header, cclib_interface, input_options, error_handler
import sys

theo_header.print_header('Check cclib')

print("cc_check.py <logfile>")
print("Check if a logfile can be parsed with cclib")

try:
    logfile = sys.argv[1]
except IndexError:
    raise error_handler.MsgError("Please enter the name of the logfile!")

ioptions = input_options.dens_ana_options(ifile=None, check_init=False)
ioptions['rtype'] = 'cclib'
ioptions['rfile'] = logfile

ccparser = cclib_interface.file_parser_cclib(ioptions)
errcode = ccparser.check()

if errcode <= 1:
    print("\n %s can be parsed by using rtype='cclib' in dens_ana.in."%logfile)
    if errcode == 0:
        print(" Conversion to Molden format also possible")
    else:
        print(" But conversion to Molden format is not possible")
Beispiel #22
0
#!/usr/bin/python

import os, sys
import numpy
import theo_header, lib_mo, error_handler

theo_header.print_header('Extract molden files')

print("""\
usage: Extract the hole/particle components out of a molden file
syntax: extract_molden.py <mo_file1> [<mo_file2> ...]
options: -ene          - interpret energies as occupations
         -thresh=0.001 - threshold for print-out
""")


class extract_mld:
    def __init__(self, thresh=0.001, rd_ene=False, decompose=True):
        self.thresh = thresh  # threshold for print-out into output file
        self.rd_ene = rd_ene  # interpret energies as occupations
        self.decompose = decompose  # decompose (for NDOs or NTOs)

        self.stdir = os.getcwd()

    def extract(self, mo_file):
        print("Extracting %s ..." % mo_file)
        os.chdir(self.stdir)

        mos = lib_mo.MO_set_molden(file=mo_file)
        mos.read()
Beispiel #23
0
#!/usr/bin/python
"""
Driver script for analyzing a set of NO files.
"""

import theo_header, lib_sden, input_options
import sys

theo_header.print_header("NO file analysis")


def ihelp():
    print(" analyze_NOs.py <MO_file> [<NO_file_ref> <NO_file2> ...]\n")
    print(" Command line options:")
    print("  -h, -H, -help: print this help")
    print("  -ifile [dens_ana.in]: name of the input file")
    exit(0)


# --------------------------------------------------------------------------#
# Input options
# --------------------------------------------------------------------------#

tmp = sys.argv.pop(0)

no_files = []
ifile = "dens_ana.in"
while len(sys.argv) > 0:
    arg = sys.argv.pop(0)
    if arg in ["-h", "-H", "-help"]:
        ihelp()
Beispiel #24
0
            if wopt['rtype'] in ['nos']:
                if wopt.read_yn('Compute number of unpaired electrons?',
                                'unpaired_ana', True):
                    wopt['prop_list'] += ['nu', 'nunl']
            wopt.AD_ana()
            wopt.BO_ana()
            wopt.ddm_parse()

    wopt.write_prop_list()

    # Program specific input
    if wopt['rtype'] in ['colmrci']:
        wopt.get_ncore()
    elif wopt['rtype'] in ['rassi']:
        wopt.get_rassi_list()

    wopt.output_options()

    wopt.flush(lvprt=1, choose_file=True)

    if wopt['rtype'] == 'colmcscf':
        print(
            "\nNow, please run write_den.bash to prepare the MCSCF density matrices!"
        )


if __name__ == '__main__':
    theo_header.print_header('Input generation')

    run_theoinp()