def __init__(self, parser_context): """ """ super(CP2KSinglePointParser, self).__init__(parser_context) self.setup_common_matcher(CP2KCommonParser(parser_context)) #======================================================================= # Cache levels self.caching_levels.update({ 'x_cp2k_energy_total_scf_iteration': CachingLevel.ForwardAndCache, 'x_cp2k_energy_XC_scf_iteration': CachingLevel.ForwardAndCache, 'x_cp2k_energy_change_scf_iteration': CachingLevel.ForwardAndCache, 'x_cp2k_stress_tensor': CachingLevel.ForwardAndCache, 'x_cp2k_section_stress_tensor': CachingLevel.ForwardAndCache, }) #======================================================================= # SimpleMatchers self.root_matcher = SM("", forwardMatch=True, sections=['section_run', "section_single_configuration_calculation", "section_system", "section_method"], otherMetaInfo=["atom_forces"], subMatchers=[ self.cm.header(), self.cm.quickstep_header(), self.cm.quickstep_calculation(), self.cm.footer(), ] )
def footer(self): return SM( " - DBCSR STATISTICS -", forwardMatch=True, subMatchers=[ SM(re.escape(" **** **** ****** ** PROGRAM ENDED AT"), forwardMatch=True, sections=['x_cp2k_section_end_information'], subMatchers=[ SM(" **** **** ****** ** PROGRAM ENDED AT\s+(?P<x_cp2k_end_time>{})" .replace("*", "\*").format(self.regexs.eol)), SM(" ***** ** *** *** ** PROGRAM RAN ON\s+(?P<x_cp2k_end_host>{})" .replace("*", "\*").format(self.regexs.word)), SM(" ** **** ****** PROGRAM RAN BY\s+(?P<x_cp2k_end_user>{})" .replace("*", "\*").format(self.regexs.word)), SM(" ***** ** ** ** ** PROGRAM PROCESS ID\s+(?P<x_cp2k_end_id>{})" .replace("*", "\*").format(self.regexs.int)), SM( " **** ** ******* ** PROGRAM STOPPED IN". replace("*", "\*"), forwardMatch=True, adHoc=self.adHoc_run_dir("x_cp2k_end_path"), ) ]), ])
def restart(self): return SM( re.escape( " * RESTART INFORMATION *" ), sections=["x_cp2k_section_restart_information"], subMatchers=[ SM( re.escape( " *******************************************************************************" )), SM( re.escape( " * *" )), SM( re.escape( " * RESTART FILE NAME: (?P<x_cp2k_restart_file_name>{})\s+*" .format(self.regexs.word))), SM( re.escape( " * *" )), SM( re.escape( " * RESTARTED QUANTITIES: *" )), SM( re.escape( " * (?P<x_cp2k_restarted_quantity>{})\s+*" .format(self.regexs.word)), repeats=True, ), SM( re.escape( " *******************************************************************************" )) ])
def __init__(self, parser_context): """ """ super(CP2KGeoOptParser, self).__init__(parser_context) self.setup_common_matcher(CP2KCommonParser(parser_context)) self.traj_iterator = None self.energy_reeval_quickstep = None #======================================================================= # Globally cached values self.cache_service.add("number_of_frames_in_sequence", 0) self.cache_service.add("frame_sequence_potential_energy", []) self.cache_service.add("frame_sequence_local_frames_ref", []) self.cache_service.add("geometry_optimization_method") #======================================================================= # Cache levels self.caching_levels.update({ '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, }) #======================================================================= # SimpleMatchers self.geo_opt = SM( " *** STARTING GEOMETRY OPTIMIZATION ***" .replace("*", "\*"), sections=[ "section_frame_sequence", "x_cp2k_section_geometry_optimization" ], subMatchers=[ SM( " *** CONJUGATE GRADIENTS ***" .replace("*", "\*"), adHoc=self.adHoc_conjugate_gradient(), otherMetaInfo=["geometry_optimization_method"], ), SM( " *** BFGS ***" .replace("*", "\*"), adHoc=self.adHoc_bfgs(), otherMetaInfo=["geometry_optimization_method"], ), SM( " *** L-BFGS ***" .replace("*", "\*"), adHoc=self.adHoc_bfgs(), otherMetaInfo=["geometry_optimization_method"], ), # SM( "", # forwardMatch=True, # sections=["section_single_configuration_calculation", "section_system", "x_cp2k_section_geometry_optimization_step"], # subMatchers=[ # self.cm.quickstep_calculation(), # SM( " -------- Informations at step"), # SM( " Optimization Method =\s+(?P<x_cp2k_optimization_method>{})".format(self.regexs.word)), # SM( " Total Energy =\s+(?P<x_cp2k_optimization_energy__hartree>{})".format(self.regexs.float), # otherMetaInfo=["frame_sequence_potential_energy"] # ), # ], # otherMetaInfo=["atom_positions"], # adHoc=self.adHoc_step(), # ), SM( " OPTIMIZATION STEP:", endReStr=" Conv. in RMS gradients =", name="geooptstep", repeats=True, subMatchers=[ SM( "", forwardMatch=True, sections=[ "x_cp2k_section_geometry_optimization_step" ], otherMetaInfo=[ "atom_positions", ], subMatchers=[ # SM( "", # forwardMatch=True, # endReStr=" *** MNBRACK - NUMBER OF ENERGY EVALUATIONS :\s+{}\s+***".replace("*", "\*").format(self.regexs.int), # subMatchers=[ # SM(" SCF WAVEFUNCTION OPTIMIZATION", # forwardMatch=True, # repeats=True, # subMatchers=[ # self.cm.quickstep_calculation(), # ] # ) # ] # ), # SM( "", # forwardMatch=True, # endReStr=" *** BRENT - NUMBER OF ENERGY EVALUATIONS :\s+{}\s+***".replace("*", "\*").format(self.regexs.int), # subMatchers=[ # SM(" SCF WAVEFUNCTION OPTIMIZATION", # forwardMatch=True, # repeats=True, # subMatchers=[ # self.cm.quickstep_calculation(), # ] # ) # ] # ), SM(" -------- Informations at step"), SM(" Optimization Method =\s+(?P<x_cp2k_optimization_method>{})" .format(self.regexs.word)), SM(" Total Energy =\s+(?P<x_cp2k_optimization_energy__hartree>{})" .format(self.regexs.float), otherMetaInfo=[ "frame_sequence_potential_energy" ]), SM(" Real energy change =\s+(?P<x_cp2k_optimization_energy_change__hartree>{})" .format(self.regexs.float)), SM(" Decrease in energy =\s+(?P<x_cp2k_optimization_energy_decrease>{})" .format(self.regexs.word)), SM(" Used time =\s+(?P<x_cp2k_optimization_used_time>{})" .format(self.regexs.float)), SM(" Max. step size =\s+(?P<x_cp2k_optimization_max_step_size__bohr>{})" .format(self.regexs.float)), SM(" Conv. limit for step size =\s+(?P<x_cp2k_optimization_step_size_convergence_limit__bohr>{})" .format(self.regexs.float), otherMetaInfo=[ "geometry_optimization_geometry_change" ]), SM(" Convergence in step size =\s+(?P<x_cp2k_optimization_step_size_convergence>{})" .format(self.regexs.word)), SM(" RMS step size =\s+(?P<x_cp2k_optimization_rms_step_size__bohr>{})" .format(self.regexs.float)), SM(" Convergence in RMS step =\s+(?P<x_cp2k_optimization_rms_step_size_convergence>{})" .format(self.regexs.word)), SM(" Max. gradient =\s+(?P<x_cp2k_optimization_max_gradient__bohr_1hartree>{})" .format(self.regexs.float)), SM(" Conv. limit for gradients =\s+(?P<x_cp2k_optimization_gradient_convergence_limit__bohr_1hartree>{})" .format(self.regexs.float), otherMetaInfo=[ "geometry_optimization_threshold_force" ]), SM(" Conv. for gradients =\s+(?P<x_cp2k_optimization_max_gradient_convergence>{})" .format(self.regexs.word)), SM(" RMS gradient =\s+(?P<x_cp2k_optimization_rms_gradient__bohr_1hartree>{})" .format(self.regexs.float)), SM(" Conv. in RMS gradients =\s+(?P<x_cp2k_optimization_rms_gradient_convergence>{})" .format(self.regexs.word)), ], # adHoc=self.adHoc_step() ), ]), SM(" *** GEOMETRY OPTIMIZATION COMPLETED ***" .replace("*", "\*"), adHoc=self.adHoc_geo_opt_converged(), otherMetaInfo=["geometry_optimization_converged"]), SM( " Reevaluating energy at the minimum", # sections=["x_cp2k_section_geometry_optimization_energy_reevaluation"], subMatchers=[ self.cm.quickstep_calculation(), # SM("", # adHoc=self.adHoc_save_energy_reeval_quickstep() # ) ], # adHoc=self.adHoc_save_energy_reeval_quickstep() ), # SM( "", # forwardMatch=True, # adHoc=self.adHoc_save_energy_reeval_quickstep() # ) ], ) # Compose root matcher according to the run type. This way the # unnecessary regex parsers will not be compiled and searched. Saves # computational time. self.root_matcher = SM( "", forwardMatch=True, sections=["section_run", "section_sampling_method"], subMatchers=[ SM( "", forwardMatch=True, sections=["section_method"], subMatchers=[ self.cm.header(), self.cm.quickstep_header(), ], ), self.geo_opt, self.cm.footer(), ])
def header(self): return SM( " DBCSR\| Multiplication driver", forwardMatch=True, subMatchers=[ SM(" DBCSR\| Multiplication driver", forwardMatch=True, sections=['x_cp2k_section_dbcsr'], subMatchers=[ SM(" DBCSR\| Multiplication driver\s+(?P<x_cp2k_dbcsr_multiplication_driver>{})" .format(self.regexs.word)), SM(" DBCSR\| Multrec recursion limit\s+(?P<x_cp2k_dbcsr_multrec_recursion_limit>{})" .format(self.regexs.int)), SM(" DBCSR\| Multiplication stack size\s+(?P<x_cp2k_dbcsr_multiplication_stack_size>{})" .format(self.regexs.int)), SM(" DBCSR\| Multiplication size stacks\s+(?P<x_cp2k_dbcsr_multiplication_size_stacks>{})" .format(self.regexs.int)), SM(" DBCSR\| Use subcommunicators\s+(?P<x_cp2k_dbcsr_use_subcommunicators>{})" .format(self.regexs.letter)), SM(" DBCSR\| Use MPI combined types\s+(?P<x_cp2k_dbcsr_use_mpi_combined_types>{})" .format(self.regexs.letter)), SM(" DBCSR\| Use MPI memory allocation\s+(?P<x_cp2k_dbcsr_use_mpi_memory_allocation>{})" .format(self.regexs.letter)), SM(" DBCSR\| Use Communication thread\s+(?P<x_cp2k_dbcsr_use_communication_thread>{})" .format(self.regexs.letter)), SM(" DBCSR\| Communication thread load\s+(?P<x_cp2k_dbcsr_communication_thread_load>{})" .format(self.regexs.int)), ]), SM(" **** **** ****** ** PROGRAM STARTED AT".replace( "*", "\*"), forwardMatch=True, sections=['x_cp2k_section_startinformation'], subMatchers=[ SM(" **** **** ****** ** PROGRAM STARTED AT\s+(?P<x_cp2k_start_time>{})" .replace("*", "\*").format(self.regexs.eol)), SM(" ***** ** *** *** ** PROGRAM STARTED ON\s+(?P<x_cp2k_start_host>{})" .replace("*", "\*").format(self.regexs.word)), SM(" ** **** ****** PROGRAM STARTED BY\s+(?P<x_cp2k_start_user>{})" .replace("*", "\*").format(self.regexs.word)), SM(" ***** ** ** ** ** PROGRAM PROCESS ID\s+(?P<x_cp2k_start_id>{})" .replace("*", "\*").format(self.regexs.int)), SM( " **** ** ******* ** PROGRAM STARTED IN". replace("*", "\*"), forwardMatch=True, adHoc=self.adHoc_run_dir("x_cp2k_start_path"), ) ]), SM(" CP2K\| version string:", sections=['x_cp2k_section_program_information'], forwardMatch=True, subMatchers=[ SM(" CP2K\| version string:\s+(?P<program_version>{})". format(self.regexs.eol)), SM(" CP2K\| source code revision number:\s+svn:(?P<x_cp2k_svn_revision>\d+)" ), SM(" CP2K\| is freely available from{}".format( self.regexs.eol)), SM(" CP2K\| Program compiled at\s+(?P<x_cp2k_program_compilation_datetime>{})" .format(self.regexs.eol)), SM(" CP2K\| Program compiled on\s+(?P<program_compilation_host>{})" .format(self.regexs.eol)), SM(" CP2K\| Program compiled for{}".format( self.regexs.eol)), SM(" CP2K\| Input file name\s+(?P<x_cp2k_input_filename>{})" .format(self.regexs.eol)), ]), SM( " GLOBAL\|", sections=['x_cp2k_section_global_settings'], subMatchers=[ SM(" GLOBAL\| Force Environment number"), SM(" GLOBAL\| Basis set file name\s+(?P<x_cp2k_basis_set_filename>{})" .format(self.regexs.eol)), SM(" GLOBAL\| Geminal file name\s+(?P<x_cp2k_geminal_filename>{})" .format(self.regexs.eol)), SM(" GLOBAL\| Potential file name\s+(?P<x_cp2k_potential_filename>{})" .format(self.regexs.eol)), SM(" GLOBAL\| MM Potential file name\s+(?P<x_cp2k_mm_potential_filename>{})" .format(self.regexs.eol)), SM(" GLOBAL\| Coordinate file name\s+(?P<x_cp2k_coordinate_filename>{})" .format(self.regexs.eol)), SM(" GLOBAL\| Method name\s+(?P<x_cp2k_method_name>{})" .format(self.regexs.eol)), SM(" GLOBAL\| Project name"), SM(" GLOBAL\| Preferred FFT library\s+(?P<x_cp2k_preferred_fft_library>{})" .format(self.regexs.eol)), SM(" GLOBAL\| Preferred diagonalization lib.\s+(?P<x_cp2k_preferred_diagonalization_library>{})" .format(self.regexs.eol)), SM(" GLOBAL\| Run type\s+(?P<x_cp2k_run_type>{})". format(self.regexs.eol)), SM(" GLOBAL\| All-to-all communication in single precision" ), SM(" GLOBAL\| FFTs using library dependent lengths"), SM(" GLOBAL\| Global print level"), SM(" GLOBAL\| Total number of message passing processes" ), SM(" GLOBAL\| Number of threads for this process"), SM(" GLOBAL\| This output is from process"), ], ), SM( " CELL\|", adHoc=self.adHoc_x_cp2k_section_cell, ), ])
def quickstep_header(self): return SM( re.escape( " ** ... make the atoms dance **" ), forwardMatch=True, sections=["x_cp2k_section_quickstep_settings"], subMatchers=[ SM( " DFT\|", forwardMatch=True, subMatchers=[ SM(" DFT\| Spin restricted Kohn-Sham (RKS) calculation\s+(?P<x_cp2k_spin_restriction>{})" .format(self.regexs.word)), SM(" DFT\| Multiplicity\s+(?P<spin_target_multiplicity>{})" .format(self.regexs.int)), SM(" DFT\| Number of spin states\s+(?P<number_of_spin_channels>{})" .format(self.regexs.int)), SM(" DFT\| Charge\s+(?P<total_charge>{})".format( self.regexs.int)), SM(" DFT\| Self-interaction correction \(SIC\)\s+(?P<self_interaction_correction_method>[^\n]+)" ), ], ), SM(" vdW POTENTIAL\|\s+", forwardMatch=True, sections=["x_cp2k_section_vdw_settings"], subMatchers=[ SM(" vdW POTENTIAL\|\s+(?P<x_cp2k_vdw_type>{})".format( self.regexs.eol)), SM(" vdW POTENTIAL\|\s+Potential Form:\s+(?P<x_cp2k_vdw_name>{})" .format(self.regexs.eol)), SM(" vdW POTENTIAL\|\s+BJ Damping:\s+(?P<x_cp2k_vdw_bj_damping_name>{})" .format(self.regexs.eol)), SM(" vdW POTENTIAL\|\s+Cutoff Radius \[Bohr\]:\s+(?P<x_cp2k_vdw_cutoff_radius>{})" .format(self.regexs.float)), SM( " vdW POTENTIAL\|\+sScaling Factor:s+(?P<x_cp2k_vdw_scaling_factor>{})" .format(self.regexs.float), sections=["x_cp2k_section_vdw_d2_settings"], subMatchers=[ SM(" vdW POTENTIAL\|\s+Exp Prefactor for Damping:\s+(?P<x_cp2k_vdw_damping_factor>{})" .format(self.regexs.float)), SM( " vdW PARAMETER\|\s+Atom=(?P<x_cp2k_vdw_parameter_element_name>{})\s+C6\[J*nm^6*mol^-1\]=\s+(?P<x_cp2k_vdw_parameter_c6>{})\s+r\(vdW\)\[A\]=\s+(?P<x_cp2k_vdw_parameter_radius>{})" .format(self.regexs.word, self.regexs.float, self.regexs.float), sections=[ "x_cp2k_section_vdw_element_settings" ], repeats=True, ), ], ), SM( " vdW POTENTIAL\|\s+s6 Scaling Factor:\s+(?P<x_cp2k_vdw_s6_scaling_factor>{})" .format(self.regexs.float), sections=["x_cp2k_section_vdw_d3_settings"], subMatchers=[ SM(" vdW POTENTIAL\|\s+sr6 Scaling Factor:\s+(?P<x_cp2k_vdw_sr6_scaling_factor>{})" .format(self.regexs.float)), SM(" vdW POTENTIAL\|\s+s8 Scaling Factor:\s+(?P<x_cp2k_vdw_s8_scaling_factor>{})" .format(self.regexs.float)), SM(" vdW POTENTIAL\|\s+Cutoff for CN calculation:\s+(?P<x_cp2k_vdw_cn_cutoff>{})" .format(self.regexs.float)), ], ) ]), SM( " DFT\+U\|", adHoc=self.adHoc_dft_plus_u, ), SM( " QS\|", forwardMatch=True, subMatchers=[ SM(" QS\| Method:\s+(?P<x_cp2k_quickstep_method>{})". format(self.regexs.word)), SM(" QS\| Density plane wave grid type\s+{}".format( self.regexs.eol)), SM(" QS\| Number of grid levels:\s+{}".format( self.regexs.int)), SM(" QS\| Density cutoff \[a\.u\.\]:\s+(?P<x_cp2k_planewave_cutoff>{})" .format(self.regexs.float)), SM(" QS\| Multi grid cutoff \[a\.u\.\]: 1\) grid level\s+{}" .format(self.regexs.float)), SM(" QS\| 2\) grid level\s+{}" .format(self.regexs.float)), SM(" QS\| 3\) grid level\s+{}" .format(self.regexs.float)), SM(" QS\| 4\) grid level\s+{}" .format(self.regexs.float)), SM(" QS\| Grid level progression factor:\s+{}".format( self.regexs.float)), SM(" QS\| Relative density cutoff \[a\.u\.\]:".format( self.regexs.float)), SM(" QS\| Consistent realspace mapping and integration" ), SM(" QS\| Interaction thresholds: eps_pgf_orb:\s+{}". format(self.regexs.float)), SM(" QS\| eps_filter_matrix:\s+{}" .format(self.regexs.float)), SM(" QS\| eps_core_charge:\s+{}" .format(self.regexs.float)), SM(" QS\| eps_rho_gspace:\s+{}" .format(self.regexs.float)), SM(" QS\| eps_rho_rspace:\s+{}" .format(self.regexs.float)), SM(" QS\| eps_gvg_rspace:\s+{}" .format(self.regexs.float)), SM(" QS\| eps_ppl:\s+{}". format(self.regexs.float)), SM(" QS\| eps_ppnl:\s+{}". format(self.regexs.float)), ], ), SM(" ATOMIC KIND INFORMATION", sections=["x_cp2k_section_atomic_kinds"], subMatchers=[ SM("\s+(?P<x_cp2k_kind_number>{0})\. Atomic kind: (?P<x_cp2k_kind_label>{1})\s+Number of atoms:\s+(?P<x_cp2k_kind_number_of_atoms>{1})" .format(self.regexs.int, self.regexs.word), repeats=True, sections=[ "x_cp2k_section_atomic_kind", "x_cp2k_section_kind_basis_set" ], subMatchers=[ SM(" Orbital Basis Set\s+(?P<x_cp2k_kind_basis_set_name>{})" .format(self.regexs.word)), SM(" Number of orbital shell sets:\s+(?P<x_cp2k_basis_set_number_of_orbital_shell_sets>{})" .format(self.regexs.int)), SM(" Number of orbital shells:\s+(?P<x_cp2k_basis_set_number_of_orbital_shells>{})" .format(self.regexs.int)), SM(" Number of primitive Cartesian functions:\s+(?P<x_cp2k_basis_set_number_of_primitive_cartesian_functions>{})" .format(self.regexs.int)), SM(" Number of Cartesian basis functions:\s+(?P<x_cp2k_basis_set_number_of_cartesian_basis_functions>{})" .format(self.regexs.int)), SM(" Number of spherical basis functions:\s+(?P<x_cp2k_basis_set_number_of_spherical_basis_functions>{})" .format(self.regexs.int)), SM(" Norm type:\s+(?P<x_cp2k_basis_set_norm_type>{})" .format(self.regexs.int)), ]) ]), SM(" Total number of", forwardMatch=True, sections=["x_cp2k_section_total_numbers"], subMatchers=[ SM(" Total number of - Atomic kinds:\s+(?P<x_cp2k_atomic_kinds>\d+)" ), SM("\s+- Atoms:\s+(?P<x_cp2k_atoms>\d+)"), SM("\s+- Shell sets:\s+(?P<x_cp2k_shell_sets>\d+)"), SM("\s+- Shells:\s+(?P<x_cp2k_shells>\d+)"), SM("\s+- Primitive Cartesian functions:\s+(?P<x_cp2k_primitive_cartesian_functions>\d+)" ), SM("\s+- Cartesian basis functions:\s+(?P<x_cp2k_cartesian_basis_functions>\d+)" ), SM("\s+- Spherical basis functions:\s+(?P<x_cp2k_spherical_basis_functions>\d+)" ), ]), SM(" Maximum angular momentum of", forwardMatch=True, sections=["x_cp2k_section_maximum_angular_momentum"], subMatchers=[ SM(" Maximum angular momentum of- Orbital basis functions::\s+(?P<x_cp2k_orbital_basis_functions>\d+)" ), SM("\s+- Local part of the GTH pseudopotential:\s+(?P<x_cp2k_local_part_of_gth_pseudopotential>\d+)" ), SM("\s+- Non-local part of the GTH pseudopotential:\s+(?P<x_cp2k_non_local_part_of_gth_pseudopotential>\d+)" ), ]), SM(" MODULE QUICKSTEP: ATOMIC COORDINATES IN angstrom", forwardMatch=True, subMatchers=[ SM( " MODULE QUICKSTEP: ATOMIC COORDINATES IN angstrom", adHoc=self. adHoc_x_cp2k_section_quickstep_atom_information(), ) ]), SM(" SCF PARAMETERS", forwardMatch=True, subMatchers=[ SM(" SCF PARAMETERS Density guess:\s+{}".format( self.regexs.eol)), SM(" max_scf:\s+(?P<scf_max_iteration>{})" .format(self.regexs.int)), SM(" max_scf_history:\s+{}". format(self.regexs.int)), SM(" max_diis:\s+{}".format( self.regexs.int)), SM(" eps_scf:\s+(?P<scf_threshold_energy_change__hartree>{})" .format(self.regexs.float)), ]), SM(" MP2\|", adHoc=self.adHoc_mp2), SM(" RI-RPA\|", adHoc=self.adHoc_rpa), ])
def quickstep_calculation(self): return SM( " SCF WAVEFUNCTION OPTIMIZATION", sections=["x_cp2k_section_quickstep_calculation"], subMatchers=[ SM(r" Trace\(PS\):", sections=["x_cp2k_section_scf_iteration"], repeats=True, subMatchers=[ SM(r" Exchange-correlation energy:\s+(?P<x_cp2k_energy_XC_scf_iteration__hartree>{})" .format(self.regexs.float)), SM(r"\s+\d+\s+\S+\s+{0}\s+{0}\s+{0}\s+(?P<x_cp2k_energy_total_scf_iteration__hartree>{0})\s+(?P<x_cp2k_energy_change_scf_iteration__hartree>{0})" .format(self.regexs.float)), ]), SM(r" \*\*\* SCF run converged in\s+(\d+) steps \*\*\*", adHoc=self.adHoc_single_point_converged), SM(r" \*\*\* SCF run NOT converged \*\*\*", adHoc=self.adHoc_single_point_not_converged), SM(r" The electron density is written in cube file format to the file:", subMatchers=[ SM(""), SM( "\s+(.+\.cube)", startReAction=self.startReAction_save_cube_filename, ), ]), SM(r" Electronic kinetic energy:\s+(?P<x_cp2k_electronic_kinetic_energy__hartree>{})" .format(self.regexs.float)), SM( r" **************************** NUMERICAL STRESS ********************************" .replace("*", "\*"), # endReStr=" **************************** NUMERICAL STRESS END *****************************".replace("*", "\*"), adHoc=self.adHoc_stress_calculation, ), SM( r" ENERGY\| Total FORCE_EVAL \( \w+ \) energy \(a\.u\.\):\s+(?P<x_cp2k_energy_total__hartree>{0})" .format(self.regexs.float), ), SM(r" ATOMIC FORCES in \[a\.u\.\]"), SM( r" # Atom Kind Element X Y Z", adHoc=self.adHoc_atom_forces, ), SM(r" (?:NUMERICAL )?STRESS TENSOR \[GPa\]", sections=["x_cp2k_section_stress_tensor"], subMatchers=[ SM( r"\s+X\s+Y\s+Z", adHoc=self.adHoc_stress_tensor, ), SM(" 1/3 Trace\(stress tensor\):\s+(?P<x_cp2k_stress_tensor_one_third_of_trace__GPa>{})" .format(self.regexs.float)), SM(" Det\(stress tensor\)\s+:\s+(?P<x_cp2k_stress_tensor_determinant__GPa3>{})" .format(self.regexs.float)), SM(" EIGENVECTORS AND EIGENVALUES OF THE STRESS TENSOR", adHoc=self.adHoc_stress_tensor_eigenpairs), ]) ])
def __init__(self, parser_context): """ """ super(CP2KMDParser, self).__init__(parser_context) self.setup_common_matcher(CP2KCommonParser(parser_context)) self.traj_iterator = None self.vel_iterator = None self.energy_iterator = None self.cell_iterator = None self.n_steps = None self.output_freq = None self.coord_freq = None self.velo_freq = None self.energy_freq = None self.cell_freq = None self.md_quicksteps = [] self.ensemble = None self.cp2k_ensemble = None #======================================================================= # Globally cached values #======================================================================= # Cache levels self.caching_levels.update({ 'x_cp2k_section_md_settings': CachingLevel.ForwardAndCache, 'x_cp2k_section_md_step': CachingLevel.ForwardAndCache, 'x_cp2k_section_quickstep_calculation': CachingLevel.ForwardAndCache, "x_cp2k_section_scf_iteration": CachingLevel.ForwardAndCache, "x_cp2k_section_stress_tensor": CachingLevel.ForwardAndCache, }) #======================================================================= # SimpleMatchers self.md = SM( " MD\| Molecular Dynamics Protocol", forwardMatch=True, sections=["section_frame_sequence", "x_cp2k_section_md"], subMatchers=[ SM(" MD\| Molecular Dynamics Protocol", forwardMatch=True, sections=[ "section_sampling_method", "x_cp2k_section_md_settings" ], subMatchers=[ SM(" MD\| Ensemble Type\s+(?P<x_cp2k_md_ensemble_type>{})" .format(self.regexs.word)), SM(" MD\| Number of Time Steps\s+(?P<x_cp2k_md_number_of_time_steps>{})" .format(self.regexs.int)), SM(" MD\| Time Step \[fs\]\s+(?P<x_cp2k_md_time_step__fs>{})" .format(self.regexs.float)), SM(" MD\| Temperature \[K\]\s+(?P<x_cp2k_md_target_temperature>{})" .format(self.regexs.float)), SM(" MD\| Temperature tolerance \[K\]\s+(?P<x_cp2k_md_target_temperature_tolerance>{})" .format(self.regexs.float)), SM(" MD\| Pressure \[Bar\]\s+(?P<x_cp2k_md_target_pressure>{})" .format(self.regexs.float)), SM(" MD\| Barostat time constant \[ fs\]\s+(?P<x_cp2k_md_barostat_time_constant>{})" .format(self.regexs.float)), SM(" MD\| Print MD information every\s+(?P<x_cp2k_md_print_frequency>{}) step\(s\)" .format(self.regexs.int)), SM(" MD\| File type Print frequency\[steps\] File names" ), SM(" MD\| Coordinates\s+(?P<x_cp2k_md_coordinates_print_frequency>{})\s+(?P<x_cp2k_md_coordinates_filename>{})" .format(self.regexs.int, self.regexs.word)), SM(" MD\| Simulation Cel\s+(?P<x_cp2k_md_simulation_cell_print_frequency>{})\s+(?P<x_cp2k_md_simulation_cell_filename>{})" .format(self.regexs.int, self.regexs.word)), SM(" MD\| Velocities\s+(?P<x_cp2k_md_velocities_print_frequency>{})\s+(?P<x_cp2k_md_velocities_filename>{})" .format(self.regexs.int, self.regexs.word)), SM(" MD\| Energies\s+(?P<x_cp2k_md_energies_print_frequency>{})\s+(?P<x_cp2k_md_energies_filename>{})" .format(self.regexs.int, self.regexs.word)), SM(" MD\| Dump\s+(?P<x_cp2k_md_dump_print_frequency>{})\s+(?P<x_cp2k_md_dump_filename>{})" .format(self.regexs.int, self.regexs.word)), ]), SM(" ************************** Velocities initialization **************************" .replace("*", "\*"), name="md_initialization_step", endReStr=" INITIAL CELL ANGLS", sections=["x_cp2k_section_md_step"], subMatchers=[ self.cm.quickstep_calculation(), SM(" ******************************** GO CP2K GO! **********************************" .replace("*", "\*")), SM(" INITIAL POTENTIAL ENERGY\[hartree\] =\s+(?P<x_cp2k_md_potential_energy_instantaneous__hartree>{})" .format(self.regexs.float)), SM(" INITIAL KINETIC ENERGY\[hartree\] =\s+(?P<x_cp2k_md_kinetic_energy_instantaneous__hartree>{})" .format(self.regexs.float)), SM(" INITIAL TEMPERATURE\[K\] =\s+(?P<x_cp2k_md_temperature_instantaneous>{})" .format(self.regexs.float)), SM(" INITIAL BAROSTAT TEMP\[K\] =\s+(?P<x_cp2k_md_barostat_temperature_instantaneous>{})" .format(self.regexs.float)), SM(" INITIAL PRESSURE\[bar\] =\s+(?P<x_cp2k_md_pressure_instantaneous__bar>{})" .format(self.regexs.float)), SM(" INITIAL VOLUME\[bohr\^3\] =\s+(?P<x_cp2k_md_volume_instantaneous__bohr3>{})" .format(self.regexs.float)), 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.regexs.float)), 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.regexs.float)), ], 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=[ self.cm.quickstep_calculation(), SM(" ENSEMBLE TYPE ="), SM(" STEP NUMBER =\s+(?P<x_cp2k_md_step_number>{})" .format(self.regexs.int)), SM(" TIME \[fs\] =\s+(?P<x_cp2k_md_time__fs>{})" .format(self.regexs.float)), SM(" CONSERVED QUANTITY \[hartree\] =\s+(?P<x_cp2k_md_conserved_quantity__hartree>{})" .format(self.regexs.float)), SM(" CPU TIME \[s\] =\s+(?P<x_cp2k_md_cpu_time_instantaneous>{})\s+(?P<x_cp2k_md_cpu_time_average>{})" .format(self.regexs.float, self.regexs.float)), SM(" ENERGY DRIFT PER ATOM \[K\] =\s+(?P<x_cp2k_md_energy_drift_instantaneous>{})\s+(?P<x_cp2k_md_energy_drift_average>{})" .format(self.regexs.float, self.regexs.float)), SM(" POTENTIAL ENERGY\[hartree\] =\s+(?P<x_cp2k_md_potential_energy_instantaneous__hartree>{})\s+(?P<x_cp2k_md_potential_energy_average__hartree>{})" .format(self.regexs.float, self.regexs.float)), SM(" KINETIC ENERGY \[hartree\] =\s+(?P<x_cp2k_md_kinetic_energy_instantaneous__hartree>{})\s+(?P<x_cp2k_md_kinetic_energy_average__hartree>{})" .format(self.regexs.float, self.regexs.float)), SM(" TEMPERATURE \[K\] =\s+(?P<x_cp2k_md_temperature_instantaneous>{})\s+(?P<x_cp2k_md_temperature_average>{})" .format(self.regexs.float, self.regexs.float)), SM(" PRESSURE \[bar\] =\s+(?P<x_cp2k_md_pressure_instantaneous__bar>{0})\s+(?P<x_cp2k_md_pressure_average__bar>{0})" .format(self.regexs.float)), SM(" BAROSTAT TEMP\[K\] =\s+(?P<x_cp2k_md_barostat_temperature_instantaneous>{0})\s+(?P<x_cp2k_md_barostat_temperature_average>{0})" .format(self.regexs.float)), SM(" VOLUME\[bohr\^3\] =\s+(?P<x_cp2k_md_volume_instantaneous__bohr3>{0})\s+(?P<x_cp2k_md_volume_average__bohr3>{0})" .format(self.regexs.float)), SM(" 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.regexs.float)), SM(" AVE. CELL LNTHS\[bohr\] =\s+(?P<x_cp2k_md_cell_length_a_average__bohr>{0})\s+(?P<x_cp2k_md_cell_length_b_average__bohr>{0})\s+(?P<x_cp2k_md_cell_length_c_average__bohr>{0})" .format(self.regexs.float)), 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.regexs.float)), 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.regexs.float)), ], adHoc=self.adHoc_save_md_quickstep()), ]) # Compose root matcher according to the run type. This way the # unnecessary regex parsers will not be compiled and searched. Saves # computational time. self.root_matcher = SM("", forwardMatch=True, sections=["section_run"], subMatchers=[ SM( "", forwardMatch=True, sections=["section_method"], subMatchers=[ self.cm.restart(), self.cm.header(), self.cm.quickstep_header(), ], ), self.md, self.cm.footer(), ])