Skip to content

Commit

Permalink
added some basic thermodynamics quantities
Browse files Browse the repository at this point in the history
  • Loading branch information
jrudz committed Jun 12, 2024
1 parent 0d1eabb commit 454312d
Showing 1 changed file with 238 additions and 0 deletions.
238 changes: 238 additions & 0 deletions src/nomad_simulations/thermodynamics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
#
# 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.
#
#
# 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, SubSection, MEnum
from .physical_property import PhysicalProperty

class Enthalpy(PhysicalProperty):
"""
Section containing the enthalpy (i.e. energy_total + pressure * volume.) of a (sub)system.
"""

value = Quantity(
type=np.float64,
unit='joule',
description="""
Value of the enthalpy.
""",
)

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

class Entropy(PhysicalProperty):
"""
Section containing the entropy of a (sub)system.
"""

value = Quantity(
type=np.float64,
unit='joule / kelvin',
description="""
Value of the entropy.
""",
)

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

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

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

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

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

value = Quantity(
type=np.float64,
unit='pascal',
description="""
Value of the pressure.
""",
)

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

class Virial(PhysicalProperty):
"""
Section containing the virial (cross product between positions and forces) of a (sub)system.
"""

value = Quantity(
type=np.float64,
unit='joule',
description="""
Value of the pressure.
""",
)

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

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

value = Quantity(
type=np.float64,
unit='kelvin',
description="""
Value of the pressure.
""",
)

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

class Volume(PhysicalProperty):
"""
Section containing the volume of a (sub)system.
"""

value = Quantity(
type=np.float64,
unit='m ** 3',
description="""
Value of the volume.
""",
)

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

class Density(PhysicalProperty):
"""
Section containing the density of a (sub)system.
"""

value = Quantity(
type=np.float64,
unit='kg / m ** 3',
description="""
Value of the density.
""",
)

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

# ? Does this go here or in energies?
# ? Naming specific to Potential Energy?
class Hessian(PhysicalProperty):
"""
Section containing the Hessian matrix, i.e., 2nd derivatives with respect to geometric (typically particle) displacements,
of the potential energy of a (sub)system.
"""

value = Quantity(
type=np.float64,
unit='joule / m ** 2',
description="""
Value of the Hessian.
""",
)

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


class HeatCapacityCV(PhysicalProperty):
"""
Section containing the heat capacity at constant volume for a (sub)system.
"""

value = Quantity(
type=np.float64,
unit='joule / kelvin',
description="""
Value of the heat capacity.
""",
)

class HeatCapacityCP(PhysicalProperty):
"""
Section containing the heat capacity at constant volume for a (sub)system.
"""

value = Quantity(
type=np.float64,
unit='joule / kelvin',
description="""
Value of the heat capacity.
""",
)

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


# ? Is this ever used?
# internal_energy = Quantity(
# type=np.dtype(np.float64),
# shape=[],
# 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.
# """,
# )


1 comment on commit 454312d

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/nomad_simulations
   atoms_state.py1871890%215–218, 242, 297–298, 366–367, 369, 551, 563–564, 625–629, 644–648, 655
   general.py68593%84, 148, 258–259, 269
   model_method.py2597471%161–164, 167–174, 265–266, 286, 307–326, 342–368, 371–388, 740, 751, 793–800, 846, 865, 945, 1004, 1079, 1191
   model_system.py2571993%507–510, 558–565, 739–740, 965–969, 975–976, 984–985, 990, 1013
   numerical_settings.py2606276%160, 230, 232–233, 236–239, 243–244, 251–254, 263–266, 270–273, 275–278, 283–286, 292–295, 466–493, 568, 603–606, 630, 633, 678, 680–683, 687, 691, 738, 742–763, 818–819, 886, 895–897, 900
   outputs.py89693%201–204, 244–247, 272, 274
   physical_property.py90199%216
   thermodynamics.py45450%37–216
   variables.py61887%110, 133, 153–154, 157, 179, 202, 222
src/nomad_simulations/properties
   band_gap.py48296%149–150
   band_structure.py1072081%235–267, 280, 287, 323–324, 327
   energies.py21290%51, 79
   fermi_surface.py12192%52
   hopping_matrix.py24292%69, 104
   permittivity.py45589%110–118
   spectral_profile.py25412352%67–70, 105–108, 209–314, 370–382, 407–410, 430, 435–438, 480–516, 540, 587–590, 606–607, 612–618
src/nomad_simulations/utils
   utils.py661183%75–84, 93–94, 99, 102
TOTAL190240479% 

Tests Skipped Failures Errors Time
299 0 💤 0 ❌ 0 🔥 2.299s ⏱️

Please sign in to comment.