I would like to print out the off diagonal components of the full stress tensor in ASE. The goal is then to calculate the Green Kubo viscosity. One should use the ensemble average of the off diagonal stress tensor.

Q1: Should I use the cell stress or the per-atom stress?

I am trying different calculators (GPAW, EMT and XTB) but none is able to print atoms.get_stresses(). They all give me this result: stresses property not implemented.

Q2: Is there a way to print out the full stress tensor in ASE?

Q3: Is there a table that lists which calculators can output it?

Please find an example with water in PBC below.

Thank you

from ase import Atoms
import ase.build

from ase.calculators.emt import EMT
calculator = EMT()

from xtb.ase.calculator import XTB
calculator = XTB(method="GFN0-xTB")

from gpaw import GPAW, PW
calculator = GPAW(xc='PBE', mode=PW(300), txt='h2o.txt')

atoms = ase.build.molecule('H2O')
cell_size = 2.8
atoms.set_cell([cell_size, cell_size, cell_size])
atoms.set_pbc([True, True, True])

# Apply the calculator

Atoms(symbols='OH2', pbc=True, cell=[2.8, 2.8, 2.8], calculator=GPAW(...))
<gpaw.calculator.GPAW object at 0x7f72944f3d00>
[0.66560263 0.53795715 0.54856487 0.         0.         0.        ]
Traceback (most recent call last):
  File "/home/mdi0316/WORK_TME022/PGEL/forum_questions/print_stresses.py", line 68, in <module>
  File "/home/mdi0316/miniconda3/envs/pgel/lib/python3.10/site-packages/ase/atoms.py", line 865, in get_stresses
    stresses = self._calc.get_stresses(self)
  File "/home/mdi0316/miniconda3/envs/pgel/lib/python3.10/site-packages/ase/calculators/abc.py", line 32, in get_stresses
    return self.get_property('stresses', atoms)
  File "/home/mdi0316/miniconda3/envs/pgel/lib/python3.10/site-packages/ase/calculators/calculator.py", line 724, in get_property
    raise PropertyNotImplementedError('{} property not implemented'
ase.calculators.calculator.PropertyNotImplementedError: stresses property not implemented
  • 2
    $\begingroup$ You already answered your question in your question. You don't get stresses from those calculators simply because stresses property not implemented. If you want to get stresses, you can use e.g. a Vasp calculator which has stresses implemented. $\endgroup$
    – Shaun Han
    Commented Nov 16, 2023 at 10:24
  • 2
    $\begingroup$ I'm not 100% sure, but do you really need get_stresses()? This particular function gives per-atom stresses, which are usually only defined for classical potentials. The full stress tensor of the system (including off-diagonal elements) is returned by the get_stress() method, which is available for most calculators (ASE uses the Voigt convention, so 6 components are output). $\endgroup$ Commented Nov 18, 2023 at 9:20
  • 1
    $\begingroup$ @KristofBal is correct. Note that you can return a 3x3 matrix instead of the Voigt form by using atoms.get_stress(voigt=False). Kinetic contributions to stress can be included with include_ideal_gas=True. I would be very surprised if the viscosity coefficient would require atomic stresses. I had a look at AllenTildesley to confirm that this is indeed not the case. I would recommend to carefully check the theory. $\endgroup$
    – flokno
    Commented Nov 20, 2023 at 8:27
  • 2
    $\begingroup$ The quoted LAMMPS example uses pxy, pxz, pyz, which are the off-diagonal global stresses (not per-atom). For per-atom stresses, LAMMPS has the compute stress/atom command. $\endgroup$ Commented Nov 20, 2023 at 9:22
  • 1
    $\begingroup$ As discussed elsewhere: Ensemble average here means multiple replicas of the simulation cell, i.e., multiple simulations for statistically independent starting conditions. $\endgroup$
    – flokno
    Commented Nov 20, 2023 at 10:31

1 Answer 1


Thank to all the comments and parallel discussions, I realised that to calculate Green Kubo viscosity one has to use the stress tensor. From Allen Tildesley, p61:

These quantities [the stress tensor] are multiple particle properties, [...], and no statistical averaging is possible.

A1 Thus, I should effectively use the stress tensor from get_stress() and not get_stresses() as initially thought.

A2&3 ASE does not ensure that a given calculator implements and benchmarks high level properties. Thus one has to check time to time whether a calculator has a property implemented


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .