Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_q_12():
atoms, boxdims = pcs.make_crystal('bcc', repetitions = [4, 4, 4])
sys = pc.System()
sys.atoms = atoms
sys.box = boxdims
sys.find_neighbors(method = 'voronoi')
sys.calculate_q(12, averaged=True)
q = sys.get_qvals(12, averaged=True)
assert np.round(np.mean(np.array(q)), decimals=2) == 0.38
def test_system_nucsize_fraction():
#create some atoms
atoms, boxdims = pcs.make_crystal('bcc', repetitions = [2, 2, 2])
sys = pc.System()
sys.atoms = atoms
sys.box = boxdims
#test that atoms are set properly
assert len(sys.atoms) == 16
#now calculate nucsize
sys.find_neighbors(method='cutoff', cutoff=3.63)
assert 16 == sys.find_solids(bonds=0.8, threshold=0.5, avgthreshold=0.6, cluster=True)
def test_system_atom_access():
#create some atoms
atoms, boxdims = pcs.make_crystal('bcc')
sys = pc.System()
sys.box = boxdims
sys.atoms = atoms
#fetch an atom
xoxo = sys.get_atom(0)
assert xoxo.pos == [0, 0, 0]
#change pos pf ayom
xoxo.pos = [1.1, 2.1, 3.1]
sys.set_atom(xoxo)
atom = sys.get_atom(0)
assert atom.pos == [1.1, 2.1, 3.1]
#sys.atoms = atoms
def test_chiparamshcp():
atoms, box = pcs.make_crystal('hcp', repetitions=[3,3,3], lattice_constant=4)
sys = pc.System()
sys.atoms = atoms
sys.box = box
sys.find_neighbors(method='cutoff', cutoff=0)
sys.calculate_chiparams()
atoms = sys.atoms
chip = atoms[2].chiparams
assert chip == [3, 0, 6, 0, 21, 12, 0, 24, 0]
def test_pickle_system():
atoms, boxdims = pcs.make_crystal('bcc', repetitions = [1, 1, 1])
sys = pc.System()
sys.atoms = atoms
sys.box = boxdims
sys.find_neighbors(method = 'voronoi')
#test write and read system
sys.to_pickle('tests/sy.npy')
#now read the pickled system
psys = pc.System()
psys.from_pickle('tests/sy.npy')
#now get atoms and a random number of atom
satoms = sys.atoms
patoms = psys.atoms
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
def test_neighbors_system():
#create some atoms
atoms, boxdims = pcs.make_crystal('bcc', repetitions = [6, 6, 6])
sys = pc.System()
sys.atoms = atoms
sys.box = boxdims
#test that atoms are set properly
assert len(sys.atoms) == 432
#then lets find neighbors
#cutoff method - first shell only
sys.find_neighbors(method = 'cutoff', cutoff=0.867)
#any atom should have 8 neighbors
atoms = sys.atoms
assert atoms[0].coordination == 8
sys.reset_neighbors()
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
def test_q_6():
atoms, boxdims = pcs.make_crystal('bcc', repetitions = [4, 4, 4])
sys = pc.System()
sys.atoms = atoms
sys.box = boxdims
sys.find_neighbors(method = 'voronoi')
sys.calculate_q(6, averaged=True)
q = sys.get_qvals(6, averaged=True)
assert np.round(np.mean(np.array(q)), decimals=2) == 0.57
def test_voro_props():
atoms, boxdims = pcs.make_crystal('bcc', repetitions = [2, 2, 2])
sys = pc.System()
sys.atoms = atoms
sys.box = boxdims
sys.find_neighbors(method = 'voronoi')
sys.calculate_vorovector()
atoms = sys.atoms
atom = atoms[0]
v = atom.vorovector
assert v == [0,6,0,8]