Commit dd17d5a3 authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Fixed unit conversion error in scf onvergence criteria, + some refactoring.

parent 1794d649
...@@ -6,20 +6,20 @@ import logging ...@@ -6,20 +6,20 @@ import logging
from nomadcore.simple_parser import SimpleMatcher as SM from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.caching_backend import CachingLevel from nomadcore.caching_backend import CachingLevel
from nomadcore.unit_conversion.unit_conversion import convert_unit from nomadcore.unit_conversion.unit_conversion import convert_unit
from nomadcore.baseclasses import CommonMatcher from nomadcore.baseclasses import CommonParser
from .inputparser import CP2KInputParser from .inputparser import CP2KInputParser
logger = logging.getLogger("nomad") logger = logging.getLogger("nomad")
#=============================================================================== #===============================================================================
class CP2KCommonMatcher(CommonMatcher): class CP2KCommonParser(CommonParser):
""" """
This class is used to store and instantiate common parts of the This class is used to store and instantiate common parts of the
hierarchical SimpleMatcher structure used in the parsing of a CP2K hierarchical SimpleMatcher structure used in the parsing of a CP2K
output file. output file.
""" """
def __init__(self, parser_context): def __init__(self, parser_context):
super(CP2KCommonMatcher, self).__init__(parser_context) super(CP2KCommonParser, self).__init__(parser_context)
self.section_method_index = None self.section_method_index = None
self.section_system_index = None self.section_system_index = None
self.test_electronic_structure_method = "DFT" self.test_electronic_structure_method = "DFT"
...@@ -285,7 +285,7 @@ class CP2KCommonMatcher(CommonMatcher): ...@@ -285,7 +285,7 @@ class CP2KCommonMatcher(CommonMatcher):
SM( " max_scf:\s+(?P<scf_max_iteration>{})".format(self.regexs.regex_i)), SM( " max_scf:\s+(?P<scf_max_iteration>{})".format(self.regexs.regex_i)),
SM( " max_scf_history:\s+{}".format(self.regexs.regex_i)), SM( " max_scf_history:\s+{}".format(self.regexs.regex_i)),
SM( " max_diis:\s+{}".format(self.regexs.regex_i)), SM( " max_diis:\s+{}".format(self.regexs.regex_i)),
SM( " eps_scf:\s+(?P<scf_threshold_energy_change>{})".format(self.regexs.regex_f)), SM( " eps_scf:\s+(?P<scf_threshold_energy_change__hartree>{})".format(self.regexs.regex_f)),
] ]
), ),
SM( " MP2\|", SM( " MP2\|",
......
...@@ -4,7 +4,7 @@ from builtins import next ...@@ -4,7 +4,7 @@ from builtins import next
from builtins import range from builtins import range
from nomadcore.simple_parser import SimpleMatcher as SM from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.baseclasses import MainHierarchicalParser from nomadcore.baseclasses import MainHierarchicalParser
from .commonmatcher import CP2KCommonMatcher from .commonparser import CP2KCommonParser
import cp2kparser.generic.configurationreading import cp2kparser.generic.configurationreading
import cp2kparser.generic.csvparsing import cp2kparser.generic.csvparsing
from nomadcore.caching_backend import CachingLevel from nomadcore.caching_backend import CachingLevel
...@@ -21,7 +21,7 @@ class CP2KGeoOptParser(MainHierarchicalParser): ...@@ -21,7 +21,7 @@ class CP2KGeoOptParser(MainHierarchicalParser):
""" """
""" """
super(CP2KGeoOptParser, self).__init__(file_path, parser_context) super(CP2KGeoOptParser, self).__init__(file_path, parser_context)
self.setup_common_matcher(CP2KCommonMatcher(parser_context)) self.setup_common_matcher(CP2KCommonParser(parser_context))
self.traj_iterator = None self.traj_iterator = None
self.energy_reeval_quickstep = None self.energy_reeval_quickstep = None
......
...@@ -4,7 +4,7 @@ from builtins import range ...@@ -4,7 +4,7 @@ from builtins import range
import numpy as np import numpy as np
from nomadcore.simple_parser import SimpleMatcher as SM from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.baseclasses import MainHierarchicalParser from nomadcore.baseclasses import MainHierarchicalParser
from .commonmatcher import CP2KCommonMatcher from .commonparser import CP2KCommonParser
import cp2kparser.generic.configurationreading import cp2kparser.generic.configurationreading
import cp2kparser.generic.csvparsing import cp2kparser.generic.csvparsing
from nomadcore.caching_backend import CachingLevel from nomadcore.caching_backend import CachingLevel
...@@ -23,7 +23,7 @@ class CP2KMDParser(MainHierarchicalParser): ...@@ -23,7 +23,7 @@ class CP2KMDParser(MainHierarchicalParser):
""" """
""" """
super(CP2KMDParser, self).__init__(file_path, parser_context) super(CP2KMDParser, self).__init__(file_path, parser_context)
self.setup_common_matcher(CP2KCommonMatcher(parser_context)) self.setup_common_matcher(CP2KCommonParser(parser_context))
self.traj_iterator = None self.traj_iterator = None
self.vel_iterator = None self.vel_iterator = None
self.energy_iterator = None self.energy_iterator = None
......
...@@ -3,7 +3,7 @@ from nomadcore.simple_parser import SimpleMatcher as SM ...@@ -3,7 +3,7 @@ from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.baseclasses import MainHierarchicalParser from nomadcore.baseclasses import MainHierarchicalParser
from .singlepointforceparser import CP2KSinglePointForceParser from .singlepointforceparser import CP2KSinglePointForceParser
from nomadcore.caching_backend import CachingLevel from nomadcore.caching_backend import CachingLevel
from .commonmatcher import CP2KCommonMatcher from .commonparser import CP2KCommonParser
import logging import logging
logger = logging.getLogger("nomad") logger = logging.getLogger("nomad")
...@@ -18,7 +18,7 @@ class CP2KSinglePointParser(MainHierarchicalParser): ...@@ -18,7 +18,7 @@ class CP2KSinglePointParser(MainHierarchicalParser):
""" """
""" """
super(CP2KSinglePointParser, self).__init__(file_path, parser_context) super(CP2KSinglePointParser, self).__init__(file_path, parser_context)
self.setup_common_matcher(CP2KCommonMatcher(parser_context)) self.setup_common_matcher(CP2KCommonParser(parser_context))
#======================================================================= #=======================================================================
# Cache levels # Cache levels
......
...@@ -49,7 +49,7 @@ object Cp2kParser extends SimpleExternalParserGenerator( ...@@ -49,7 +49,7 @@ object Cp2kParser extends SimpleExternalParserGenerator(
"parser-cp2k/cp2kparser/versions/cp2k262/mdparser.py", "parser-cp2k/cp2kparser/versions/cp2k262/mdparser.py",
"parser-cp2k/cp2kparser/versions/cp2k262/singlepointforceparser.py", "parser-cp2k/cp2kparser/versions/cp2k262/singlepointforceparser.py",
"parser-cp2k/cp2kparser/versions/cp2k262/inputparser.py", "parser-cp2k/cp2kparser/versions/cp2k262/inputparser.py",
"parser-cp2k/cp2kparser/versions/cp2k262/commonmatcher.py", "parser-cp2k/cp2kparser/versions/cp2k262/commonparser.py",
"parser-cp2k/cp2kparser/versions/cp2k262/input_data/cp2k_input_tree.pickle", "parser-cp2k/cp2kparser/versions/cp2k262/input_data/cp2k_input_tree.pickle",
"parser-cp2k/cp2kparser/scalainterface.py", "parser-cp2k/cp2kparser/scalainterface.py",
"nomad_meta_info/public.nomadmetainfo.json", "nomad_meta_info/public.nomadmetainfo.json",
......
...@@ -295,7 +295,7 @@ class TestEnergyForce(unittest.TestCase): ...@@ -295,7 +295,7 @@ class TestEnergyForce(unittest.TestCase):
def test_scf_threshold_energy_change(self): def test_scf_threshold_energy_change(self):
result = self.results["scf_threshold_energy_change"] result = self.results["scf_threshold_energy_change"]
self.assertEqual(result, 1.00E-07) self.assertEqual(result, convert_unit(1.00E-07, "hartree"))
def test_number_of_spin_channels(self): def test_number_of_spin_channels(self):
result = self.results["number_of_spin_channels"] result = self.results["number_of_spin_channels"]
......
Markdown is supported
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