Update copyright statements and change license to LGPL
[alexxy/gromacs.git] / src / tools / 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  * check out http://www.gromacs.org for more information.
7  * Copyright (c) 2012, by the GROMACS development team, led by
8  * David van der Spoel, Berk Hess, Erik Lindahl, and including many
9  * others, as listed in the AUTHORS file in the top-level source
10  * directory and at http://www.gromacs.org.
11  *
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.
16  *
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.
21  *
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.
26  *
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.
34  *
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.
37  */
38 #include "typedefs.h"
39
40 #define FLAG_DOTS       01
41 #define FLAG_VOLUME     02
42 #define FLAG_ATOM_AREA  04
43
44
45
46 extern int nsc_dclm_pbc(rvec *coords, real *radius, int nat,
47                         int  densit, int mode,
48                         real *value_of_area, real **at_area,
49                         real *value_of_vol,
50                         real **lidots, int *nu_dots,
51                         atom_id index[],int ePBC,matrix box);
52
53 /* 
54     User notes :
55 The input requirements :
56   The arrays with atom coordinates and radii are thought to start
57   with index 0, i.e., places 0, 1, and 2 are the x-, y-, and z-
58   coordinates of the zero-th atom and place 0 in the other array
59   is its radius.
60
61   PLEASE TAKE INTO ACCOUNT THAT THE RADII GIVEN HERE ARE DIRECTLY
62   USED FOR SURFACE CALCULATION. NSC does not increment with a probe 
63   radius.
64
65   The user can define any number of dots. The program selects a
66   dot density that is the lowest possible with at least the required
67   number of dots. The points are distributed in accordance with the
68   icosahedron-based or the dodecahedron-based method as described in
69   ref. 1.
70
71 The output requirements are :
72   1 and 3 :  pointer to an existing real
73   2 and 4 :  pointer to an existing pointer to real
74              NSC allocates memory for an array
75   5       :  pointer to an existing integer
76
77 The subroutine NSC makes use of variant 2 described in reference 1.
78 By selecting the necessary output via flags, the requirements for
79 cpu-time and computer memory can be adapted to the actual needs.
80
81 Example : flag = FLAG_VOLUME | FLAG_ATOM_AREA | FLAG_DOTS
82           The routine calculates the area, volume and the dot surface. The
83           program allocates arrays for the atomwise areas and for the surface
84           dots. The addresses are returned in the pointers to pointers to
85           real. 
86           This variant is not recommended because normally the dot surface
87           is needed for low point density (e.g.42) at which area and volume 
88           are inaccurate. The sign "|" is used as binary AND !
89
90           flag = FLAG_VOLUME | FLAG_ATOM_AREA
91           In this case the large arrays for storing the surface dots
92           are not allocated. A large point number of the fully accessible
93           sphere can be selected. Good accuracy is already achieved with
94           600-700 points per sphere (accuracy of about 1.5 square Angstrem
95           per atomic sphere).
96           Output pointers 4 and 5 may be NULL.
97
98           flag = FLAG_DOTS
99           Only the dot surface is produced.
100           Output pointers 2 and 3 may be NULL.
101
102 The output pointer 1 cannot be set to NULL in any circumstances. The
103 overall area value is returned in every mode.
104
105 All files calling NSC should include nsc.h !!
106
107
108 Example for calling NSC (contents of user file): 
109
110   ...
111 #include "nsc.h"
112
113 int routine_calling_NSC(int n_atom, real *coordinates, real *radii) {
114   real area, volume, *atomwise_area, *surface_dots;
115   int    i, density = 300, n_dots;
116
117   ...
118
119   for (i=0; i<n_atom; i++) {
120    radii[i]  += 1.4      /# add the probe radius if necessary #/
121
122   if (NSC(coordinates, radii, n_atom, density,
123           FLAG_AREA | FLAG_VOLUME | FLAG_DOTS,
124           &area, &atomwise_area, &volume, &surface_dots, &n_dots))
125     printf("error occured\n");
126     return 1;
127     }
128
129   ...
130
131 /# do something with areas, volume and surface dots #/
132
133   ...
134
135   return 0;
136   }
137
138 */