コード例 #1
0
ファイル: theo_oldtest.py プロジェクト: MFSJMenger/test_theo
 def test_header(self):
     # TODO: use local path rather than THEODIR
     theo_header.print_header('TheoDORE tests')
     warnings.warn("THEODIR: " + os.environ["THEODIR"])
     sys.path.append(os.environ["THEODIR"] + "/bin")
コード例 #2
0
#!/usr/bin/env python3
from __future__ import print_function, division
"""
Driver script for analyzing a set of NO files.
"""

import os, sys

from theodore import theo_header, lib_sden, input_options

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"]:
コード例 #3
0
    vopt.write_lfile(pltfiles, auxfiles)
    vopt.write_pfile(pltfiles, auxfiles)
    vopt.write_cfile(pltfiles)
    vopt.write_hfile(pltfiles)

    print("Converting coordinate file ...")
    struc = lib_struc.structure()
    try:
        struc.read_file(file_path=pltfiles[0], file_type=None)
        struc.make_coord_file(file_path='coord.xyz',file_type='xyz',lvprt=1)
    except:
        print("*** WARNING: The coordinate file coord.xyz could not be created. ***")
        print("    Please create this file yourself.\n\n")

    print("""
Files created. Now do the following:
1. vmd coord.xyz
2.   File - Load Visualization State - %s
3.   Adjust the perspective
4.   File - Load Visualization State - %s
5. bash %s
6. Open in browser: %s
"""%(vopt['lfile'], vopt['pfile'], vopt['cfile'], vopt['hfile']))

if __name__=='__main__':
    import sys

    theo_header.print_header('Automatic plotting in VMD')
    run()
コード例 #4
0
ファイル: convert_table.py プロジェクト: MFSJMenger/TheoDORE

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()
コード例 #5
0
from __future__ import print_function, division
from theodore import theo_header, input_options, error_handler, lib_diab
import sys, os, numpy


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)


if __name__ == '__main__':
    theo_header.print_header('Fragment charge difference analysis')

    ifile = 'fcd.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)
        else:
            raise error_handler.ElseError(arg, 'command line option')

    if not os.path.exists(ifile):
        print('Input file %s not found!' % ifile)
コード例 #6
0
ファイル: parse_libwfa.py プロジェクト: MFSJMenger/TheoDORE
        ifile = sys.argv.pop(0)
    else:
        args2.append(arg)

ioptions = input_options.libwfa_parse_options(ifile, check_init=False)

if len(args2) >= 1:
    ioptions['rfile'] = args2[0]
    if len(args2) >= 2:
        ioptions['rtype'] = args2[1]

if ioptions['rtype'] == 'qctda':
    ioptions['TDA'] = True
    ioptions['rtype'] = 'qctddft'

if (not 'rfile' in ioptions) or (not 'rtype' in ioptions):
    ihelp()

theo_header.print_header('Parse libwfa output', ioptions=ioptions)

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

dena = dens_ana_base.dens_ana_base(ioptions)
#sdena.read_mos()

dena.read_dens()

dena.print_summary()
コード例 #7
0
        value=(value+1.)*10./2.
        big=int(value)
        small=value-big
        string='%s!%i!%s' % (colors_all[big+1],int(small*100),colors_all[big])
        return string




# =======================================================================
# =======================================================================
# =======================================================================

def run_plot():
    anOm = AnCorr_options('ancorr.in')
    anOm.read_OmFrag()
    anOm.AnCorr_input()
    anOm.compute()

    anOm.print_results(anOm.output_h,'Hole')
    anOm.print_results(anOm.output_e,'Electron')
    anOm.print_results(anOm.output_m,'Mixed')

    if anOm.opt_dict['dolatex']:
        anOm.create_latex(anOm.output_h, anOm.output_e, anOm.output_m)

if __name__ == '__main__':
    theo_header.print_header('Correlation analysis and clustering of Omega matrices ')

    run_plot()
コード例 #8
0
ファイル: extract_molden.py プロジェクト: MFSJMenger/TheoDORE
#!/usr/bin/env python3

from __future__ import print_function, division
import os, sys
import numpy
from theodore 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
         -alphabeta    - use alpha/beta labels for hole/electron
