File: test_fixcom.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 (18 lines) | stat: -rw-r--r-- 443 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
def test_fixcom():
    from ase.calculators.emt import EMT
    from ase.optimize import BFGS
    from ase.constraints import FixCom
    from ase.build import molecule

    atoms = molecule('H2O')
    atoms.center(vacuum=4)
    atoms.calc = EMT()
    cold = atoms.get_center_of_mass()
    atoms.set_constraint(FixCom())

    opt = BFGS(atoms)
    opt.run(steps=5)

    cnew = atoms.get_center_of_mass()

    assert max(abs(cnew - cold)) < 1e-8