Merge release-5-0 into master
[alexxy/gromacs.git] / src / gromacs / fileio / tngio.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2013,2014, 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.
8  *
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.
13  *
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.
18  *
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.
23  *
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.
31  *
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.
34  */
35
36 #ifndef GMX_FILEIO_TNGIO_H
37 #define GMX_FILEIO_TNGIO_H
38
39 #include "tng/tng_io_fwd.h"
40
41 #include "gromacs/legacyheaders/types/inputrec.h"
42 #include "gromacs/math/vectypes.h"
43 #include "gromacs/utility/real.h"
44
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 #if 0
49 }
50 #endif
51
52 struct gmx_mtop_t;
53
54 /*! \brief Open a TNG trajectory file
55  *
56  * \param filename   Name of file to open
57  * \param mode       Can be set to 'r', 'w' or 'a' for reading, writing or appending respectively.
58  * \param tng_data_p Pointer to an allocated tng_trajectory_t into which a handle to a TNG trajectory will be stored.
59  *
60  * Handles all I/O errors internally via fatal error
61  */
62 void gmx_tng_open(const char       *filename,
63                   char              mode,
64                   tng_trajectory_t *tng_data_p);
65
66 /*! \brief Finish writing a TNG trajectory file */
67 void gmx_tng_close(tng_trajectory_t *tng);
68
69 /*!\brief Add molecular topology information to TNG output (if
70  * available)
71  *
72  * \param tng   Valid handle to a TNG trajectory
73  * \param mtop  Pointer to a topology (can be NULL)
74  */
75 void gmx_tng_add_mtop(tng_trajectory_t         tng,
76                       const struct gmx_mtop_t *mtop);
77
78 /*! \brief Do all TNG preparation for full-precision whole-system
79  * trajectory writing during MD simulations.
80  *
81  * \param tng   Valid handle to a TNG trajectory
82  * \param mtop  Global topology
83  * \param ir    Input settings (for writing frequencies)
84  */
85 void gmx_tng_prepare_md_writing(tng_trajectory_t         tng,
86                                 const struct gmx_mtop_t *mtop,
87                                 const t_inputrec        *ir);
88
89 /*! \brief Set the default compression precision for TNG writing
90  *
91  * \param tng   Valid handle to a TNG trajectory
92  * \param prec  GROMACS-style precision setting (i.e. 1000 for 3 digits of precision) */
93 void gmx_tng_set_compression_precision(tng_trajectory_t tng,
94                                        real             prec);
95
96 /*! \brief Do all TNG preparation for low-precision selection-based
97  * trajectory writing during MD simulations.
98  *
99  * \param tng   Valid handle to a TNG trajectory
100  * \param mtop  Global topology
101  * \param ir    Input settings (for writing frequencies)
102  */
103 void gmx_tng_prepare_low_prec_writing(tng_trajectory_t         tng,
104                                       const struct gmx_mtop_t *mtop,
105                                       const t_inputrec        *ir);
106
107 /*! \brief Write a frame to a TNG file
108  *
109  * \param tng                  Valid handle to a TNG trajectory
110  * \param bUseLossyCompression Whether to use lossy compression
111  * \param step                 MD step number
112  * \param elapsedPicoSeconds   Elapsed MD time
113  * \param lambda               Free-energy lambda value
114  * \param box                  Simulation box
115  * \param nAtoms               Number of atoms (i.e. vector lengths)
116  * \param x                    Vector of position coordinates
117  * \param v                    Vector of elocities
118  * \param f                    Vector of forces
119  *
120  * The pointers tng, x, v, f may be NULL, which triggers not writing
121  * (that component). box can only be NULL if x is also NULL. */
122 void gmx_fwrite_tng(tng_trajectory_t tng,
123                     const gmx_bool   bUseLossyCompression,
124                     int              step,
125                     real             elapsedPicoSeconds,
126                     real             lambda,
127                     const rvec      *box,
128                     int              nAtoms,
129                     const rvec      *x,
130                     const rvec      *v,
131                     const rvec      *f);
132
133 /*! \brief Write the current frame set to disk. Perform compression
134  * etc.
135  *
136  * \param tng Valid handle to a TNG trajectory
137  */
138 void fflush_tng(tng_trajectory_t tng);
139
140 /*! \brief Get the time (in picoseconds) of the final frame in the
141  * trajectory.
142  *
143  * \param tng Valid handle to a TNG trajectory
144  */
145 float gmx_tng_get_time_of_final_frame(tng_trajectory_t tng);
146
147 #ifdef __cplusplus
148 }
149 #endif
150
151 #endif /* GMX_FILEIO_TNGIO_H */