-
Notifications
You must be signed in to change notification settings - Fork 16
/
test_q_atom.py
35 lines (31 loc) · 1.42 KB
/
test_q_atom.py
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
import pytest
import os,sys,inspect
import numpy as np
import pyscal.core as pc
import pyscal.crystal_structures as pcs
def test_q_4():
atoms, boxdims = pcs.make_crystal('bcc', repetitions = [4, 4, 4])
sys = pc.System()
sys.atoms = atoms
sys.box = boxdims
#sys.get_neighbors(method = 'voronoi')
sys.find_neighbors(method = 'cutoff', cutoff=0.9)
sys.calculate_q([4, 6], averaged=True)
atoms = sys.atoms
#assert np.round(atoms[0].q[2], decimals=2) == 0.51
assert np.round(atoms[0].get_q(4, averaged=True), decimals=2) == 0.51
assert np.round(atoms[0].get_q([4, 6])[0], decimals=2) == 0.51
assert np.round(atoms[0].get_q([4, 6], averaged=True)[1], decimals=2) == 0.63
assert np.round(atoms[0].get_q([4, 6]), decimals=2)[0] == 0.51
assert np.round(atoms[0].get_q([4, 6], averaged=True)[1], decimals=2) == 0.63
#now change the q4 values
atoms[0].set_q(4, .23)
atoms[0].set_q(4, .23, averaged=True)
assert np.round(atoms[0].get_q(4), decimals=2) == 0.23
assert np.round(atoms[0].get_q(4, averaged=True), decimals=2) == 0.23
atoms[0].set_q([4, 6], [.23, .46])
atoms[0].set_q([4, 6], [.23, .46], averaged=True)
assert np.round(atoms[0].get_q(4), decimals=2) == 0.23
assert np.round(atoms[0].get_q(4, averaged=True), decimals=2) == 0.23
assert np.round(atoms[0].get_q(6), decimals=2) == 0.46
assert np.round(atoms[0].get_q(6, averaged=True), decimals=2) == 0.46