Skip to content
Snippets Groups Projects
Commit 43954fc7 authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Fixed issue that created only one section_system in geo_opt.

parent d49fa530
Branches
Tags
No related merge requests found
...@@ -21,7 +21,10 @@ class CPMDCommonParser(CommonParser): ...@@ -21,7 +21,10 @@ class CPMDCommonParser(CommonParser):
#======================================================================= #=======================================================================
# Globally cached values # 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 # Common SimpleMatchers
...@@ -235,7 +238,7 @@ class CPMDCommonParser(CommonParser): ...@@ -235,7 +238,7 @@ class CPMDCommonParser(CommonParser):
A2_array = self.vector_from_string(A2) A2_array = self.vector_from_string(A2)
A3_array = self.vector_from_string(A3) A3_array = self.vector_from_string(A3)
cell = np.vstack((A1_array, A2_array, A3_array)) 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 # Plane wave basis
cutoff = section.get_latest_value("x_cpmd_wave_function_cutoff") cutoff = section.get_latest_value("x_cpmd_wave_function_cutoff")
...@@ -291,9 +294,8 @@ class CPMDCommonParser(CommonParser): ...@@ -291,9 +294,8 @@ class CPMDCommonParser(CommonParser):
# If anything found, push the results to the correct section # If anything found, push the results to the correct section
if len(coordinates) != 0: if len(coordinates) != 0:
self.cache_service["initial_positions"] = coordinates self.cache_service["initial_positions"] = coordinates
# parser.backend.addArrayValues("atom_positions", coordinates, unit="bohr") self.cache_service["atom_labels"] = labels
parser.backend.addArrayValues("atom_labels", labels) self.cache_service["number_of_atoms"] = coordinates.shape[0]
parser.backend.addValue("number_of_atoms", coordinates.shape[0])
return wrapper return wrapper
......
...@@ -35,7 +35,7 @@ class CPMDGeoOptParser(MainHierarchicalParser): ...@@ -35,7 +35,7 @@ class CPMDGeoOptParser(MainHierarchicalParser):
# Main structure # Main structure
self.root_matcher = SM("", self.root_matcher = SM("",
forwardMatch=True, 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=[ subMatchers=[
self.cm.header(), self.cm.header(),
self.cm.method(), self.cm.method(),
...@@ -65,7 +65,7 @@ class CPMDGeoOptParser(MainHierarchicalParser): ...@@ -65,7 +65,7 @@ class CPMDGeoOptParser(MainHierarchicalParser):
forwardMatch=True, forwardMatch=True,
endReStr=re.escape(" *** CNSTR="), endReStr=re.escape(" *** CNSTR="),
repeats=True, 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=[ 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), 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"], sections=["x_cpmd_section_geo_opt_scf_iteration"],
...@@ -129,5 +129,10 @@ class CPMDGeoOptParser(MainHierarchicalParser): ...@@ -129,5 +129,10 @@ class CPMDGeoOptParser(MainHierarchicalParser):
self.sampling_method_gid = gIndex self.sampling_method_gid = gIndex
backend.addValue("sampling_method", "geometry_optimization") 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 # adHoc
...@@ -84,6 +84,9 @@ class CPMDSinglePointParser(MainHierarchicalParser): ...@@ -84,6 +84,9 @@ class CPMDSinglePointParser(MainHierarchicalParser):
def onClose_section_system(self, backend, gIndex, section): def onClose_section_system(self, backend, gIndex, section):
self.cache_service.addArrayValues("atom_positions", "initial_positions", unit="bohr") 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 # adHoc
......
...@@ -73,7 +73,7 @@ class TestInputParser(unittest.TestCase): ...@@ -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") 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): 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"]
#=============================================================================== #===============================================================================
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment