Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
parser-cp2k
Commits
1070a2d1
Commit
1070a2d1
authored
Jun 13, 2016
by
Lauri Himanen
Browse files
Now more method related data is parsed.
parent
dfecd23b
Changes
3
Hide whitespace changes
Inline
Side-by-side
parser/parser-cp2k/cp2kparser/versions/cp2k262/commonmatcher.py
View file @
1070a2d1
...
...
@@ -37,6 +37,7 @@ class CommonMatcher(object):
'section_XC_functionals'
:
CachingLevel
.
ForwardAndCache
,
'self_interaction_correction_method'
:
CachingLevel
.
Cache
,
'x_cp2k_section_programinformation'
:
CachingLevel
.
ForwardAndCache
,
'x_cp2k_section_quickstep_settings'
:
CachingLevel
.
ForwardAndCache
,
}
#=======================================================================
...
...
@@ -189,11 +190,14 @@ class CommonMatcher(object):
def
quickstep_header
(
self
):
return
SM
(
" *******************************************************************************"
.
replace
(
"*"
,
"\*"
),
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
.
regex_word
)),
SM
(
" DFT\| Multiplicity\s+(?P<spin_target_multiplicity>{})"
.
format
(
self
.
regex_i
)),
SM
(
" DFT\| Number of spin states\s+(?P<number_of_spin_channels>{})"
.
format
(
self
.
regex_i
)),
SM
(
" DFT\| Charge\s+(?P<total_charge>{})"
.
format
(
self
.
regex_i
)),
SM
(
" DFT\| Self-interaction correction \(SIC\)\s+(?P<self_interaction_correction_method>[^
\n
]+)"
),
],
...
...
@@ -231,6 +235,16 @@ class CommonMatcher(object):
otherMetaInfo
=
[
"atom_labels"
,
"atom_positions"
]
)
]
),
SM
(
" SCF PARAMETERS"
,
forwardMatch
=
True
,
subMatchers
=
[
SM
(
" SCF PARAMETERS Density guess:\s+{}"
.
format
(
self
.
regex_eol
)),
SM
(
" max_scf:\s+(?P<scf_max_iteration>{})"
.
format
(
self
.
regex_i
)),
SM
(
" max_scf_history:\s+{}"
.
format
(
self
.
regex_i
)),
SM
(
" max_diis:\s+{}"
.
format
(
self
.
regex_i
)),
SM
(
" eps_scf:\s+(?P<scf_threshold_energy_change>{})"
.
format
(
self
.
regex_f
)),
]
)
]
)
...
...
@@ -243,13 +257,6 @@ class CommonMatcher(object):
if
number_of_atoms
is
not
None
:
self
.
cache_service
[
"number_of_atoms"
]
=
number_of_atoms
def
onClose_section_run
(
self
,
backend
,
gIndex
,
section
):
"""Information that is pushed regardless at the end of parsing.
Contains also information that is totally agnostic on the calculation
contents, like program_basis_set_type.
"""
backend
.
addValue
(
"program_basis_set_type"
,
"gaussian"
)
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
...
...
@@ -276,6 +283,10 @@ class CommonMatcher(object):
except
:
pass
def
onClose_x_cp2k_section_quickstep_settings
(
self
,
backend
,
gIndex
,
section
):
backend
.
addValue
(
"program_basis_set_type"
,
"gaussian"
)
# backend.addValue("electronic_structure_method", "DFT")
def
onClose_x_cp2k_section_programinformation
(
self
,
backend
,
gIndex
,
section
):
input_file
=
section
.
get_latest_value
(
"x_cp2k_input_filename"
)
self
.
file_service
.
set_file_id
(
input_file
,
"input"
)
...
...
parser/parser-cp2k/cp2kparser/versions/cp2k262/inputparser.py
View file @
1070a2d1
...
...
@@ -64,6 +64,7 @@ class CP2KInputParser(BasicParser):
self
.
cache_service
.
add
(
"vel_add_last"
)
self
.
cache_service
.
add
(
"each_geo_opt"
)
self
.
cache_service
.
add
(
"traj_add_last"
)
self
.
cache_service
.
add
(
"electronic_structure_method"
)
def
parse
(
self
):
...
...
@@ -215,6 +216,10 @@ class CP2KInputParser(BasicParser):
pint_vel_unit
=
self
.
get_pint_unit_string
(
vel_unit
)
self
.
cache_service
[
"velocity_unit"
]
=
pint_vel_unit
#=======================================================================
# See if some more exotic calculation is requested (e.g. MP2, DFT+U, GW, RPA)
#=======================================================================
# Stress tensor calculation method
stress_tensor_method
=
self
.
input_tree
.
get_keyword
(
"FORCE_EVAL/STRESS_TENSOR"
)
...
...
test/unittests/cp2k_2.6.2/run_tests.py
View file @
1070a2d1
...
...
@@ -281,6 +281,18 @@ class TestEnergyForce(unittest.TestCase):
expected_result
=
convert_unit
(
np
.
array
(
-
32.2320848878
),
"hartree"
)
self
.
assertTrue
(
np
.
array_equal
(
result
[
0
],
expected_result
))
def
test_scf_max_iteration
(
self
):
result
=
self
.
results
[
"scf_max_iteration"
]
self
.
assertEqual
(
result
,
300
)
def
test_scf_threshold_energy_change
(
self
):
result
=
self
.
results
[
"scf_threshold_energy_change"
]
self
.
assertEqual
(
result
,
1.00E-07
)
def
test_number_of_spin_channels
(
self
):
result
=
self
.
results
[
"number_of_spin_channels"
]
self
.
assertEqual
(
result
,
1
)
def
test_energy_change_scf_iteration
(
self
):
energy_change
=
self
.
results
[
"energy_change_scf_iteration"
]
expected_result
=
convert_unit
(
np
.
array
(
-
3.22E+01
),
"hartree"
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment