コード例 #1
0
ファイル: fcidump.py プロジェクト: andyj10224/psi4
def compare_fcidumps(expected: str, computed: str, label: str):
    """Comparison function for FCIDUMP files.
    Compares the first six below, then computes energies from MO integrals and compares the last four.

      - 'norb' : number of basis functions
      - 'nelec' : number of electrons
      - 'ms2' : spin polarization of the system
      - 'isym' : symmetry of state (if present in FCIDUMP)
      - 'orbsym' : list of symmetry labels of each orbital
      - 'uhf' : whether restricted or unrestricted
      - 'ONE-ELECTRON ENERGY' : SCF one-electron energy
      - 'TWO-ELECTRON ENERGY' : SCF two-electron energy
      - 'SCF TOTAL ENERGY' : SCF total energy
      - 'MP2 CORRELATION ENERGY' : MP2 correlation energy

    :param expected: Reference FCIDUMP file against which `computed` is compared.
    :param computed: Input FCIDUMP file to compare against `expected`.
    :param label: string labeling the test
    """

    # Grab expected header and integrals
    ref_intdump = fcidump_from_file(expected)
    intdump = fcidump_from_file(computed)

    # Compare headers
    compare_recursive(ref_intdump,
                      intdump,
                      'FCIDUMP header',
                      forgive=['enuc', 'hcore', 'eri', 'epsilon'])

    ref_energies = energies_from_fcidump(ref_intdump)
    energies = energies_from_fcidump(intdump)

    pass_1el = compare_values(ref_energies['ONE-ELECTRON ENERGY'],
                              energies['ONE-ELECTRON ENERGY'], 7,
                              label + '. 1-electron energy')
    pass_2el = compare_values(ref_energies['TWO-ELECTRON ENERGY'],
                              energies['TWO-ELECTRON ENERGY'], 7,
                              label + '. 2-electron energy')
    pass_scf = compare_values(ref_energies['SCF TOTAL ENERGY'],
                              energies['SCF TOTAL ENERGY'], 10,
                              label + '. SCF total energy')
    pass_mp2 = compare_values(ref_energies['MP2 CORRELATION ENERGY'],
                              energies['MP2 CORRELATION ENERGY'], 10,
                              label + '. MP2 correlation energy')

    compare_integers(True, (pass_1el and pass_2el and pass_scf and pass_mp2),
                     label)
コード例 #2
0
ファイル: fcidump.py プロジェクト: yqcaogit/psi4
def compare_fcidumps(expected, computed, label):
    """Function to compare two FCIDUMP files. Prints :py:func:`util.success`
    when value *computed* matches value *expected*.
    Performs a system exit on failure. Used in input files in the test suite.

    :returns: a dictionary of energies computed from the MO integrals.
    The key-value pairs are:
      - 'NUCLEAR REPULSION ENERGY' : nuclear repulsion plus frozen core energy
      - 'ONE-ELECTRON ENERGY' : SCF one-electron energy
      - 'TWO-ELECTRON ENERGY' : SCF two-electron energy
      - 'SCF TOTAL ENERGY' : SCF total energy
      - 'MP2 CORRELATION ENERGY' : MP2 correlation energy

    :param expected: reference FCIDUMP file
    :param computed: computed FCIDUMP file
    :param label: string labelling the test
    """

    # Grab expected header and integrals
    ref_intdump = fcidump_from_file(expected)
    intdump = fcidump_from_file(computed)

    # Compare headers
    compare_recursive(ref_intdump,
                      intdump,
                      'FCIDUMP header',
                      forgive=['enuc', 'hcore', 'eri', 'epsilon'])

    ref_energies = energies_from_fcidump(ref_intdump)
    energies = energies_from_fcidump(intdump)

    pass_1el = compare_values(ref_energies['ONE-ELECTRON ENERGY'],
                              energies['ONE-ELECTRON ENERGY'], 7,
                              label + '. 1-electron energy')
    pass_2el = compare_values(ref_energies['TWO-ELECTRON ENERGY'],
                              energies['TWO-ELECTRON ENERGY'], 7,
                              label + '. 2-electron energy')
    pass_scf = compare_values(ref_energies['SCF TOTAL ENERGY'],
                              energies['SCF TOTAL ENERGY'], 10,
                              label + '. SCF total energy')
    pass_mp2 = compare_values(ref_energies['MP2 CORRELATION ENERGY'],
                              energies['MP2 CORRELATION ENERGY'], 10,
                              label + '. MP2 correlation energy')

    compare_integers(True, (pass_1el and pass_2el and pass_scf and pass_mp2),
                     label)
コード例 #3
0
ファイル: fcidump.py プロジェクト: psi4/psi4
def compare_fcidumps(expected, computed, label):
    """Function to compare two FCIDUMP files. Prints :py:func:`util.success`
    when value *computed* matches value *expected*.
    Performs a system exit on failure. Used in input files in the test suite.

    :returns: a dictionary of energies computed from the MO integrals.
    The key-value pairs are:
      - 'NUCLEAR REPULSION ENERGY' : nuclear repulsion plus frozen core energy
      - 'ONE-ELECTRON ENERGY' : SCF one-electron energy
      - 'TWO-ELECTRON ENERGY' : SCF two-electron energy
      - 'SCF TOTAL ENERGY' : SCF total energy
      - 'MP2 CORRELATION ENERGY' : MP2 correlation energy

    :param expected: reference FCIDUMP file
    :param computed: computed FCIDUMP file
    :param label: string labelling the test
    """

    # Grab expected header and integrals
    ref_intdump = fcidump_from_file(expected)
    intdump = fcidump_from_file(computed)

    # Compare headers
    compare_recursive(
        ref_intdump,
        intdump,
        'FCIDUMP header',
        forgive=['enuc', 'hcore', 'eri', 'epsilon'])

    ref_energies = energies_from_fcidump(ref_intdump)
    energies = energies_from_fcidump(intdump)

    pass_1el = compare_values(ref_energies['ONE-ELECTRON ENERGY'], energies['ONE-ELECTRON ENERGY'], 7,
                              label + '. 1-electron energy')
    pass_2el = compare_values(ref_energies['TWO-ELECTRON ENERGY'], energies['TWO-ELECTRON ENERGY'], 7,
                              label + '. 2-electron energy')
    pass_scf = compare_values(ref_energies['SCF TOTAL ENERGY'], energies['SCF TOTAL ENERGY'], 10,
                              label + '. SCF total energy')
    pass_mp2 = compare_values(ref_energies['MP2 CORRELATION ENERGY'], energies['MP2 CORRELATION ENERGY'], 10,
                              label + '. MP2 correlation energy')

    compare_integers(True, (pass_1el and pass_2el and pass_scf and pass_mp2), label)