File: test_phasediagram.py

package info (click to toggle)
python-ase 3.22.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 14,344 kB
  • sloc: python: 126,379; xml: 946; makefile: 111; javascript: 47
file content (17 lines) | stat: -rw-r--r-- 479 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
"""Test phasediagram code."""
import pytest
from ase.phasediagram import PhaseDiagram


def test_phasediagram():
    """Test example from docs."""
    refs = [('Cu', 0.0),
            ('Au', 0.0),
            ('CuAu2', -0.2),
            ('CuAu', -0.5),
            ('Cu2Au', -0.7)]
    pd = PhaseDiagram(refs)
    energy, indices, coefs = pd.decompose('Cu3Au')
    assert energy == pytest.approx(-0.7)
    assert (indices == [4, 0]).all()
    assert coefs == pytest.approx(1.0)