Commit fe5b18d0 authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Started adding support for geoopt.

parent e83d29d7
......@@ -54,8 +54,13 @@ lib/
env/
# CP2K files
*.wfn
*.cube
test/**/*.wfn
test/**/*.cube
test/**/*.cell
test/**/*.restart
test/**/*.restart.bak-1
test/**/*.restart.bak-2
test/**/*.restart.bak-3
parser/parser-cp2k/cp2kparser/versions/**/input_data/*.xml
parser/parser-cp2k/cp2kparser/versions/**/input_data/*.html
test/unittests/BASIS_SET
......
import re
import numpy as np
from nomadcore.simple_parser import SimpleMatcher as SM
from inputparser import CP2KInputParser
import logging
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.simple_parser import extractOnCloseTriggers
from nomadcore.caching_backend import CachingLevel
from inputparser import CP2KInputParser
logger = logging.getLogger("nomad")
......@@ -22,6 +23,20 @@ class CommonMatcher(object):
self.regex_f = "-?\d+\.\d+(?:E(?:\+|-)\d+)?" # Regex for a floating point value
self.regex_i = "-?\d+" # Regex for an integer
self.caching_levels = {
'section_XC_functionals': CachingLevel.ForwardAndCache,
'self_interaction_correction_method': CachingLevel.Cache,
'cp2k_section_md_coordinates': CachingLevel.Cache,
'cp2k_section_md_coordinate_atom': CachingLevel.Cache,
'cp2k_md_coordinate_atom_string': CachingLevel.Cache,
'cp2k_md_coordinate_atom_float': CachingLevel.Cache,
'cp2k_section_md_forces': CachingLevel.Cache,
'cp2k_section_md_force_atom': CachingLevel.Cache,
'cp2k_md_force_atom_string': CachingLevel.Cache,
'cp2k_md_force_atom_float': CachingLevel.Cache,
}
def adHoc_cp2k_section_cell(self):
"""Used to extract the cell information.
"""
......
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.baseclasses import MainHierarchicalParser
from commonmatcher import CommonMatcher
import logging
logger = logging.getLogger("nomad")
#===============================================================================
class CP2KGeoOptParser(MainHierarchicalParser):
"""Used to parse the CP2K calculation with run types:
-GEO_OPT/GEOMETRY_OPTIMIZATION
"""
def __init__(self, file_path, parser_context):
"""
"""
super(CP2KGeoOptParser, self).__init__(file_path, parser_context)
self.cm = CommonMatcher(parser_context)
# Simple matcher for run type ENERGY_FORCE, ENERGY with QUICKSTEP
self.geo_opt = SM(
" MODULE QUICKSTEP: ATOMIC COORDINATES IN angstrom",
forwardMatch=True,
subMatchers=[
SM( " MODULE QUICKSTEP: ATOMIC COORDINATES IN angstrom",
adHoc=self.adHoc_cp2k_section_quickstep_atom_information(),
otherMetaInfo=["atom_label", "atom_position"]
),
SM( " SCF WAVEFUNCTION OPTIMIZATION",
subMatchers=[
SM( r" Trace\(PS\):",
sections=["section_scf_iteration"],
repeats=True,
subMatchers=[
SM( r" Exchange-correlation energy:\s+(?P<energy_XC_scf_iteration__hartree>{})".format(self.cm.regex_f)),
SM( r"\s+\d+\s+\S+\s+{0}\s+{0}\s+{0}\s+(?P<energy_total_scf_iteration__hartree>{0})\s+(?P<energy_change_scf_iteration__hartree>{0})".format(self.cm.regex_f)),
]
),
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" Electronic kinetic energy:\s+(?P<electronic_kinetic_energy__hartree>{})".format(self.cm.regex_f)),
SM( r" ENERGY\| Total FORCE_EVAL \( \w+ \) energy \(a\.u\.\):\s+(?P<energy_total__hartree>{0})".format(self.cm.regex_f)),
SM( r" ATOMIC FORCES in \[a\.u\.\]"),
SM( r" # Atom Kind Element X Y Z",
adHoc=self.adHoc_atom_forces()
),
]
)
]
)
# 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_single_configuration_calculation", "section_system_description", "section_method"],
subMatchers=[
self.cm.header(),
self.geo_opt
]
)
#=======================================================================
# The cache settings
self.caching_level_for_metaname = self.cm.caching_levels
#=======================================================================
# The additional onClose trigger functions
self.onClose = self.cm.getOnCloseTriggers()
#===========================================================================
# onClose triggers. These are specific to this main parser, common
# triggers are imprted from commonmatchers module.
#===========================================================================
# adHoc functions. Primarily these
# functions are used for data that is formatted as a table or a list.
......@@ -43,18 +43,3 @@
O 12.2353220000 1.3766420000 10.8698800000
H 12.4752917518 2.2561254118 11.2121163217
H 11.9031806595 1.5481019598 9.9671120050
3
i = 10, E = -17.1646204237
O 12.2353220000 1.3766420000 10.8698800000
H 12.4755864059 2.2562726297 11.2125118440
H 11.9026358443 1.5480115451 9.9673498890
3
i = 11, E = -17.1646204766
O 12.2353220000 1.3766420000 10.8698800000
H 12.4754906682 2.2560912723 11.2123985687
H 11.9026556670 1.5480524898 9.9673305122
3
i = 12, E = -17.1646347711
O 12.2353220000 1.3766420000 10.8698800000
H 12.4754916182 2.2560930719 11.2123996927
H 11.9026554703 1.5480520836 9.9673307045
&GLOBAL
PROJECT H2O
RUN_TYPE GEO_OPT
PRINT_LEVEL LOW
&END GLOBAL
&FORCE_EVAL
METHOD QS
&SUBSYS
&CELL
ABC 12.4138 12.4138 12.4138
&END CELL
&COORD
O 12.235322 1.376642 10.869880
H 12.415139 2.233125 11.257611
H 11.922476 1.573799 9.986994
&END COORD
&KIND H
BASIS_SET DZVP-GTH-PADE
POTENTIAL GTH-PADE-q1
&END KIND
&KIND O
BASIS_SET DZVP-GTH-PADE
POTENTIAL GTH-PADE-q6
&END KIND
&END SUBSYS
&DFT
BASIS_SET_FILE_NAME ./BASIS_SET
POTENTIAL_FILE_NAME ./POTENTIAL
&QS
EPS_DEFAULT 1.0E-7
&END QS
&MGRID
CUTOFF 200
NGRIDS 4
REL_CUTOFF 30
&END MGRID
&SCF
SCF_GUESS ATOMIC
EPS_SCF 1.0E-05
MAX_SCF 200
&DIAGONALIZATION T
ALGORITHM STANDARD
&END DIAGONALIZATION
&MIXING T
ALPHA 0.5
METHOD PULAY_MIXING
NPULAY 5
&END MIXING
&PRINT
&RESTART OFF
&END RESTART
&END PRINT
&END SCF
&XC
&XC_FUNCTIONAL PADE
&END XC_FUNCTIONAL
&END XC
&END DFT
&END FORCE_EVAL
&MOTION
&GEO_OPT
TYPE MINIMIZATION
MAX_DR 1.0E-03
MAX_FORCE 1.0E-03
RMS_DR 1.0E-03
RMS_FORCE 1.0E-03
MAX_ITER 200
OPTIMIZER CG
&CG
MAX_STEEP_STEPS 0
RESTART_LIMIT 9.0E-01
&END CG
&END GEO_OPT
&CONSTRAINT
&FIXED_ATOMS
COMPONENTS_TO_FIX XYZ
LIST 1
&END FIXED_ATOMS
&END CONSTRAINT
&END MOTION
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment