From 8d1bf0152a809e67760920ff61da9d09520327db Mon Sep 17 00:00:00 2001 From: Nathan Daelman Date: Mon, 18 Nov 2024 00:19:01 +0100 Subject: [PATCH] Move out `SpinChannel` and `MometumTransfer` to `variables.py` --- .../schema_packages/properties/band_gap.py | 29 ++----------------- .../schema_packages/variables.py | 26 ++++++++++++++++- tests/properties/test_band_gap.py | 5 ++-- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/nomad_simulations/schema_packages/properties/band_gap.py b/src/nomad_simulations/schema_packages/properties/band_gap.py index 297effa6..20ccb7a0 100644 --- a/src/nomad_simulations/schema_packages/properties/band_gap.py +++ b/src/nomad_simulations/schema_packages/properties/band_gap.py @@ -1,40 +1,17 @@ -from typing import TYPE_CHECKING, Optional +from typing import TYPE_CHECKING import numpy as np -import pint from nomad.units import ureg from nomad.metainfo import MEnum, Quantity -from nomad.metainfo.dataset import MDataset, Dataset -from nomad.datamodel import EntryArchive +from nomad.metainfo.dataset import MDataset from nomad.datamodel.metainfo.physical_properties import PhysicalProperty +from ..variables import SpinChannel, MomentumTransfer if TYPE_CHECKING: from nomad.datamodel.datamodel import EntryArchive from structlog.stdlib import BoundLogger -class SpinChannel(MDataset): - m_def = Dataset( - type=MEnum('up', 'down', 'all'), # ? alpha, beta - ) - - -class MomentumTransfer(MDataset): - m_def = Dataset( - type=np.float64, - shape=[2, 3], - unit='1/meter', - description=""" - The change in momentum for any (quasi-)particle, e.g. electron, hole, - traversing the band gap. - - For example, the momentum transfer in bulk Si happens - between the Γ and X points in the Brillouin zone; thus: - `momentum_transfer = [[0, 0, 0], [0.5, 0.5, 0]]`. - """, - ) - - class ElectronicBandGap(MDataset): # ? add optical band gap m_def = PhysicalProperty( type=np.float64, diff --git a/src/nomad_simulations/schema_packages/variables.py b/src/nomad_simulations/schema_packages/variables.py index 34e3c8c4..25487f4b 100644 --- a/src/nomad_simulations/schema_packages/variables.py +++ b/src/nomad_simulations/schema_packages/variables.py @@ -2,7 +2,9 @@ import numpy as np from nomad.datamodel.data import ArchiveSection -from nomad.metainfo import Quantity +from nomad.metainfo import MEnum, Quantity +from nomad.metainfo.dataset import MDataset, Dataset +from nomad.datamodel.metainfo.physical_properties import PhysicalProperty if TYPE_CHECKING: from nomad.datamodel.datamodel import EntryArchive @@ -17,6 +19,28 @@ ) +class SpinChannel(MDataset): + m_def = Dataset( + type=MEnum('up', 'down', 'all'), # ? alpha, beta + ) + + +class MomentumTransfer(MDataset): + m_def = Dataset( + type=np.float64, + shape=[2, 3], + unit='1/meter', + description=""" + The change in momentum for any (quasi-)particle, e.g. electron, hole, + traversing the band gap. + + For example, the momentum transfer in bulk Si happens + between the Γ and X points in the Brillouin zone; thus: + `momentum_transfer = [[0, 0, 0], [0.5, 0.5, 0]]`. + """, + ) + + class Variables(ArchiveSection): """ Variables over which the physical property varies, and they are defined as grid points, i.e., discretized diff --git a/tests/properties/test_band_gap.py b/tests/properties/test_band_gap.py index 3b4234e7..64c33c2c 100644 --- a/tests/properties/test_band_gap.py +++ b/tests/properties/test_band_gap.py @@ -5,12 +5,11 @@ from nomad.datamodel import EntryArchive from nomad.units import ureg -from nomad_simulations.schema_packages.properties.band_gap import ( - ElectronicBandGap, +from nomad_simulations.schema_packages.variables import ( SpinChannel, MomentumTransfer, ) -# from nomad_simulations.schema_packages.variables import Temperature +from nomad_simulations.schema_packages.properties import ElectronicBandGap from . import logger