diff --git a/parser/parser-cpmd/cpmdparser/versions/cpmd41/commonparser.py b/parser/parser-cpmd/cpmdparser/versions/cpmd41/commonparser.py index 46a922130b17e45f55fb06a18caf8391a5faf3ff..154ecf80cb54333561abef4d6c3d04ca20f8e3fe 100644 --- a/parser/parser-cpmd/cpmdparser/versions/cpmd41/commonparser.py +++ b/parser/parser-cpmd/cpmdparser/versions/cpmd41/commonparser.py @@ -21,7 +21,10 @@ class CPMDCommonParser(CommonParser): #======================================================================= # Globally cached values - self.cache_service.add("initial_positions") + self.cache_service.add("initial_positions", single=False, update=False) + self.cache_service.add("atom_labels", single=False, update=False) + self.cache_service.add("number_of_atoms", single=False, update=False) + self.cache_service.add("simulation_cell", single=False, update=False) #=========================================================================== # Common SimpleMatchers @@ -235,7 +238,7 @@ class CPMDCommonParser(CommonParser): A2_array = self.vector_from_string(A2) A3_array = self.vector_from_string(A3) cell = np.vstack((A1_array, A2_array, A3_array)) - backend.addArrayValues("simulation_cell", cell, unit="bohr") + self.cache_service["simulation_cell"] = cell # Plane wave basis cutoff = section.get_latest_value("x_cpmd_wave_function_cutoff") @@ -291,9 +294,8 @@ class CPMDCommonParser(CommonParser): # If anything found, push the results to the correct section if len(coordinates) != 0: self.cache_service["initial_positions"] = coordinates - # parser.backend.addArrayValues("atom_positions", coordinates, unit="bohr") - parser.backend.addArrayValues("atom_labels", labels) - parser.backend.addValue("number_of_atoms", coordinates.shape[0]) + self.cache_service["atom_labels"] = labels + self.cache_service["number_of_atoms"] = coordinates.shape[0] return wrapper diff --git a/parser/parser-cpmd/cpmdparser/versions/cpmd41/geooptparser.py b/parser/parser-cpmd/cpmdparser/versions/cpmd41/geooptparser.py index 75b7d0f154d42c13244ef6d005bc403c54613a08..546e4fa7bee761cb66a73563dbe8dc7b0cda2b75 100644 --- a/parser/parser-cpmd/cpmdparser/versions/cpmd41/geooptparser.py +++ b/parser/parser-cpmd/cpmdparser/versions/cpmd41/geooptparser.py @@ -35,7 +35,7 @@ class CPMDGeoOptParser(MainHierarchicalParser): # Main structure self.root_matcher = SM("", forwardMatch=True, - sections=['section_run', "section_frame_sequence", "section_sampling_method", "section_system", "section_method"], + sections=['section_run', "section_frame_sequence", "section_sampling_method", "section_method"], subMatchers=[ self.cm.header(), self.cm.method(), @@ -65,7 +65,7 @@ class CPMDGeoOptParser(MainHierarchicalParser): forwardMatch=True, endReStr=re.escape(" *** CNSTR="), repeats=True, - sections=["section_single_configuration_calculation", "x_cpmd_section_geo_opt_step"], + sections=["section_single_configuration_calculation", "section_system", "x_cpmd_section_geo_opt_step"], subMatchers=[ SM( "\s+(?P<x_cpmd_geo_opt_scf_nfi>{0})\s+(?P<x_cpmd_geo_opt_scf_gemax>{1})\s+(?P<x_cpmd_geo_opt_scf_cnorm>{1})\s+(?P<x_cpmd_geo_opt_scf_etot__hartree>{1})\s+(?P<x_cpmd_geo_opt_scf_detot__hartree>{1})\s+(?P<x_cpmd_geo_opt_scf_tcpu__s>{1})".format(self.regexs.int, self.regexs.float), sections=["x_cpmd_section_geo_opt_scf_iteration"], @@ -129,5 +129,10 @@ class CPMDGeoOptParser(MainHierarchicalParser): self.sampling_method_gid = gIndex backend.addValue("sampling_method", "geometry_optimization") + def onClose_section_system(self, backend, gIndex, section): + self.cache_service.addArrayValues("atom_labels") + self.cache_service.addArrayValues("simulation_cell", unit="bohr") + self.cache_service.addValue("number_of_atoms") + #======================================================================= # adHoc diff --git a/parser/parser-cpmd/cpmdparser/versions/cpmd41/singlepointparser.py b/parser/parser-cpmd/cpmdparser/versions/cpmd41/singlepointparser.py index 829f6f3e674364e6bb1d0fce2297e882269de869..f8b007d051657dc24c888bac8338530592d65dab 100644 --- a/parser/parser-cpmd/cpmdparser/versions/cpmd41/singlepointparser.py +++ b/parser/parser-cpmd/cpmdparser/versions/cpmd41/singlepointparser.py @@ -84,6 +84,9 @@ class CPMDSinglePointParser(MainHierarchicalParser): def onClose_section_system(self, backend, gIndex, section): self.cache_service.addArrayValues("atom_positions", "initial_positions", unit="bohr") + self.cache_service.addArrayValues("atom_labels") + self.cache_service.addArrayValues("simulation_cell", unit="bohr") + self.cache_service.addValue("number_of_atoms") #======================================================================= # adHoc diff --git a/test/unittests/cpmd_4.1/run_tests.py b/test/unittests/cpmd_4.1/run_tests.py index 0c1d1fe76f7a06f3c0db582ba3ad11677f6bc745..da888cf26ee23c761e83f95b05c859752a34818b 100644 --- a/test/unittests/cpmd_4.1/run_tests.py +++ b/test/unittests/cpmd_4.1/run_tests.py @@ -73,7 +73,7 @@ class TestInputParser(unittest.TestCase): self.assertEqual(result, "*H_MT_LDA.psp\nLMAX=S\n2\n4.371 4.000 4.000\n3.629 4.000 4.000") def test_x_cpmd_input_optimize_wavefunction(self): - result = self.results["x_cpmd_section_input_CPMD.OPTIMIZE_WAVEFUNCTION"] + self.results["x_cpmd_section_input_CPMD.OPTIMIZE_WAVEFUNCTION"] #===============================================================================