コード例 #1
0
ファイル: buildingblocks.py プロジェクト: yangxi1209/pele
def reduced_coordinates_displace(stepsize,
                                 lattice_matrix,
                                 coords,
                                 indices=None):
    """uniform random displacement of reduced coordinates

    Parameters
    ----------
    coords : array like x(:,3)
       coordinates
    indices : list, optional
       list of coordinates to displace, None for all coordinates in array

    """
    coords = coords.reshape(-1, 3)
    ilattice = vec3.invert3x3(lattice_matrix)  # inverse_lattice
    if indices is not None:
        for i in indices:
            coords[i] += np.dot(
                ilattice,
                stepsize * rotations.vector_random_uniform_hypersphere(3))
        return

    for x in coords:
        x += np.dot(ilattice,
                    stepsize * rotations.vector_random_uniform_hypersphere(3))
コード例 #2
0
ファイル: test_rotations.py プロジェクト: dimaslave/pele
 def test_invert3x3(self):
     q = rotations.random_q()
     mx = rotations.q2mx(q)
     mxi1 = invert3x3(mx)
     mxi2 = np.linalg.inv(mx)
     self.assertEqual(mxi1.shape, mxi2.shape)
     for v1, v2 in izip(mxi1.reshape(-1), mxi2.reshape(-1)):
         self.assertAlmostEqual(v1, v2, places=5)
コード例 #3
0
 def test_invert3x3(self):
     q = rotations.random_q()
     mx = rotations.q2mx(q)
     mxi1 = invert3x3(mx)
     mxi2 = np.linalg.inv(mx)
     self.assertEqual(mxi1.shape, mxi2.shape)
     for v1, v2 in zip(mxi1.reshape(-1), mxi2.reshape(-1)):
         self.assertAlmostEqual(v1, v2, places=5)
コード例 #4
0
ファイル: buildingblocks.py プロジェクト: cjforman/pele
def reduced_coordinates_displace(stepsize, lattice_matrix, coords, indices=None):
    """uniform random displacement of reduced coordinates

    Parameters
    ----------
    coords : array like x(:,3)
       coordinates
    indices : list, optional
       list of coordinates to displace, None for all coordinates in array

    """
    ilattice = vec3.invert3x3(lattice_matrix)  # inverse_lattice
    if indices:
        for i in indices:
            coords[i] += np.dot(ilattice, stepsize * rotations.vector_random_uniform_hypersphere(3))
        return

    for x in coords:
        x += np.dot(ilattice, stepsize * rotations.vector_random_uniform_hypersphere(3))