Commits (2)
......@@ -52,8 +52,9 @@ class FhiAimsDosParserContext(object):
self.writeMetaData = writeMetaData
# unit cell volume is necessary for unit-conversion compliant with
# NOMAD-metaInfo
# unit_cell_volume is set by the 'main' FhiAimsParser before calling us
# unit_cell_volume and self.fermi_energy is set by the 'main' FhiAimsParser before calling us
self.unit_cell_volume = None
self.fermi_energy = None
def startedParsing(self, fInName, parser):
"""Function is called when the parsing starts and the compiled parser is obtained.
......@@ -117,7 +118,7 @@ def build_FhiAimsDosFileSimpleMatcher():
sections = ['section_run'],
subMatchers = [
SM (name = 'Root3',
startReStr = r"# The energy reference for this output is the (?:average )?chemical potential, mu =\s*[-+0-9.]+ *eV",
startReStr = r"# The energy reference for this output is the vacuum level",
sections = ['section_single_configuration_calculation'],
subMatchers = [
SM (name = 'Root4',
......
......@@ -98,6 +98,7 @@ class FhiAimsParserContext(object):
self.MD = False
self.MDUnitCell = None
self.unit_cell_volume = None
self.fermi_energy = None
self.band_segm_start_end = None
# start with -1 since zeroth iteration is the initialization
self.scfIterNr = -1
......@@ -595,10 +596,14 @@ class FhiAimsParserContext(object):
if self.dosFound:
self.dosRefSingleConfigurationCalculation = gIndex
self.dosFound = False
# Save the Fermi energy from the last converged SCF step
try:
fermi_ref = section['x_fhi_aims_energy_reference_fermi'][0]
backend.addArrayValues('energy_reference_fermi', np.array([fermi_ref, fermi_ref]) * ureg.eV)
except:
scf_iterations = section["section_scf_iteration"]
last_iteration = scf_iterations[-1]
self.fermi_energy = (last_iteration['x_fhi_aims_energy_reference_fermi'][0] * ureg.eV).to(ureg.J).m
backend.addArrayValues('energy_reference_fermi', [self.fermi_energy, self.fermi_energy])
except Exception:
pass
self.lastCalculationGIndex = gIndex
......@@ -665,15 +670,16 @@ class FhiAimsParserContext(object):
self.dos_values = None
# construct file name
dirName = os.path.dirname(os.path.abspath(self.fName))
dFile = 'KS_DOS_total.dat'
dFile = 'KS_DOS_total_raw.dat'
fName = os.path.normpath(os.path.join(dirName, dFile))
try:
with open(fName) as fIn:
# construct parser for DOS file if not present
if self.dosSuperContext is None or self.dosParser is None:
self.compile_dos_parser()
# forward the unit cell volume to the DOS parser for
# forward the unit cell volume and fermi energy to the DOS parser for
# normalization
self.dosSuperContext.fermi_energy = self.fermi_energy
self.dosSuperContext.unit_cell_volume = self.unit_cell_volume
# parse DOS file
self.dosParser.parseFile(fIn)
......@@ -1585,7 +1591,7 @@ def build_FhiAimsMainFileSimpleMatcher():
subMatchers = [
SM (r"\s*Date\s*:\s*(?P<x_fhi_aims_scf_date_start>[-.0-9/]+)\s*,\s*Time\s*:\s*(?P<x_fhi_aims_scf_time_start>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)"),
SM (r"\s*-{20}-*", weak = True),
SM (r"\s*\| Chemical potential \(Fermi level\):\s*(?P<x_fhi_aims_energy_reference_fermi__eV>[-+]?[0-9]*\.?[0-9]+)\s*eV", name='FermiLevel'),
SM (r"\s*\| Chemical potential \(Fermi level\) (in eV)?\s*:\s*(?P<x_fhi_aims_energy_reference_fermi__eV>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)(\s*eV)?", name='FermiLevel'),
EigenvaluesGroupSubMatcher,
TotalEnergyScfSubMatcher,
SM (r"\s*End scf initialization - timings\s*:\s*max\(cpu_time\)\s+wall_clock\(cpu1\)"),
......@@ -1599,6 +1605,7 @@ def build_FhiAimsMainFileSimpleMatcher():
subMatchers = [
SM (r"\s*Date\s*:\s*(?P<x_fhi_aims_scf_date_start>[-.0-9/]+)\s*,\s*Time\s*:\s*(?P<x_fhi_aims_scf_time_start>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)"),
SM (r"\s*-{20}-*", weak = True),
SM (r"\s*\| Chemical potential \(Fermi level\) (in eV)?\s*:\s*(?P<x_fhi_aims_energy_reference_fermi__eV>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)(\s*eV)?", name='FermiLevel'),
EigenvaluesGroupSubMatcher.copy(), # need copy since SubMatcher already used for ScfInitialization
TotalEnergyScfSubMatcher.copy(), # need copy since SubMatcher already used for ScfInitialization
# raw forces
......@@ -1629,6 +1636,7 @@ def build_FhiAimsMainFileSimpleMatcher():
subMatchers = [
SM (r"\s*Date\s*:\s*(?P<x_fhi_aims_scf_date_start>[-.0-9/]+)\s*,\s*Time\s*:\s*(?P<x_fhi_aims_scf_time_start>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)"),
SM (r"\s*-{20}-*", weak = True),
SM (r"\s*\| Chemical potential \(Fermi level\) (in eV)?\s*:\s*(?P<x_fhi_aims_energy_reference_fermi__eV>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)(\s*eV)?", name='FermiLevel'),
EigenvaluesGroupSubMatcher.copy(), # need copy since SubMatcher already used for ScfInitialization
TotalEnergyScfSubMatcher.copy(), # need copy since SubMatcher already used for ScfInitialization
# raw forces
......@@ -1774,6 +1782,8 @@ def get_cachingLevelForMetaName(metaInfoEnv):
'x_fhi_aims_single_configuration_calculation_converged': CachingLevel.Cache,
'x_fhi_aims_species_projected_dos_file': CachingLevel.Cache,
'x_fhi_aims_species_projected_dos_species_label': CachingLevel.Cache,
'section_scf_iteration': CachingLevel.ForwardAndCache,
'x_fhi_aims_energy_reference_fermi': CachingLevel.ForwardAndCache,
'section_dos': CachingLevel.Ignore,
}
# Set all controlIn and controlInOut metadata to Cache to capture multiple occurrences of keywords and
......
......@@ -820,9 +820,6 @@ class section_single_configuration_calculation(public.section_single_configurati
repeats=False,
a_legacy=LegacyDefinition(name='x_fhi_aims_section_eigenvalues_ZORA'))
x_fhi_aims_energy_reference_fermi = Quantity(
type=float, unit=ureg.eV, a_legacy=LegacyDefinition(name='x_fhi_aims_energy_reference_fermi'))
class section_scf_iteration(public.section_scf_iteration):
......@@ -968,6 +965,9 @@ class section_scf_iteration(public.section_scf_iteration):
repeats=False,
a_legacy=LegacyDefinition(name='x_fhi_aims_section_eigenvalues_group'))
x_fhi_aims_energy_reference_fermi = Quantity(
type=float, unit=ureg.eV, a_legacy=LegacyDefinition(name='x_fhi_aims_energy_reference_fermi'))
class section_atom_projected_dos(public.section_atom_projected_dos):
......