File: test_al.py

package info (click to toggle)
python-ase 3.22.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 14,344 kB
  • sloc: python: 126,379; xml: 946; makefile: 111; javascript: 47
file content (50 lines) | stat: -rw-r--r-- 1,489 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import pytest
from ase.build import bulk
from ase.test.factories import ObsoleteFactoryWrapper


omx_par = {'definition_of_atomic_species': [['Al', 'Al8.0-p1', 'Al_CA13'],
                                            ['O', 'O6.0-p1', 'O_CA13']]}


required = {'aims': dict(sc_accuracy_rho=5.e-3)}


calc = pytest.mark.calculator


@calc('abinit', ecut=200, toldfe=0.0001, chksymbreak=0)
@calc('openmx', **omx_par)
@calc('elk', rgkmax=5.0)
def test_al(factory):
    run(factory)


@pytest.mark.parametrize('name', sorted(required))
def test_al_old(name):
    factory = ObsoleteFactoryWrapper(name)
    run(factory)


def run(factory):
    name = factory.name
    par = required.get(name, {})
    # What on earth does kpts=1.0 mean?  Was failing, I changed it.  --askhl
    # Disabled GPAW since it was failing anyway. --askhl
    kpts = [2, 2, 2]
    calc = factory.calc(label=name, xc='LDA', kpts=kpts, **par)
    al = bulk('AlO', crystalstructure='rocksalt', a=4.5)
    al.calc = calc
    e = al.get_potential_energy()
    calc.set(xc='PBE', kpts=kpts)
    epbe = al.get_potential_energy()
    print(e, epbe)
    calc = factory.calc(restart=name)
    print(calc.parameters, calc.results, calc.atoms)
    assert not calc.calculation_required(al, ['energy'])
    al = calc.get_atoms()
    print(al.get_potential_energy())
    label = 'dir/' + name + '-2'
    calc = factory.calc(label=label, atoms=al, xc='LDA', kpts=kpts,
                        **par)
    print(al.get_potential_energy())