Skip to content

Commit

Permalink
standardized normalization function syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
jrudz committed Jun 28, 2024
1 parent b02888e commit 8081ef8
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 21 deletions.
8 changes: 4 additions & 4 deletions src/nomad_simulations/schema_packages/properties/energies.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class EnergyContribution(BaseEnergy, PropertyContribution):
from some method.
"""

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


Expand Down Expand Up @@ -105,7 +105,7 @@ def __init__(
super().__init__(m_def, m_context, **kwargs)
self.name = self.m_def.name

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


Expand All @@ -115,7 +115,7 @@ class KineticEnergy(BaseEnergy):
Physical property section describing the kinetic energy of a (sub)system.
"""

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


Expand All @@ -124,7 +124,7 @@ class PotentialEnergy(BaseEnergy):
Physical property section describing the potential energy of a (sub)system.
"""

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


Expand Down
13 changes: 10 additions & 3 deletions src/nomad_simulations/schema_packages/properties/forces.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,20 @@
# limitations under the License.
#

from typing import TYPE_CHECKING

import numpy as np

from nomad.metainfo import Quantity, Section, Context, SubSection

if TYPE_CHECKING:
from nomad.metainfo import Section, Context
from nomad.datamodel.datamodel import EntryArchive
from structlog.stdlib import BoundLogger

from nomad_simulations.schema_packages.physical_property import (
PhysicalProperty,
PropertyContribution,
)

####################################################
# Abstract force classes
Expand Down Expand Up @@ -74,7 +81,7 @@ class ForceContribution(BaseForce, PropertyContribution):
from some method.
"""

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


Expand All @@ -96,7 +103,7 @@ def __init__(
super().__init__(m_def, m_context, **kwargs)
self.name = self.m_def.name

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


Expand Down
40 changes: 26 additions & 14 deletions src/nomad_simulations/schema_packages/properties/thermodynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,17 @@
# limitations under the License.
#

from typing import TYPE_CHECKING

import numpy as np

from nomad.metainfo import Quantity

if TYPE_CHECKING:
from nomad.metainfo import Section, Context
from nomad.datamodel.datamodel import EntryArchive
from structlog.stdlib import BoundLogger

from nomad_simulations.schema_packages.physical_property import PhysicalProperty
from nomad_simulations.schema_packages.properties import BaseEnergy

Expand All @@ -57,7 +66,7 @@ class Pressure(PhysicalProperty):
""",
)

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


Expand All @@ -74,7 +83,7 @@ class Volume(PhysicalProperty):
""",
)

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


Expand All @@ -91,7 +100,7 @@ class Temperature(PhysicalProperty):
""",
)

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


Expand All @@ -100,7 +109,7 @@ class HeatAdded(BaseEnergy):
Physical property section describing the heat added to a (sub)system.
"""

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


Expand All @@ -109,7 +118,7 @@ class WorkDone(BaseEnergy):
Physical property section describing the internal energy (i.e., heat added - work) for a (sub)system.
"""

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


Expand All @@ -118,7 +127,7 @@ class InternalEnergy(BaseEnergy):
Physical property section describing the internal energy (i.e., heat added - work) for a (sub)system.
"""

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


Expand All @@ -127,7 +136,7 @@ class Enthalpy(BaseEnergy):
Physical property section describing the enthalpy (i.e. internal_energy + pressure * volume.) of a (sub)system.
"""

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


Expand All @@ -144,7 +153,7 @@ class Entropy(PhysicalProperty):
""",
)

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


Expand All @@ -153,7 +162,7 @@ class GibbsFreeEnergy(BaseEnergy):
Physical property section describing the Gibbs free energy (i.e., enthalpy - temperature * entropy) of a (sub)system.
"""

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


Expand All @@ -162,7 +171,7 @@ class HelmholtzFreeEnergy(BaseEnergy):
Physical property section describing the Gibbs free energy (i.e., internal_energy - temperature * entropy) of a (sub)system.
"""

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


Expand Down Expand Up @@ -199,6 +208,9 @@ class HeatCapacityCV(PhysicalProperty):
""",
)

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


class HeatCapacityCP(PhysicalProperty):
"""
Expand All @@ -213,7 +225,7 @@ class HeatCapacityCP(PhysicalProperty):
""",
)

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


Expand All @@ -227,7 +239,7 @@ class Virial(BaseEnergy):
Physical property section describing the virial of a (sub)system.
"""

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


Expand All @@ -244,7 +256,7 @@ class Density(PhysicalProperty):
""",
)

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


Expand All @@ -263,7 +275,7 @@ class Hessian(PhysicalProperty):
""",
)

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

# ? Is this ever used?
Expand Down

0 comments on commit 8081ef8

Please sign in to comment.