Merge release-5-0 into master
[alexxy/gromacs.git] / src / gromacs / trajectoryanalysis / modules / nsc.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5  * Copyright (c) 2001-2004, The GROMACS development team.
6  * Copyright (c) 2013,2014, by the GROMACS development team, led by
7  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
8  * and including many others, as listed in the AUTHORS file in the
9  * top-level source directory and at http://www.gromacs.org.
10  *
11  * GROMACS is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public License
13  * as published by the Free Software Foundation; either version 2.1
14  * of the License, or (at your option) any later version.
15  *
16  * GROMACS is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with GROMACS; if not, see
23  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
25  *
26  * If you want to redistribute modifications to GROMACS, please
27  * consider that scientific software is very special. Version
28  * control is crucial - bugs must be traceable. We will be happy to
29  * consider code for inclusion in the official distribution, but
30  * derived work must not be called official GROMACS. Details are found
31  * in the README & COPYING files - if they are missing, get the
32  * official version at http://www.gromacs.org.
33  *
34  * To help us fund GROMACS development, we humbly ask that you cite
35  * the research papers on the package. Check out http://www.gromacs.org.
36  */
37 #ifndef GMX_TRAJECTORYANALYSIS_NSC_H
38 #define GMX_TRAJECTORYANALYSIS_NSC_H
39
40 #include "gromacs/legacyheaders/types/simple.h"
41
42 #define FLAG_DOTS       01
43 #define FLAG_VOLUME     02
44 #define FLAG_ATOM_AREA  04
45
46 #ifdef __cplusplus
47 extern "C"
48 {
49 #endif
50
51 int nsc_dclm_pbc(const rvec *coords, real *radius, int nat,
52                  int  densit, int mode,
53                  real *value_of_area, real **at_area,
54                  real *value_of_vol,
55                  real **lidots, int *nu_dots,
56                  atom_id index[], int ePBC, matrix box);
57
58 /*
59     User notes :
60    The input requirements :
61    The arrays with atom coordinates and radii are thought to start
62    with index 0, i.e., places 0, 1, and 2 are the x-, y-, and z-
63    coordinates of the zero-th atom and place 0 in the other array
64    is its radius.
65
66    PLEASE TAKE INTO ACCOUNT THAT THE RADII GIVEN HERE ARE DIRECTLY
67    USED FOR SURFACE CALCULATION. NSC does not increment with a probe
68    radius.
69
70    The user can define any number of dots. The program selects a
71    dot density that is the lowest possible with at least the required
72    number of dots. The points are distributed in accordance with the
73    icosahedron-based or the dodecahedron-based method as described in
74    ref. 1.
75
76    The output requirements are :
77    1 and 3 :  pointer to an existing real
78    2 and 4 :  pointer to an existing pointer to real
79              NSC allocates memory for an array
80    5       :  pointer to an existing integer
81
82    The subroutine NSC makes use of variant 2 described in reference 1.
83    By selecting the necessary output via flags, the requirements for
84    cpu-time and computer memory can be adapted to the actual needs.
85
86    Example : flag = FLAG_VOLUME | FLAG_ATOM_AREA | FLAG_DOTS
87           The routine calculates the area, volume and the dot surface. The
88           program allocates arrays for the atomwise areas and for the surface
89           dots. The addresses are returned in the pointers to pointers to
90           real.
91           This variant is not recommended because normally the dot surface
92           is needed for low point density (e.g.42) at which area and volume
93           are inaccurate. The sign "|" is used as binary AND !
94
95           flag = FLAG_VOLUME | FLAG_ATOM_AREA
96           In this case the large arrays for storing the surface dots
97           are not allocated. A large point number of the fully accessible
98           sphere can be selected. Good accuracy is already achieved with
99           600-700 points per sphere (accuracy of about 1.5 square Angstrem
100           per atomic sphere).
101           Output pointers 4 and 5 may be NULL.
102
103           flag = FLAG_DOTS
104           Only the dot surface is produced.
105           Output pointers 2 and 3 may be NULL.
106
107    The output pointer 1 cannot be set to NULL in any circumstances. The
108    overall area value is returned in every mode.
109
110    All files calling NSC should include nsc.h !!
111
112
113    Example for calling NSC (contents of user file):
114
115    ...
116    #include "nsc.h"
117
118    int routine_calling_NSC(int n_atom, real *coordinates, real *radii) {
119    real area, volume, *atomwise_area, *surface_dots;
120    int    i, density = 300, n_dots;
121
122    ...
123
124    for (i=0; i<n_atom; i++) {
125    radii[i]  += 1.4      /# add the probe radius if necessary #/
126
127    if (NSC(coordinates, radii, n_atom, density,
128           FLAG_AREA | FLAG_VOLUME | FLAG_DOTS,
129           &area, &atomwise_area, &volume, &surface_dots, &n_dots))
130     printf("error occured\n");
131     return 1;
132     }
133
134    ...
135
136    /# do something with areas, volume and surface dots #/
137
138    ...
139
140    return 0;
141    }
142
143  */
144
145 #ifdef __cplusplus
146 }
147 #endif
148
149 #endif