Merge branch 'master' of git.gromacs.org:gromacs
[gromacs/rigid-bodies.git] / include / enxio.h
blob04e2677c17b52288d77752f135c230077c9f999f
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"
46 #include "gmxfio.h"
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
52 /**************************************************************
54 * The routines in the corresponding c-file enxio.c
55 * are based on the lower level routines in gmxfio.c
56 * The integer file pointer returned from open_enx
57 * can also be used with the routines in gmxfio.h
59 **************************************************************/
61 typedef struct {
62 char *name;
63 char *unit;
64 } gmx_enxnm_t;
66 /*
67 * Index for the additional blocks in the energy file.
68 * Blocks can be added without sacrificing backward and forward
69 * compatibility of the energy files.
71 enum {
72 enxOR, /* Time and ensemble averaged data for orientation restraints */
73 enxORI, /* Instantaneous data for orientation restraints */
74 enxORT, /* Order tensor(s) for orientation restraints */
75 enxNR /* Total number of extra blocks in the current code,
76 * note that the enxio code can read files written by
77 * future code which contain more blocks.
81 typedef struct {
82 double t; /* Timestamp of this frame */
83 gmx_large_int_t step; /* MD step */
84 gmx_large_int_t nsteps; /* The number of steps between frames */
85 int nsum; /* The number of terms for the sums in ener */
86 int nre; /* Number of energies */
87 int ndisre; /* Number of distance restraints */
88 int nblock; /* Number of following energy blocks */
89 int *nr; /* Number of things in additional blocks (nblock) */
90 int e_size; /* Size (in bytes) of energies */
91 int d_size; /* Size (in bytes) of disre blocks */
92 int nr_alloc; /* Allocated size of nr and block */
93 int e_alloc; /* Allocated size (in elements) of ener */
94 int d_alloc; /* Allocated size (in elements) of rav and rt */
95 int *b_alloc; /* Allocated size (in elements) of each block */
96 t_energy *ener; /* The energies */
97 real *disre_rm3tav; /* Time averaged data for distance restraints */
98 real *disre_rt; /* Instantaneous data for distance restraints */
99 real **block; /* Additional energy blocks (nblock x b_alloc[b]) */
100 } t_enxframe;
102 /* file handle */
103 typedef struct ener_file *ener_file_t;
106 * An energy file is read like this:
108 * ener_file_t fp;
109 * t_enxframe *fr;
111 * fp = open_enx(...);
112 * do_enxnms(fp,...);
113 * snew(fr,1);
114 * while (do_enx(fp,fr)) {
115 * ...
117 * free_enxframe(fr);
118 * sfree(fr);
121 /* New energy reading and writing interface */
122 extern void free_enxframe(t_enxframe *fr);
123 /* Frees all allocated memory in fr */
125 extern ener_file_t open_enx(const char *fn,const char *mode);
127 extern t_fileio *enx_file_pointer(const ener_file_t ef);
129 extern void close_enx(ener_file_t ef);
131 extern void do_enxnms(ener_file_t ef,int *nre,gmx_enxnm_t **enms);
133 extern void free_enxnms(int n,gmx_enxnm_t *nms);
134 /* Frees nms and all strings in it */
136 extern bool do_enx(ener_file_t ef,t_enxframe *fr);
137 /* Reads enx_frames, memory in fr is (re)allocated if necessary */
139 extern void get_enx_state(const char *fn, real t,
140 gmx_groups_t *groups, t_inputrec *ir,
141 t_state *state);
143 * Reads state variables from enx file fn at time t.
144 * atoms and ir are required for determining which things must be read.
145 * Currently pcoupl and tcoupl state are read from enx.
148 #ifdef __cplusplus
150 #endif
152 #endif /* _enerio_h */