File: test_fix_bond_length_mic.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 (26 lines) | stat: -rw-r--r-- 856 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
def test_fix_bond_length_mic():
    import ase
    from ase.calculators.lj import LennardJones
    from ase.constraints import FixBondLength
    from ase.optimize import FIRE

    for wrap in [False, True]:
        a = ase.Atoms('CCC',
                      positions=[[1, 0, 5],
                                 [0, 1, 5],
                                 [-1, 0.5, 5]],
                      cell=[10, 10, 10],
                      pbc=True)

        if wrap:
            a.set_scaled_positions(a.get_scaled_positions() % 1.0)
        a.calc = LennardJones()
        a.set_constraint(FixBondLength(0, 2))

        d1 = a.get_distance(0, 2, mic=True)

        FIRE(a, logfile=None).run(fmax=0.01)
        e = a.get_potential_energy()
        d2 = a.get_distance(0, 2, mic=True)
        assert abs(e - -2.034988) < 1e-6
        assert abs(d1 - d2) < 1e-6