-
Notifications
You must be signed in to change notification settings - Fork 16
/
test_adaptive.py
49 lines (39 loc) · 1.34 KB
/
test_adaptive.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import pytest
import os,sys,inspect
import numpy as np
import pyscal.core as pc
import pyscal.crystal_structures as pcs
def test_neighbors_sann():
#create some atoms
atoms, boxdims = pcs.make_crystal('bcc', repetitions = [6, 6, 6])
sys = pc.System()
sys.atoms = atoms
sys.box = boxdims
#then lets find neighbors
#SANN algo test
sys.find_neighbors(method = 'cutoff', cutoff='sann')
#any atom should have 8 neighbors
atoms = sys.atoms
assert atoms[0].coordination == 14
sys.find_neighbors(method = 'cutoff', cutoff='sann', threshold=1)
#any atom should have 8 neighbors
atoms = sys.atoms
assert atoms[0].coordination == 14
sys.calculate_q(8, averaged=True)
q = sys.get_qvals(8, averaged=True)
assert np.round(np.mean(np.array(q)), decimals=2) == 0.45
sys.calculate_q(7, averaged=True)
q = sys.get_qvals(7, averaged=True)
assert np.round(np.mean(np.array(q)), decimals=2) == 0.05
def test_neighbors_adaptive():
#create some atoms
atoms, boxdims = pcs.make_crystal('bcc', repetitions = [6, 6, 6])
sys = pc.System()
sys.atoms = atoms
sys.box = boxdims
#then lets find neighbors
#SANN algo test
sys.find_neighbors(method = 'cutoff', cutoff='adaptive')
#any atom should have 8 neighbors
atoms = sys.atoms
assert atoms[0].coordination == 14