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
2b827c50
Commit
2b827c50
authored
Apr 18, 2018
by
Lauri Himanen
Browse files
Added initial functionality for opening cube files.
parent
39930754
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
parser/parser-cp2k/cp2kparser/versions/cp2k262/commonparser.py
View file @
2b827c50
...
...
@@ -54,6 +54,7 @@ class CP2KCommonParser(CommonParser):
self
.
cache_service
.
add
(
"map_kind_to_basis"
,
single
=
False
,
update
=
False
)
self
.
cache_service
.
add
(
"map_index_to_kind"
,
single
=
False
,
update
=
False
)
self
.
cache_service
.
add
(
"map_kind_number_to_basis_ref"
,
single
=
False
,
update
=
False
)
self
.
cache_service
.
add
(
"electron_density_filename"
,
single
=
False
,
update
=
True
)
#===========================================================================
# SimpleMatchers
...
...
@@ -191,6 +192,15 @@ class CP2KCommonParser(CommonParser):
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("*", "\*"),
...
...
@@ -556,6 +566,10 @@ class CP2KCommonParser(CommonParser):
# Cell dependent basis mapping
self
.
cache_service
.
addValue
(
"mapping_section_basis_set_cell_dependent"
)
# If a cube file was found, open it and store values.
filename
=
self
.
cache_service
[
"electron_density_filename"
]
absolute_filepath
=
self
.
parser_context
.
file_service
.
get_absolute_path_to_file
(
filename
)
backend
.
closeSection
(
"section_basis_set"
,
scc_basis_id
)
#===========================================================================
...
...
@@ -736,3 +750,9 @@ class CP2KCommonParser(CommonParser):
def
wrapper
(
parser
,
groups
):
print
(
msg
)
return
wrapper
#=======================================================================
# StarReActions
def
startReAction_save_cube_filename
(
self
,
backend
,
groups
):
filename
=
groups
[
0
]
self
.
cache_service
[
"electron_density_filename"
]
=
filename
regtests/cp2k_2.6.2/cube/single_point_default_name/Si_bulk8-ELECTRON_DENSITY-1_0.cube
0 → 100644
View file @
2b827c50
This diff is collapsed.
Click to expand it.
regtests/cp2k_2.6.2/cube/single_point_default_name/Si_bulk8-RESTART.wfn
0 → 100644
View file @
2b827c50
File added
regtests/cp2k_2.6.2/cube/single_point_default_name/si_bulk8.inp
0 → 100644
View file @
2b827c50
&GLOBAL
PROJECT Si_bulk8
RUN_TYPE ENERGY_FORCE
PRINT_LEVEL MEDIUM
&END GLOBAL
&FORCE_EVAL
METHOD Quickstep
STRESS_TENSOR ANALYTICAL
&SUBSYS
&KIND Si
ELEMENT Si
BASIS_SET DZVP-GTH-PADE
POTENTIAL GTH-PADE-q4
&END KIND
&CELL
A 5.430697500 0.000000000 0.000000000
B 0.000000000 5.430697500 0.000000000
C 0.000000000 0.000000000 5.430697500
&END CELL
&COORD
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 300
REL_CUTOFF 60
&END MGRID
&XC
&XC_FUNCTIONAL PADE
&END XC_FUNCTIONAL
&END XC
&SCF
SCF_GUESS ATOMIC
EPS_SCF 1.0E-7
MAX_SCF 300
&DIAGONALIZATION ON
ALGORITHM STANDARD
&END DIAGONALIZATION
&MIXING T
METHOD BROYDEN_MIXING
ALPHA 0.4
NBROYDEN 8
&END MIXING
&END SCF
&PRINT
&E_DENSITY_CUBE MEDIUM
ADD_LAST NUMERIC
STRIDE 3 3 3
&END E_DENSITY_CUBE
&END PRINT
&END DFT
&PRINT
&FORCES ON
&END FORCES
&END PRINT
&END FORCE_EVAL
regtests/cp2k_2.6.2/cube/single_point_default_name/unittest.out
0 → 100644
View file @
2b827c50
This diff is collapsed.
Click to expand it.
regtests/regtests.py
View file @
2b827c50
...
...
@@ -1326,6 +1326,13 @@ class TestElectronicStructureMethod(unittest.TestCase):
self
.
assertEqual
(
result
,
"RPA"
)
class
TestCubeFiles
(
unittest
.
TestCase
):
"""Tests that different methods are recognized correctly.
"""
def
test_electron_density
(
self
):
results
=
get_result
(
"cube/single_point_default_name"
)
if
__name__
==
'__main__'
:
logger
=
logging
.
getLogger
(
"cp2kparser"
)
...
...
@@ -1335,28 +1342,29 @@ if __name__ == '__main__':
for
VERSION
in
VERSIONS
:
suites
=
[]
suites
.
append
(
unittest
.
TestLoader
().
loadTestsFromTestCase
(
TestErrors
))
suites
.
append
(
unittest
.
TestLoader
().
loadTestsFromTestCase
(
TestUnknownInput
))
suites
.
append
(
unittest
.
TestLoader
().
loadTestsFromTestCase
(
TestXCFunctional
))
suites
.
append
(
unittest
.
TestLoader
().
loadTestsFromTestCase
(
TestEnergyForce
))
suites
.
append
(
unittest
.
TestLoader
().
loadTestsFromTestCase
(
TestGeometryInfo
))
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
))
suites
.
append
(
unittest
.
TestLoader
().
loadTestsFromTestCase
(
TestGeoOptOptimizers
))
suites
.
append
(
unittest
.
TestLoader
().
loadTestsFromTestCase
(
TestGeoOptTrajectory
))
suites
.
append
(
unittest
.
TestLoader
().
loadTestsFromTestCase
(
TestRestart
))
suites
.
append
(
unittest
.
TestLoader
().
loadTestsFromTestCase
(
TestMD
))
suites
.
append
(
unittest
.
TestLoader
().
loadTestsFromTestCase
(
TestMDPrintSettings
))
suites
.
append
(
unittest
.
TestLoader
().
loadTestsFromTestCase
(
TestMDEnsembles
))
suites
.
append
(
unittest
.
TestLoader
().
loadTestsFromTestCase
(
TestMDEnsembles
))
suites
.
append
(
unittest
.
TestLoader
().
loadTestsFromTestCase
(
TestVDWMethod
))
suites
.
append
(
unittest
.
TestLoader
().
loadTestsFromTestCase
(
TestElectronicStructureMethod
))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestErrors))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestUnknownInput))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestXCFunctional))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestEnergyForce))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestGeometryInfo))
# 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))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestGeoOptOptimizers))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestGeoOptTrajectory))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestRestart))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestMD))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestMDPrintSettings))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestMDEnsembles))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestMDEnsembles))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestVDWMethod))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestElectronicStructureMethod))
suites
.
append
(
unittest
.
TestLoader
().
loadTestsFromTestCase
(
TestCubeFiles
))
alltests
=
unittest
.
TestSuite
(
suites
)
result
=
unittest
.
TextTestRunner
(
verbosity
=
0
).
run
(
alltests
)
...
...
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