File: test_counterions.py

package info (click to toggle)
python-ase 3.21.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 13,936 kB
  • sloc: python: 122,428; xml: 946; makefile: 111; javascript: 47
file content (24 lines) | stat: -rw-r--r-- 743 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
def test_counterions():
    """ Test AtomicCounterIon is force/energy consistent over 
        PBCs and with cutoff """

    import numpy as np
    from ase import Atoms
    from ase import units
    from ase.calculators.counterions import AtomicCounterIon as ACI

    sigma = 1.868 * (1.0/2.0)**(1.0/6.0)
    epsilon = 0.00277 * units.kcal / units.mol

    atoms = Atoms('3Na', positions=np.array([[0, 0, -2], [0,0,0], [0,0,2]]))
    atoms.cell = [10, 10, 10]
    atoms.pbc = True

    atoms.calc = ACI(1, epsilon, sigma, rc=4.5)
    points = np.arange(-15., 15., 0.2)

    for p in points:
        f = atoms.get_forces()
        fn = atoms.calc.calculate_numerical_forces(atoms, 1e-5)
        df = (f-fn)
        assert abs(df).max() < 1e-8