File: test_ace_calculator.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 (45 lines) | stat: -rw-r--r-- 1,689 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
# fmt: off
from ase import Atoms
from ase.calculators.acemolecule import ACE


def dict_is_subset(d1, d2):
    """True if all the key-value pairs in dict 1 are in dict 2"""

    return all(key in d2 and d2[key] == d1[key] for key in d1)


def test_acemolecule_calculator():

    ace_cmd = "_ase_dummy_ace_command"

    basis = dict(
        Scaling='0.5',
        Cell=7.0,
        Grid='Basic',
        Centered=0,
        Pseudopotential={
            'Pseudopotential': 1,
            'Format': 'upf',
            'PSFilenames': '/PATH/TO/He.pbe.UPF'})
    guess = dict(InitialGuess=1, InitialFilenames='/PATH/TO/He.pbe.UPF')
    scf = dict(IterateMaxCycle=50, ConvergenceType='Energy',
               ConvergenceTolerance=0.000001, EnergyDecomposition=1,
               ExchangeCorrelation={
                   'XFunctional': 'LDA_X',
                   'CFunctional': 'LDA_C_PW'},
               Diagonalize={'Tolerance': 1e-7},
               Mixing={'MixingType': 'Density', 'MixingParameter': 0.3,
                       'MixingMethod': 1})
    he = Atoms("He", positions=[[0.0, 0.0, 0.0]])
    he.calc = ACE(command=ace_cmd, BasicInformation=basis,
                  Guess=guess, Scf=scf)
    sample_parameters = he.calc.parameters
    assert dict_is_subset(basis, sample_parameters['BasicInformation'][0])
    assert dict_is_subset(guess, sample_parameters['Guess'][0])
    assert dict_is_subset(scf, sample_parameters['Scf'][0])
    he.calc.set(BasicInformation={"Pseudopotential": {"UsingDoubleGrid": 1}})
    sample_parameters = he.calc.parameters
    assert dict_is_subset(
        {"UsingDoubleGrid": 1},
        sample_parameters['BasicInformation'][0]["Pseudopotential"])