File: test_acn.py

package info (click to toggle)
python-ase 3.26.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,484 kB
  • sloc: python: 148,112; xml: 2,728; makefile: 110; javascript: 47
file content (29 lines) | stat: -rw-r--r-- 764 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
# fmt: off
from ase import Atoms
from ase.calculators.acn import ACN, m_me, r_cn, r_mec
from ase.calculators.fd import calculate_numerical_forces


def test_acn():
    """Test ACN forces."""

    dimer = Atoms('CCNCCN',
                  [(-r_mec, 0, 0),
                   (0, 0, 0),
                   (r_cn, 0, 0),
                   (r_mec, 3.7, 0),
                   (0, 3.7, 0),
                   (-r_cn, 3.7, 0)])

    # Set mass of methyls
    masses = dimer.get_masses()
    masses[::3] = m_me
    dimer.set_masses(masses)

    dimer.calc = ACN(rc=5.0, width=2.0)  # Put C-C distance in the cutoff range
    F = dimer.get_forces()
    print(F)
    Fnum = calculate_numerical_forces(dimer)
    dF = Fnum - F
    print(dF)
    assert abs(dF).max() < 2e-6