From e4b7eb6cc8cdc24e8f8b2ab305a43346f4fe2c54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Kratochv=C3=ADl?= Date: Tue, 30 Jul 2024 15:38:18 +0200 Subject: [PATCH] FHIaims: smearing kind and width improvements --- .../fhiaims/metainfo/fhi_aims.py | 18 ----------------- electronicparsers/fhiaims/parser.py | 20 +++++++++++++++++-- tests/test_fhiaimsparser.py | 6 ++++++ 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/electronicparsers/fhiaims/metainfo/fhi_aims.py b/electronicparsers/fhiaims/metainfo/fhi_aims.py index 4c598df5..9fec9419 100644 --- a/electronicparsers/fhiaims/metainfo/fhi_aims.py +++ b/electronicparsers/fhiaims/metainfo/fhi_aims.py @@ -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=[], diff --git a/electronicparsers/fhiaims/parser.py b/electronicparsers/fhiaims/parser.py index b32e749d..1440d547 100644 --- a/electronicparsers/fhiaims/parser.py +++ b/electronicparsers/fhiaims/parser.py @@ -44,6 +44,7 @@ FrequencyMesh, BasisSetContainer, Scf, + Smearing, ) from runschema.system import System, Atoms from runschema.calculation import ( @@ -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': diff --git a/tests/test_fhiaimsparser.py b/tests/test_fhiaimsparser.py index f9eb65eb..dcd8c62b 100644 --- a/tests/test_fhiaimsparser.py +++ b/tests/test_fhiaimsparser.py @@ -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[ @@ -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 @@ -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