Skip to content

Commit

Permalink
Outputs inherits PhysicalProperty
Browse files Browse the repository at this point in the history
  • Loading branch information
jrudz committed Apr 9, 2024
1 parent da69521 commit 595843c
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 106 deletions.
61 changes: 27 additions & 34 deletions src/nomad_simulations/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,16 @@
from nomad.datamodel.data import ArchiveSection
from nomad.metainfo import Quantity, SubSection, MEnum
from nomad.datamodel.metainfo.annotations import ELNAnnotation
<<<<<<< HEAD
=======
from nomad.metainfo import Quantity, SubSection, SectionProxy, Reference
# ? are we planning to enforce a dependency on simulationworkflowschema?
from nomad.dependencies.simulationworkflowschema import SimulationWorkflow, MolecularDynamics
>>>>>>> 8399aa9 (Outputs inherits PhysicalProperty)

from .model_system import ModelSystem
from .numerical_settings import SelfConsistency
<<<<<<< HEAD
from .physical_property import PhysicalProperty

from .variables import Variables, Temperatures # ? delete these imports
Expand Down Expand Up @@ -56,9 +63,12 @@ class ElectronicBandGap(PhysicalProperty):

def normalize(self, archive, logger) -> None:
super().normalize(archive, logger)
=======
from .property import PhysicalProperty
>>>>>>> 8399aa9 (Outputs inherits PhysicalProperty)


class Outputs(ArchiveSection):
class Outputs(PhysicalProperty):
"""
Output properties of a simulation. This base class can be used for inheritance in any of the output properties
defined in this schema.
Expand Down Expand Up @@ -156,53 +166,36 @@ def normalize(self, archive, logger) -> None:
)

class MDOutputs(Outputs):
class WorkflowOutputs(Outputs):
"""
This section contains the self-consistent (SCF) steps performed to converge an output property,
as well as the information if the output property `is_converged` or not, depending on the
settings in the `SelfConsistency` base class defined in `numerical_settings.py`.
For simplicity, we contain the SCF steps of a simulation as part of the minimal workflow defined in NOMAD,
the `SinglePoint`, i.e., we do not split each SCF step in its own entry. Thus, each `SinglePoint`
`Simulation` entry in NOMAD contains the final output properties and all the SCF steps.
This section contains output properties that depend on a single system, but were
calculated as part of a workflow. Examples include geometry optimization and molecular dynamics.
"""

step = Quantity(
type=np.int32,
description="""
Number of self-consistent steps to converge the output property. Note that the SCF steps belong to
the same minimal `Simulation` workflow entry which is known as `SinglePoint`.
The step number with respect to the workflow.
""",
)

time = Quantity(
type=np.int32,
description="""
Number of self-consistent steps to converge the output property. Note that the SCF steps belong to
the same minimal `Simulation` workflow entry which is known as `SinglePoint`.
""",
)

scf_step = SubSection(
sub_section=Outputs.m_def,
repeats=True,
description="""
Self-consistent (SCF) steps performed for converging a given output property. Note that the SCF steps belong to
the same minimal `Simulation` workflow entry which is known as `SinglePoint`.
""",
)

ff_ref = Quantity(
type=SelfConsistency,
workflow_ref = Quantity(
type=SimulationWorkflow,
description="""
Reference to the `SelfConsistency` section that defines the numerical settings to converge the
output property.
""",
)

md_ref = Quantity(
type=SelfConsistency,
class TrajectoryOutputs(WorkflowOutputs):
"""
This section contains output properties that depend on a single system, but were
calculated as part of a workflow. Examples include geometry optimization and molecular dynamics.
"""

time = Quantity(
type=np.float64,
description="""
Reference to the `SelfConsistency` section that defines the numerical settings to converge the
output property.
The elapsed simulated physical time since the start of the trajectory.
""",
)
)
168 changes: 105 additions & 63 deletions src/nomad_simulations/outputs_JFR_temp.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
from nomad.metainfo.metainfo import DirectQuantity, Dimension
from nomad.datamodel.metainfo.annotations import ELNAnnotation

from .outputs import MDOutputs
from .property import BaseProperty
from .outputs import Outputs, SCFOutputs, WorkflowOutputs, TrajectoryOutputs
from .atoms_state import AtomsState


Expand All @@ -69,16 +68,6 @@

from .model_system import ModelSystem

class ScalarProperty(BaseProperty):
"""
Generic section containing the values and information for any scalar property.
"""

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

# TODO check that all variable and bin quantities are None

class AtomicProperty(BaseProperty):
"""
Generic section containing the values and information reqarding an atomic quantity
Expand Down Expand Up @@ -1000,7 +989,7 @@ class MultipolesEntry(Atomic):
orbital_projected = SubSection(sub_section=MultipolesValues.m_def, repeats=True)


class Enthalpy(MDOutputs, ScalarProperty):
class Enthalpy(TrajectoryOutputs):
"""
Section containing the enthalpy (i.e. energy_total + pressure * volume.) of a (sub)system.
"""
Expand All @@ -1013,10 +1002,12 @@ class Enthalpy(MDOutputs, ScalarProperty):
def normalize(self, archive, logger) -> None:
super().normalize(archive, logger)
self.value_unit = 'joule'
self.name = 'enthalpy'
self.is_scalar = True

class Entropy(ScalarProperty):
class Entropy(TrajectoryOutputs):
"""
Section containing the entropy of a (sub)system.
Section containing the (scalar) entropy of a (sub)system.
"""

