File: test_integration.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 (28 lines) | stat: -rw-r--r-- 948 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
# fmt: off
import numpy as np
import pytest

from ase.build import bulk
from ase.filters import FrechetCellFilter
from ase.optimize import BFGS
from ase.units import Ry


# XXX 2023-08-07: segfaults with ecutwfc=300 / Ry and espresso-7.0 (Ubuntu)
@pytest.mark.calculator_lite()
@pytest.mark.calculator('espresso',
                        input_data={"system": {"ecutwfc": 200 / Ry}})
@pytest.mark.calculator('abinit')
def test_socketio_espresso(factory):
    atoms = bulk('Si')
    atoms.rattle(stdev=.2, seed=42)

    with BFGS(FrechetCellFilter(atoms)) as opt, \
            pytest.warns(UserWarning, match='Subprocess exited'), \
            factory.socketio(unixsocket=f'ase_test_socketio_{factory.name}',
                             kpts=[2, 2, 2]) as atoms.calc:

        for _ in opt.irun(fmax=0.05):
            e = atoms.get_potential_energy()
            fmax = max(np.linalg.norm(atoms.get_forces(), axis=0))
            print(e, fmax)