File: idealgas.py

package info (click to toggle)
python-ase 3.24.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 15,448 kB
  • sloc: python: 144,945; xml: 2,728; makefile: 113; javascript: 47
file content (32 lines) | stat: -rw-r--r-- 1,098 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""Ideal gas calculator - the potential energy is always zero."""

import numpy as np

from ase.calculators.calculator import Calculator, all_changes


class IdealGas(Calculator):
    """The ideal gas: non-interacting atoms.

    The ideal gas is atoms that do not interact.  The potential is thus
    always zero, and so are forces and stresses (apart from the dynamic
    part of the stress, which is handled by the atoms themselves).

    This calculator is probably only useful for testing purposes.
    """

    implemented_properties = ['energy', 'energies', 'forces',
                              'stress', 'stresses']

    def calculate(self, atoms=None, properties=[],
                  system_changes=all_changes):
        """'Calculate' the zero energies and their derivatives."""
        super().calculate(atoms, properties, system_changes)
        n = len(self.atoms)
        self.results = {
            'energy': 0.0,
            'energies': np.zeros(n),
            'forces': np.zeros((n, 3)),
            'stress': np.zeros(6),
            'stresses': np.zeros((n, 6)),
        }