2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2019, 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 Declares the Parrinello-Rahman barostat for the modular simulator
38 * \author Pascal Merz <pascal.merz@me.com>
39 * \ingroup module_modularsimulator
42 #ifndef GMX_MODULARSIMULATOR_PARRINELLORAHMANBAROSTAT_H
43 #define GMX_MODULARSIMULATOR_PARRINELLORAHMANBAROSTAT_H
45 #include "gromacs/math/vectypes.h"
47 #include "modularsimulatorinterfaces.h"
48 #include "propagator.h"
57 class StatePropagatorData;
60 * \ingroup module_modularsimulator
61 * \brief Element implementing the Parrinello-Rahman barostat
64 * * integrates the Parrinello-Rahman box velocity equations,
65 * * takes a callback to the propagator to update the velocity
67 * * scales the box and the positions of the system.
69 class ParrinelloRahmanBarostat final : public ISimulatorElement, public ICheckpointHelperClient
73 ParrinelloRahmanBarostat(int nstpcouple,
75 real couplingTimeStep,
77 ArrayRef<rvec> scalingTensor,
78 PropagatorCallbackPtr propagatorCallback,
79 StatePropagatorData* statePropagatorData,
80 EnergyElement* energyElement,
82 const t_inputrec* inputrec,
83 const MDAtoms* mdAtoms,
84 const t_state* globalState,
88 /*! \brief Register run function for step / time
90 * @param step The step number
91 * @param time The time
92 * @param registerRunFunction Function allowing to register a run function
94 void scheduleTask(Step step, Time time, const RegisterRunFunctionPtr& registerRunFunction) override;
96 //! Fix relative box shape
97 void elementSetup() override;
98 //! No element teardown needed
99 void elementTeardown() override {}
101 //! Getter for the box velocities
102 const rvec* boxVelocities() const;
105 //! The frequency at which the barostat is applied
106 const int nstpcouple_;
107 //! If != 0, offset the step at which the barostat is applied
109 //! The coupling time step - simulation time step x nstcouple_
110 const real couplingTimeStep_;
111 //! The first step of the simulation
112 const Step initStep_;
114 //! Whether this is the first step
117 //! View on the velocity scaling tensor (owned by the propagator)
118 ArrayRef<rvec> scalingTensor_;
119 //! Callback to let propagator know that we updated lambda
120 PropagatorCallbackPtr propagatorCallback_;
122 //! Relative change in box before - after barostatting
124 //! Relative box shape
129 //! Pointer to the micro state
130 StatePropagatorData* statePropagatorData_;
131 //! Pointer to the energy element
132 EnergyElement* energyElement_;
134 //! Integrate the PR box vector equations of motion - does not alter state
135 void integrateBoxVelocityEquations(Step step);
136 //! Scale box and positions
137 void scaleBoxAndPositions();
139 //! ICheckpointHelperClient implementation
140 void writeCheckpoint(t_state* localState, t_state* globalState) override;
142 // Access to ISimulator data
145 //! Contains user input mdp options.
146 const t_inputrec* inputrec_;
147 //! Atom parameters for this domain.
148 const MDAtoms* mdAtoms_;
153 #endif // GMX_MODULARSIMULATOR_PARRINELLORAHMANBAROSTAT_H