File: test_psi4_HF_3_21G.py

package info (click to toggle)
python-ase 3.24.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 15,448 kB
  • sloc: python: 144,945; xml: 2,728; makefile: 113; javascript: 47
file content (35 lines) | stat: -rw-r--r-- 1,187 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import pytest
from numpy.testing import assert_allclose

from ase.build import molecule
from ase.calculators.fd import calculate_numerical_forces


@pytest.mark.skip(reason='we do not know how to compile psi4')
@pytest.mark.filterwarnings('once::DeprecationWarning')
@pytest.mark.calculator_lite()
@pytest.mark.calculator('psi4')
def test_main(factory):
    atoms = molecule('H2O')
    atoms.rotate(30, 'x')

    calc = factory.calc(basis='3-21G')
    atoms.calc = calc

    # Calculate forces ahead of time, compare against finite difference after
    # checking the psi4-calc.dat file
    atoms.get_forces()
    assert_allclose(atoms.get_potential_energy(), -2056.785854116688,
                    rtol=1e-4, atol=1e-4)

    # Test the reader
    calc2 = factory.calc()
    calc2.read('psi4-calc')
    assert_allclose(calc2.results['energy'], atoms.get_potential_energy(),
                    rtol=1e-4, atol=1e-4)
    assert_allclose(calc2.results['forces'], atoms.get_forces(),
                    rtol=1e-4, atol=1e-4)

    # Compare analytical vs numerical forces
    assert_allclose(atoms.get_forces(), calculate_numerical_forces(atoms),
                    rtol=1e-4, atol=1e-4)