File: test_wien2k.py

package info (click to toggle)
phonopy 2.47.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 29,380 kB
  • sloc: python: 43,690; xml: 12,080; ansic: 3,227; cpp: 525; sh: 213; makefile: 20
file content (24 lines) | stat: -rw-r--r-- 813 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""Tests for wien2k interface."""

import os

import numpy as np

from phonopy.interface.phonopy_yaml import read_cell_yaml
from phonopy.interface.wien2k import parse_wien2k_struct

data_dir = os.path.dirname(os.path.abspath(__file__))


def test_parse_wien2k_struct():
    """Test structure parsing."""
    filename_BaGa2 = os.path.join(data_dir, "BaGa2.struct")
    cell, _, _, _ = parse_wien2k_struct(filename_BaGa2)
    filename = os.path.join(data_dir, "BaGa2-wien2k.yaml")
    cell_ref = read_cell_yaml(filename)
    assert (np.abs(cell.cell - cell_ref.cell) < 1e-5).all()
    diff_pos = cell.scaled_positions - cell_ref.scaled_positions
    diff_pos -= np.rint(diff_pos)
    assert (np.abs(diff_pos) < 1e-5).all()
    for s, s_r in zip(cell.symbols, cell_ref.symbols, strict=True):
        assert s == s_r