Esempio n. 1
0
def test_order_from_traj():
    """Made a perfectly aligned monolayer, should have S2 = 1
    """
    traj = md.load(get_fn('alkane-monolayer.pdb'))
    indices = [list(range(1900+x, 1900+x+36)) for x in range(0, 64*36, 36)]
    s2 = md.compute_nematic_order(traj, indices=indices)
    assert_allclose(1.0, s2)
Esempio n. 2
0
def test_order_from_traj():
    """Made a perfectly aligned monolayer, should have S2 = 1
    """
    traj = md.load(get_fn('alkane-monolayer.pdb'))
    indices = [
        list(range(1900 + x, 1900 + x + 36)) for x in range(0, 64 * 36, 36)
    ]
    s2 = md.compute_nematic_order(traj, indices=indices)
    assert_allclose(1.0, s2)
Esempio n. 3
0
def test_read_write_4():
    traj = md.load(get_fn('frame0.nc'), top=get_fn('native.pdb'))
    traj[0].save(temp2)
    assert_true(os.path.exists(temp2))
    rsttraj = md.load(temp2, top=get_fn('native.pdb'))
    assert_allclose(rsttraj.xyz, traj[0].xyz)
    os.unlink(temp2)
    traj.save(temp2)
    for i in range(traj.n_frames):
        assert_true(os.path.exists('%s.%03d' % (temp2, i + 1)))
        os.unlink('%s.%03d' % (temp2, i + 1))
Esempio n. 4
0
def test_directors_angle_from_traj():
    """All chains in example system aligned along z axis
    """
    traj = md.load(get_fn('alkane-monolayer.pdb'))
    # only use the carbons for this calculation since they are excactly aligned
    # with the z-axis, and the hydrogens can throw things off just a bit
    indices = [list(range(1900+x, 1900+x+30, 3)) for x in range(0, 64*36, 36)]
    directors = md.compute_directors(traj, indices=indices)
    for axis, target_angle in zip(np.eye(3), [90.0, 90.0, 0.0]):
        dotproducts = np.tensordot(directors, axis, axes=1)
        angles = np.degrees(np.arccos(dotproducts))
        angles = np.minimum(angles, 180-angles)  # make vector point in positive z
        assert_allclose(target_angle, angles)
Esempio n. 5
0
def test_directors_angle_from_traj():
    """All chains in example system aligned along z axis
    """
    traj = md.load(get_fn('alkane-monolayer.pdb'))
    # only use the carbons for this calculation since they are excactly aligned
    # with the z-axis, and the hydrogens can throw things off just a bit
    indices = [
        list(range(1900 + x, 1900 + x + 30, 3)) for x in range(0, 64 * 36, 36)
    ]
    directors = md.compute_directors(traj, indices=indices)
    for axis, target_angle in zip(np.eye(3), [90.0, 90.0, 0.0]):
        dotproducts = np.tensordot(directors, axis, axes=1)
        angles = np.degrees(np.arccos(dotproducts))
        angles = np.minimum(angles,
                            180 - angles)  # make vector point in positive z
        assert_allclose(target_angle, angles)
Esempio n. 6
0
def _run_amber_traj(traj, ext_ref):
    # Test triclinic case where simple approach in Tuckerman text does not
    # always work
    distopt = md.compute_distances(traj, [[0, 9999]], opt=True)
    distslw = md.compute_distances(traj, [[0, 9999]], opt=False)
    dispopt = md.compute_displacements(traj, [[0, 9999]], opt=True)
    dispslw = md.compute_displacements(traj, [[0, 9999]], opt=False)

    eq(distopt, distslw, decimal=5)
    eq(dispopt, dispslw, decimal=5)

    assert_allclose(distopt.flatten(), ext_ref, atol=2e-5)

    # Make sure distances from displacements are the same
    eq(np.sqrt((dispopt.squeeze()**2).sum(axis=1)), distopt.squeeze())
    eq(np.sqrt((dispslw.squeeze()**2).sum(axis=1)), distslw.squeeze())
    eq(dispopt, dispslw, decimal=5)
Esempio n. 7
0
def _run_amber_traj(trajname, ext_ref):
    # Test triclinic case where simple approach in Tuckerman text does not
    # always work
    traj = md.load(get_fn(trajname), top=get_fn("test.parm7"))
    distopt = md.compute_distances(traj, [[0, 9999]], opt=True)
    distslw = md.compute_distances(traj, [[0, 9999]], opt=False)
    dispopt = md.compute_displacements(traj, [[0, 9999]], opt=True)
    dispslw = md.compute_displacements(traj, [[0, 9999]], opt=False)

    eq(distopt, distslw, decimal=5)
    eq(dispopt, dispslw, decimal=5)

    assert_allclose(distopt.flatten(), ext_ref, atol=2e-5)

    # Make sure distances from displacements are the same
    eq(np.sqrt((dispopt.squeeze() ** 2).sum(axis=1)), distopt.squeeze())
    eq(np.sqrt((dispslw.squeeze() ** 2).sum(axis=1)), distslw.squeeze())
    eq(dispopt, dispslw, decimal=5)