Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
parser-nwchem
Commits
85e6c71d
Commit
85e6c71d
authored
Sep 06, 2016
by
Lauri Himanen
Browse files
Fixed the issue with repeating information added to backend.
parent
0d9c5dbd
Changes
2
Show whitespace changes
Inline
Side-by-side
parser/parser-nwchem/nwchemparser/versions/nwchem66/mainparser.py
View file @
85e6c71d
...
...
@@ -10,7 +10,7 @@ LOGGER = logging.getLogger("nomad")
#===============================================================================
class
NWChemMainParser
(
MainHierarchicalParser
):
"""The main parser class that is called for all run types. Parses the
CPMD
"""The main parser class that is called for all run types. Parses the
NWChem
output file.
"""
def
__init__
(
self
,
file_path
,
parser_context
):
...
...
@@ -22,6 +22,8 @@ class NWChemMainParser(MainHierarchicalParser):
self
.
frame_sequence_local_frames_ref
=
[]
self
.
method_index
=
None
self
.
system_index
=
None
self
.
electronic_structure_method
=
None
self
.
save_method
=
False
#=======================================================================
# Cache levels
...
...
@@ -239,7 +241,10 @@ class NWChemMainParser(MainHierarchicalParser):
backend
.
addValue
(
"single_configuration_calculation_to_system_ref"
,
self
.
system_index
)
def
onClose_x_nwchem_section_dft
(
self
,
backend
,
gIndex
,
section
):
backend
.
addValue
(
"electronic_structure_method"
,
"DFT"
)
self
.
electronic_structure_method
=
"DFT"
def
onClose_section_method
(
self
,
backend
,
gIndex
,
section
):
backend
.
addValue
(
"electronic_structure_method"
,
self
.
electronic_structure_method
)
def
onClose_x_nwchem_section_geo_opt_task
(
self
,
backend
,
gIndex
,
section
):
steps
=
section
[
"x_nwchem_section_geo_opt_step"
]
...
...
@@ -268,6 +273,7 @@ class NWChemMainParser(MainHierarchicalParser):
# onOpen triggers
def
onOpen_section_method
(
self
,
backend
,
gIndex
,
section
):
self
.
method_index
=
gIndex
self
.
save_method
=
True
#=======================================================================
# adHoc
...
...
@@ -343,12 +349,24 @@ class NWChemMainParser(MainHierarchicalParser):
section
.
add_latest_value
(
"x_nwchem_dft_energy_total"
,
"energy_total"
)
section
.
add_latest_value
(
"x_nwchem_dft_energy_X"
,
"energy_X"
)
section
.
add_latest_value
(
"x_nwchem_dft_energy_C"
,
"energy_C"
)
section
.
add_latest_value
(
"x_nwchem_dft_spin_multiplicity"
,
"spin_target_multiplicity"
)
#
section.add_latest_value("x_nwchem_dft_spin_multiplicity", "spin_target_multiplicity")
section
.
add_latest_value
(
"x_nwchem_dft_number_of_atoms"
,
"number_of_atoms"
)
# section.add_latest_value("x_nwchem_dft_total_charge", "total_charge")
# section.add_latest_value("x_nwchem_dft_max_iteration", "scf_max_iteration")
# section.add_latest_value("x_nwchem_dft_scf_threshold_energy_change", "scf_threshold_energy_change")
backend
.
addValue
(
"number_of_scf_iterations"
,
self
.
n_scf_iterations
)
# If a geo opt has just been started, save the general settings
if
self
.
save_method
:
section
.
add_latest_value
(
"x_nwchem_dft_spin_multiplicity"
,
"spin_target_multiplicity"
)
section
.
add_latest_value
(
"x_nwchem_dft_total_charge"
,
"total_charge"
)
section
.
add_latest_value
(
"x_nwchem_dft_max_iteration"
,
"scf_max_iteration"
)
section
.
add_latest_value
(
"x_nwchem_dft_scf_threshold_energy_change"
,
"scf_threshold_energy_change"
)
backend
.
addValue
(
"number_of_scf_iterations"
,
self
.
n_scf_iterations
)
self
.
save_method
=
False
# print(multiplicity)
# print(energy_total)
self
.
n_scf_iterations
=
0
return
wrapper
...
...
@@ -381,3 +399,8 @@ class NWChemMainParser(MainHierarchicalParser):
backend
.
addArrayValues
(
"frame_sequence_local_frames_ref"
,
np
.
array
(
self
.
frame_sequence_local_frames_ref
))
self
.
frame_sequence_local_frames_ref
=
[]
return
wrapper
def
save_method
(
self
):
def
wrapper
(
backend
,
gIndex
,
section
):
self
.
save_method
=
True
return
wrapper
test/unittests/nwchem_6.6/run_tests.py
View file @
85e6c71d
...
...
@@ -138,7 +138,7 @@ class TestDFTEnergy(unittest.TestCase):
result
=
self
.
results
[
"number_of_scf_iterations"
]
self
.
assertEqual
(
result
,
6
)
def
test_target_multiplicity
(
self
):
def
test_
spin_
target_multiplicity
(
self
):
multiplicity
=
self
.
results
[
"spin_target_multiplicity"
]
self
.
assertEqual
(
multiplicity
,
1
)
...
...
@@ -146,9 +146,9 @@ class TestDFTEnergy(unittest.TestCase):
result
=
self
.
results
[
"single_configuration_to_calculation_method_ref"
]
self
.
assertEqual
(
result
,
0
)
#
def test_single_configuration_calculation_to_system_description_ref(self):
#
result = self.results["single_configuration_calculation_to_system_ref"]
#
self.assertEqual(result, 0)
def
test_single_configuration_calculation_to_system_description_ref
(
self
):
result
=
self
.
results
[
"single_configuration_calculation_to_system_ref"
]
self
.
assertEqual
(
result
,
0
)
# def test_single_configuration_calculation_converged(self):
# result = self.results["single_configuration_calculation_converged"]
...
...
@@ -260,7 +260,8 @@ class TestDFTGeoOpt(unittest.TestCase):
self
.
assertEqual
(
n_frames
,
4
)
# Potential energy
pot_ener
=
sequence
[
"frame_sequence_potential_energy"
][
0
]
pot_ener
=
sequence
[
"frame_sequence_potential_energy"
]
# print(pot_ener)
expected_pot_ener
=
convert_unit
(
np
.
array
([
-
76.42941861
,
...
...
@@ -1053,9 +1054,9 @@ class TestDFTGeoOpt(unittest.TestCase):
#===============================================================================
if
__name__
==
'__main__'
:
suites
=
[]
#
suites.append(unittest.TestLoader().loadTestsFromTestCase(TestDFTEnergy))
suites
.
append
(
unittest
.
TestLoader
().
loadTestsFromTestCase
(
TestDFTEnergy
))
suites
.
append
(
unittest
.
TestLoader
().
loadTestsFromTestCase
(
TestDFTForce
))
#
suites.append(unittest.TestLoader().loadTestsFromTestCase(TestDFTGeoOpt))
suites
.
append
(
unittest
.
TestLoader
().
loadTestsFromTestCase
(
TestDFTGeoOpt
))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestGeoOpt))
# suites.append(unittest.TestLoader().loadTestsFromTestCase(TestInputParser))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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