コード例 #1
0
def energy(method, output_str):
    """ Reads the the total electronic energy from the output file string.
        Returns the energy in Hartrees.

        :param method: electronic structure method to read
        :type method: str
        :param output_str: string of the program's output file
        :type output_str: str
        :rtype: float
    """
    # Parse the method and lists
    core_method, pfxs = Method.evaluate_method_type(method)
    full_method = (core_method, frozenset(pfxs))
    assert full_method in method_list()

    # Get the appropriate reader and call it
    if Method.is_nonstandard_dft(core_method):
        if core_method not in DOUB_HYB_DFT:
            energy_reader = _dft_energy
        else:
            energy_reader = _doub_hyb_dft_energy
    else:
        energy_reader = ENERGY_READER_DCT[full_method]

    return energy_reader(output_str)
コード例 #2
0
ファイル: energ.py プロジェクト: Auto-Mech/autoio
def energy(method, output_str):
    """ get total energy from output
    """

    # Parse the method and lists
    core_method, pfxs = Method.evaluate_method_type(method)
    full_method = (core_method, frozenset(pfxs))
    assert full_method in method_list()

    # Get the appropriate reader and call it
    if Method.is_nonstandard_dft(method):
        energy_reader = _scf_energy
    else:
        energy_reader = ENERGY_READER_DCT[method]

    return energy_reader(output_str)
コード例 #3
0
ファイル: energ.py プロジェクト: Auto-Mech/autoio
def energy(method, output_str):
    """ Reads the the total electronic energy from the output file string.
        Returns the energy in Hartrees.

        :param method: electronic structure method to read
        :type method: str
        :param output_str: string of the program's output file
        :type output_str: str
        :rtype: float
    """

    # Parse the method and lists
    core, pfxs = Method.evaluate_method_type(method)
    _method = (core, frozenset(pfxs))
    assert _method in method_list()

    # First try and grab the energy printed at the end of the file
    ene = _end_file_energy(output_str)

    # If no energy is found, get the appropriate reader and call it
    if ene is None:
        energy_reader = ENERGY_READER_DCT[_method]
        ene = energy_reader(output_str)

    return ene
コード例 #4
0
ファイル: energ.py プロジェクト: Auto-Mech/autoio
def energy(method, output_string):
    """ get total energy from output
    """

    # Parse the method and lists
    core_method, pfxs = Method.evaluate_method_type(method)
    full_method = (core_method, frozenset(pfxs))
    assert full_method in method_list()

    # get the appropriate reader and call it
    energy_reader = ENERGY_READER_DCT[full_method]

    return energy_reader(output_string)
コード例 #5
0
ファイル: energ.py プロジェクト: Auto-Mech/autoio
def energy(method, output_str):
    """ Reads the the total electronic energy from the output file string.
        Returns the energy in Hartrees.

        :param method: electronic structure method to read
        :type method: str
        :param output_str: string of the program's output file
        :type output_str: str
        :rtype: float
    """

    # Parse the method and lists
    core_method, pfxs = Method.evaluate_method_type(method)
    _method = (core_method, frozenset(pfxs))
    assert _method in method_list()

    # Get the appropriate reader and call it
    energy_reader = ENERGY_READER_DCT[method]

    return energy_reader(output_str)
コード例 #6
0
ファイル: fill.py プロジェクト: Auto-Mech/autoio
def program_method_names(prog, method, basis, mult, orb_restricted):
    """ Sets all the names of all the components of a theoretical method
        to those specific to the program of interest so that a proper input
        file can be written.

        :param prog: electronic structure program to use as a backend
        :type prog: str
        :param method: electronic structure method
        :type method: str
        :param basis: basis set
        :type basis: str
        :param mult: spin multiplicity
        :type mult: int
        :param orb_restricted: parameter designating if restriced refrence used
        :type orb_restricted: bool
        :rtype: (str, str, str)
    """

    # Set the singlet variable used by prog_method
    singlet = (mult == 1)

    # Determine the reference for the given method
    prog_reference = _reference(prog, method, mult, orb_restricted)

    # Determine the method
    if Method.is_casscf(method):
        prog_method = prog_reference
    elif method == Method.HF[0]:
        if prog in (Program.GAUSSIAN09, Program.GAUSSIAN16):
            prog_method = prog_reference
        else:
            prog_method = program_method_name(prog, method, singlet=singlet)
    else:
        prog_method = program_method_name(prog, method, singlet=singlet)

    # core_prog_method, mod = elstruct.Method.evaluate_method_type(prog_method)

    # Set the basis
    prog_basis = program_basis_name(prog, basis)

    return prog_method, prog_reference, prog_basis
コード例 #7
0
ファイル: fill.py プロジェクト: Auto-Mech/autoio
def _reference(prog, method, mult, orb_restricted):
    """ Determine the string for what the Hartree-Fock or Kohn-Sham
        reference should be based on the electronic structure method
        and electronic structure program is.

        :param prog: electronic structure program to use as a backend
        :type prog: str
        :param method: electronic structure method
        :type method: str
        :param mult: spin multiplicity
        :type mult: int
        :param orb_restricted: parameter designating if restriced refrence used
        :type orb_restricted: bool
        :rtype: str
    """
    # Need a multiref version
    if Method.is_dft(method):
        reference = _dft_reference(prog, orb_restricted)
    elif method == Method.HF[0]:
        reference = _hf_reference(prog, mult, orb_restricted)
    else:
        reference = _corr_reference(prog, mult, orb_restricted)

    return reference
コード例 #8
0
ファイル: energ.py プロジェクト: Auto-Mech/autoio
    return ene


# A dictionary of functions for reading the energy from the output, by method
ENERGY_READER_DCT = {
    (Method.HF[0], frozenset({})): _scf_energy,
    (Method.Corr.MP2[0], frozenset({})): _mp2_energy,
    (Method.Corr.CCSD[0], frozenset({})): _ccsd_energy,
    (Method.Corr.CCSD_T[0], frozenset({})): _ccsd_t_energy,
}

# Add DFT methods to the reader dictionary
METHODS = program_methods(PROG)
for METHOD in METHODS:
    if Method.is_standard_dft(METHOD):
        ENERGY_READER_DCT[(METHOD, frozenset({}))] = _scf_energy

# Add DFT methods to the reader dictionary
READ_METHODS = set(method[0] for method in ENERGY_READER_DCT)
assert READ_METHODS <= set(METHODS)


def method_list():
    """ Constructs a list of available electronic structure methods.
    """
    return tuple(sorted(ENERGY_READER_DCT.keys()))


def energy(method, output_str):
    """ get total energy from output