def test_neighbors(): atom = pc.Atom(pos=[0, 0, 0], id=1) atom.neighbors = [1, 2] assert atom.neighbors == [1, 2] assert atom.coordination == 2 atom.neighbor_weights = [0.6, 0.4] assert atom.neighbor_weights == [0.6, 0.4]
def _get_steinhardt_parameter(cell, positions, cutoff=3.50, n_clusters=2, q=[4, 6]): sys = pc.System() prism = UnfoldingPrism(cell, digits=15) xhi, yhi, zhi, xy, xz, yz = prism.get_lammps_prism_str() coords = [prism.pos_to_lammps(position) for position in positions] sys.box = [[0.0, float(xhi)], [0.0, float(yhi)], [0.0, float(zhi)]] sys.atoms = [pc.Atom(pos=p, id=i) for i, p in enumerate(coords)] sys.find_neighbors(method='cutoff', cutoff=cutoff) sys.calculate_q(q, averaged=True) sysq = sys.get_qvals(q, averaged=True) cl = cluster.KMeans(n_clusters=n_clusters) ind = cl.fit(list(zip(*sysq))).labels_ == 0 return sysq, ind
def test_set_solid(): atom = pc.Atom(pos=[0, 0, 0], id=1, type=1) atom.solid = 1 assert atom.solid == 1 with pytest.raises(ValueError): atom.solid = 2
def test_set_type(): atom = pc.Atom(pos=[0, 0, 0], id=1, type=1) assert atom.type == 1 atom.type = 2 assert atom.type == 2
def test_set_x(): atom = pc.Atom(pos=[0, 0, 0], id=1) newx = [0, 0, 2] atom.pos = newx assert atom.pos == newx
def test_get_x(): atom = pc.Atom(pos=[0, 0, 0], id=1) assert atom.pos == [0, 0, 0] atom.id = 5 assert atom.id == 5
def test_set_solid(): atom = pc.Atom(pos=[0, 0, 0], id=1, type=1) atom.solid = 1 assert atom.solid == 1