File: test_mirror.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 (29 lines) | stat: -rw-r--r-- 950 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
def test_mirror():
    from ase.build import molecule
    from ase.constraints import MirrorForce, FixBondLength, MirrorTorque
    from ase.constraints import ExternalForce
    from ase.optimize import FIRE
    from ase.calculators.emt import EMT


    atoms = molecule('cyclobutene')
    dist = atoms.get_distance(0, 1)
    con1 = MirrorForce(2, 3, max_dist=5., fmax=0.05)
    con2 = FixBondLength(0, 1)
    atoms.set_constraint([con1, con2])
    atoms.calc = EMT()
    opt = FIRE(atoms)
    opt.run(fmax=0.05)
    assert round(dist - atoms.get_distance(0, 1), 5) == 0

    atoms = molecule('butadiene')
    # Break symmetry
    atoms[0].position[2] += 0.2
    dist = atoms.get_distance(1, 2)
    con1 = MirrorTorque(0, 1, 2, 3, fmax=0.05)
    con2 = ExternalForce(9, 4, f_ext=0.1)
    atoms.set_constraint([con1, con2])
    atoms.calc = EMT()
    opt = FIRE(atoms)
    opt.run(fmax=0.05, steps=300)
    # The result is not realistic because of EMT