Beispiel #1
0
def read_element(filename, symbol, format=None):
    """
    Read element data from files.

    Parameters:
    -----------
    fileobj:   filename of file-object to read from
    symbol:    chemical symbol of the element
    """

    if format is None:
        format = filetype(filename)

    if format == 'elm':
        from hotbit.io.native import read_element_from_elm
        return read_element_from_elm(filename, symbol)

    if format == 'skf':
        from hotbit.io.dftb import read_element_from_skf
        return read_element_from_skf(filename, symbol)

    raise RuntimeError('File format "'+format+'" not recognized!')
Beispiel #2
0
try:
    parf = open(argv[1] + '_' + argv[2] + '.par')
    elmf = open(argv[1] + '.elm')
except:
    parf = open(argv[2] + '_' + argv[1] + '.par')

# Read line-by-line (needed for repulsive term)
tmp = parf.readlines()

for carousel in [(argv[1], argv[2]), (argv[2], argv[1])]:

    # Open Outfile
    skff = open(carousel[0] + '-' + carousel[1] + '.skf', 'w')

    # Read relevant data (A-B and B-A is different!)
    elmdat = native.read_element_from_elm(elmf, argv[1])
    pardat = native.read_HS_from_par(parf, carousel[0], carousel[1])

    # Generate DFTBplus format string
    print 'Reading in Hotbit Metadata and repulsive potential'
    header = generate_DFTBplus_header(elmdat,
                                      pardat,
                                      argv[1] == argv[2]) + \
        generate_DFTBplus_repulsion(tmp,
                                    DEBUG=False)

    skff.write(header)
    skff.close()

# Close files
parf.close()
Beispiel #3
0
    elmf = open(argv[1] + '.elm')
except:
    parf = open(argv[2] + '_' + argv[1] + '.par')


# Read line-by-line (needed for repulsive term)
tmp = parf.readlines()


for carousel in [(argv[1], argv[2]), (argv[2], argv[1])]:

    # Open Outfile
    skff = open(carousel[0] + '-' + carousel[1] + '.skf', 'w')

    # Read relevant data (A-B and B-A is different!)
    elmdat = native.read_element_from_elm(elmf, argv[1])
    pardat = native.read_HS_from_par(parf, carousel[0], carousel[1])

    # Generate DFTBplus format string
    print 'Reading in Hotbit Metadata and repulsive potential'
    header = generate_DFTBplus_header(elmdat,
                                      pardat,
                                      argv[1] == argv[2]) + \
        generate_DFTBplus_repulsion(tmp,
                                    DEBUG=False)

    skff.write(header)
    skff.close()

# Close files
parf.close()