-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
317df26
commit 8d569cd
Showing
13 changed files
with
198 additions
and
470 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from .pw import PwParser | ||
from .dos import DosParser | ||
from .projwfc import ProjwfcParser | ||
from .ld1 import Ld1Parser | ||
|
||
__all__ = [PwParser, DosParser, ProjwfcParser] | ||
__all__ = [PwParser, DosParser, ProjwfcParser, Ld1Parser] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# -*- coding: utf-8 -*- | ||
"""`Parser` implementation for the `ld1.x` code of Quantum ESPRESSO. | ||
""" | ||
|
||
from aiida_quantumespresso.utils.mapping import get_logging_container | ||
from .exit_code import NamelistsExitCodes | ||
from .base import BaseParser | ||
import re | ||
|
||
|
||
class Ld1Parser(BaseParser): | ||
"""`Parser` implementation for the `dos.x` calculation, modified from aiida-quantumespresso.""" | ||
|
||
success_string = "End of pseudopotential test" | ||
|
||
def __init__(self, directory, outputname): | ||
"""Initialize the instance of `PwParser`.""" | ||
super().__init__(directory, output_filename=outputname) | ||
self.outputname = outputname | ||
self.exit_codes = NamelistsExitCodes() | ||
|
||
def parse(self, **kwargs): | ||
"""Parse the retrieved files of a ``DosCalculation`` into output nodes.""" | ||
|
||
logs = get_logging_container() | ||
|
||
_, parsed_stdout, logs = self.parse_stdout_from_retrieved(logs) | ||
|
||
base_exit_code = self.check_base_errors(logs) | ||
if base_exit_code: | ||
return self.exit(base_exit_code, logs) | ||
|
||
self.out("output_parameters", parsed_stdout) | ||
|
||
if "ERROR_OUTPUT_STDOUT_INCOMPLETE" in logs.error: | ||
return self.exit(self.exit_codes.ERROR_OUTPUT_STDOUT_INCOMPLETE, logs) | ||
|
||
# Parse the Energy | ||
filepath_dos = self.directory / self.outputname | ||
try: | ||
with open(filepath_dos, "r") as handle: | ||
text = handle.read() | ||
energy_data = parse_energy_totals(text) | ||
self.out("ld1", energy_data) | ||
except OSError: | ||
return self.exit(self.exit_codes.ERROR_READING_DOS_FILE, logs) | ||
|
||
return self.exit(logs=logs) | ||
|
||
|
||
def parse_energy_totals(text): | ||
# Pattern to find Etot and Etotps lines and capture relevant parts | ||
etot_pattern = r"Etot\s+=\s+([-\d\.]+)\s+Ry,\s+([-\d\.]+)\s+Ha,\s+([-\d\.]+)\s+eV" | ||
etotps_pattern = ( | ||
r"Etotps\s+=\s+([-\d\.]+)\s+Ry,\s+([-\d\.]+)\s+Ha,\s+([-\d\.]+)\s+eV" | ||
) | ||
|
||
# Search for patterns and extract values | ||
etot_match = re.search(etot_pattern, text) | ||
etotps_match = re.search(etotps_pattern, text) | ||
|
||
# Structured data | ||
energy_data = {} | ||
|
||
if etot_match: | ||
energy_data["Etot"] = { | ||
"Ry": float(etot_match.group(1)), | ||
"Ha": float(etot_match.group(2)), | ||
"eV": float(etot_match.group(3)), | ||
} | ||
|
||
if etotps_match: | ||
energy_data["Etotps"] = { | ||
"Ry": float(etotps_match.group(1)), | ||
"Ha": float(etotps_match.group(2)), | ||
"eV": float(etotps_match.group(3)), | ||
} | ||
|
||
return energy_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from ase_quantumespresso.espresso import Espresso, EspressoProfile | ||
from ase_quantumespresso.ld1 import Ld1Template | ||
|
||
input_data = { | ||
"input": { | ||
"title": "Pt", | ||
"zed": 78.0, | ||
"rel": 1, | ||
"config": "[Xe] 4f13 6s1 6p0 5d9", | ||
"iswitch": 3, | ||
"dft": "PBE", | ||
}, | ||
"inputp": { | ||
"lpaw": True, | ||
"use_xsd": False, | ||
"pseudotype": 3, | ||
"file_pseudopw": "Pt.star4f.pbe-n-kjpaw_psl.1.0.0.UPF", | ||
"author": "Test", | ||
"lloc": -1, | ||
"rcloc": 2.4, | ||
"which_augfun": "PSQ", | ||
"rmatch_augfun_nc": True, | ||
"nlcc": True, | ||
"new_core_ps": True, | ||
"rcore": 1.8, | ||
"tm": True, | ||
}, | ||
} | ||
pseudo_potential_test_cards = """ | ||
6 | ||
6S 1 0 1.00 0.00 2.00 2.20 0.0 | ||
6S 1 0 0.00 4.40 2.00 2.20 0.0 | ||
6P 2 1 0.00 0.00 2.30 2.50 0.0 | ||
6P 2 1 0.00 6.40 2.30 2.50 0.0 | ||
5D 3 2 9.00 0.00 1.00 2.20 0.0 | ||
5D 3 2 0.00 0.80 1.00 2.20 0.0 | ||
""" | ||
|
||
|
||
def test_base_ld1(): | ||
profile = EspressoProfile(command="ld1.x", pseudo_dir=".") | ||
calc = Espresso( | ||
directory="calculatioin", | ||
profile=profile, | ||
template=Ld1Template(), | ||
input_data=input_data, | ||
pseudo_potential_test_cards=pseudo_potential_test_cards, | ||
) | ||
calc.get_property("ld1") | ||
assert calc.results["exit_code"].status == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters