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
f7b1801c
Commit
f7b1801c
authored
Jun 01, 2016
by
Lauri Himanen
Browse files
Added tests for comments.
parent
cf877716
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
parser/parser-cp2k/cp2kparser/versions/cp2k262/inputparser.py
View file @
f7b1801c
...
...
@@ -246,6 +246,8 @@ class CP2KInputParser(BasicParser):
self
.
input_tree
.
root_section
.
accessed
=
True
for
line
in
self
.
input_lines
:
# Remove comments and whitespaces
line
=
line
.
split
(
'!'
,
1
)[
0
].
strip
()
# Skip empty lines
...
...
@@ -283,6 +285,8 @@ class CP2KInputParser(BasicParser):
# Contents (keywords, default keywords)
else
:
split
=
line
.
split
(
' '
,
1
)
if
len
(
split
)
<=
1
:
raise
IndexError
(
"A keyword in the CP2K input had no value associated with it. The line causing this is: '{}'"
.
format
(
line
))
keyword_name
=
split
[
0
].
upper
()
keyword_value
=
split
[
1
]
self
.
input_tree
.
set_keyword
(
path
+
"/"
+
keyword_name
,
keyword_value
)
...
...
test/unittests/cp2k_2.6.2/input_preprocessing/comments/si_bulk8.inp
0 → 100644
View file @
f7b1801c
! Starting comment
&GLOBAL
PROJECT Si_bulk8 ! Keyword comment
RUN_TYPE ENERGY_FORCE
PRINT_LEVEL MEDIUM
&END GLOBAL
&FORCE_EVAL ! Section comment
METHOD Quickstep
&SUBSYS
&KIND Si
ELEMENT Si
BASIS_SET DZVP-GTH-PADE
POTENTIAL GTH-PADE-q4
&END KIND
&CELL
A 5.430697500 0.000000000 0.000000000 ! test
B 0.000000000 5.430697500 0.000000000
C 0.000000000 0.000000000 5.430697500
&END CELL ! Comment in end tag
&COORD ! Comment where default keyword starts
Si 0.000000000 0.000000000 0.000000000
Si 0.000000000 2.715348700 2.715348700
Si 2.715348700 2.715348700 0.000000000
Si 2.715348700 0.000000000 2.715348700
Si 4.073023100 1.357674400 4.073023100
Si 1.357674400 1.357674400 1.357674400
Si 1.357674400 4.073023100 4.073023100
Si 4.073023100 4.073023100 1.357674400
&END COORD
&END SUBSYS
&DFT
BASIS_SET_FILE_NAME ../../BASIS_SET
POTENTIAL_FILE_NAME ../../GTH_POTENTIALS
&QS
EPS_DEFAULT 1.0E-10
&END QS
&MGRID
NGRIDS 4
CUTOFF 120
REL_CUTOFF 40
&END MGRID
&XC
&XC_FUNCTIONAL PADE
&END XC_FUNCTIONAL
&END XC
&SCF
SCF_GUESS ATOMIC
EPS_SCF 1.0E-5
MAX_SCF 50
&DIAGONALIZATION ON
ALGORITHM STANDARD
&END DIAGONALIZATION
&MIXING T
METHOD BROYDEN_MIXING
ALPHA 0.4
NBROYDEN 8
&END MIXING
&END SCF
&END DFT
&PRINT
&FORCES ON
&END FORCES
&END PRINT
&END FORCE_EVAL
! Comment at the end
test/unittests/cp2k_2.6.2/input_preprocessing/comments/unittest.out
0 → 100644
View file @
f7b1801c
This diff is collapsed.
Click to expand it.
test/unittests/cp2k_2.6.2/run_tests.py
View file @
f7b1801c
...
...
@@ -446,6 +446,10 @@ class TestPreprocessor(unittest.TestCase):
result
=
get_result
(
"input_preprocessing/variable_multiple"
,
"x_cp2k_CP2K_INPUT.FORCE_EVAL.DFT.MGRID.CUTOFF"
,
optimize
=
False
)
self
.
assertEqual
(
result
,
50
)
def
test_comments
(
self
):
result
=
get_result
(
"input_preprocessing/comments"
,
"x_cp2k_CP2K_INPUT.FORCE_EVAL.DFT.MGRID.CUTOFF"
,
optimize
=
False
)
self
.
assertEqual
(
result
,
120
)
#===============================================================================
class
TestGeoOpt
(
unittest
.
TestCase
):
...
...
@@ -611,13 +615,13 @@ if __name__ == '__main__':
suites
=
[]
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestErrors))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestXCFunctional))
suites
.
append
(
unittest
.
TestLoader
().
loadTestsFromTestCase
(
TestEnergyForce
))
#
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
(
TestPreprocessor
))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestGeoOpt))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestGeoOptTrajFormats))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestGeoOptOptimizers))
...
...
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