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_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, 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!"
def test_q_11():
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(11, averaged=True)
q = sys.get_qvals(11, averaged=True)
assert np.round(np.mean(np.array(q)), decimals=2) == 0.00
def test_q_10():
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(10, averaged=True)
q = sys.get_qvals(10, averaged=True)
assert np.round(np.mean(np.array(q)), decimals=2) == 0.41
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_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')
atoms = sys.atoms
vols = []
avgvols = []
for atom in atoms:
vols.append(atom.volume)
avgvols.append(atom.avg_volume)
assert np.mean(np.array(vols)) == 0.5
assert np.mean(np.array(avgvols)) == 0.5
def test_q_8():
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(8, averaged=True)
q = sys.get_qvals(8, averaged=True)
assert np.round(np.mean(np.array(q)), decimals=2) == 0.33
def test_customvals_dump():
"""
Test writing customvals
"""
atoms, boxdims = pcs.make_crystal('bcc', repetitions=[1,1,1])
sys = pc.System()
sys.atoms = atoms
sys.box = boxdims
#test for multiple customvals
customks = 'one'
customvs = [1,1]
ptp.write_structure(sys, "tests/bcc4.dump", customkey=customks, customvals=customvs)
#now read this file
lines = []
for line in open("tests/bcc4.dump", 'r'):
lines.append(line)
#now check the atoms
def test_q_9():
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(9, averaged=True)
q = sys.get_qvals(9, averaged=True)
assert np.round(np.mean(np.array(q)), decimals=2) == 0.00