Merge branch 'master' of git@git.gromacs.org:gromacs
[gromacs/rigid-bodies.git] / include / enxio.h
blob57e612affded4e9f1dbfdc3337fd30de802b83df
1 /*
2 *
3 * This source code is part of
4 *
5 * G R O M A C S
6 *
7 * GROningen MAchine for Chemical Simulations
8 *
9 * VERSION 3.2.0
10 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12 * Copyright (c) 2001-2004, The GROMACS development team,
13 * check out http://www.gromacs.org for more information.
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * If you want to redistribute modifications, please consider that
21 * scientific software is very special. Version control is crucial -
22 * bugs must be traceable. We will be happy to consider code for
23 * inclusion in the official distribution, but derived work must not
24 * be called official GROMACS. Details are found in the README & COPYING
25 * files - if they are missing, get the official version at www.gromacs.org.
27 * To help us fund GROMACS development, we humbly ask that you cite
28 * the papers on the package - you can find them in the top README file.
30 * For more info, check our website at http://www.gromacs.org
32 * And Hey:
33 * Gromacs Runs On Most of All Computer Systems
36 #ifndef _enxio_h
37 #define _enxio_h
39 #ifdef HAVE_CONFIG_H
40 #include <config.h>
41 #endif
43 #include "sysstuff.h"
44 #include "typedefs.h"
45 #include "pbc.h"
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
51 /**************************************************************
53 * The routines in the corresponding c-file enxio.c
54 * are based on the lower level routines in gmxfio.c
55 * The integer file pointer returned from open_enx
56 * can also be used with the routines in gmxfio.h
58 **************************************************************/
60 typedef struct {
61 char *name;
62 char *unit;
63 } gmx_enxnm_t;
65 /*
66 * Index for the additional blocks in the energy file.
67 * Blocks can be added without sacrificing backward and forward
68 * compatibility of the energy files.
70 enum {
71 enxOR, /* Time and ensemble averaged data for orientation restraints */
72 enxORI, /* Instantaneous data for orientation restraints */
73 enxORT, /* Order tensor(s) for orientation restraints */
74 enxNR /* Total number of extra blocks in the current code,
75 * note that the enxio code can read files written by
76 * future code which contain more blocks.
80 typedef struct {
81 double t; /* Timestamp of this frame */
82 gmx_large_int_t step; /* MD step */
83 gmx_large_int_t nsteps; /* The number of steps between frames */
84 gmx_large_int_t nsum; /* The number of terms for the sums in ener */
85 int nre; /* Number of energies */
86 int ndisre; /* Number of distance restraints */
87 int nblock; /* Number of following energy blocks */
88 int *nr; /* Number of things in additional blocks (nblock) */
89 int e_size; /* Size (in bytes) of energies */
90 int d_size; /* Size (in bytes) of disre blocks */
91 int nr_alloc; /* Allocated size of nr and block */
92 int e_alloc; /* Allocated size (in elements) of ener */
93 int d_alloc; /* Allocated size (in elements) of rav and rt */
94 int *b_alloc; /* Allocated size (in elements) of each block */
95 t_energy *ener; /* The energies */
96 real *disre_rm3tav; /* Time averaged data for distance restraints */
97 real *disre_rt; /* Instantaneous data for distance restraints */
98 real **block; /* Additional energy blocks (nblock x b_alloc[b]) */
99 } t_enxframe;
101 /* file handle */
102 typedef struct ener_file *ener_file_t;
105 * An energy file is read like this:
107 * ener_file_t fp;
108 * t_enxframe *fr;
110 * fp = open_enx(...);
111 * do_enxnms(fp,...);
112 * snew(fr,1);
113 * while (do_enx(fp,fr)) {
114 * ...
116 * free_enxframe(fr);
117 * sfree(fr);
120 /* New energy reading and writing interface */
121 extern void free_enxframe(t_enxframe *fr);
122 /* Frees all allocated memory in fr */
124 extern ener_file_t open_enx(const char *fn,const char *mode);
126 extern int enx_file_pointer(const ener_file_t ef);
128 extern void close_enx(ener_file_t ef);
130 extern void do_enxnms(ener_file_t ef,int *nre,gmx_enxnm_t **enms);
132 extern void free_enxnms(int n,gmx_enxnm_t *nms);
133 /* Frees nms and all strings in it */
135 extern bool do_enx(ener_file_t ef,t_enxframe *fr);
136 /* Reads enx_frames, memory in fr is (re)allocated if necessary */
138 extern void get_enx_state(const char *fn, real t,
139 gmx_groups_t *groups, t_inputrec *ir,
140 t_state *state);
142 * Reads state variables from enx file fn at time t.
143 * atoms and ir are required for determining which things must be read.
144 * Currently pcoupl and tcoupl state are read from enx.
147 #ifdef __cplusplus
149 #endif
151 #endif /* _enerio_h */