4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
17 * GROMACS: A message-passing parallel molecular dynamics implementation
18 * H.J.C. Berendsen, D. van der Spoel and R. van Drunen
19 * Comp. Phys. Comm. 91, 43-56 (1995)
21 * Also check out our WWW page:
22 * http://md.chem.rug.nl/~gmx
27 * Good ROcking Metal Altar for Chronical Sinners
33 static char *SRCID_pbc_h = "$Id$";
40 #ident "@(#) pbc.h 1.17 2/2/97"
41 #endif /* HAVE_IDENT */
49 #define BOX_MARGIN 0.5001
50 /* margin factor for checking if the box is too skewed */
52 #define TRICLINIC(box) (box[YY][XX]!=0 || box[ZZ][XX]!=0 || box[ZZ][YY]!=0)
58 extern char *check_box(matrix box);
59 /* Returns NULL if the box is supported by Gromacs.
60 * Otherwise is returns a string with the problem.
63 extern void init_pbc(matrix box,bool bNotUsed);
64 /* Initiate the periodic boundary conditions. */
66 extern void pbc_dx(const rvec x1, const rvec x2, rvec dx);
67 /* Calculate the correct distance vector from x1 and x2 and put it in
68 * dx. init_pbc must be called before ever calling this routine
69 * (this is done by put_charge_groups_in_box).
72 extern bool image_rect(ivec xi,ivec xj,ivec box_size,
73 real rlong2,int *shift,real *r2);
74 /* Calculate the distance between xi and xj for a rectangular box.
75 * When the distance is SMALLER than rlong2 return TRUE, return
76 * the shift code in shift and the distance in r2. When the distance is
77 * >= rlong2 return FALSE;
78 * It is assumed that rlong2 is scaled the same way as the ivecs xi and xj.
81 extern bool image_tri(ivec xi,ivec xj,imatrix box,
82 real rlong2,int *shift,real *r2);
83 /* Calculate the distance between xi and xj for a triclinic box.
84 * When the distance is SMALLER than rlong2 return TRUE, return
85 * the shift code in shift and the distance in r2. When the distance is
86 * >= rlong2 return FALSE;
87 * It is assumed that rlong2 is scaled the same way as the ivecs xi and xj.
90 extern bool image_cylindric(ivec xi,ivec xj,ivec box_size,real rlong2,
92 /* Calculate the distance between xi and xj for a rectangular box
93 * using a cylindric cutoff for long-range only.
94 * When the distance is SMALLER than rlong2 (in X and Y dir.)
96 * the shift code in shift and the distance in r2. When the distance is
97 * >= rlong2 return FALSE;
98 * It is assumed that rlong2 is scaled the same way as the ivecs xi and xj.
101 extern void calc_shifts(matrix box,rvec box_size,rvec shift_vec[],
103 /* This routine calculates ths shift vectors necessary to use the
104 * ns routine. Note that for the truncated octahedron case too many
105 * shift vectors can be calculated: The ones for which exactly
106 * 2 of the k,l,m indexes are not 0 (12 vectors lying along the box
107 * edges. This can be compensated for by removing all the shift_vecs with
108 * (k+l+m) even. This is a feature of the way in which the counting is
109 * done. It implies that, when using truncated octahedron,
110 * the shift codes 1,3,5,7,9,11,15,17,19,21,23,25 should never occur,
111 * that is, every second entry, EXCEPT the central box.
114 extern void calc_cgcm(FILE *log,int cg0,int cg1,t_block *cgs,
115 rvec pos[],rvec cg_cm[]);
116 /* Routine to compute centers of geometry of charge groups. No periodicity
120 extern void put_charge_groups_in_box (FILE *log,int cg0,int cg1,bool bNotUsed,
121 matrix box,rvec box_size,t_block *cgs,
125 /* This routine puts charge groups in the periodic box, keeping them
129 extern void calc_box_center(matrix box,rvec box_center);
130 /* Calculates the center of the box */
132 extern void calc_triclinic_images(matrix box,rvec img[]);
133 /* Calculates the NTRICIMG box images */
135 extern void calc_compact_unitcell_vertices(matrix box,rvec vert[]);
136 /* Calculates the NCUCVERT vertices of a compact unitcell */
138 extern int *compact_unitcell_edges(void);
139 /* Return an array of unitcell edges of length NCUCEDGE*2,
140 * this is an index in vert[], which is calculated by calc_unitcell_vertices.
141 * The index consists of NCUCEDGE pairs of vertex indices.
142 * The index does not change, so it needs to be retrieved only once.
145 extern void put_atoms_in_box(matrix box,int natoms,rvec x[]);
146 /* This puts ALL atoms in the box, not caring about charge groups!
147 * Also works for triclinic cells.
150 extern void put_atoms_in_triclinic_unitcell(matrix box,int natoms,rvec x[]);
151 /* This puts ALL atoms in the triclinic unit cell, centered around the
152 * box center as calculated by calc_box_center.
155 extern void put_atoms_in_compact_unitcell(matrix box,int natoms,rvec x[]);
156 /* This puts ALL atoms at the closest distance for the center of the box
157 * as calculated by calc_box_center.