File: test_chgcar.py

package info (click to toggle)
python-ase 3.26.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,484 kB
  • sloc: python: 148,112; xml: 2,728; makefile: 110; javascript: 47
file content (17 lines) | stat: -rw-r--r-- 558 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# fmt: off
"""Tests for CHG/CHGCAR."""
import numpy as np
import pytest

from ase.build import bulk
from ase.calculators.calculator import compare_atoms
from ase.calculators.vasp import VaspChargeDensity


def test_chgcar(datadir):
    """Test if a CHG/CHGCAR file can be parsed correctly."""
    charge_density = VaspChargeDensity(datadir / 'vasp/Li/CHG')
    atoms = charge_density.atoms[0]
    chg = charge_density.chg[0]
    assert not compare_atoms(atoms, bulk('Li', a=3.49))
    assert np.mean(chg) * atoms.get_volume() == pytest.approx(1.0, rel=1e-3)