Commit 996db6bc authored by Alvin Noe Ladines's avatar Alvin Noe Ladines
Browse files

Merge branch 'exciting-parser' into text-parser

parents ec8e72b7 6512f3ae
Pipeline #85359 passed with stages
in 34 minutes and 10 seconds
Subproject commit 6fcf51ac6088192c166b5d80571edce06dded232
Subproject commit 885c487a897d0daf54a4d35718052e8a4995e635
......@@ -945,7 +945,7 @@ class section_method(public.section_method):
gw_frequency_number = Quantity(
type=np.dtype(np.int32),
shape=[],
shape=['gw_number_of_frequencies'],
description='''
Number referring to the frequency used in the calculation of the self energy.
''',
......@@ -953,7 +953,7 @@ class section_method(public.section_method):
gw_frequency_values = Quantity(
type=np.dtype(np.float64),
shape=[],
shape=['gw_number_of_frequencies'],
unit='joule',
description='''
Values of the frequency used in the calculation of the self energy.
......@@ -962,7 +962,7 @@ class section_method(public.section_method):
gw_frequency_weights = Quantity(
type=np.dtype(np.float64),
shape=[],
shape=['gw_number_of_frequencies'],
description='''
Weights of the frequency used in the calculation of the self energy.
''',
......
......@@ -3596,6 +3596,16 @@ class section_scf_iteration(MSection):
m_def = Section(validate=False, a_legacy=LegacyDefinition(name='section_scf_iteration'))
charge_total_scf_iteration = Quantity(
type=np.dtype(np.float64),
shape=[],
unit='coulomb',
description='''
Value of the total charge, calculated with the method described in XC_method
during each self-consistent field (SCF) iteration.
''',
a_legacy=LegacyDefinition(name='charge_total_scf_iteration'))
electronic_kinetic_energy_scf_iteration = Quantity(
type=np.dtype(np.float64),
shape=[],
......@@ -3849,6 +3859,16 @@ class section_scf_iteration(MSection):
categories=[time_info, accessory_info],
a_legacy=LegacyDefinition(name='time_scf_iteration_wall_start'))
time_scf_iteration = Quantity(
type=np.dtype(np.float64),
shape=[],
unit='second',
description='''
Total time of the self-consistent field (SCF) iteration.
''',
categories=[time_info, accessory_info],
a_legacy=LegacyDefinition(name='time_scf_iteration'))
class section_single_configuration_calculation(MSection):
'''
......@@ -3977,6 +3997,15 @@ class section_single_configuration_calculation(MSection):
categories=[atom_forces_type],
a_legacy=LegacyDefinition(name='atom_forces'))
charge_total = Quantity(
type=np.dtype(np.float64),
shape=[],
unit='coulomb',
description='''
Value of the total charge, calculated with the method described in XC_method.
''',
a_legacy=LegacyDefinition(name='charge_total'))
electronic_kinetic_energy = Quantity(
type=np.dtype(np.float64),
shape=[],
......@@ -5192,6 +5221,18 @@ class section_system(MSection):
categories=[configuration_core],
a_legacy=LegacyDefinition(name='lattice_vectors'))
lattice_vectors_reciprocal = Quantity(
type=np.dtype(np.float64),
shape=[3, 3],
unit='1/meter',
description='''
Reciprocal lattice vectors (in Cartesian coordinates) of the simulation cell. The
first index runs over the $x,y,z$ Cartesian coordinates, and the second index runs
over the 3 lattice vectors.
''',
categories=[configuration_core],
a_legacy=LegacyDefinition(name='lattice_vectors_reciprocal'))
local_rotations = Quantity(
type=np.dtype(np.float64),
shape=['number_of_atoms', 3, 3],
......
......@@ -30,6 +30,7 @@ from elasticparser import ElasticParser
from lammpsparser import LammpsParser
from fhiaimsparser import FHIAimsParser
from gromacsparser import GromacsParser
from excitingparser import ExcitingParser
try:
# these packages are not available without parsing extra, which is ok, if the
......@@ -129,13 +130,8 @@ parsers = [
mainfile_name_re=r'(.*/)?OUTCAR(\.[^\.]*)?',
mainfile_contents_re=(r'^\svasp\.')
),
LegacyParser(
name='parsers/exciting', code_name='exciting', code_homepage='http://exciting-code.org/',
parser_class_name='excitingparser.ExcitingParser',
mainfile_name_re=r'^.*.OUT(\.[^/]*)?$',
mainfile_contents_re=(r'EXCITING.*started')
),
FHIAimsParser(),
ExcitingParser(),
LegacyParser(
name='parsers/cp2k', code_name='CP2K', code_homepage='https://www.cp2k.org/',
parser_class_name='cp2kparser.CP2KParser',
......
......@@ -144,6 +144,7 @@ class Quantity:
elif isinstance(val, dict):
for k, v in val.items():
self.dtype = None
val[k] = _process(v)
return val
......@@ -171,13 +172,16 @@ class FileParser:
self._mainfile = os.path.abspath(mainfile) if mainfile else mainfile
self.logger = logger if logger else logging
self._results = None
# a key is necessary for xml parsers
self._key = None
self._file_handler = None
@property
def results(self):
if self._results is None:
self._results = dict()
self.parse()
if self._key not in self._results:
self.parse(self._key)
return self._results
......@@ -201,6 +205,7 @@ class FileParser:
self._mainfile = val
def get(self, key, default=None, unit=None):
self._key = key
val = self.results.get(key, None)
if val is None:
val = default
......@@ -223,7 +228,7 @@ class FileParser:
elif isinstance(key, int):
return self[int]
def parse(self):
def parse(self, key=None):
for key, val in self._results.items():
try:
setattr(self, key, val)
......@@ -411,9 +416,6 @@ class UnstructuredTextFileParser(FileParser):
for key in self.keys():
yield key, self[key]
def __getitem__(self, key):
return self.get(key)
def _parse_quantities(self, quantities):
re_findall = '|'.join([q.re_pattern.pattern.decode() for q in quantities])
if len(quantities) == 1:
......@@ -541,10 +543,13 @@ class UnstructuredTextFileParser(FileParser):
self.logger.warn('Error setting value for %s ' % quantity.name)
pass
def parse(self):
def parse(self, key=None):
if self._results is None:
self._results = dict()
if len(self._results) > 1:
return
if self.file_mmap is None:
return
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment