Coverage for /builds/ase/ase/ase/calculators/idealgas.py: 100.00%

8 statements  

« prev     ^ index     » next       coverage.py v7.5.3, created at 2025-08-02 00:12 +0000

1# fmt: off 

2 

3"""Ideal gas calculator - the potential energy is always zero.""" 

4 

5import numpy as np 

6 

7from ase.calculators.calculator import Calculator, all_changes 

8 

9 

10class IdealGas(Calculator): 

11 """The ideal gas: non-interacting atoms. 

12 

13 The ideal gas is atoms that do not interact. The potential is thus 

14 always zero, and so are forces and stresses (apart from the dynamic 

15 part of the stress, which is handled by the atoms themselves). 

16 

17 This calculator is probably only useful for testing purposes. 

18 """ 

19 

20 implemented_properties = ['energy', 'energies', 'forces', 

21 'stress', 'stresses'] 

22 

23 def calculate(self, atoms=None, properties=[], 

24 system_changes=all_changes): 

25 """'Calculate' the zero energies and their derivatives.""" 

26 super().calculate(atoms, properties, system_changes) 

27 n = len(self.atoms) 

28 self.results = { 

29 'energy': 0.0, 

30 'energies': np.zeros(n), 

31 'forces': np.zeros((n, 3)), 

32 'stress': np.zeros(6), 

33 'stresses': np.zeros((n, 6)), 

34 }