Coverage for ase/calculators/idealgas.py: 90.00%
10 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-11-27 15:21 +0000
« prev ^ index » next coverage.py v7.16.2, created at 2026-11-27 15:21 +0000
1"""Ideal gas calculator - the potential energy is always zero."""
3import numpy as np
5from ase.calculators.calculator import Calculator, all_changes
8class IdealGas(Calculator):
9 """The ideal gas: non-interacting atoms.
11 The ideal gas is atoms that do not interact. The potential is thus
12 always zero, and so are forces and stresses (apart from the dynamic
13 part of the stress, which is handled by the atoms themselves).
15 This calculator is probably only useful for testing purposes.
16 """
18 implemented_properties = [
19 'energy',
20 'energies',
21 'forces',
22 'stress',
23 'stresses',
24 ]
26 def calculate(
27 self, atoms=None, properties=None, system_changes=all_changes
28 ):
29 """'Calculate' the zero energies and their derivatives."""
30 if properties is None:
31 properties = []
32 super().calculate(atoms, properties, system_changes)
33 n = len(self.atoms)
34 self.results = {
35 'energy': 0.0,
36 'energies': np.zeros(n),
37 'forces': np.zeros((n, 3)),
38 'stress': np.zeros(6),
39 'stresses': np.zeros((n, 6)),
40 }