-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest_Read_reference_output.py
More file actions
executable file
·91 lines (62 loc) · 2.3 KB
/
Test_Read_reference_output.py
File metadata and controls
executable file
·91 lines (62 loc) · 2.3 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 9 13:09:00 2022
@author: simula
"""
import numpy as np
import Read_reference_output as rr
def test_find_tags_positions():
"""
Test the success of the method to get indeces of the relevant tags:
'kt_gf', 'upper[GPa]', 'lower[GPa]'
Returns
-------
None.
"""
sample_list = ['kt_gf = 300', 'irrelevant', 'upper[GPa]', 'lower[GPa]']
line_num = rr.find_tags_positions(sample_list)
assert line_num[0] == 0
assert line_num[1] == 2
assert line_num[2] == 3
###############################################################################
def test_get_qm_atoms():
"""
Test the success of the method to extract qm atomic labels and qm atomic
coordinates as list of strings from a slice of the block_list.
Returns
-------
None.
"""
sample_list = ['H 1 1 1', 'C 1 3 4', 'abcd']
qm_lbl, qm_pos = rr.get_qm_atoms(sample_list)
assert qm_lbl == ['H', 'C']
assert qm_pos == [['1', '1', '1'], ['1', '3', '4']]
###############################################################################
def test_get_gf_atoms():
"""
Test the success of the method to extract gf atomic coordinates as list of
strings and get the total number of gf atoms.
Returns
-------
None.
"""
sample_list = ['1 1 1', '1 3 4', 'abcd']
num, gf_pos = rr.get_gf_atoms(sample_list)
assert num == len(gf_pos)
assert num == 2
assert gf_pos == [['1','1','1'],['1','3','4']]
###############################################################################
def test_sort_atoms():
"""
Test the success of the method to sort atoms along the z direction starting
from their list of strings and returning the sorted indeces and the index
corresponding to the maximum z separation between the atoms.
Returns
-------
None.
"""
list2sort = [['1','2','4'], ['0','1','1'], ['3','2','-5']]
idx_z_sort, up_slab_index = rr.sort_atoms(list2sort)
assert (idx_z_sort == np.array([2, 1, 0], dtype=int)).all
assert up_slab_index == 1
###############################################################################