-
Notifications
You must be signed in to change notification settings - Fork 18
Add energy contributions #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
13d82b4
60efdb4
49b9657
ede7500
a055b49
e74b640
48e3554
3591c12
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -4,6 +4,23 @@ | |||||
|
||||||
from .common import FLOAT, BlockMatch | ||||||
|
||||||
MAIN_ENERGY_RE = re.compile( | ||||||
rf""" | ||||||
^\s*Overlap\ energy\ of\ the\ core\ charge\ distribution:\s*(?P<overlap_core>{FLOAT})\n | ||||||
\s*Self\ energy\ of\ the\ core\ charge\ distribution:\s*(?P<self_core>{FLOAT})\n | ||||||
\s*Core\ Hamiltonian\ energy:\s*(?P<core_hamiltonian>{FLOAT})\n | ||||||
\s*Hartree\ energy:\s*(?P<hartree>{FLOAT})\n | ||||||
(?:\s*Exchange-correlation\ energy:\s*(?P<xc>{FLOAT})\n)? | ||||||
(?:\s*Electronic\ entropic\ energy:\s*(?P<electronic_entropic>{FLOAT})\n)? | ||||||
(?:\s*Fermi\ energy:\s*(?P<fermi>{FLOAT})\n)? | ||||||
(?:\s*Dispersion\ energy:\s*(?P<dispersion>{FLOAT})\n)? | ||||||
\n | ||||||
\s*Total\ energy:\s*(?P<total>{FLOAT})\n | ||||||
""", | ||||||
re.VERBOSE | re.MULTILINE, | ||||||
) | ||||||
|
||||||
|
||||||
FORCE_EVAL_ENERGY_RE = re.compile( | ||||||
rf""" | ||||||
^\s*ENERGY\|\ Total\ FORCE_EVAL [^:]+:\s*(?P<value>{FLOAT})\n | ||||||
|
@@ -13,9 +30,16 @@ | |||||
|
||||||
|
||||||
def match_energies(content: str) -> Optional[BlockMatch]: | ||||||
spans = [] | ||||||
energies = {} | ||||||
match = MAIN_ENERGY_RE.search(content) | ||||||
if match: | ||||||
energies = match.groupdict() | ||||||
spans = match.spans(0) | ||||||
match = FORCE_EVAL_ENERGY_RE.search(content) | ||||||
|
||||||
if not match: | ||||||
if match: | ||||||
energies["total force_eval"] = match["value"] | ||||||
spans += match.spans(0) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reversed this change since it was resulting in the cli tests to fail. Checking the output I believe that my original implementation was actually already giving the correct output? |
||||||
if not energies: | ||||||
return None | ||||||
|
||||||
return BlockMatch({"energies": {"total force_eval": float(match["value"])}}, match.spans(0)) | ||||||
return BlockMatch({"energies": {key: float(val) for key, val in energies.items() if val is not None}}, spans) |
Uh oh!
There was an error while loading. Please reload this page.