""")


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)
コード例 #9
0
        if weight == 1:
            pylab.plot(xlist, self.spec / max(self.spec), 'k-')
            for A, x0 in plot_sticks:
                pylab.plot([x0, x0], [-1., A], 'rx-')
        elif weight == 2:
            pylab.plot(xlist, self.dos / max(self.dos), 'k-')
        else:
            raise error_handler.ElseError('weight', weight)

        pylab.axis(xmin=xmin, xmax=xmax, ymin=0., ymax=1.)
        pylab.savefig(pname)

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


if __name__ == '__main__':
    import sys

    theo_header.print_header('Create a convoluted spectrum')
    print('spectrum.py <tden_summ1> [<tden_summ2> ...]')

    if len(sys.argv) < 2:
        raise error_handler.MsgError('Enter at least one argument')

    sopt = spec_options('spectrum.in')
    sopt['ana_files'] = sys.argv[1:]
    sopt.spec_input()

    sopt.make_spec()
コード例 #10
0
ファイル: plot_VIST.py プロジェクト: MFSJMenger/test_theo
from theodore import theo_header, lib_NICS, error_handler, cclib_interface, input_options


def ihelp():
    print(" plot_VIST.py [options] <logfile1> <logfile2>")
    print(" Command line options:")
    print("  -h, -H, --help: print this help")
    print("  -v, --vist    : VIST for only these dummy atoms, e.g. -v '0 3 5'")
    print("  -o            : Name of output file (for VMD)")
    print("  -s, --scale   : Scale factor for VIST dumb-bells")
    print("  -c, --coor    : Create coordinate files (using cclib)")
    print("  -p            : Render and plot all tensors separately")
    exit(0)


theo_header.print_header('Read NICS values and prepare VIST plot')

vlist = None
logfiles = []
do_coor = False
ofile = 'VIST.vmd'
scale = 1.
plot_all = False

arg = sys.argv.pop(0)
while len(sys.argv) > 0:
    arg = sys.argv.pop(0)
    if arg in ["-h", "-H", "--help"]:
        ihelp()
    elif arg in ["-v", "--vist"]:
        arg = sys.argv.pop(0)
コード例 #11
0
ファイル: cc2molden.py プロジェクト: MFSJMenger/TheoDORE
#!/usr/bin/env python3
"""
Convert a log-file to Molden format with the help of cclib.
"""
from __future__ import print_function, division
import sys

from theodore import theo_header, cclib_interface, input_options, error_handler, lib_mo

theo_header.print_header('cc2molden')

print("cc2molden.py <logfile>")
print("Convert a log-file to Molden format with the help of cclib.")
print(
    "  WARNING: This script is not well-tested and might fail for some of the quantum chemistry codes."
)

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:
    mos = ccparser.read_mos()
コード例 #12
0
    """
    def __init__(self, st_ind, en_ind, mldfile):
        self.mldfile = mldfile
        self.viblist = list(range(st_ind, en_ind+1))

    def vibname(self, ivib):
        return str(ivib)

    def vibpath(self, ivib, of='png'):
        if of == 'pngt': of = 'png'
        return "vib_%i.%s"%(ivib,of)    

if __name__=='__main__':
    import sys

    theo_header.print_header('Plotting of vibrations in Jmol')
    print('jmol_MOs.py <mldfile>\n')

    vibfile = sys.argv[1]
    
    jopt = jmol_vib_opts('jmol.in')
    jopt.input()
    
    jo = lib_file.wfile('jmol_vibs.spt')
    ho = lib_file.htmlfile('vibs.html')
    
    ho.pre('Vibrations')
    
    vibc = vibcoll(jopt['st_ind'], jopt['en_ind'], vibfile)

    vibout = vib_output_jmol(vibc, jopt)
コード例 #13
0
    /pgf/number format/precision=1},
  legend style={at={(1.01,0.00)}, anchor=south west, draw=none, fill=black!5, inner sep=0.5pt, outer sep=0.5pt},
  legend columns=1, legend cell align=left},
}
\pgfplotsset{colormap={CI}{color=(white); color=(blue!50); color=(O!70);}}

% ===========================================================================

