From 0f4b8a5df44d21f444af6f236edd4f434a08d2e5 Mon Sep 17 00:00:00 2001 From: JosePizarro3 Date: Tue, 14 May 2024 10:07:17 +0200 Subject: [PATCH] Defined ElectronicEigenvalues.value_contributions Defined KLineSegment(Variables) --- .../properties/band_structure.py | 31 +++++++- src/nomad_simulations/variables.py | 70 ++++++++++++++++--- 2 files changed, 89 insertions(+), 12 deletions(-) diff --git a/src/nomad_simulations/properties/band_structure.py b/src/nomad_simulations/properties/band_structure.py index 1f269ec5..8e8531b6 100644 --- a/src/nomad_simulations/properties/band_structure.py +++ b/src/nomad_simulations/properties/band_structure.py @@ -21,7 +21,7 @@ from typing import Optional, Tuple import pint -from nomad.metainfo import Quantity, Section, Context +from nomad.metainfo import Quantity, Section, Context, SubSection from nomad_simulations.physical_property import PhysicalProperty from nomad_simulations.properties import ElectronicBandGap @@ -118,6 +118,20 @@ class ElectronicEigenvalues(BaseElectronicEigenvalues): """, ) + value_contributions = SubSection( + sub_section=BaseElectronicEigenvalues.m_def, + repeats=True, + description=""" + Contributions to the electronic eigenvalues. Example, in the case of a DFT+GW calculation, the GW eigenvalues + are stored under `value`, and each contribution is identified by `label`: + - `'KS'`: Kohn-Sham contribution. This is also stored in the DFT entry under `ElectronicEigenvalues.value`. + - `'KSxc'`: Diagonal matrix elements of the expectation value of the Kohn-Sahm exchange-correlation potential. + - `'SigX'`: Diagonal matrix elements of the exchange self-energy. This is also stored in the GW entry under `ElectronicSelfEnergy.value`. + - `'SigC'`: Diagonal matrix elements of the correlation self-energy. This is also stored in the GW entry under `ElectronicSelfEnergy.value`. + - `'Zk'`: Quasiparticle renormalization factors contribution. This is also stored in the GW entry under `QuasiparticleWeights.value`. + """, + ) + def __init__( self, m_def: Section = None, m_context: Context = None, **kwargs ) -> None: @@ -312,6 +326,19 @@ def normalize(self, archive, logger) -> None: self.m_parent.fermi_surface.append(fermi_surface) +class BandSegments(ElectronicEigenvalues): + """ """ + + def __init__( + self, m_def: Section = None, m_context: Context = None, **kwargs + ) -> None: + super().__init__(m_def, m_context, **kwargs) + self.name = self.m_def.name + + def normalize(self, archive, logger) -> None: + super().normalize(archive, logger) + + class ElectronicBandStructure(ElectronicEigenvalues): """ Accessible energies by the charges (electrons and holes) in the reciprocal space. @@ -319,6 +346,8 @@ class ElectronicBandStructure(ElectronicEigenvalues): iri = 'http://fairmat-nfdi.eu/taxonomy/ElectronicBandStructure' + band_segment = SubSection(type=BandSegments.m_def, repeats=True) + def __init__( self, m_def: Section = None, m_context: Context = None, **kwargs ) -> None: diff --git a/src/nomad_simulations/variables.py b/src/nomad_simulations/variables.py index 0dd93ba2..bf7600b1 100644 --- a/src/nomad_simulations/variables.py +++ b/src/nomad_simulations/variables.py @@ -21,9 +21,9 @@ from structlog.stdlib import BoundLogger from nomad.datamodel.data import ArchiveSection -from nomad.metainfo import Quantity, Section, Context +from nomad.metainfo import Quantity, Section, Context, SubSection -from nomad_simulations.numerical_settings import KMesh +from nomad_simulations.numerical_settings import KMesh, LinePathSegment class Variables(ArchiveSection): @@ -163,10 +163,11 @@ class KMesh(Variables): other k-space properties. The `grid_points` are obtained from a refernece to the `NumericalSettings` section, `KMesh(NumericalSettings)`. """ - numerical_settings_ref = Quantity( + kmesh_settings_ref = Quantity( type=KMesh, description=""" - Reference to the `KMesh(NumericalSettings)` section to extract `grid_points`. + Reference to the `KMesh(NumericalSettings)` section in the `ModelMethod` section. This reference is useful + to extract `grid_points` and, then, obtain the shape of `value` of the `PhysicalProperty`. """, ) @@ -186,7 +187,7 @@ def __init__( def extract_grid_points(self, logger: BoundLogger) -> Optional[list]: """ - Extract the `grid_points` list from the `numerical_settings_ref` pointing to the `KMesh` section. + Extract the `grid_points` list from the `kmesh_settings_ref` pointing to the `KMesh` section. Args: logger (BoundLogger): The logger to log messages. @@ -194,16 +195,63 @@ def extract_grid_points(self, logger: BoundLogger) -> Optional[list]: Returns: (Optional[list]): The `grid_points` list. """ - if self.numerical_settings_ref is not None: - if self.numerical_settings_ref.points is not None: - return self.numerical_settings_ref.points - points, _ = self.numerical_settings_ref.resolve_points_and_offset(logger) + if self.kmesh_settings_ref is not None: + if self.kmesh_settings_ref.points is not None: + return self.kmesh_settings_ref.points + points, _ = self.kmesh_settings_ref.resolve_points_and_offset(logger) return points - logger.error('`numerical_settings_ref` is not defined.') + logger.error('`kmesh_settings_ref` is not defined.') return None def normalize(self, archive, logger) -> None: - # Extracting `grid_points` from the `numerical_settings_ref` BEFORE doing `super().normalize()` + # Extracting `grid_points` from the `kmesh_settings_ref` BEFORE doing `super().normalize()` + self.grid_points = self.extract_grid_points(logger) + + super().normalize(archive, logger) + + +class KLineSegment(Variables): + """ """ + + line_path_segment_ref = Quantity( + type=LinePathSegment, + description=""" + Reference to the `LinePathSegment(NumericalSettings)` section in the `ModelMethod` section. This reference is useful + to extract `grid_points` and, then, obtain the shape of `value` of the `PhysicalProperty`. + """, + ) + + grid_points = Quantity( + type=np.float64, + shape=['n_grid_points', 'dimensionality'], + description=""" + Points along the line path segment in which the physical property is calculated. These are 3D arrays stored in fractional coordinates. + """, + ) + + def __init__( + self, m_def: Section = None, m_context: Context = None, **kwargs + ) -> None: + super().__init__(m_def, m_context, **kwargs) + self.name = self.m_def.name + + def extract_grid_points(self, logger: BoundLogger) -> Optional[list]: + """ + Extract the `grid_points` list from the `line_path_segment_ref` pointing to the `LinePathSegment` section. + + Args: + logger (BoundLogger): The logger to log messages. + + Returns: + (Optional[list]): The `grid_points` list. + """ + if self.line_path_segment_ref is not None: + return self.line_path_segment_ref.points + logger.error('`line_path_segment_ref` is not defined.') + return None + + def normalize(self, archive, logger) -> None: + # Extracting `grid_points` from the `line_path_segment_ref` BEFORE doing `super().normalize()` self.grid_points = self.extract_grid_points(logger) super().normalize(archive, logger)