|
41 | 41 | DLP_CONFIG,
|
42 | 42 | CPPTRAJ_TRAJ_TOP,
|
43 | 43 | CPPTRAJ_TRAJ,
|
| 44 | + PRMNCRST, |
| 45 | + TRJNCRST, |
44 | 46 | )
|
45 | 47 | from MDAnalysisTests.coordinates.test_trj import _TRJReaderTest
|
46 | 48 | from MDAnalysisTests.coordinates.reference import RefVGV, RefTZ2
|
@@ -389,6 +391,72 @@ def test_warn_user_no_time_information(self, u):
|
389 | 391 | u2 = mda.Universe(CPPTRAJ_TRAJ_TOP, CPPTRAJ_TRAJ)
|
390 | 392 |
|
391 | 393 |
|
| 394 | +class TestNCDFReader5(object): |
| 395 | + """NCRST Restart File with positions and forces, exported by CPPTRAJ. |
| 396 | +
|
| 397 | + Contributed by Jeremy M. G. Leung |
| 398 | + """ |
| 399 | + |
| 400 | + prec = 6 |
| 401 | + |
| 402 | + @pytest.fixture(scope="class") |
| 403 | + def u(self): |
| 404 | + return mda.Universe(PRMNCRST, TRJNCRST) |
| 405 | + |
| 406 | + def test_positions(self, u): |
| 407 | + """Check positions on first frame""" |
| 408 | + u.trajectory[0] |
| 409 | + ref_1 = np.array( |
| 410 | + [ |
| 411 | + [-1.1455358, -2.0177484, -0.55771565], |
| 412 | + [-0.19042611, -2.2511053, -1.0282656], |
| 413 | + [ 0.53238064, -1.5778863, -0.56737846], |
| 414 | + ], |
| 415 | + dtype=np.float64, |
| 416 | + ) |
| 417 | + assert_almost_equal(ref_1, u.atoms.positions[:3], self.prec) |
| 418 | + |
| 419 | + def test_velocities(self, u): |
| 420 | + """Check forces on first frame""" |
| 421 | + u.trajectory[0] |
| 422 | + ref_1 = np.array( |
| 423 | + [ |
| 424 | + [11.86471367, 31.22108269, -4.03538418], |
| 425 | + [7.36676359, -4.68035316, 1.78124952], |
| 426 | + [12.86675262, 1.39324546, -14.97190762], |
| 427 | + ], |
| 428 | + dtype=np.float64, |
| 429 | + ) |
| 430 | + assert_almost_equal(ref_1, u.atoms.velocities[:3], self.prec) |
| 431 | + |
| 432 | + def test_forces(self, u): |
| 433 | + """Check forces on first frame""" |
| 434 | + u.trajectory[0] |
| 435 | + ref_1 = np.array( |
| 436 | + [ |
| 437 | + [-9.7262249, -0.37627634, -24.79876137], |
| 438 | + [-32.43384552, 37.47783279, -12.45422745], |
| 439 | + [24.10939026, -19.80618095, -17.09523582], |
| 440 | + ], |
| 441 | + dtype=np.float64, |
| 442 | + ) |
| 443 | + assert_almost_equal(ref_1, u.atoms.forces[:3], self.prec) |
| 444 | + |
| 445 | + def test_time(self, u): |
| 446 | + """Check time on first frame""" |
| 447 | + ref = 5.0 |
| 448 | + assert_almost_equal(ref, u.trajectory[0].time, self.prec) |
| 449 | + |
| 450 | + def test_dt(self, u): |
| 451 | + """Default 1.0 fs""" |
| 452 | + ref = 1.0 |
| 453 | + assert_almost_equal(ref, u.trajectory.dt, self.prec) |
| 454 | + assert_almost_equal(ref, u.trajectory.ts.dt, self.prec) |
| 455 | + |
| 456 | + def test_box(self, u): |
| 457 | + assert u.trajectory[0].dimensions is None |
| 458 | + |
| 459 | + |
392 | 460 | class _NCDFGenerator(object):
|
393 | 461 | """A class for generating abitrary ncdf files and exhaustively test
|
394 | 462 | edge cases which might not be found in the wild"""
|
|
0 commit comments