From 5877fe2e0eae3c43cbacc0031f553d4ce6935e37 Mon Sep 17 00:00:00 2001 From: temok-mx <temok.mx@gmail.com> Date: Wed, 19 Aug 2020 15:05:33 -0500 Subject: [PATCH] Fermi energy: fixed bug on unopened section_single_configuration_calculation --- octopusparser/aseoct.py | 25 ++++++++++--------------- octopusparser/parser_octopus.py | 25 +++++++------------------ 2 files changed, 17 insertions(+), 33 deletions(-) diff --git a/octopusparser/aseoct.py b/octopusparser/aseoct.py index e3aa10f..02904d8 100644 --- a/octopusparser/aseoct.py +++ b/octopusparser/aseoct.py @@ -310,7 +310,6 @@ def read_static_info_kpoints(fd): return dict(ibz_k_points=ibz_k_points, k_point_weights=k_point_weights) -#def read_static_info_eigenvalues(fd, energy_unit): def read_static_info_eigenvalues_efermi(fd, energy_unit): ''' Parse eigenvalues and Fermi Energy from `static/info` @@ -318,6 +317,13 @@ def read_static_info_eigenvalues_efermi(fd, energy_unit): energy_unit: string Returns: dictionary ''' + + # we had to allow this function to handle both + # eigenvalues and Fermi energies because the later + # comes in the output file immediately after the last + # eigenvalue, hence the "fermi line" is consumed by the + # line checkers that look for eigenvalues. + values_sknx = {} nbands = 0 @@ -383,7 +389,6 @@ def read_static_info(fd): elif line.startswith('Eigenvalues ['): unit = get_energy_unit(line) results.update(read_static_info_eigenvalues_efermi(fd, unit)) - ## print('I found:', results['efermi']) elif line.startswith('Energy ['): unit = get_energy_unit(line) results.update(read_static_info_energy(fd, unit)) @@ -424,18 +429,6 @@ def read_static_info(fd): tokens = line.split()[-3:] forces.append([float(f) for f in tokens]) results['forces'] = np.array(forces) * forceunit - elif line.startswith('Fermi'): - # this check is 'one line too late' - # hence we capture Fermi energy from - # `read_static_info_eigenvalues()` - # print('Point 1', line) - tokens = line.split() - unit = {'eV': eV, 'H': Hartree}[tokens[-1]] - eFermi = float(tokens[-2]) * unit - results['efermi'] = eFermi - # print("helloo, eFermi:", eFermi, unit) - # print('####1', line) - if 'ibz_k_points' not in results: results['ibz_k_points'] = np.zeros((1, 3)) @@ -454,7 +447,6 @@ def read_static_info(fd): results['efermi'] = eFermi # print('eFermi estimate', eFermi) # this produces bad estimate # ---- - #print('finish', results['efermi']) return results @@ -490,6 +482,9 @@ class Octopus(FileIOCalculator): def get_fermi_level(self): return self.results['efermi'] + def get_fermi_energy(self): + return self.results['efermi'] + def get_dipole_moment(self, atoms=None): if 'dipole' not in self.results: msg = ('Dipole moment not calculated.\n' diff --git a/octopusparser/parser_octopus.py b/octopusparser/parser_octopus.py index a05cdf2..f0f5966 100644 --- a/octopusparser/parser_octopus.py +++ b/octopusparser/parser_octopus.py @@ -67,20 +67,6 @@ def parse_infofile(meta_info_env, pew, fname): iterations = int(line.split()[-2]) pew.addValue('x_octopus_info_scf_converged_iterations', iterations) - # - - - - - if line.startswith('Fermi'): - # print('\tLINE:', line) - #pew.addValue('energy_reference_fermi', fermiref) - break - # ############ - # CHAT WITH MARKUS - for line in fd: # Jump down to Fermi FIXME as in FIRST BLOCK - # beware of units - # 'Fermi energy': 'energy_reference_fermi' - if line.startswith('Fermi'): - #octunit = line.strip().split()[-1].strip('[]:') - #nomadunit = {'eV': 'eV', 'H': 'hartree'}[octunit] # keep it - break for line in fd: # Jump down to energies: if line.startswith('Energy ['): @@ -109,10 +95,6 @@ def parse_infofile(meta_info_env, pew, fname): if tokens[0] in names: pew.addValue(names[tokens[0]], convert_unit(float(tokens[2]), nomadunit)) - if tokens[0] == 'Fermi energy': - pass - # print(tokens) - # print('#', line) def parse_logfile(meta_info_env, pew, fname): @@ -451,6 +433,10 @@ def parse_without_class(fname, backend, parser_info): nspins = calc.get_number_of_spins() nkpts = len(calc.get_k_point_weights()) + #fermi_energy = calc.get_fermi_level() + #print('I can see: ', fermi_energy) + #pew.addArrayValues('energy_reference_fermi', [fermi_energy, fermi_energy]) + if logfile is None: # print('No stdout logfile found', file=fd) logging.debug('No stdout logfile found') @@ -541,6 +527,9 @@ def parse_without_class(fname, backend, parser_info): # np.array(atoms.pbc)) with open_section('section_single_configuration_calculation'): + fermi_energy = calc.get_fermi_level() + pew.addArrayValues('energy_reference_fermi', [fermi_energy, fermi_energy]) + pew.addValue('single_configuration_calculation_to_system_ref', system_gid) # print('Parse info file %s' % fname) #, file=fd) -- GitLab