From 840f15cfeaccf24b16e17d0992e5621050831167 Mon Sep 17 00:00:00 2001 From: JosePizarro3 Date: Tue, 27 Feb 2024 11:04:39 +0100 Subject: [PATCH] Added test_normalize for HubbardInteractions --- tests/test_atoms_state.py | 23 ++++++++++++++++++++++- tests/test_model_system.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 tests/test_model_system.py diff --git a/tests/test_atoms_state.py b/tests/test_atoms_state.py index f251542a..8d20b5b4 100644 --- a/tests/test_atoms_state.py +++ b/tests/test_atoms_state.py @@ -116,6 +116,14 @@ def test_degeneracy( resolved_degeneracy = orbital_state.resolve_degeneracy() assert resolved_degeneracy == degeneracy + def test_normalize(self, orbital_state): + """ + Test the normalization of the `OrbitalsState`. Inputs are defined as the quantities of the `OrbitalsState` section. + """ + orbital_state.normalize(None, self.logger) + # assert orbital_state.degeneracy == 6 + # assert orbital_state.occupation == 0.0 + class TestCoreHole: """ @@ -173,7 +181,7 @@ def test_normalize( self, core_hole, orbital_ref, n_excited_electrons, dscf_state, results ): """ - Test the normalization of the `CoreHole` state. Inputs are defined as the quantities of the `CoreHole` section. + Test the normalization of the `CoreHole`. Inputs are defined as the quantities of the `CoreHole` section. """ core_hole.orbital_ref = orbital_ref core_hole.n_excited_electrons = n_excited_electrons @@ -261,3 +269,16 @@ def test_u_effective( assert np.isclose(resolved_u_effective.to("eV").magnitude, u_effective) else: assert resolved_u_effective == u_effective + + def test_normalize(self, hubbard_interactions): + """ + Test the normalization of the `HubbardInteractions`. Inputs are defined as the quantities of the `HubbardInteractions` section. + """ + hubbard_interactions.u_interaction = 3.0 * ureg("eV") + hubbard_interactions.u_interorbital_interaction = 1.0 * ureg("eV") + hubbard_interactions.j_hunds_coupling = 3.0 * ureg("eV") + + hubbard_interactions.normalize(None, self.logger) + assert hubbard_interactions.u_effective == 2.0 * ureg("eV") + assert hubbard_interactions.u_interaction == 3.0 * ureg("eV") + assert hubbard_interactions.j_local_exchange_interaction == 1.0 * ureg("eV") diff --git a/tests/test_model_system.py b/tests/test_model_system.py new file mode 100644 index 00000000..01698458 --- /dev/null +++ b/tests/test_model_system.py @@ -0,0 +1,31 @@ +# +# Copyright The NOMAD Authors. +# +# This file is part of NOMAD. See https://nomad-lab.eu for further info. +# +# 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. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import pytest + +from simulationdataschema.model_system import AtomicCell + + +class TestAtomicCell: + @pytest.fixture(autouse=True) + def atomic_cell(self): + return AtomicCell( + lattice_vectors=[[1, 0, 0], [0, 1, 0], [0, 0, 1]], + positions=[[0, 0, 0], [0.5, 0.5, 0.5]], + species=["H", "O"], + )