コード例 #1
0
def test_plot_atoms():
    padb = ProAtomDB.from_refatoms(numbers=[8, 1], max_cation=1, max_anion=1)
    with tmpdir('horton.scripts.test.test_atomdb.test_plot_atoms') as dn:
        plot_atoms(padb, dn)
        fns = [
            'dens_001__h.png',
            'rdens_001__h.png',
            'fukui_001__h.png',
            'rfukui_001__h.png',
            'dens_008__o.png',
            'rdens_008__o.png',
            'fukui_008__o.png',
            'rfukui_008__o.png',
        ]
        check_files(dn, fns)
コード例 #2
0
ファイル: test_atomdb.py プロジェクト: tovrstra/horton
def test_plot_atoms():
    padb = ProAtomDB.from_refatoms(numbers=[8, 1], max_cation=1, max_anion=1)
    with tmpdir("horton.scripts.test.test_atomdb.test_plot_atoms") as dn:
        plot_atoms(padb, dn)
        fns = [
            "dens_001__h.png",
            "rdens_001__h.png",
            "fukui_001__h.png",
            "rfukui_001__h.png",
            "dens_008__o.png",
            "rdens_008__o.png",
            "fukui_008__o.png",
            "rfukui_008__o.png",
        ]
        check_files(dn, fns)
コード例 #3
0
ファイル: horton-atomdb.py プロジェクト: susilehtola/horton
def main_convert(args):
    # The atomic grid specification
    agspec = AtomicGridSpec(args.grid)

    # The program is detected based on the run script that is present
    run_scripts = glob("run_*.sh")
    if len(run_scripts) != 1:
        raise RuntimeError(
            'Found %i run_*.sh scripts while exactly one is needed to know which program was used to run the atomic computations.'
            % len(run_scripts))
    program = atom_programs[run_scripts[0][4:-3]]

    # Loop over all sensible directories
    energy_table = EnergyTable()
    records = []
    for dn_state in sorted(glob("[01]??_??_[01]??_q[+-]??")):
        number = int(dn_state[:3])
        pop = int(dn_state[7:10])

        cases = []
        for dn_mult in sorted(glob('%s/mult??' % dn_state)):
            if log.do_medium:
                log('Loading from', dn_mult)
            data, energy = program.load_atom(dn_mult)
            if energy is None:
                if log.do_medium:
                    log('No (sensible) results found:  ', dn_mult)
                continue
            cases.append((energy, data))

        if len(cases) == 0:
            if log.do_medium:
                log('Nothing found in:  ', dn_state)
            continue

        # Get the lowest in energy and write to chk file
        cases.sort()
        energy, data = cases[0]

        # Add case to energy table
        energy_table.add(number, pop, energy)

        # Write atom to HORTON file if possible
        if data is not None:
            data.to_file('%s/horton.h5' % dn_state)

        # Construct a record for the proatomdb
        records.append(ProAtomRecord.from_iodata(data, agspec))

        # Release memory
        data = None
        del cases

        # Let user know we are alive.
        if log.do_medium:
            log('Succesfull:        ', dn_state)

    # Report energies
    if log.do_medium:
        energy_table.log()

    # Write out atoms file
    proatomdb = ProAtomDB(records)
    proatomdb.to_file('atoms.h5')
    if log.do_medium:
        log('Written atoms.h5')

    # Make nice figures
    plot_atoms(proatomdb)
コード例 #4
0
def main_convert(args):
    # The atomic grid specification
    agspec = AtomicGridSpec(args.grid)

    # The program is detected based on the run script that is present
    run_scripts = glob("run_*.sh")
    if len(run_scripts) != 1:
        raise RuntimeError('Found %i run_*.sh scripts while exactly one is needed to know which program was used to run the atomic computations.' % len(run_scripts))
    program = atom_programs[run_scripts[0][4:-3]]

    # Loop over all sensible directories
    energy_table = EnergyTable()
    records = []
    for dn_state in sorted(glob("[01]??_??_[01]??_q[+-]??")):
        number = int(dn_state[:3])
        pop = int(dn_state[7:10])

        cases = []
        for dn_mult in sorted(glob('%s/mult??' % dn_state)):
            if log.do_medium:
                log('Loading from', dn_mult)
            data, energy = program.load_atom(dn_mult)
            if energy is None:
                if log.do_medium:
                    log('No (sensible) results found:  ', dn_mult)
                continue
            cases.append((energy, data))

        if len(cases) == 0:
            if log.do_medium:
                log('Nothing found in:  ', dn_state)
            continue

        # Get the lowest in energy and write to chk file
        cases.sort()
        energy, data = cases[0]

        # Add case to energy table
        energy_table.add(number, pop, energy)

        # Write atom to HORTON file if possible
        if data is not None:
            data.to_file('%s/horton.h5' % dn_state)

        # Construct a record for the proatomdb
        records.append(ProAtomRecord.from_iodata(data, agspec))

        # Release memory
        data = None
        del cases

        # Let user know we are alive.
        if log.do_medium:
            log('Succesfull:        ', dn_state)

    # Report energies
    if log.do_medium:
        energy_table.log()

    # Write out atoms file
    proatomdb = ProAtomDB(records)
    proatomdb.to_file('atoms.h5')
    if log.do_medium:
        log('Written atoms.h5')

    # Make nice figures
    plot_atoms(proatomdb)