Skip to content

Commit

Permalink
Add ElectronicDOS and XASSpectra properties (#54)
Browse files Browse the repository at this point in the history
* Added .pyenv to .gitignore

* Change inheritance of OrbitalsState and AtomsState to Entity

* Added FermiLevel, ChemicalPotential, ElectronicDensityOfStates, XASSpectra to outputs list

Deleted custom_physical_property from Outputs

* Added todos in PhysicalProperty

Added note to change iri and rank to m_def definitions

* Added properties/spectral_profile.py and properties/energies.py modules

Added SpectralProfile, DOSProfile, ElectronicDensityOfStates, XASSpectra in the spectral_profile.py module

* Added conftest generate_simulation, generate_model_system, generate_simulation_electronic_dos fixtures

Testing default iri, name, rank

Fix test_outputs property

 Added testing for spectral_profile classes and methods

* Improved functionalities with @ndaelman-hu comments.
  • Loading branch information
JosePizarro3 authored Apr 29, 2024
1 parent d9542f8 commit b159b0c
Show file tree
Hide file tree
Showing 12 changed files with 1,204 additions and 39 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ celerybeat.pid
# Environments
.env
.venv
.pyenv
env/
venv/
ENV/
Expand Down
5 changes: 3 additions & 2 deletions src/nomad_simulations/atoms_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@

from nomad.metainfo import Quantity, SubSection, MEnum, Section, Context
from nomad.datamodel.data import ArchiveSection
from nomad.datamodel.metainfo.basesections import Entity
from nomad.datamodel.metainfo.annotations import ELNAnnotation

from .utils import RussellSaundersState


class OrbitalsState(ArchiveSection):
class OrbitalsState(Entity):
"""
A base section used to define the orbital state of an atom.
"""
Expand Down Expand Up @@ -537,7 +538,7 @@ def normalize(self, archive, logger) -> None:
)


class AtomsState(ArchiveSection):
class AtomsState(Entity):
"""
A base section to define each atom state information.
"""
Expand Down
22 changes: 14 additions & 8 deletions src/nomad_simulations/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
from .numerical_settings import SelfConsistency
from .properties import (
ElectronicBandGap,
FermiLevel,
ChemicalPotential,
ElectronicDensityOfStates,
XASSpectra,
)


Expand All @@ -53,20 +57,22 @@ class Outputs(ArchiveSection):
a_eln=ELNAnnotation(component='ReferenceEditQuantity'),
)

custom_physical_property = SubSection(
sub_section=PhysicalProperty.m_def,
repeats=True,
description="""
A custom physical property used to store properties not yet covered by the NOMAD schema.
""",
)

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# List of properties
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

fermi_level = SubSection(sub_section=FermiLevel.m_def, repeats=True)

chemical_potential = SubSection(sub_section=ChemicalPotential.m_def, repeats=True)

electronic_band_gap = SubSection(sub_section=ElectronicBandGap.m_def, repeats=True)

electronic_dos = SubSection(
sub_section=ElectronicDensityOfStates.m_def, repeats=True
)

xas_spectra = SubSection(sub_section=XASSpectra.m_def, repeats=True)

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

Expand Down
3 changes: 3 additions & 0 deletions src/nomad_simulations/physical_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class PhysicalProperty(ArchiveSection):
string identifiers and quantities for referencing and establishing the character of a physical property.
"""

# TODO add `errors`
# TODO add `smearing`

name = Quantity(
type=str,
description="""
Expand Down
7 changes: 7 additions & 0 deletions src/nomad_simulations/properties/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .energies import FermiLevel, ChemicalPotential
from .band_gap import ElectronicBandGap
from .spectral_profile import (
SpectralProfile,
DOSProfile,
ElectronicDensityOfStates,
XASSpectra,
)
2 changes: 2 additions & 0 deletions src/nomad_simulations/properties/band_gap.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class ElectronicBandGap(PhysicalProperty):
Energy difference between the highest occupied electronic state and the lowest unoccupied electronic state.
"""

# ! implement `iri` and `rank` as part of `m_def = Section()`

iri = 'http://fairmat-nfdi.eu/taxonomy/ElectronicBandGap'

type = Quantity(
Expand Down
79 changes: 79 additions & 0 deletions src/nomad_simulations/properties/energies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#
# Copyright The NOMAD Authors.
#
# This file is part of NOMAD. See https://nomad-lab.eu for further info.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import numpy as np

from nomad.metainfo import Quantity, Section, Context

from ..physical_property import PhysicalProperty


class FermiLevel(PhysicalProperty):
"""
Energy required to add or extract a charge from a material at zero temperature. It can be also defined as the chemical potential at zero temperature.
"""

# ! implement `iri` and `rank` as part of `m_def = Section()`

iri = 'http://fairmat-nfdi.eu/taxonomy/FermiLevel'

value = Quantity(
type=np.float64,
unit='joule',
description="""
The value of the Fermi level.
""",
)

def __init__(
self, m_def: Section = None, m_context: Context = None, **kwargs
) -> None:
super().__init__(m_def, m_context, **kwargs)
self.rank = []
self.name = self.m_def.name

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


class ChemicalPotential(PhysicalProperty):
"""
Free energy cost of adding or extracting a particle from a thermodynamic system.
"""

# ! implement `iri` and `rank` as part of `m_def = Section()`

iri = 'http://fairmat-nfdi.eu/taxonomy/ChemicalPotential'

value = Quantity(
type=np.float64,
unit='joule',
description="""
The value of the chemical potential.
""",
)

def __init__(
self, m_def: Section = None, m_context: Context = None, **kwargs
) -> None:
super().__init__(m_def, m_context, **kwargs)
self.rank = []
self.name = self.m_def.name

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

0 comments on commit b159b0c

Please sign in to comment.