def test_calculate_mean_squared_disp_for_single_ideal_mof():
    """ Test trajectory class calculate_mean_squared_disp function for single ideal mof """
    traj = Trajectory(read=os.path.join(mof_trial_dir, 'Run1', 'traj.xyz'))
    traj.set_cell([80, 80, 80])
    traj.calculate_distances()
    traj.calculate_mean_squared_disp()
    assert np.all(traj.mean_squared_disp > 0.0)
    assert np.all(traj.mean_squared_disp < 0.4)
Пример #2
0
def test_calculate_distances_with_trajectory_calculate_distances(max_dist=5):
    """
    Tests interatomic distance calculation for the Trajectory class
        - Test first frame is all zeros
        - Make sure all distances are less than max distance (5 A)
        - Test a known distance
    """
    traj = Trajectory(read=os.path.join(mof_trial_dir, 'Run1', 'traj.xyz'))
    traj.set_cell([80, 80, 80])
    traj.calculate_distances()
    distances = calculate_distances(traj.coordinates, [80, 80, 80],
                                    reference_frame=0)
    assert np.allclose(traj.distances, distances)
Пример #3
0
def test_trajectory_calculate_distances_nonzero_reference_frame(max_dist=5):
    """
    Tests interatomic distance calculation for the Trajectory class
        - Test seventh frame (reference frame) is all zeros
        - Make sure all distances are less than max distance (5 A)
        - Test a known distance
    """
    traj = Trajectory(read=os.path.join(mof_trial_dir, 'Run1', 'traj.xyz'))
    traj.set_cell([80, 80, 80])
    traj.calculate_distances(reference_frame=7)
    assert np.allclose(traj.distances[7], np.zeros(traj.n_atoms))
    for frame in traj.distances:
        assert np.all(frame < max_dist)
    assert np.isclose(traj.distances[0][3], 0.23030113908032163)
Пример #4
0
def test_trajectory_calculate_distances(max_dist=5):
    """
    Tests interatomic distance calculation for the Trajectory class
        - Test first frame is all zeros
        - Make sure all distances are less than max distance (5 A)
        - Test a known distance
    """
    traj = Trajectory(read=os.path.join(mof_trial_dir, 'Run1', 'traj.xyz'))
    traj.set_cell([80, 80, 80])
    traj.calculate_distances()
    assert np.allclose(traj.distances[0], np.zeros(traj.n_atoms))
    for frame in traj.distances:
        assert np.all(frame < max_dist)
    assert np.isclose(traj.distances[3][3], 0.5159079779340517)
def test_calculate_mean_disp_and_mean_squared_disp_for_linear_motion_of_particles():
    """ Test trajectory class calculate_mean_disp and calculate_mean_squared_disp functions
        for 6 particles with linear motion with alternative calculation """
    n_atoms, n_frames = 6, 6
    traj = Trajectory()
    traj.coordinates = [[[i + j, i + j, i + j] for i in range(n_atoms)] for j in range(n_frames)]
    traj.n_atoms, traj.n_frames = n_atoms, n_frames
    traj.set_cell([10, 10, 10])
    traj.calculate_distances()
    traj.calculate_mean_disp()
    traj.calculate_mean_squared_disp()
    assert np.allclose([np.sum(range(n_frames)) / n_frames * np.sqrt(3)] * n_atoms, traj.mean_disp)
    for i in range(traj.n_atoms):
        c0 = traj.coordinates[0][i]
        x2 = (np.array([f[i][0] for f in traj.coordinates]) - c0[0]) ** 2
        y2 = (np.array([f[i][1] for f in traj.coordinates]) - c0[1]) ** 2
        z2 = (np.array([f[i][2] for f in traj.coordinates]) - c0[2]) ** 2
        mean_squared_disp = sum(x2 + y2 + z2) / n_frames
        mean_disp = sum(np.sqrt(x2 + y2 + z2)) / n_frames
        assert np.allclose(mean_disp, traj.mean_disp[i])
        assert np.allclose(mean_squared_disp, traj.mean_squared_disp[i])