value = Quantity(
Expand All @@ -1027,10 +1018,12 @@ class Entropy(ScalarProperty):
def normalize(self, archive, logger) -> None:
super().normalize(archive, logger)
self.value_unit = 'joule / kelvin'
self.name = 'entropy'
self.is_scalar = True

class ChemicalPotential(ScalarProperty):
class ChemicalPotential(TrajectoryOutputs):
"""
Section containing the chemical potential of a (sub)system.
Section containing the (scalar) chemical potential of a (sub)system.
"""

value = Quantity(
Expand All @@ -1041,10 +1034,11 @@ class ChemicalPotential(ScalarProperty):
def normalize(self, archive, logger) -> None:
super().normalize(archive, logger)
self.value_unit = 'joule'

class KineticEnergy(ScalarProperty):
self.name = 'chemical_potential'
self.is_scalar = True
class KineticEnergy(TrajectoryOutputs):
"""
Section containing the kinetic energy of a (sub)system.
Section containing the (scalar) kinetic energy of a (sub)system.
"""

value = Quantity(
Expand All @@ -1055,52 +1049,94 @@ class KineticEnergy(ScalarProperty):
def normalize(self, archive, logger) -> None:
super().normalize(archive, logger)
self.value_unit = 'joule'
self.name = 'kinetic_energy'
self.is_scalar = True

potential_energy = Quantity(
type=np.dtype(np.float64),
shape=[],
unit='joule',
description="""
Value of the potential energy.
""",
)
class PotentialEnergy(TrajectoryOutputs):
"""
Section containing the (scalar) potential energy of a (sub)system.
"""

internal_energy = Quantity(
type=np.dtype(np.float64),
shape=[],
value = Quantity(
type=np.float64,
unit='joule',
description="""
Value of the internal energy.
""",
)

vibrational_free_energy_at_constant_volume = Quantity(
type=np.dtype(np.float64),
shape=[],
unit='joule',
description="""
Value of the vibrational free energy per cell unit at constant volume.
""",
def normalize(self, archive, logger) -> None:
super().normalize(archive, logger)
self.value_unit = 'joule'
self.name = 'potential_energy'
self.is_scalar = True

class Pressure(TrajectoryOutputs):
"""
Section containing the (scalar) pressure of a (sub)system.
"""

value = Quantity(
type=np.float64,
unit='pascal',
)

pressure = Quantity(
def normalize(self, archive, logger) -> None:
super().normalize(archive, logger)
self.value_unit = 'pascal'
self.name = 'pressure'
self.is_scalar = True

class PressureTensor(TrajectoryOutputs):
"""
Section containing the pressure in terms of the x, y, z components of the (sub)system simulation cell.
Typically calculated as the difference between the kinetic energy and the virial.
"""

value = Quantity(
type=np.dtype(np.float64),
shape=[],
shape=[3, 3],
unit='pascal',
description="""
Value of the pressure of the system.
""",
)

temperature = Quantity(
def normalize(self, archive, logger) -> None:
super().normalize(archive, logger)
self.value_unit = 'pascal'
self.name = 'pressure_tensor'
self.variables = [['xx', 'xy', 'xz'], ['yx', 'yy', 'yz'], ['zx', 'zy', 'zz']]

class VirialTensor(TrajectoryOutputs):
"""
Section containing the virial in terms of the x, y, z components of the (sub)system simulation cell.
Typically calculated as the cross product between positions and forces.
"""

value = Quantity(
type=np.dtype(np.float64),
shape=[],
shape=[3, 3],
unit='joule',
)

def normalize(self, archive, logger) -> None:
super().normalize(archive, logger)
self.value_unit = 'joule'
self.name = 'virial_tensor'
self.variables = [['xx', 'xy', 'xz'], ['yx', 'yy', 'yz'], ['zx', 'zy', 'zz']]

class Temperature(TrajectoryOutputs):
"""
Section containing the (scalar) temperature of a (sub)system.
"""

value = Quantity(
type=np.float64,
unit='kelvin',
description="""
Value of the temperature of the system at which the properties are calculated.
""",
)

def normalize(self, archive, logger) -> None:
super().normalize(archive, logger)
self.value_unit = 'kelvin'
self.name = 'temperature'
self.is_scalar = True


volume = Quantity(
type=np.dtype(np.float64),
shape=[],
Expand Down Expand Up @@ -1128,14 +1164,28 @@ def normalize(self, archive, logger) -> None:
""",
)

time_step = Quantity(
type=int,

internal_energy = Quantity(
type=np.dtype(np.float64),
shape=[],
unit='joule',
description="""
The number of time steps with respect to the start of the calculation.
Value of the internal energy.
""",
)

vibrational_free_energy_at_constant_volume = Quantity(
type=np.dtype(np.float64),
shape=[],
unit='joule',
description="""
Value of the vibrational free energy per cell unit at constant volume.
""",
)





class RadiusOfGyrationValues(AtomicGroupValues):
"""
Expand Down Expand Up @@ -1377,15 +1427,7 @@ class BaseCalculation(ArchiveSection):
""",
)

virial_tensor = Quantity(
type=np.dtype(np.float64),
shape=[3, 3],
unit='joule',
description="""
Value of the virial in terms of the x, y, z components of the simulation cell.
Typically calculated as the cross product between positions and forces.
""",
)


enthalpy = Quantity(
type=np.dtype(np.float64),
Expand Down
Loading

0 comments on commit 595843c

Please sign in to comment.