2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2004, The GROMACS development team.
6 * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
7 * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
8 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
9 * and including many others, as listed in the AUTHORS file in the
10 * top-level source directory and at http://www.gromacs.org.
12 * GROMACS is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public License
14 * as published by the Free Software Foundation; either version 2.1
15 * of the License, or (at your option) any later version.
17 * GROMACS is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with GROMACS; if not, see
24 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
25 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 * If you want to redistribute modifications to GROMACS, please
28 * consider that scientific software is very special. Version
29 * control is crucial - bugs must be traceable. We will be happy to
30 * consider code for inclusion in the official distribution, but
31 * derived work must not be called official GROMACS. Details are found
32 * in the README & COPYING files - if they are missing, get the
33 * official version at http://www.gromacs.org.
35 * To help us fund GROMACS development, we humbly ask that you cite
36 * the research papers on the package. Check out http://www.gromacs.org.
38 #ifndef GMX_TRAJECTORY_ENERGYFRAME_H
39 #define GMX_TRAJECTORY_ENERGYFRAME_H
44 #include "gromacs/utility/basedefinitions.h"
45 #include "gromacs/utility/real.h"
51 //! The current energy.
53 //! The running average of the energy
55 //! The sum of energies until now.
59 /* The frames that are read/written */
62 double t; /* Timestamp of this frame */
63 int64_t step; /* MD step */
64 int64_t nsteps; /* The number of steps between frames */
65 double dt; /* The MD time step */
66 int nsum; /* The number of terms for the sums in ener */
67 int nre; /* Number of energies */
68 int e_size; /* Size (in bytes) of energies */
69 int e_alloc; /* Allocated size (in elements) of ener */
70 t_energy* ener; /* The energies */
71 int nblock; /* Number of following energy blocks */
72 t_enxblock* block; /* The blocks */
73 int nblock_alloc; /* The number of blocks allocated */
80 * \brief Contains the content of an .edr frame read by an EnergyFrameReader
82 * The interface of this class is intended to resemble a subset of std::map. */
87 using MapType = std::map<std::string, real>;
89 using MapConstIterator = MapType::const_iterator;
91 EnergyFrame(const t_enxframe& enxframe, const std::map<std::string, int>& indicesOfEnergyFields);
92 /*! \brief Return string that helps users identify this frame, containing time and step number.
94 * \throws std::bad_alloc when out of memory */
95 std::string frameName() const;
96 /*! \brief Return the value read for energy \c name.
98 * \throws APIError if \c name was not registered with EnergyFileReader. */
99 const real& at(const std::string& name) const;
100 //! Return const interator to first element of values.
101 MapConstIterator begin() const;
102 //! Return const interator to past the end element of values.
103 MapConstIterator end() const;
104 //! Return a const interator to the element with \c key, or end() if not found.
105 MapConstIterator find(const std::string& key) const;
108 //! Container for energy values, indexed by name
110 //! Step number read from the .edr file frame
112 //! Time read from the .edr file frame