# IODATA is an input and output module for quantum chemistry.# Copyright (C) 2011-2019 The IODATA Development Team## This file is part of IODATA.## IODATA is free software; you can redistribute it and/or# modify it under the terms of the GNU General Public License# as published by the Free Software Foundation; either version 3# of the License, or (at your option) any later version.## IODATA is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, see <http://www.gnu.org/licenses/># --"""Test iodata.formats.gromacs module."""fromimportlib.resourcesimportas_file,filesfromnumpy.testingimportassert_allclose,assert_equalfrom..apiimportload_many,load_onefrom..utilsimportnanometer,picosecond
[docs]deftest_load_water():# test gro file of one waterwithas_file(files("iodata.test.data").joinpath("water.gro"))asfn_gro:mol=load_one(str(fn_gro))check_water(mol)
[docs]defcheck_water(mol):"""Test some things on a water file."""assertmol.title=="MD of 2 waters"assertmol.atcoords.shape==(6,3)assert_allclose(mol.atcoords[-1]/nanometer,[1.326,0.120,0.568])assertmol.atffparams["attypes"][2]=="HW3"assertmol.atffparams["resnames"][-1]=="WATER"assert_equal(mol.atffparams["resnums"][2:4],[1,2])assert_allclose(mol.cellvecs[0][0],1.82060*nanometer,atol=1.0e-5)assertmol.extra["velocities"].shape==(6,3)vel=mol.extra["velocities"][-1]assert_allclose(vel*(picosecond/nanometer),[1.9427,-0.8216,-0.0244])