1# -*- coding: utf-8 -*-
2# MolMod is a collection of molecular modelling tools for python.
3# Copyright (C) 2007 - 2019 Toon Verstraelen <Toon.Verstraelen@UGent.be>, Center
4# for Molecular Modeling (CMM), Ghent University, Ghent, Belgium; all rights
5# reserved unless otherwise stated.
6#
7# This file is part of MolMod.
8#
9# MolMod is free software; you can redistribute it and/or
10# modify it under the terms of the GNU General Public License
11# as published by the Free Software Foundation; either version 3
12# of the License, or (at your option) any later version.
13#
14# MolMod is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program; if not, see <http://www.gnu.org/licenses/>
21#
22# --
23
24
25from __future__ import division
26
27import pkg_resources
28
29from molmod.test.common import BaseTestCase
30from molmod.io import *
31from molmod import *
32
33
34__all__ = ["GromacsTestCase"]
35
36
37class GromacsTestCase(BaseTestCase):
38    def test_reader(self):
39        gr = GroReader(pkg_resources.resource_filename("molmod", "data/test/water2.gro"))
40        next(gr) # skip one
41        for time, pos, vel, cell in gr:
42            self.assertAlmostEqual(time/picosecond, 1.0)
43            self.assertAlmostEqual(pos[0,1]/nanometer, 1.624,6)
44            self.assertAlmostEqual(vel[3,2]/nanometer*picosecond, -0.1734)
45            self.assertAlmostEqual(cell[0,0]/nanometer, 1.82060)
46            break
47