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