Skip to content

Commit

Permalink
FHIaims: smearing kind and width improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonKratochvil authored and ondracka committed Sep 9, 2024
1 parent dafe7ef commit e4b7eb6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
18 changes: 0 additions & 18 deletions electronicparsers/fhiaims/metainfo/fhi_aims.py
Original file line number Diff line number Diff line change
Expand Up @@ -1076,24 +1076,6 @@ class Method(runschema.method.Method):
categories=[x_fhi_aims_controlIn_method],
)

x_fhi_aims_controlIn_occupation_type = Quantity(
type=str,
shape=[],
description="""
-
""",
categories=[x_fhi_aims_controlIn_method],
)

x_fhi_aims_controlIn_occupation_width = Quantity(
type=np.float64,
shape=[],
description="""
-
""",
categories=[x_fhi_aims_controlIn_method],
)

x_fhi_aims_controlIn_override_relativity = Quantity(
type=str,
shape=[],
Expand Down
20 changes: 18 additions & 2 deletions electronicparsers/fhiaims/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
FrequencyMesh,
BasisSetContainer,
Scf,
Smearing,
)
from runschema.system import System, Atoms
from runschema.calculation import (
Expand Down Expand Up @@ -2201,8 +2202,23 @@ def _prep_elemental_tier(basis_settings: MSection) -> dict[str, Any]:
'Error setting controlIn metainfo.', data=dict(key=key)
)
elif key == 'occupation_type':
sec_method.x_fhi_aims_controlIn_occupation_type = val[0]
sec_method.x_fhi_aims_controlIn_occupation_width = val[1]
sec_smearing = Smearing()
sec_electronic.smearing = sec_smearing

# integer and cubic smearing don't match well the upstream metainfo definitions
occupation_types_dict = {
'gaussian': 'gaussian',
'methfessel-paxton': 'methfessel-paxton',
'fermi': 'fermi',
'integer': None,
'cubic': None,
'cold': 'marzari-vanderbilt',
}

sec_smearing.kind = occupation_types_dict.get(val[0])
# width is defined as unitless in the metainfo (should be Joules)
sec_smearing.width = (float(val[1]) * ureg.eV).to_base_units().magnitude

if len(val) > 2:
sec_method.x_fhi_aims_controlIn_occupation_order = int(val[2])
elif key == 'relativistic':
Expand Down
6 changes: 6 additions & 0 deletions tests/test_fhiaimsparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def test_scf_spinpol(parser):
assert list(sec_method.k_mesh.grid) == [16] * 3
assert sec_method.electronic.n_spin_channels == 2
assert sec_method.electronic.relativity_method == 'scalar_relativistic_atomic_ZORA'
assert sec_method.electronic.smearing.kind == 'gaussian'
assert sec_method.electronic.smearing.width == approx(1.602176634e-20)
assert sec_method.dft.xc_functional.correlation[0].name == 'LDA_C_PW'
assert sec_method.scf.threshold_energy_change.magnitude == approx(1.602176634e-24)
sec_basis_func = sec_method.x_fhi_aims_section_controlIn_basis_set[
Expand Down Expand Up @@ -106,6 +108,8 @@ def test_geomopt(parser):
assert len(sec_methods) == 1
assert list(sec_methods[0].k_mesh.grid) == [8] * 3
assert sec_methods[0].scf.threshold_energy_change.magnitude == approx(1.602176634e-25)
assert sec_methods[0].electronic.smearing.kind == 'gaussian'
assert sec_methods[0].electronic.smearing.width == approx(1.602176633e-21)

sec_sccs = archive.run[0].calculation
assert len(sec_sccs) == 6
Expand Down Expand Up @@ -221,6 +225,8 @@ def test_dos(parser):
sec_method = archive.run[0].method[0]
assert list(sec_method.k_mesh.grid) == [10] * 3
assert sec_method.scf.threshold_energy_change.magnitude == approx(1.602176634e-25)
assert sec_method.electronic.smearing.kind == 'gaussian'
assert sec_method.electronic.smearing.width == approx(1.602176633e-21)

sec_scc = archive.run[0].calculation[0]
sec_dos = sec_scc.dos_electronic
Expand Down

0 comments on commit e4b7eb6

Please sign in to comment.