Пример #1
0
def _run_calc(atoms_in, theory, eref, forces=False, **kwargs):
    atoms = atoms_in.copy()
    calc = NWChem(label=theory, theory=theory, **kwargs)
    atoms.calc = calc
    assert_allclose(atoms.get_potential_energy(), eref, atol=1e-4, rtol=1e-4)
    if forces:
        assert_allclose(atoms.get_forces(),
                        calc.calculate_numerical_forces(atoms),
                        atol=1e-4,
                        rtol=1e-4)

    # Delete all perm/scratch files to ensure tests are idempotent
    for suffix in ['db', 'movecs', 'cfock', 'mp2nos', 't2']:
        _try_delete(theory, theory, suffix)

    for element in ['H', 'O']:
        for suffix in ['psp', 'vpp', 'cpp', 'jpp']:
            _try_delete(theory, element, suffix)
        _try_delete(theory, element, 'basis', sep='_')

    _try_delete(theory, 'junk', 'inp')