Skip to content

Commit

Permalink
Defined ElectronicEigenvalues.value_contributions
Browse files Browse the repository at this point in the history
Defined KLineSegment(Variables)
  • Loading branch information
JosePizarro3 committed May 14, 2024
1 parent 4478f47 commit 0f4b8a5
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 12 deletions.
31 changes: 30 additions & 1 deletion src/nomad_simulations/properties/band_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -312,13 +326,28 @@ 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.
"""

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:
Expand Down
70 changes: 59 additions & 11 deletions src/nomad_simulations/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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`.
""",
)

Expand All @@ -186,24 +187,71 @@ 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.
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)

0 comments on commit 0f4b8a5

Please sign in to comment.