Skip to content

Commit

Permalink
Added energies_origin
Browse files Browse the repository at this point in the history
  • Loading branch information
JosePizarro3 committed Apr 4, 2024
1 parent b25a1e8 commit 54dd980
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/nomad_simulations/spectral_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import numpy as np
from structlog.stdlib import BoundLogger
from typing import Optional
import pint

from nomad.units import ureg
from nomad.datamodel.data import ArchiveSection
Expand Down Expand Up @@ -197,6 +198,26 @@ def check_spin_polarized(self) -> bool:
return True
return False

def resolve_energies_origin(self) -> Optional[pint.Quantity]:
"""
Resolve the origin of reference for the energies from the `Eigenvalues` output property, or if this does not exist,
from the `FermiLevel` output property.
Returns:
(Optional[pint.Quantity]): The resolved origin of reference for the energies.
"""
energies_origin = self.energies_origin
# ! We need schema for `Eigenvalues` to store `highest_occupied` and `lowest_occupied` to use in `ElectronicBandGap` and `ElectronicDOS`
# if energies_origin is None:
# fermi_level = self.resolve_fermi_level()
# if fermi_level is not None:
# energies_origin = fermi_level
# else:
# eigenvalues = resolve_output_value(self, Eigenvalues)
# if eigenvalues is not None:
# energies_origin = eigenvalues.highest_occupied
return energies_origin

def normalize(self, archive, logger) -> None:
super().normalize(archive, logger)

Expand All @@ -209,6 +230,9 @@ def normalize(self, archive, logger) -> None:
'Spin-polarized calculation detected but the `spin_channel` is not set.'
)

# Resolve `energies_origin`
self.energies_origin = self.resolve_energies_origin()


class XASSpectra(ElectronicSpectralProfile):
"""
Expand Down

0 comments on commit 54dd980

Please sign in to comment.