diff --git a/parser/parser-cp2k/cp2kparser/__main__.py b/parser/parser-cp2k/cp2kparser/__main__.py deleted file mode 100644 index 2a3c01975b83f2ebf0eb34bd3422ce035bb2c0b1..0000000000000000000000000000000000000000 --- a/parser/parser-cp2k/cp2kparser/__main__.py +++ /dev/null @@ -1,27 +0,0 @@ -""" -When this package is run on a folder with python -m cp2kparser, the current -directory is searched for calculation data and the contents are parsed. -""" - -import os -from cp2kparser.implementation.autoparser import parse_path -import argparse -import json - -parser = argparse.ArgumentParser(description='Parse a CP2K calculation from folder.') -parser.add_argument('--metaInfoToKeep', type=str, help='A json list containing the names of the metainfos to keep during parsing.') -parser.add_argument('-dump', action='store_true') -args = parser.parse_args() - -# Try to decode the metaInfoTokeep -metaInfoToKeep = [] -if args.metaInfoToKeep: - try: - metaInfoToKeep = json.loads(args.metaInfoToKeep) - except: - raise Exception("Could not decode the 'metaInfoToKeep' argument as a json list. You might need to surround the string with single quotes if it contains double quotes.") - -dump = args.dump - -path = os.getcwd() -parse_path(path, metaInfoToKeep, dump) diff --git a/parser/parser-cp2k/cp2kparser/parsing/versions/cp2k262/outputparser.py b/parser/parser-cp2k/cp2kparser/parsing/versions/cp2k262/outputparser.py index ac95060850c1b6281ce29794e6cb5bcc7ffe76a3..32112110ffb13ad467fc4d788adc96b1be3cab62 100644 --- a/parser/parser-cp2k/cp2kparser/parsing/versions/cp2k262/outputparser.py +++ b/parser/parser-cp2k/cp2kparser/parsing/versions/cp2k262/outputparser.py @@ -10,12 +10,12 @@ class CP2KOutputParser(FileParser): """The object that goes through the CP2K output file and parses everything it can using the SimpleParser architecture. """ - def __init__(self, files, parser_context): """Initialize an output parser. """ FileParser.__init__(self, files, parser_context) - self.f_regex = "-?\d+\.\d+(?:E+|-\d+)?" # Regex for a floating point value + self.f_regex = "-?\d+\.\d+(?:E(?:\+|-)\d+)?" # Regex for a floating point value + self.i_regex = "-?\d+" # Regex for an integer # Define the output parsing tree for this version self.root_matcher = SM( @@ -80,10 +80,21 @@ class CP2KOutputParser(FileParser): ] ), SM( - # sections=["cp2k_section_quickstep_atom_information"], startReStr=" MODULE QUICKSTEP: ATOMIC COORDINATES IN angstrom", adHoc=self.adHoc_cp2k_section_quickstep_atom_information(), ), + # SCF + SM( + sections=["section_single_configuration_calculation"], + startReStr=" SCF WAVEFUNCTION OPTIMIZATION", + subMatchers=[ + SM( + sections=["section_scf_iteration"], + startReStr=r"\s+\d+\s+\S+\s+{f}\s+{f}\s+{f}\s+(?P<energy_total_scf_iteration>{f})\s+{f}".format(f=self.f_regex), + repeats=True, + ), + ] + ), SM( sections=["cp2k_section_md"], startReStr=" MD| Molecular Dynamics Protocol",