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

Removed issue with multiple parents.

parent 43ad0095
Branches
Tags
No related merge requests found
......@@ -47,7 +47,7 @@ class CommonMatcher(object):
#=======================================================================
# Globally cached values
self.cache_service.add("simulation_cell", single=False, update=True)
self.cache_service.add("simulation_cell", single=False, update=False)
self.cache_service.add("number_of_scf_iterations", 0)
self.cache_service.add("atom_positions", single=False, update=True)
self.cache_service.add("atom_labels", single=False, update=False)
......@@ -313,6 +313,12 @@ class CommonMatcher(object):
if number_of_atoms is not None:
self.cache_service["number_of_atoms"] = number_of_atoms
# def onClose_x_cp2k_section_quickstep_calculation(self, backend, gIndex, section):
# print "quickstep CLOSED"
# def onClose_x_cp2k_section_geometry_optimization_step(self, backend, gIndex, section):
# print "Optimisation step CLOSED"
def onClose_section_method(self, backend, gIndex, section):
"""When all the functional definitions have been gathered, matches them
with the nomad correspondents and combines into one single string which
......@@ -591,10 +597,10 @@ class CommonMatcher(object):
self.test_electronic_structure_method = "RPA"
return wrapper
def debug(self):
def wrapper(parser):
print("FOUND")
return wrapper
# def debug(self):
# def wrapper(parser):
# print("FOUND")
# return wrapper
#===========================================================================
# MISC functions
......
......@@ -19,6 +19,7 @@ class CP2KGeoOptParser(MainHierarchicalParser):
super(CP2KGeoOptParser, self).__init__(file_path, parser_context)
self.setup_common_matcher(CommonMatcher(parser_context))
self.traj_iterator = None
self.energy_reeval_quickstep = None
#=======================================================================
# Globally cached values
......@@ -30,11 +31,10 @@ class CP2KGeoOptParser(MainHierarchicalParser):
#=======================================================================
# Cache levels
self.caching_level_for_metaname.update({
'x_cp2k_optimization_energy': CachingLevel.ForwardAndCache,
'x_cp2k_section_geometry_optimization_step': CachingLevel.ForwardAndCache,
'x_cp2k_section_quickstep_calculation': CachingLevel.ForwardAndCache,
'x_cp2k_section_geometry_optimization': CachingLevel.ForwardAndCache,
'x_cp2k_section_geometry_optimization_energy_reevaluation': CachingLevel.ForwardAndCache,
# 'x_cp2k_section_geometry_optimization_energy_reevaluation': CachingLevel.ForwardAndCache,
})
#=======================================================================
......@@ -73,7 +73,6 @@ class CP2KGeoOptParser(MainHierarchicalParser):
endReStr=" Conv. in RMS gradients =",
name="geooptstep",
repeats=True,
# sections=["section_single_configuration_calculation", "section_system"],
subMatchers=[
SM( "",
forwardMatch=True,
......@@ -140,12 +139,19 @@ class CP2KGeoOptParser(MainHierarchicalParser):
otherMetaInfo=["geometry_optimization_converged"]
),
SM( " Reevaluating energy at the minimum",
sections=["x_cp2k_section_geometry_optimization_energy_reevaluation"],
# sections=["x_cp2k_section_geometry_optimization_energy_reevaluation"],
subMatchers=[
self.cm.quickstep_calculation(),
# SM("",
# adHoc=self.adHoc_save_energy_reeval_quickstep()
# )
],
# adHoc=self.adHoc_step()
# adHoc=self.adHoc_save_energy_reeval_quickstep()
),
# SM( "",
# forwardMatch=True,
# adHoc=self.adHoc_save_energy_reeval_quickstep()
# )
],
)
......@@ -173,11 +179,9 @@ class CP2KGeoOptParser(MainHierarchicalParser):
def onClose_x_cp2k_section_geometry_optimization(self, backend, gIndex, section):
# Get the re-evaluated energy and add it to frame_sequence_potential_energy
energy = section.get_latest_value([
"x_cp2k_section_geometry_optimization_energy_reevaluation",
"x_cp2k_section_quickstep_calculation",
"x_cp2k_energy_total"]
)
reeval_quickstep = self.energy_reeval_quickstep
if reeval_quickstep is not None:
energy = reeval_quickstep.get_latest_value("x_cp2k_energy_total")
if energy is not None:
self.cache_service["frame_sequence_potential_energy"].append(energy)
......@@ -231,6 +235,9 @@ class CP2KGeoOptParser(MainHierarchicalParser):
def onClose_section_sampling_method(self, backend, gIndex, section):
self.backend.addValue("sampling_method", "geometry_optimization")
def onClose_x_cp2k_section_quickstep_calculation(self, backend, gIndex, section):
self.energy_reeval_quickstep = section
def onClose_x_cp2k_section_geometry_optimization_step(self, backend, gIndex, section):
energy = section["x_cp2k_optimization_energy"]
if energy is not None:
......@@ -283,11 +290,18 @@ class CP2KGeoOptParser(MainHierarchicalParser):
self.cache_service["geometry_optimization_method"] = "bfgs"
return wrapper
# def adHoc_step(self):
# """Called when all the step information has been retrieved from the
# output file. Here further information is gathered from external files.
# """
# def adHoc_save_energy_reeval_quickstep(self):
# def wrapper(parser):
# self.cache_service["number_of_frames_in_sequence"] += 1
# section_managers = parser.backend.sectionManagers
# section_run_manager = section_managers["section_run"]
# section_run = section_run_manager.openSections[0]
# print section_run.subSectionValues
# # quickstep = section_run.get_latest_value("x_cp2k_section_quickstep_calculation")
# # print quickstep
# # self.energy_reeval_quickstep = quickstep
# return wrapper
def debug(self):
def wrapper(parser):
print "DEBUG"
return wrapper
......@@ -31,6 +31,7 @@ class CP2KMDParser(MainHierarchicalParser):
self.velo_freq = None
self.energy_freq = None
self.cell_freq = None
self.md_quicksteps = []
#=======================================================================
# Globally cached values
......@@ -88,10 +89,12 @@ class CP2KMDParser(MainHierarchicalParser):
SM( " INITIAL CELL LNTHS\[bohr\] =\s+(?P<x_cp2k_md_cell_length_a_instantaneous__bohr>{0})\s+(?P<x_cp2k_md_cell_length_b_instantaneous__bohr>{0})\s+(?P<x_cp2k_md_cell_length_c_instantaneous__bohr>{0})".format(self.cm.regex_f)),
SM( " INITIAL CELL ANGLS\[deg\] =\s+(?P<x_cp2k_md_cell_angle_a_instantaneous__deg>{0})\s+(?P<x_cp2k_md_cell_angle_b_instantaneous__deg>{0})\s+(?P<x_cp2k_md_cell_angle_c_instantaneous__deg>{0})".format(self.cm.regex_f)),
],
adHoc=self.adHoc_save_md_quickstep()
),
SM( " SCF WAVEFUNCTION OPTIMIZATION",
endReStr=" TEMPERATURE \[K\] =",
name="md_step",
forwardMatch=True,
repeats=True,
sections=["x_cp2k_section_md_step"],
subMatchers=[
......@@ -113,6 +116,7 @@ class CP2KMDParser(MainHierarchicalParser):
SM( " CELL ANGLS\[deg\] =\s+(?P<x_cp2k_md_cell_angle_a_instantaneous__deg>{0})\s+(?P<x_cp2k_md_cell_angle_b_instantaneous__deg>{0})\s+(?P<x_cp2k_md_cell_angle_c_instantaneous__deg>{0})".format(self.cm.regex_f)),
SM( " AVE. CELL ANGLS\[deg\] =\s+(?P<x_cp2k_md_cell_angle_a_average__deg>{0})\s+(?P<x_cp2k_md_cell_angle_b_average__deg>{0})\s+(?P<x_cp2k_md_cell_angle_c_average__deg>{0})".format(self.cm.regex_f)),
],
adHoc=self.adHoc_save_md_quickstep()
),
]
)
......@@ -321,7 +325,7 @@ class CP2KMDParser(MainHierarchicalParser):
if md_steps:
if (i_step + 1) % freqs["output"][0] == 0:
md_step = md_steps[i_md_step]
quickstep = md_step.get_latest_value("x_cp2k_section_quickstep_calculation")
quickstep = self.md_quicksteps[i_md_step]
if quickstep is not None:
quickstep.add_latest_value("x_cp2k_atom_forces", "atom_forces")
quickstep.add_latest_value("x_cp2k_stress_tensor", "stress_tensor")
......@@ -388,3 +392,14 @@ class CP2KMDParser(MainHierarchicalParser):
mean_pressure = frame_sequence_pressure.mean()
std_pressure = frame_sequence_pressure.std()
backend.addArrayValues("frame_sequence_pressure_stats", np.array([mean_pressure, std_pressure]))
#===========================================================================
# adHoc functions
def adHoc_save_md_quickstep(self):
def wrapper(parser):
section_managers = parser.backend.sectionManagers
section_run_manager = section_managers["section_run"]
section_run = section_run_manager.openSections[0]
quickstep = section_run.get_latest_value("x_cp2k_section_quickstep_calculation")
self.md_quicksteps.append(quickstep)
return wrapper
......@@ -1022,14 +1022,14 @@ if __name__ == '__main__':
logger.setLevel(logging.ERROR)
suites = []
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestErrors))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestXCFunctional))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestEnergyForce))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestStressTensorMethods))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestSelfInteractionCorrectionMethod))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestConfigurationPeriodicDimensions))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestSCFConvergence))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestForceFiles))
suites.append(unittest.TestLoader().loadTestsFromTestCase(TestErrors))
suites.append(unittest.TestLoader().loadTestsFromTestCase(TestXCFunctional))
suites.append(unittest.TestLoader().loadTestsFromTestCase(TestEnergyForce))
suites.append(unittest.TestLoader().loadTestsFromTestCase(TestStressTensorMethods))
suites.append(unittest.TestLoader().loadTestsFromTestCase(TestSelfInteractionCorrectionMethod))
suites.append(unittest.TestLoader().loadTestsFromTestCase(TestConfigurationPeriodicDimensions))
suites.append(unittest.TestLoader().loadTestsFromTestCase(TestSCFConvergence))
suites.append(unittest.TestLoader().loadTestsFromTestCase(TestForceFiles))
suites.append(unittest.TestLoader().loadTestsFromTestCase(TestPreprocessor))
suites.append(unittest.TestLoader().loadTestsFromTestCase(TestGeoOpt))
suites.append(unittest.TestLoader().loadTestsFromTestCase(TestGeoOptTrajFormats))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment