Skip to content

Commit

Permalink
Fix testing and schema to be QuantityReference
Browse files Browse the repository at this point in the history
  • Loading branch information
JosePizarro3 committed May 29, 2024
1 parent 57b7178 commit 17350bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/nomad_simulations/properties/band_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def resolve_reciprocal_cell(self) -> Optional[pint.Quantity]:
break
if k_space is None:
return None
return k_space.reciprocal_lattice_vectors
return k_space

def normalize(self, archive, logger) -> None:
super().normalize(archive, logger)
Expand All @@ -341,13 +341,13 @@ def normalize(self, archive, logger) -> None:
# `ElectronicBandGap` extraction
band_gap = self.extract_band_gap(logger)
if band_gap is not None:
self.m_parent.electronic_band_gap.append(band_gap)
self.m_parent.electronic_band_gaps.append(band_gap)

# TODO uncomment once `FermiSurface` property is implemented
# `FermiSurface` extraction
# fermi_surface = self.extract_fermi_surface(logger)
# if fermi_surface is not None:
# self.m_parent.fermi_surface.append(fermi_surface)
# self.m_parent.fermi_surfaces.append(fermi_surface)

# Resolve `reciprocal_cell` from the `KSpace` numerical settings section
self.reciprocal_cell = self.resolve_reciprocal_cell()
Expand Down
9 changes: 7 additions & 2 deletions tests/test_band_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import numpy as np
from typing import Optional, Tuple, Union, List

from nomad.datamodel import EntryArchive

from nomad_simulations.model_method import ModelMethod
from nomad_simulations.numerical_settings import KSpace, BasisSet
from nomad_simulations.outputs import Outputs
Expand Down Expand Up @@ -416,15 +418,18 @@ def test_resolve_reciprocal_cell(
result: Optional[List[List[float]]],
):
"""
Test the `resolve_reciprocal_cell` method.
Test the `resolve_reciprocal_cell` method. This is done via the `normalize` function because `reciprocal_cell` is a
`QuantityReference`, hence we need to assign it.
"""
simulation = generate_simulation(outputs=Outputs())
if numerical_settings is not None:
model_method = ModelMethod(numerical_settings=[numerical_settings])
simulation.model_method.append(model_method)
electronic_eigenvalues = generate_electronic_eigenvalues()
simulation.outputs[-1].electronic_eigenvalues.append(electronic_eigenvalues)
reciprocal_cell = electronic_eigenvalues.resolve_reciprocal_cell()
electronic_eigenvalues.normalize(EntryArchive(), logger)
reciprocal_cell = electronic_eigenvalues.reciprocal_cell
# reciprocal_cell = electronic_eigenvalues.resolve_reciprocal_cell()
if reciprocal_cell is not None:
assert np.allclose(reciprocal_cell.magnitude, result)
else:
Expand Down

0 comments on commit 17350bc

Please sign in to comment.