File: test_maxstep.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 (23 lines) | stat: -rw-r--r-- 724 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
# fmt: off
import numpy as np

from ase.build import molecule
from ase.calculators.qmmm import ForceConstantCalculator
from ase.optimize import MDMin


def test_mdmin_maxstep():
    atoms = molecule("N2", vacuum=10)
    calc = ForceConstantCalculator(np.eye(6) * 100,
                                   atoms.copy(), np.zeros((2, 3)))
    atoms.calc = calc
    atoms.positions[1] += np.array([1.0, 1.0, 1.0])
    initial_positions = atoms.positions.copy()
    # Both atoms now have huge forces on them.

    # This is a very large dt to force the maxstep clipping to trigger.
    opt = MDMin(atoms, dt=1.0)
    opt.run(steps=1)

    assert np.max(
        np.linalg.norm(atoms.positions - initial_positions, axis=1)) <= 0.2