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 76166fb commit 8399aa9
Showing 3 changed files with 144 additions and 112 deletions.
60 changes: 20 additions & 40 deletions src/nomad_simulations/outputs.py
Original file line number Diff line number Diff line change
@@ -23,13 +23,16 @@
from nomad.datamodel.data import ArchiveSection
from nomad.datamodel.metainfo.annotations import ELNAnnotation
from nomad.metainfo import Quantity, SubSection, SectionProxy, Reference
# ? are we planning to enforce a dependency on simulationworkflowschema?
from nomad.dependencies.simulationworkflowschema import SimulationWorkflow, MolecularDynamics

from .atoms_state import AtomsState, OrbitalsState
from .model_system import ModelSystem
from .numerical_settings import SelfConsistency
from .property import 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.
@@ -161,59 +164,36 @@ class SCFOutputs(Outputs):
def normalize(self, archive, logger) -> None:
super().normalize(archive, logger)

# Set if the output property `is_converged` or not.
self.is_scf_converged = self.check_is_scf_converged(
self.is_scf_converged, logger
)

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
@@ -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


@@ -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
@@ -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.
"""
@@ -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(
@@ -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(
@@ -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(
@@ -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=[],
@@ -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):
"""
@@ -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),
Loading

0 comments on commit 8399aa9

Please sign in to comment.