Ejemplo n.º 1
0
def test_primitive():
  """ Tests whether primitivization works. """
  from numpy import abs, dot
  from numpy.linalg import inv
  from pylada.crystal.cppwrappers import supercell, Structure, are_periodic_images as api, \
                                       primitive, is_primitive
  from pylada.math import is_integer

  lattice = Structure( 0.0, 0.5, 0.5,
                       0.5, 0.0, 0.5,
                       0.5, 0.5, 0.0, scale=2.0, m=True ) \
                     .add_atom(0, 0, 0, "As")           \
                     .add_atom(0.25, 0.25, 0.25, ['In', 'Ga'], m = True)
  assert is_primitive(lattice)
  for cell in itercells(10): 
    structure = supercell(lattice, dot(lattice.cell, cell))
    assert not is_primitive(structure)
    structure = primitive(structure, 1e-8)
    assert is_primitive(structure)
    assert abs(structure.volume - lattice.volume) < 1e-8
    assert len(structure) == len(lattice)
    assert is_integer(dot(structure.cell, inv(lattice.cell)))
    assert is_integer(dot(lattice.cell, inv(structure.cell)))
    invcell = inv(lattice.cell)
    for atom in structure:
      assert api(lattice[atom.site].pos, atom.pos, invcell) and \
             atom.type == lattice[atom.site].type and \
             getattr(lattice[atom.site], 'm', False) == getattr(atom, 'm', False) and \
             (getattr(atom, 'm', False) or atom.site == 0)
Ejemplo n.º 2
0
def test_primitive():
    """ Tests whether primitivization works. """
    from numpy import abs, dot
    from numpy.linalg import inv
    from pylada.crystal.cppwrappers import supercell, Structure, are_periodic_images as api, primitive, is_primitive
    from pylada.math import is_integer

    lattice = (
        Structure(0.0, 0.5, 0.5, 0.5, 0.0, 0.5, 0.5, 0.5, 0.0, scale=2.0, m=True)
        .add_atom(0, 0, 0, "As")
        .add_atom(0.25, 0.25, 0.25, ["In", "Ga"], m=True)
    )
    assert is_primitive(lattice)
    for cell in itercells(10):
        structure = supercell(lattice, dot(lattice.cell, cell))
        assert not is_primitive(structure)
Ejemplo n.º 3
0
def test_primitive():
  """ Tests whether primitivization works. """
  from numpy import abs, dot
  from numpy.linalg import inv
  from pylada.crystal.cppwrappers import supercell, Structure, are_periodic_images as api, \
                                       primitive, is_primitive
  from pylada.math import is_integer

  lattice = Structure( 0.0, 0.5, 0.5,
                       0.5, 0.0, 0.5,
                       0.5, 0.5, 0.0, scale=2.0, m=True ) \
                     .add_atom(0, 0, 0, "As")           \
                     .add_atom(0.25, 0.25, 0.25, ['In', 'Ga'], m = True)
  assert is_primitive(lattice)
  for cell in itercells(10): 
    structure = supercell(lattice, dot(lattice.cell, cell))
    assert not is_primitive(structure)