From 8e80cf427e77a6bf5e2e7c1025ffabe9635573b5 Mon Sep 17 00:00:00 2001 From: ndaelman Date: Tue, 12 Nov 2024 12:47:58 +0100 Subject: [PATCH] Remove remaining ranks --- .../schema_packages/properties/band_gap.py | 1 - .../properties/greens_function.py | 45 +++++++++---------- 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/src/nomad_simulations/schema_packages/properties/band_gap.py b/src/nomad_simulations/schema_packages/properties/band_gap.py index 05c1ba57..7348f599 100644 --- a/src/nomad_simulations/schema_packages/properties/band_gap.py +++ b/src/nomad_simulations/schema_packages/properties/band_gap.py @@ -67,7 +67,6 @@ def __init__( ) -> None: super().__init__(m_def, m_context, **kwargs) self.name = self.m_def.name - self.rank = [] def validate_values(self, logger: 'BoundLogger') -> Optional[pint.Quantity]: """ diff --git a/src/nomad_simulations/schema_packages/properties/greens_function.py b/src/nomad_simulations/schema_packages/properties/greens_function.py index 3da09e53..d5355919 100644 --- a/src/nomad_simulations/schema_packages/properties/greens_function.py +++ b/src/nomad_simulations/schema_packages/properties/greens_function.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, Optional import numpy as np from nomad.metainfo import MEnum, Quantity @@ -129,16 +129,6 @@ class BaseGreensFunction(PhysicalProperty): """, ) - def __init__( - self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs - ) -> None: - super().__init__(m_def, m_context, **kwargs) - # ! n_orbitals need to be set up during initialization of the class - self.rank = [ - int(kwargs.get('n_atoms')), - int(kwargs.get('n_correlated_orbitals')), - ] - def resolve_space_id(self) -> str: """ Resolves the `space_id` based on the stored `variables` in the class. @@ -196,9 +186,10 @@ class ElectronicGreensFunction(BaseGreensFunction): iri = 'http://fairmat-nfdi.eu/taxonomy/ElectronicGreensFunction' - value = Quantity( + _base_value = Quantity( type=np.complex128, unit='1/joule', + shape=['n_atoms', 'n_correlated_orbitals'], description=""" Value of the electronic Green's function matrix. """, @@ -221,9 +212,10 @@ class ElectronicSelfEnergy(BaseGreensFunction): iri = 'http://fairmat-nfdi.eu/taxonomy/ElectronicSelfEnergy' - value = Quantity( + _base_value = Quantity( type=np.complex128, unit='joule', + shape=['n_atoms', 'n_correlated_orbitals'], description=""" Value of the electronic self-energy matrix. """, @@ -246,9 +238,10 @@ class HybridizationFunction(BaseGreensFunction): iri = 'http://fairmat-nfdi.eu/taxonomy/HybridizationFunction' - value = Quantity( + _base_value = Quantity( type=np.complex128, unit='joule', + shape=['n_atoms', 'n_correlated_orbitals'], description=""" Value of the electronic hybridization function. """, @@ -336,8 +329,9 @@ class QuasiparticleWeight(PhysicalProperty): """, ) - value = Quantity( + _base_value = Quantity( type=np.float64, + shape=['n_atoms', 'n_correlated_orbitals'], description=""" Value of the quasiparticle weight matrices. """, @@ -347,11 +341,6 @@ def __init__( self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs ) -> None: super().__init__(m_def, m_context, **kwargs) - # ! n_orbitals need to be set up during initialization of the class - self.rank = [ - int(kwargs.get('n_atoms')), - int(kwargs.get('n_correlated_orbitals')), - ] self.name = self.m_def.name def is_valid_quasiparticle_weight(self) -> bool: @@ -362,18 +351,23 @@ def is_valid_quasiparticle_weight(self) -> bool: Returns: (bool): True if the quasiparticle weight is valid, False otherwise. """ - if (self.value < 0.0).any() or (self.value > 1.0).any(): + if self.value is None: + return False + elif (self.value < 0.0).any() or (self.value > 1.0).any(): return False - return True + else: + return True - def resolve_system_correlation_strengths(self) -> str: + def resolve_system_correlation_strengths(self) -> Optional[str]: """ Resolves the `system_correlation_strengths` of the quasiparticle weight based on the stored `value` values. Returns: str: The resolved `system_correlation_strengths` of the quasiparticle weight. """ - if np.all(self.value > 0.7): + if self.value is None: + return None + elif np.all(self.value > 0.7): return 'non-correlated metal' elif np.all((self.value < 0.4) & (self.value > 0)): return 'strongly-correlated metal' @@ -381,7 +375,8 @@ def resolve_system_correlation_strengths(self) -> str: return 'OSMI' elif np.all(self.value < 1e-2): return 'Mott insulator' - return None + else: + return None def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None: super().normalize(archive, logger)