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):
#=======================================================================
# 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
......
......@@ -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
......@@ -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
......
......@@ -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"]
#===============================================================================
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment