File: test.py

package info (click to toggle)
python-ase 3.26.0-3
  • 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 (31 lines) | stat: -rw-r--r-- 714 bytes parent folder | download | duplicates (2)
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
30
31
# creates: test.txt
import runpy
from pathlib import Path

import numpy as np

# Monkey-patch view() to avoid ASE-GUI windows popping up:
import ase.visualize

ase.visualize.view = lambda *args, **kwargs: None


def run(script):
    return runpy.run_path(Path('selfdiffusion') / script)


def run_and_get_ptp_energy(script):
    dct = run(script)
    energy = np.ptp([i.get_potential_energy() for i in dct['images']])
    return energy


e1 = run_and_get_ptp_energy('neb1.py')
assert abs(e1 - 0.111) < 0.002
e2 = run_and_get_ptp_energy('neb2.py')
assert abs(e2 - 0.564) < 0.002
e3 = run_and_get_ptp_energy('neb3.py')
assert abs(e3 - 0.239) < 0.002

with open('test.txt', 'w') as fd:
    print(e1, e2, e3, file=fd)