Coverage for gpaw/directmin/functional/lcao/__init__.py: 87%
15 statements
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-19 00:19 +0000
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-19 00:19 +0000
1"""
2files in functional should describe the derivatives of the KS functional
3"""
5from gpaw.xc import xc_string_to_dict
6from ase.utils import basestring
7from gpaw.directmin.functional.lcao.ks import KSLCAO
8from gpaw.directmin.functional.lcao.pz import PZSICLCAO
11def get_functional(func, *args):
13 if isinstance(func, KSLCAO) or isinstance(func, PZSICLCAO):
14 return func
15 elif isinstance(func, basestring):
16 func = xc_string_to_dict(func)
18 if isinstance(func, dict):
19 kwargs = func.copy()
20 name = kwargs.pop('name').replace('-', '').lower()
21 functional = {'ks': KSLCAO,
22 'pzsic': PZSICLCAO}[name](*args, **kwargs)
23 return functional
24 else:
25 raise TypeError('Check functional parameter.')