diff --git a/express/parsers/apps/espresso/formats/espresso_640xml.py b/express/parsers/apps/espresso/formats/espresso_640xml.py index d775ae7b..cdeb64bb 100644 --- a/express/parsers/apps/espresso/formats/espresso_640xml.py +++ b/express/parsers/apps/espresso/formats/espresso_640xml.py @@ -25,6 +25,16 @@ def steps(self): self._steps = sorted(self.root.findall("step"), key=lambda node: int(node.get("n_step"))) return self._steps + def application_version(self) -> str: + """ + Returns the version of Espresso found in the XML file. + Returns: + str: The version of the application + """ + creator_node = self.traverse_xml(self.root, ("general_info", "creator")) + creator_version = creator_node.get("VERSION", default="VERSION_NOT_FOUND") + return creator_version + def fermi_energy(self) -> float: """ Extracts fermi energy. diff --git a/express/parsers/apps/espresso/formats/espresso_legacyxml.py b/express/parsers/apps/espresso/formats/espresso_legacyxml.py index f041031f..51a42e13 100644 --- a/express/parsers/apps/espresso/formats/espresso_legacyxml.py +++ b/express/parsers/apps/espresso/formats/espresso_legacyxml.py @@ -45,6 +45,16 @@ def _get_xml_tag_value(self, tag): result = TAG_VALUE_CAST_MAP[type](tag.text, size, columns) return result[0][0] if size == 1 and type not in ['logical', 'character'] else result + def application_version(self) -> str: + """ + Returns the version of Espresso found in the XML file. + Returns: + str: The version of the application + """ + creator_node = self.traverse_xml(self.root, ("HEADER", "CREATOR")) + creator_version = creator_node.get("VERSION", default="VERSION_NOT_FOUND") + return creator_version + def fermi_energy(self): """ Extracts fermi energy. diff --git a/express/parsers/apps/espresso/parser.py b/express/parsers/apps/espresso/parser.py index 3429054d..72c13475 100644 --- a/express/parsers/apps/espresso/parser.py +++ b/express/parsers/apps/espresso/parser.py @@ -61,6 +61,27 @@ def find_xml_file(self): is_sternheimer_gw and settings.STERNHEIMER_GW0_DIR_PATTERN in file_path): return file_path + def application_version(self) -> str: + """ + Returns the version of Espresso found in the XML file. + Returns: + str: The version of the application + """ + # This dict maps the version reported by the XML parser to the full version number, for use in the rest of + # our platform + versions_map = { + "6.5": "6.5.0", + "6.6": "6.6.0", + "6.7MaX": "6.7.0", + "6.7": "6.7.0", + "6.8": "6.8.0" + + } + parsed_version = self.xml_parser.application_version() + version = versions_map.get(parsed_version, parsed_version) + return version + + def total_energy(self) -> float: """ Returns total energy. @@ -360,3 +381,4 @@ def final_structure_strings(self) -> List[str]: print(f"exception finalizing structures: {repr(e)}") pass return structures + diff --git a/tests/fixtures/espresso/references.py b/tests/fixtures/espresso/references.py index c582c2d3..f3f91317 100644 --- a/tests/fixtures/espresso/references.py +++ b/tests/fixtures/espresso/references.py @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:73a816a8cb6644914e2b86b6bed981aa26b8b1ad613bc99ca08c21ae53100d0d -size 21392 +oid sha256:7da5eefb30c71519e46d4101352f106f1e5e4c9cba6e91eccaf6c1b203f19a29 +size 21876 diff --git a/tests/manifest.yaml b/tests/manifest.yaml index 8421cf82..912b9a07 100644 --- a/tests/manifest.yaml +++ b/tests/manifest.yaml @@ -36,6 +36,8 @@ tests: comparison: assertDeepAlmostEqual final_lattice_vectors: comparison: assertDeepAlmostEqual + application_version: + comparison: assertDeepAlmostEqual test_config_schema: - name: name @@ -77,6 +79,7 @@ applications: # fixtures/ - atomic_forces - total_energy_contributions - final_lattice_vectors + - application_version - subdir: projwfc.x/dos filename: projwfc.out tests: @@ -101,6 +104,7 @@ applications: # fixtures/ - final_lattice_vectors - name: eigenvalues_at_kpoints actual_index: 0 + - application_version - subdir: pw.x/pw_vc_relax filename: pw.out tests: @@ -112,6 +116,7 @@ applications: # fixtures/ - final_lattice_vectors - name: eigenvalues_at_kpoints actual_index: 0 + - application_version 6.5.0: - subdir: pw.x/pw_scf filename: pw.out @@ -124,6 +129,7 @@ applications: # fixtures/ - final_lattice_vectors - name: eigenvalues_at_kpoints actual_index: 0 + - application_version - subdir: pw.x/pw_vc_relax filename: pw.out tests: @@ -135,6 +141,7 @@ applications: # fixtures/ - final_lattice_vectors - name: eigenvalues_at_kpoints actual_index: 0 + - application_version 6.6.0: - subdir: pw.x/pw_scf filename: pw.out @@ -147,6 +154,7 @@ applications: # fixtures/ - final_lattice_vectors - name: eigenvalues_at_kpoints actual_index: 0 + - application_version - subdir: pw.x/pw_vc_relax filename: pw.out tests: @@ -158,6 +166,7 @@ applications: # fixtures/ - final_lattice_vectors - name: eigenvalues_at_kpoints actual_index: 0 + - application_version 6.7.0: - subdir: pw.x/pw_scf filename: pw.out @@ -170,6 +179,7 @@ applications: # fixtures/ - final_lattice_vectors - name: eigenvalues_at_kpoints actual_index: 0 + - application_version - subdir: pw.x/pw_vc_relax filename: pw.out tests: @@ -181,6 +191,7 @@ applications: # fixtures/ - final_lattice_vectors - name: eigenvalues_at_kpoints actual_index: 0 + - application_version 6.8.0: - subdir: pw.x/pw_scf filename: pw.out @@ -193,6 +204,7 @@ applications: # fixtures/ - final_lattice_vectors - name: eigenvalues_at_kpoints actual_index: 0 + - application_version - subdir: pw.x/pw_vc_relax filename: pw.out tests: @@ -204,6 +216,7 @@ applications: # fixtures/ - final_lattice_vectors - name: eigenvalues_at_kpoints actual_index: 0 + - application_version vasp: 5.3.5: