Exemplo n.º 1
0
def test_unitcell_1():
    # try round-tripping some random lengths and angles through
    # lengths_and_angles_to_box_vectors and box_vectors_to_lengths_and_angles,
    # and make sure we get back to where we started
    for _ in range(10):
        arg = np.hstack((random.rand(3), random.uniform(70, 110, size=3)))
        vectors = lengths_and_angles_to_box_vectors(*arg)
        out = box_vectors_to_lengths_and_angles(*vectors)
        np.testing.assert_array_almost_equal(arg, out)
Exemplo n.º 2
0
def test_unitcell_1():
    # try round-tripping some random lengths and angles through
    # lengths_and_angles_to_box_vectors and box_vectors_to_lengths_and_angles,
    # and make sure we get back to where we started
    for _ in range(10):
        arg = np.hstack((random.rand(3), random.uniform(70, 110, size=3)))
        vectors = lengths_and_angles_to_box_vectors(*arg)
        out = box_vectors_to_lengths_and_angles(*vectors)
        np.testing.assert_array_almost_equal(arg, out)
Exemplo n.º 3
0
def test_box_vector_calculation(len_a, len_b, len_c, alpha, beta, gamma):
    box = struc.vectors_from_unitcell(len_a, len_b, len_c, np.deg2rad(alpha),
                                      np.deg2rad(beta), np.deg2rad(gamma))

    from mdtraj.utils import lengths_and_angles_to_box_vectors
    ref_box = np.stack(
        lengths_and_angles_to_box_vectors(len_a, len_b, len_c, alpha, beta,
                                          gamma))
    assert np.allclose(box, ref_box)

    assert struc.unitcell_from_vectors(box) == pytest.approx(
        (len_a, len_b, len_c, alpha * 2 * np.pi / 360, beta * 2 * np.pi / 360,
         gamma * 2 * np.pi / 360))
Exemplo n.º 4
0
def test_unitcell_0():
    result = lengths_and_angles_to_box_vectors(1, 1, 1, 90.0, 90.0, 90.0)
    expected = (np.array([1, 0, 0]), np.array([0., 1.,
                                               0.]), np.array([0., 0., 1.]))
    for (a, b) in zip(result, expected):
        np.testing.assert_array_almost_equal(a, b)
Exemplo n.º 5
0
def test_unitcell_0():
    result = lengths_and_angles_to_box_vectors(1, 1, 1, 90.0, 90.0, 90.0)
    expected = (np.array([1, 0, 0]), np.array([ 0.,  1.,  0.]), np.array([ 0.,  0.,  1.]))
    for (a, b) in zip(result, expected):
        np.testing.assert_array_almost_equal(a, b)