core.components.calculate.recipes.energy#
Copyright (c) Meta Platforms, Inc. and affiliates.
This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree.
Original source: janosh/matbench-discovery
MIT License
Copyright (c) 2022 Janosh Riebesell
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
The software is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.
Functions#
|
Calculate energy per atom relative to reference states (e.g., for formation or |
Module Contents#
- core.components.calculate.recipes.energy.calc_energy_from_e_refs(struct_or_entry: pymatgen.util.typing.EntryLike | pymatgen.core.Structure | pymatgen.core.Composition | str, ref_energies: dict[str, float], total_energy: float | None = None) float #
Calculate energy per atom relative to reference states (e.g., for formation or cohesive energy calculations).
- Parameters:
struct_or_entry (EntryLike | Structure | Composition | str) –
Either: - A pymatgen Entry (PDEntry, ComputedEntry, etc.) or entry dict containing
’energy’ and ‘composition’ keys
A Structure or Composition object or formula string (must also provide total_energy)
ref_energies (dict[str, float]) – Dictionary of reference energies per atom. For formation energy: elemental reference energies (e.g. mp_elemental_ref_energies). For cohesive energy: isolated atom reference energies
total_energy (float | None) – Total energy of the structure/composition. Required if struct_or_entry is not an Entry or entry dict. Ignored otherwise.
- Returns:
Energy per atom relative to references (e.g., formation or cohesive energy) in the same units as input energies.
- Return type:
float
- Raises:
TypeError – If input types are invalid
ValueError – If missing reference energies for some elements