예제 #1
0
def test(cell, numops):
    """ Test structure initialization. """
    from numpy import all, abs, dot, array
    from numpy.linalg import inv, det
    from pylada.crystal.cppwrappers import cell_invariants, Structure
    from pylada.math import is_integer

    ops = cell_invariants(cell)
    if isinstance(cell, Structure): cell = cell.cell.copy()
    assert len(ops) == numops
    for op in ops:
        assert op.shape == (4, 3)
        assert all(abs(op[3, :]) < 1e-8)
        transformation = dot(dot(inv(cell), op[:3]), cell)
        assert is_integer(transformation)
        assert abs(abs(det(transformation)) - 1e0) < 1e-8
    if numops != 48:
        allops = cell_invariants(
            array([[0, 0.5, 0.5], [0.5, 0, 0.5], [0.5, 0.5, 0]]))
        failed = 0
        for op in allops:
            transformation = dot(dot(inv(cell), op[:3]), cell)
            if not (is_integer(transformation)
                    and abs(abs(det(transformation)) - 1e0) < 1e-8):
                failed += 1
        assert failed == 48 - numops
예제 #2
0
def motif(A, B):
    """ Check changes in motif. """
    from numpy import dot
    from pylada.crystal.cppwrappers import cell_invariants
    for op in cell_invariants(A)[1:]:
        print "op: ", op
        C = B.copy()
        for atom in C:
            atom.pos = dot(op[:3], atom.pos)
        scale(A, C)
예제 #3
0
파일: equivalent.py 프로젝트: mdavezac/LaDa
def motif(A, B):
  """ Check changes in motif. """
  from numpy import dot
  from pylada.crystal.cppwrappers import cell_invariants
  for op in cell_invariants(A)[1:]:
    print "op: ", op
    C = B.copy()
    for atom in C:
      atom.pos = dot(op[:3], atom.pos)
    scale(A, C)
예제 #4
0
def test(cell, numops):
  """ Test structure initialization. """
  from numpy import all, abs, dot, array
  from numpy.linalg import inv, det
  from pylada.crystal.cppwrappers import cell_invariants, Structure
  from pylada.math import is_integer

  ops = cell_invariants(cell) 
  if isinstance(cell, Structure): cell = cell.cell.copy()
  assert len(ops) == numops
  for op in ops:
    assert op.shape == (4, 3)
    assert all(abs(op[3, :]) < 1e-8) 
    transformation = dot(dot(inv(cell), op[:3]), cell)
    assert is_integer(transformation)
    assert abs(abs(det(transformation))-1e0) < 1e-8
  if numops != 48:
    allops = cell_invariants(array([[0,0.5,0.5],[0.5,0,0.5],[0.5,0.5,0]]))
    failed = 0
    for op in allops: 
      transformation = dot(dot(inv(cell), op[:3]), cell)
      if not (is_integer(transformation) and abs(abs(det(transformation))-1e0) < 1e-8):
        failed += 1
    assert failed == 48 - numops