Exemplo n.º 1
0
def get_orthorhombic_pbc(full_pbc):
    """\
    the input is matrix 3x3, the output is diagonal.
    Non-diagonal elements must be zero.
    """
    if full_pbc is None or len(full_pbc) == 0:
        raise ValueError("no PBC")
    assert is_diagonal(numpy.array(full_pbc))
    return numpy.diagonal(full_pbc)
Exemplo n.º 2
0
def get_orthorhombic_pbc(full_pbc):
    """\
    the input is matrix 3x3, the output is diagonal.
    Non-diagonal elements must be zero.
    """
    if full_pbc is None or len(full_pbc) == 0:
        raise ValueError("no PBC")
    assert is_diagonal(numpy.array(full_pbc))
    return numpy.diagonal(full_pbc)
Exemplo n.º 3
0
 def __init__(self, atoms, r, pbc=None):
     self.atoms = atoms
     if pbc is not None:
         assert rotmat.is_diagonal(pbc)
         self.box_d = self.pbc = pbc.diagonal()
     else:
         box_min, box_max = self._find_containing_box()
         self.box_d = box_max - box_min
         self.pbc = None
     self._make_cells(r)
Exemplo n.º 4
0
def _get_orthorhombic_pbc(m):
    """\
    the input is matrix 3x3, the output is diagonal.
    Distorts the input matrix such that the output
    is orthorhombic with the same volume as the
    space defined by the input matrix.
    """
    if is_diagonal(m):
        return m
    else:
        # x, y, z === unit vector in orthogonal cartesian space
        x, y, z = numpy.identity(3)
        # xi, yi, zi === initial matrix (m)
        xi, yi, zi = m
        # xf, yf, zf === final matrix (orthorhombic matrix)
        #
        # rotate full_pbc to make xi colinear with x
        angle = -1.0*numpy.sign(xi[0])*math.acos(xi[0]/linalg.norm(xi))
        ortho = numpy.dot(m, rodrigues(z, angle))
        # yf (zf) is the projection of the rotated yi (zi) onto y (z)
        ortho = numpy.diag(numpy.diagonal(ortho))
        return ortho
Exemplo n.º 5
0
def _get_orthorhombic_pbc(m):
    """\
    the input is matrix 3x3, the output is diagonal.
    Distorts the input matrix such that the output
    is orthorhombic with the same volume as the
    space defined by the input matrix.
    """
    if is_diagonal(m):
        return m
    else:
        # x, y, z === unit vector in orthogonal cartesian space
        x, y, z = numpy.identity(3)
        # xi, yi, zi === initial matrix (m)
        xi, yi, zi = m
        # xf, yf, zf === final matrix (orthorhombic matrix)
        #
        # rotate full_pbc to make xi colinear with x
        angle = -1.0 * numpy.sign(xi[0]) * math.acos(xi[0] / linalg.norm(xi))
        ortho = numpy.dot(m, rodrigues(z, angle))
        # yf (zf) is the projection of the rotated yi (zi) onto y (z)
        ortho = numpy.diag(numpy.diagonal(ortho))
        return ortho
Exemplo n.º 6
0
 def get_atoms_to_be_removed(self, atoms, distance):
     assert rotmat.is_diagonal(self.pbc)
     cm = mdprim.CellMethod(atoms, distance, self.pbc)
     return cm.get_atoms_to_remove()
Exemplo n.º 7
0
 def get_atoms_to_be_removed(self, atoms, distance):
     assert rotmat.is_diagonal(self.pbc)
     cm = mdprim.CellMethod(atoms, distance, self.pbc)
     return cm.get_atoms_to_remove()