Commit 5742af28 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Added metainfo python code.

parent b87cd29b
import sys
from nomad.metainfo import Environment
from nomad.metainfo.legacy import LegacyMetainfoEnvironment
import cp2kparser.metainfo.cp2k
import cp2kparser.metainfo.cp2k_general
import nomad.datamodel.metainfo.common
import nomad.datamodel.metainfo.public
import nomad.datamodel.metainfo.general
m_env = LegacyMetainfoEnvironment()
m_env.m_add_sub_section(Environment.packages, sys.modules['cp2kparser.metainfo.cp2k'].m_package) # type: ignore
m_env.m_add_sub_section(Environment.packages, sys.modules['cp2kparser.metainfo.cp2k_general'].m_package) # type: ignore
m_env.m_add_sub_section(Environment.packages, sys.modules['nomad.datamodel.metainfo.common'].m_package) # type: ignore
m_env.m_add_sub_section(Environment.packages, sys.modules['nomad.datamodel.metainfo.public'].m_package) # type: ignore
m_env.m_add_sub_section(Environment.packages, sys.modules['nomad.datamodel.metainfo.general'].m_package) # type: ignore
This diff is collapsed.
This diff is collapsed.
# Copyright 2015-2018 Lauri Himanen, Fawzi Mohamed, Ankit Kariryaa
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
......@@ -637,7 +637,7 @@ class CP2KCommonParser(CommonParser):
# If anything found, push the results to the correct section
if len(force_array) != 0:
# self.cache_service["atom_forces"] = force_array
self.backend.addArrayValues("x_cp2k_atom_forces", force_array, unit="forceAu")
self.backend.addArrayValues("x_cp2k_atom_forces", force_array, unit="hartree / bohr")
def adHoc_stress_tensor(self, parser):
"""Used to extract the stress tensor printed at the end of a
......
# Copyright 2015-2018 Lauri Himanen, Fawzi Mohamed, Ankit Kariryaa
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
......@@ -36,7 +36,7 @@ class CP2KSinglePointForceParser(AbstractBaseParser):
continue
elif line.startswith(" SUM"):
forces = np.array(forces)
self.backend.addArrayValues("atom_forces", forces, unit="forceAu")
self.backend.addArrayValues("atom_forces", forces, unit="hartree / bohr")
break
elif start:
components = [float(comp) for comp in line.split()[-3:]]
......
......@@ -160,7 +160,7 @@ class TestForceFiles(unittest.TestCase):
[-0.00000001, -0.00000001, -0.00000001],
[-0.00000001, -0.00000001, -0.00000001],
]),
"forceAu"
"hartree / bohr"
)
self.assertTrue(np.array_equal(result, expected_result))
......@@ -519,7 +519,7 @@ class TestEnergyForce(unittest.TestCase):
[-0.00000001, -0.00000001, -0.00000001],
[-0.00000001, -0.00000001, -0.00000001],
]),
"forceAu"
"hartree / bohr"
)
self.assertTrue(np.array_equal(result, expected_result))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment