2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2020,2021, 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 /*! \libinternal \file
36 * \brief Translation layer to GROMACS data structures for force calculations.
38 * Implements the translation layer between the user scope and
39 * GROMACS data structures for force calculations. Sets up the
42 * \author Victor Holanda <victor.holanda@cscs.ch>
43 * \author Joe Jordan <ejjordan@kth.se>
44 * \author Prashanth Kanduri <kanduri@cscs.ch>
45 * \author Sebastian Keller <keller@cscs.ch>
48 #ifndef NBLIB_GMXSETUP_H
49 #define NBLIB_GMXSETUP_H
51 #include "nblib/gmxcalculator.h"
52 #include "nblib/simulationstate.h"
62 /*! \brief Sets up the GROMACS data structures for the non-bonded force calculator
64 * This data structure initializes the GmxForceCalculator object which internally
65 * contains various objects needed to perform non-bonded force calculations using
66 * the internal representation for the problem as required for GROMACS.
68 * The public functions of this class basically translate the problem description
69 * specified by the user in NBLIB. This ultimately returns the GmxForceCalculator
70 * object which is used by the ForceCalculator object in the user-facing library.
73 class NbvSetupUtil final
78 //! Sets hardware params from the execution context
79 void setExecutionContext(const NBKernelOptions& options);
81 //! Sets non-bonded parameters to be used to build GMX data structures
82 void setNonBondedParameters(const std::vector<ParticleType>& particleTypes,
83 const NonBondedInteractionMap& nonBondedInteractionMap);
85 //! Marks particles to have Van der Waals interactions
86 void setParticleInfoAllVdv(size_t numParticles);
88 //! Set up StepWorkload data
89 void setupStepWorkload(const NBKernelOptions& options);
91 //! Return an interaction constants struct with members set appropriately
92 void setupInteractionConst(const NBKernelOptions& options);
94 //! Sets Particle Types and Charges and VdW params
95 void setAtomProperties(const std::vector<int>& particleTypeIdOfAllParticles,
96 const std::vector<real>& charges);
98 //! Sets up non-bonded verlet on the GmxForceCalculator
99 void setupNbnxmInstance(size_t numParticleTypes, const NBKernelOptions& options);
101 //! Puts particles on a grid based on bounds specified by the box
102 void setParticlesOnGrid(const std::vector<Vec3>& coordinates, const Box& box);
104 //! Constructs pair lists
105 void constructPairList(ExclusionLists<int> exclusionLists);
107 //! Sets up t_forcerec object on the GmxForceCalculator
108 void setupForceRec(const matrix& box);
110 //! Returns a unique pointer a GmxForceCalculator object
111 std::unique_ptr<GmxForceCalculator> getGmxForceCalculator()
113 return std::move(gmxForceCalculator_);
117 //! Storage for parameters for short range interactions.
118 std::vector<real> nonbondedParameters_;
120 //! Particle info where all particles are marked to have Van der Waals interactions
121 std::vector<int64_t> particleInfoAllVdw_;
123 //! GROMACS force calculator to compute forces
124 std::unique_ptr<GmxForceCalculator> gmxForceCalculator_;
127 /*! \brief Calls the setup utilities needed to initialize a GmxForceCalculator object
129 * The GmxSetupDirector encapsulates the multi-stage setup of the GmxForceCalculator which
130 * is done using the public functions of the NbvSetupUtil. This separation ensures that the
131 * NbvSetupUtil object is temporary in scope. The function definition makes it easy for the
132 * developers to follow the sequence of calls and the dataflow involved in setting up
133 * the non-bonded force calculation backend. This is the only function needed to be called
134 * from the ForceCalculator during construction.
137 class GmxSetupDirector
140 //! Sets up and returns a GmxForceCalculator
141 static std::unique_ptr<GmxForceCalculator> setupGmxForceCalculator(const SimulationState& system,
142 const NBKernelOptions& options);
146 #endif // NBLIB_GMXSETUP_H