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-big-dft
Commits
c45a92f9
Commit
c45a92f9
authored
Dec 02, 2016
by
Lauri Himanen
Browse files
Added some basic metavalues, fixed issue with non-recursive parsing with pyyaml.
parent
ef591291
Pipeline
#8782
failed with stage
in 9 minutes and 6 seconds
Changes
9
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
c45a92f9
...
...
@@ -9,7 +9,7 @@ testing:
-
cd nomad-lab-base
-
git submodule foreach git checkout master
-
git submodule foreach git pull
-
sbt
nwchem
/test
-
sbt
bigdft
/test
-
export PYTHONEXE=/labEnv/bin/python
-
sbt bigdft/test
only
:
...
...
parser/parser-big-dft/bigdftparser/regtest/bigdft_1.8/run_tests.py
View file @
c45a92f9
...
...
@@ -59,37 +59,51 @@ class TestSinglePoint(unittest.TestCase):
result
=
self
.
results
[
"program_name"
]
self
.
assertEqual
(
result
,
"BigDFT"
)
def
test_simulation_cell
(
self
):
result
=
self
.
results
[
"simulation_cell"
]
expected_result
=
convert_unit
(
np
.
array
(
[
[
7.1439
,
0
,
0
],
[
0
,
7.1439
,
0
],
[
0
,
0
,
8.3345
],
]
),
"angstrom"
)
self
.
assertTrue
(
np
.
array_equal
(
result
,
expected_result
))
# def test_configuration_periodic_dimensions(self):
# result = self.results["configuration_periodic_dimensions"]
# self.assertTrue(np.array_equal(result, np.array([False, False, False])))
#
def test_program_version(self):
#
result = self.results["program_version"]
#
self.assertEqual(result, "
6.6
")
def
test_program_version
(
self
):
result
=
self
.
results
[
"program_version"
]
self
.
assertEqual
(
result
,
"
1.8
"
)
# def test_xc_functional(self):
# result = self.results["XC_functional"]
# self.assertEqual(result, "1.0*MGGA_C_TPSS+1.0*MGGA_X_TPSS")
# def test_atom_labels(self):
# atom_labels = self.results["atom_labels"]
# expected_labels = np.array(["O", "H", "H"])
# self.assertTrue(np.array_equal(atom_labels, expected_labels))
# def test_atom_positions(self):
# atom_position = self.results["atom_positions"]
# expected_position = convert_unit(np.array(
# [
# [0.00000000, 0.00000000, -0.11817375],
# [0.76924532, 0.00000000, 0.47269501],
# [-0.76924532, 0.00000000, 0.47269501],
# ]
# ), "angstrom")
# self.assertTrue(np.array_equal(atom_position, expected_position))
# def test_number_of_atoms(self):
# n_atoms = self.results["number_of_atoms"]
# self.assertEqual(n_atoms, 3)
def
test_atom_labels
(
self
):
atom_labels
=
self
.
results
[
"atom_labels"
]
expected_labels
=
np
.
array
([
"N"
,
"N"
])
self
.
assertTrue
(
np
.
array_equal
(
atom_labels
,
expected_labels
))
def
test_atom_positions
(
self
):
atom_position
=
self
.
results
[
"atom_positions"
]
expected_position
=
convert_unit
(
np
.
array
(
[
[
3.571946174
,
3.571946174
,
3.609775538
],
[
3.571946174
,
3.571946174
,
4.724765534
],
]
),
"angstrom"
)
self
.
assertTrue
(
np
.
array_equal
(
atom_position
,
expected_position
))
def
test_number_of_atoms
(
self
):
n_atoms
=
self
.
results
[
"number_of_atoms"
]
self
.
assertEqual
(
n_atoms
,
2
)
def
test_electronic_structure_method
(
self
):
result
=
self
.
results
[
"electronic_structure_method"
]
self
.
assertEqual
(
result
,
"DFT"
)
# def test_total_charge(self):
# charge = self.results["total_charge"]
...
...
@@ -137,9 +151,6 @@ class TestSinglePoint(unittest.TestCase):
# result = self.results["scf_threshold_energy_change"]
# self.assertEqual(result, convert_unit(1.00E-06, "hartree"))
# def test_electronic_structure_method(self):
# result = self.results["electronic_structure_method"]
# self.assertEqual(result, "DFT")
# def test_scf_dft_number_of_iterations(self):
# result = self.results["number_of_scf_iterations"]
...
...
parser/parser-big-dft/bigdftparser/regtest/bigdft_1.8/yaml_test/data.yml
0 → 100644
View file @
c45a92f9
This diff is collapsed.
Click to expand it.
parser/parser-big-dft/bigdftparser/regtest/bigdft_1.8/yaml_test/node_data.yml
0 → 100644
View file @
c45a92f9
scalar1
:
Moi
scalar2
:
Terve
scalar3
:
5
parser/parser-big-dft/bigdftparser/regtest/bigdft_1.8/yaml_test/node_reader.py
0 → 100644
View file @
c45a92f9
# from yaml import CLoader as Loader
from
yaml
import
Loader
with
open
(
"node_data.yml"
,
"r"
)
as
fin
:
loader
=
Loader
(
fin
)
node
=
loader
.
compose_node
()
print
(
node
)
# while(True):
# token = loader.get_token()
# if token is None:
# break
# print(token)
parser/parser-big-dft/bigdftparser/regtest/bigdft_1.8/yaml_test/output.out
0 → 100644
View file @
c45a92f9
Version Number : 1.8
scalar1: Moi
scalar2: Terve
scalar3: 5
parser/parser-big-dft/bigdftparser/regtest/bigdft_1.8/yaml_test/yaml_creator.py
0 → 100644
View file @
c45a92f9
import
yaml
data
=
{}
listy
=
[]
data
[
"list"
]
=
[
1000000000000
+
x
for
x
in
range
(
2000000
)]
with
open
(
'data.yml'
,
'w'
)
as
outfile
:
yaml
.
dump
(
data
,
outfile
,
default_flow_style
=
True
)
parser/parser-big-dft/bigdftparser/regtest/bigdft_1.8/yaml_test/yaml_reader.py
0 → 100644
View file @
c45a92f9
from
yaml
import
CLoader
as
Loader
from
pympler
import
tracker
tr
=
tracker
.
SummaryTracker
()
tr
.
print_diff
()
tr
.
print_diff
()
with
open
(
"data.yml"
,
"r"
)
as
fin
:
loader
=
Loader
(
fin
)
# data = loader.get_data()
# tr.print_diff()
index
=
0
while
(
loader
.
check_data
()):
token
=
loader
.
get_token
()
index
+=
1
if
index
%
100
==
0
:
tr
.
print_diff
()
print
(
token
)
parser/parser-big-dft/bigdftparser/versions/bigdft18/mainparser.py
View file @
c45a92f9
...
...
@@ -17,6 +17,14 @@ class BigDFTMainParser(AbstractBaseParser):
"""
super
(
BigDFTMainParser
,
self
).
__init__
(
file_path
,
parser_context
)
# Map keys in the output to funtions that handle the values
self
.
key_to_funct_map
=
{
"Version Number"
:
lambda
x
:
self
.
backend
.
addValue
(
"program_version"
,
x
),
"Atomic structure"
:
self
.
atomic_structure
,
"Sizes of the simulation domain"
:
self
.
simulation_domain
,
# "Atomic Forces (Ha/Bohr)": self.atomic_structure
}
def
parse
(
self
):
"""The output file of a BigDFT run is a YAML document. Here we directly
parse this document with an existing YAML library, and push its
...
...
@@ -32,6 +40,7 @@ class BigDFTMainParser(AbstractBaseParser):
section_system_id
=
self
.
backend
.
openSection
(
"section_system"
)
section_method_id
=
self
.
backend
.
openSection
(
"section_method"
)
self
.
backend
.
addValue
(
"program_name"
,
"BigDFT"
)
self
.
backend
.
addValue
(
"electronic_structure_method"
,
"DFT"
)
loader
=
Loader
(
fin
)
generator
=
self
.
generate_root_nodes
(
loader
)
...
...
@@ -40,8 +49,9 @@ class BigDFTMainParser(AbstractBaseParser):
# function on the value.
for
key
,
value
in
generator
:
if
key
==
"Version Number"
:
self
.
backend
.
addValue
(
"program_version"
,
value
)
function
=
self
.
key_to_funct_map
.
get
(
key
)
if
function
is
not
None
:
function
(
value
)
# Close default sections
self
.
backend
.
closeSection
(
"section_method"
,
section_method_id
)
...
...
@@ -64,9 +74,9 @@ class BigDFTMainParser(AbstractBaseParser):
key
=
loader
.
construct_scalar
(
loader
.
compose_node
(
node
,
None
))
value
=
loader
.
compose_node
(
node
,
key
)
if
isinstance
(
value
,
MappingNode
):
value
=
loader
.
construct_mapping
(
value
)
value
=
loader
.
construct_mapping
(
value
,
deep
=
True
)
elif
isinstance
(
value
,
SequenceNode
):
value
=
loader
.
construct_sequence
(
value
)
value
=
loader
.
construct_sequence
(
value
,
deep
=
True
)
elif
isinstance
(
value
,
ScalarNode
):
value
=
loader
.
construct_scalar
(
value
)
yield
(
key
,
value
)
...
...
@@ -76,3 +86,20 @@ class BigDFTMainParser(AbstractBaseParser):
"""
print
(
"Moi"
)
return
def
atomic_structure
(
self
,
structure
):
np_positions
=
[]
np_labels
=
[]
positions
=
structure
[
"Positions"
]
for
position
in
positions
:
np_positions
.
append
(
*
position
.
values
())
np_labels
.
append
(
*
position
.
keys
())
np_positions
=
np
.
array
(
np_positions
)
np_labels
=
np
.
array
(
np_labels
)
self
.
backend
.
addArrayValues
(
"atom_positions"
,
np_positions
,
unit
=
"angstrom"
)
self
.
backend
.
addArrayValues
(
"atom_labels"
,
np_labels
)
self
.
backend
.
addValue
(
"number_of_atoms"
,
np_labels
.
size
)
def
simulation_domain
(
self
,
value
):
simulation_cell
=
np
.
diag
(
value
[
"Angstroem"
])
self
.
backend
.
addArrayValues
(
"simulation_cell"
,
simulation_cell
,
unit
=
"angstrom"
)
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