Introduce GMX_USE_SIMD_KERNELS cmake option
[gromacs.git] / python_packaging / test / test_fr15.py
blobd59d3f639736038689744419e455c8f5bdf6828a
2 # This file is part of the GROMACS molecular simulation package.
4 # Copyright (c) 2019,2020, by the GROMACS development team, led by
5 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 # and including many others, as listed in the AUTHORS file in the
7 # top-level source directory and at http://www.gromacs.org.
9 # GROMACS is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public License
11 # as published by the Free Software Foundation; either version 2.1
12 # of the License, or (at your option) any later version.
14 # GROMACS 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 GNU
17 # Lesser General Public License for more details.
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with GROMACS; if not, see
21 # http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 # If you want to redistribute modifications to GROMACS, please
25 # consider that scientific software is very special. Version
26 # control is crucial - bugs must be traceable. We will be happy to
27 # consider code for inclusion in the official distribution, but
28 # derived work must not be called official GROMACS. Details are found
29 # in the README & COPYING files - if they are missing, get the
30 # official version at http://www.gromacs.org.
32 # To help us fund GROMACS development, we humbly ask that you cite
33 # the research papers on the package. Check out http://www.gromacs.org.
35 """Test gmxapi functionality described in roadmap.rst."""
37 import logging
39 import pytest
41 import gmxapi as gmx
43 # Configure the `logging` module before proceeding any further.
44 gmx.logger.setLevel(logging.WARNING)
46 try:
47 from mpi4py import MPI
48 rank_number = MPI.COMM_WORLD.Get_rank()
49 except ImportError:
50 rank_number = 0
51 rank_tag = ''
52 MPI = None
53 else:
54 rank_tag = 'rank{}:'.format(rank_number)
56 # Use this formatter to improve the caplog log records.
57 formatter = logging.Formatter(rank_tag + '%(name)s:%(levelname)s: %(message)s')
59 @pytest.mark.usefixtures('cleandir')
60 def test_fr15(spc_water_box, caplog):
61 """FR15: Simulation input modification.
63 * *gmx.modify_input produces new (tpr) simulation input in data flow operation*
64 (requires interaction with library development)
65 """
66 try:
67 from mpi4py import MPI
68 current_rank = MPI.COMM_WORLD.Get_rank()
69 ensemble_size = MPI.COMM_WORLD.Get_size()
70 except ImportError:
71 current_rank = 0
72 ensemble_size = 1
74 with caplog.at_level(logging.DEBUG):
75 caplog.handler.setFormatter(formatter)
76 with caplog.at_level(logging.WARNING, 'gmxapi'), \
77 caplog.at_level(logging.DEBUG, 'gmxapi.mdrun'), \
78 caplog.at_level(logging.DEBUG, 'gmxapi.modify_input'), \
79 caplog.at_level(logging.DEBUG, 'gmxapi.read_tpr'), \
80 caplog.at_level(logging.DEBUG, 'gmxapi.simulation'):
82 initial_input = gmx.read_tpr([spc_water_box for _ in range(ensemble_size)])
83 parameters = list([{'ld-seed': i} for i in range(ensemble_size)])
84 param_sweep = gmx.modify_input(input=initial_input,
85 parameters=parameters
87 md = gmx.mdrun(param_sweep)
88 # TODO: (#3179) Handle ensembles of size 1 more elegantly.
89 if md.output.ensemble_width > 1:
90 result_list = md.output.parameters['ld-seed'].result()
91 else:
92 result_list = [md.output.parameters['ld-seed'].result()]
93 for expected, actual in zip(parameters, result_list):
94 assert expected['ld-seed'] == actual