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_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_create_multislice_dump():
"""
Create a multitest dump file and test it
"""
atoms, boxdims = pcs.make_crystal('bcc', repetitions=[6,6,6])
sys = pc.System()
sys.atoms = atoms
sys.box = boxdims
ptp.write_structure(sys, "tests/bcc1.dump")
atoms2, boxdims2 = pcs.make_crystal('bcc', repetitions=[6,6,6])
#modify the coordinates of one atom
x = atoms2[0].pos
x[0] += 0.01
atoms2[0].pos = x
assert len(atoms2) == 432
#write it out
sys2 = pc.System()
sys2.atoms = atoms2
sys2.box = boxdims2
def test_q_2():
#this might take a while, it will find all qs
atoms, boxdims = pcs.make_crystal('bcc', repetitions = [6, 6, 6])
sys = pc.System()
sys.atoms = atoms
sys.box = boxdims
#sys.read_inputfile("tests/bcc.dat")
sys.find_neighbors(method = 'voronoi')
#sys.get_neighbors(method = 'cutoff', cutoff=0.9)
sys.calculate_q(2)
q = sys.get_qvals(2)
assert np.round(np.mean(np.array(q)), decimals=2) == 0.00
def test_chiparamsbcc():
atoms, box = pcs.make_crystal('bcc', 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, 0, 0, 36, 12, 0, 36, 0]
def test_file_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')
sys.to_file('tests/tjkf.dat')
#now try to read in the file
sys2 = pc.System()
sys2.read_inputfile('tests/tjkf.dat')
assert len(sys2.atoms) == 2
#now add some custom values
atoms[0].custom = {"velocity":12}
atoms[1].custom = {"velocity":24}
#now try to read in the file
def test_chiparamsdia():
atoms, box = pcs.make_crystal('diamond', 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 == [0, 0, 0, 0, 6, 0, 0, 0, 0]
def test_system_nucsize():
#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=6, threshold=0.5, avgthreshold=0.6, cluster=True)
#check the atom cluster props
#assert np.round(sys.get_connection(atoms[0], atoms[1]), decimals=2) == 1.00
#nothing to assert - just check if it works
sys.calculate_frenkelnumbers()
sys.find_clusters()
def test_basic_system():
#basic system tests
sys = pc.System()
#sys.set_box([[0,1],[0,1],[0,1]])
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)
def test_q_4_size():
atoms, boxdims = pcs.make_crystal('bcc', repetitions = [5, 5, 6])
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, averaged=True)
q = sys.get_qvals(4, averaged=True)
assert np.round(np.mean(np.array(q)), decimals=2) == 0.51 , "Calculated q4 value is wrong!"