\\tikzstyle{orb} = [ellipse, draw, color=black, fill=black!5, inner sep=-1pt, align=center]
\\tikzstyle{arrow} = [-open triangle 45, black, thick]
\\newcommand{\\incMO}[1]{\\includegraphics[width=4.5cm, trim=1cm 1cm 1cm 1cm, clip=true]{#1}}

\\begin{document}
\\begin{tikzpicture}
"""
        return str

def run_plot():
    opt = Om_bar_options('plot.in')
    opt.read_str("Name of the file with the Omega matrix entries", "OmFfile", "OmFrag.txt", autocomp=True)
    opt.read_OmFrag(opt['OmFfile'])
    opt.Om_bar_input()
    opt.Om_bar_data()
    opt.make_tex()


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

    run_plot()
コード例 #14
0
        # self.vmd_coors(-.4 * fac, -.6 * fac, coor[0, mu], coor[1, mu], coor[2, mu])
        # self.af.write('radius % .3f\n'%(2*self['2P_rad']))

    def vmd_coors(self, fac1, fac2, x, y, z):
        self.af.write('{% .3f % .3f % .3f} ' % (fac1 * x, fac1 * y, fac1 * z))
        self.af.write('{% .3f % .3f % .3f} ' % (fac2 * x, fac2 * y, fac2 * z))

    def vmd_color(self, val, eps=1.e-3):
        if abs(val) < eps:
            return False
        elif val > 0.0:
            self.af.write('draw color blue\n')
            return True
        else:
            self.af.write('draw color red\n')
            return True


if __name__ == '__main__':
    import sys

    theo_header.print_header('Plotting of dipole and quadrupole moments')
    print('draw_moments.py <tden_summ>')
    if len(sys.argv) < 2:
        raise error_handler.MsgError('Enter one argument')

    opt = mom_options('mom.in')
    opt['ana_file'] = sys.argv[1]
    opt.input()
    opt.write_afile()
コード例 #15
0
#!/usr/bin/env python3
"""
Driver script for analyzing a set of NO files.
"""

from __future__ import print_function, division
import sys

from theodore import theo_header, lib_sden, input_options

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)
if len(sys.argv) == 0: ihelp()

no_files = []
ifile = 'dens_ana.in'
while len(sys.argv) > 0:
コード例 #16
0
#!/usr/bin/env python3
"""
Check if a file can be read by cclib and if all the required information is available.
"""
from __future__ import print_function, division
import sys

from theodore import theo_header, cclib_interface, input_options, error_handler

theo_header.print_header('Check cclib')

print("cc_check.py <logfile> [<printlevel=1>]")
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!")
if len(sys.argv) >= 3:
    lvprt = int(sys.argv[2])
else:
    lvprt = 1

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(lvprt=lvprt)

if errcode <= 1:
コード例 #17
0
    elif arg == '-ifile' or arg == '-f':
        ifile = sys.argv.pop(0)
    elif arg == '-s':
        spin_comp = True
    else:
        raise error_handler.ElseError(arg, 'command line option')

if not os.path.exists(ifile):
    print('Input file %s not found!' % ifile)
    print(
        'Please create this file using theoinp or specify its location using -ifile\n'
    )
    ihelp()

ioptions = input_options.tden_ana_options(ifile)
theo_header.print_header('1TDM analysis for spin-orbit coupled states',
                         ioptions=ioptions)

tdena = lib_soc.tden_ana_soc(ioptions)
if 'mo_file' in ioptions: tdena.read_mos()
tdena.read_dens()
tdena.compute_all_OmAt(fullmat=True)
tdena.soc_transform()

tdena.print_info('mch')
if spin_comp:
    tdena.print_info('aa')
    tdena.print_info('bb')
    tdena.print_info('ab')
    tdena.print_info('ba')
tdena.print_info('soc')
コード例 #18
0
            pylab.colorbar()

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

        tel = '<img src="axes.%s", border="1" width="200">\n' % self.settings[
            '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():
    # read data from commandline
    state_list, maxOm = read_om_frag()
    Oopt = OmFrag_options.from_questions(state_list,
                                         maxOm,
                                         config='plot_OmFrag.in')
    Oopt.plot()


if __name__ == '__main__':
    theo_header.print_header('Plot Omega matrices')
    run_plot()
コード例 #19
0
ファイル: dgrid_prep.py プロジェクト: MFSJMenger/TheoDORE
        bfilen = basen + '.md'
        ifilen = basen + '.inp'

        print('\nAnalyzing %s -> %s ...'%(mldfile, bfilen))

        iproc += 1
        if iproc%dopt['nproc'] == 0:
            lend = '|| exit 1'
        else:
            lend = '&'

        wfile.write('echo " *** Running %s ..."\n'%mldfile)
        wfile.write('$DGRID %s && $DGRID %s %s\n'%(mldfile, ifilen, lend))
        wfile.write('ln -s %s.md.rho_r %s.cube\n\n'%(basen, basen2))

        with open(ifilen, 'w') as ifile:
            ifile.write(""":: dgrid_prep.py
basis=%s
output=.

compute=rho
format=cube
mesh=%.4f %.2f\n"""%(bfilen, dopt['msize'], dopt['mborder']))

    wfile.close()
    print("File run_dgrid.bash written.\n  Run as:\n  bash run_dgrid.bash")

if __name__=='__main__':
    theo_header.print_header('Prepare input for DGrid')
    run()
コード例 #20
0
ファイル: tden_OV.py プロジェクト: MFSJMenger/TheoDORE
elif len(largs) == 3:
    dir1 = largs[0]
    dir2 = largs[1]
    AO_OV = largs[2]
else:
    ihelp()

if not os.path.exists(ifile):
    print('Input file %s not found!' % ifile)
    print(
        'Please create this file using theoinp or specify its location using -ifile\n'
    )
    ihelp()

ioptions = input_options.tden_ana_options(ifile)
theo_header.print_header('Transition density matrix overlap',
                         ioptions=ioptions)

if ifile2 == '':
    ioptions2 = ioptions
else:
    ioptions2 = input_options.tden_ana_options(ifile2)

sdir = os.getcwd()

# Read info for the first job
os.chdir(dir1)
tdena1 = lib_tden.tden_ana(ioptions)
if 'mo_file' in ioptions:
    tdena1.read_mos()
tdena1.read_dens()
os.chdir(sdir)
コード例 #21
0
ファイル: cc_opt.py プロジェクト: MFSJMenger/TheoDORE
#!/usr/bin/env python3
"""
Use cclib and openbabel to analyze a geometry optimization.
"""

from __future__ import print_function, division
import sys

from theodore import theo_header, cclib_interface, input_options, error_handler, units
import openbabel

theo_header.print_header('Analysis of a geometry optimization or relaxed scan')


def ihelp():
    print(" cc_opt.py <logfile>")
    print(" Command line options:")
    print("  -h, -H, --help: print this help")
    print("  -s, --scan: Analyze a relaxed scan")
    print("  -t, --thresh: Discontinuity threshold for scan")
    print("  -o, --output: Name (and path) of output file")
    exit(0)


logfile = None
scan = False
scan_thresh = 500
fname = "cc_opt.xyz"

arg = sys.argv.pop(0)
while len(sys.argv) > 0:
コード例 #22
0
ファイル: analyze_tden.py プロジェクト: MFSJMenger/TheoDORE
    if arg in ["-h", "-H", "--help"]:
        ihelp()
    elif arg == '-ifile' or arg == '-f':
        ifile = sys.argv.pop(0)
    else:
        raise error_handler.ElseError(arg, 'command line option')

if not os.path.exists(ifile):
    print('Input file %s not found!' % ifile)
    print(
        'Please create this file using theoinp or specify its location using -ifile\n'
    )
    ihelp()

ioptions = input_options.tden_ana_options(ifile)
theo_header.print_header('Transition density matrix analysis',
                         ioptions=ioptions)

tdena = lib_tden.tden_ana(ioptions)
if 'mo_file' in ioptions: tdena.read_mos()

tdena.read_dens()

if 'at_lists' in ioptions or ioptions['eh_pop'] >= 1:
    tdena.compute_all_OmAt()

if 'at_lists' in ioptions:
    tdena.compute_all_OmFrag()
    if ioptions['print_OmFrag']: tdena.fprint_OmFrag()

if ioptions['comp_ntos']: tdena.compute_all_NTO()
if ioptions['comp_dntos']: tdena.compute_all_DNTO()
コード例 #23
0
                      color=self['colors'][iF],
                      **barkwargs)
            hbottom += hpops[:, iF]

        pylab.xlabel('Excited states')
        pylab.ylabel('  Hole   <---> Electron')
        pylab.plot([ind[0] - 0.5, ind[-1] + 0.5 + self['barwidth']], [0., 0.],
                   'k-')

        pylab.legend()
        pylab.xticks([])

        fname = 'frag_decomp.%s' % self['output_format']
        pylab.savefig(fname, dpi=self['plot_dpi'])
        print(("File %s written." % fname))


def run_plot():
    opt = decomp_options('plot.in')
    opt.read_OmFrag()

    opt.decomp_input()

    opt.plot()


if __name__ == '__main__':
    theo_header.print_header('Plot fragment decomposition')

    run_plot()
コード例 #24
0
#!/usr/bin/env python3

#import argparse - only available in version 2.7
from __future__ import print_function, division
import sys
from theodore 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
   or   babel.py <infile> <outfile>

""")

if len(sys.argv) == 4 + 1:
    (intype, infile, outtype, outfile) = sys.argv[1:]
elif len(sys.argv) == 2 + 1:
    (infile, outfile) = sys.argv[1:]
    intype = outtype = None
else:
    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)
コード例 #25
0
ファイル: plot_graph.py プロジェクト: MFSJMenger/TheoDORE
from __future__ import print_function, division
from theodore import theo_header, lib_plot
        
def run_plot():
    infilen = 'graph.in'
    
    popt = lib_plot.write_plot_options(infilen)
    ropt = lib_plot.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.flush()
    
    popt.read_data()
    
    if popt['doplots']: popt.plot()
    if popt['dotxt']:   popt.txt_files()
    if popt['dognu']:   popt.gnu_inp()
    
if __name__ == '__main__':
    theo_header.print_header('Graph plotting')
    
    run_plot()