Exemplo n.º 1
0
def axes(self):
    """
    Return principal, secondary and perpendicular axes of the Mol

    Returns
    -------
    axes_out : 3 x 3 np array
        Principal, followed by secondary and perpendicular axes of the molecule

    """
    if np.count_nonzero(self.geom.plane_coeffs) == 0:
        self.calc_plane_coeffs()
    # get the quadrangle which best describes the coordinates (possibly a
    # triangle with the far point repeated twice)
    vertices = ao.quadrangle_from_coord(self.geom.coord_array)
    # if the mol is linear, we need to reorder the quadrangle
    if self.geom.linear:
        vertices = np.array([vertices[1],vertices[2],vertices[3],vertices[0]])
    # if the mole is rectangular, we want an embedded quadrangle
    else:
        # get the embedded quadrangle vertices
        vertices = ao.embedded_vert(vertices)
    # get vectors from projected diagonals
    axes_out_raw = ao.project_quad_to_vectors(vertices,self.geom.plane_coeffs)
    # we want the first raw to be the secondary and vice versa and the principal
    # to be *(-1) in order to maintain a convention
    axes_out_unnormal = np.array([-axes_out_raw[1], axes_out_raw[0]])
    # orthonogalise them
    # if the mol is linear, just move the secondary axis
    if self.geom.linear:
        axes_out_prin_sec = ao.orthogonalise_asym(axes_out_unnormal)
    # if the mol is not linear, move principal and secondary axes equally
    else:
        axes_out_prin_sec = ao.orthogonalise_sym(axes_out_unnormal)
    # get the perpendicular vector
    perp = np.cross(axes_out_prin_sec[0], axes_out_prin_sec[1])
    # ensure normalisation
    perp = perp/np.linalg.norm(perp)

    lis_axes_out = list(axes_out_prin_sec)
    lis_axes_out.append(perp)
    axes_out = np.array(lis_axes_out)
    return axes_out
Exemplo n.º 2
0
def test_tri_project_quad_to_vectors(triangle_corners_4, z_plane_coeffs):
    emb_vert = ao.embedded_vert(triangle_corners_4)
    projected_vecs = ao.project_quad_to_vectors(emb_vert, z_plane_coeffs)
    expected = np.array([[0., -1., 0.], [-0.995037, 0.099504, 0.]])
    assert_allclose(projected_vecs, expected, rtol=1e-4)
    return
Exemplo n.º 3
0
def test_tri_embedded_vert(triangle_corners_4):
    new_pairs = ao.embedded_vert(triangle_corners_4)
    expected = np.array([[3.5, 3., 0.], [6., 2., 0.], [3.5, 1.5, 0.],
                         [1., 2.5, 0.]])
    assert_allclose(new_pairs, expected)
Exemplo n.º 4
0
def test_embedded_vert(rectangle_array):
    new_vert = ao.embedded_vert(rectangle_array)
    expected = np.array([[0., 1., 0.], [2., 2., 0.], [4., 1., 0.],
                         [2., 0., 0.]])
    assert_allclose(new_vert, expected)
Exemplo n.º 5
0
def test_arb_project_quad_to_vectors(arbitrary_flat_vertices, z_plane_coeffs):
    emb_vert = ao.embedded_vert(arbitrary_flat_vertices)
    projected_vecs = ao.project_quad_to_vectors(emb_vert, z_plane_coeffs)
    expected = np.array([[0.03173, -0.999496, 0.], [-0.999966, 0.008196, 0.]])
    assert_allclose(projected_vecs, expected, rtol=1e-4)
    return
Exemplo n.º 6
0
def test_arb_embedded_vert(arbitrary_flat_vertices):
    new_pairs = ao.embedded_vert(arbitrary_flat_vertices)
    expected = np.array([[3., 3.05, 0.], [6.1, 1.45, 0.], [3.1, -0.1, 0.],
                         [0., 1.5, 0.]])
    assert_allclose(new_pairs, expected)