Moved genbox utility to preprocessing module from analysis module.
Renamed its addconf implementation files. Fixed necessary #include
dependencies. Made several functions static.
Renamed gbutil.[ch] to conformation-utilities.[ch], because they are
not exclusive to anything abbreviated "gb." These are mostly used by
gmxpreprocess, but also mdlib/tpi.c, and the header file is not really
useful to install, so the only current place they should move is
gmxlib. Removed unused orient(). Renamed genconf() and gen_box() to
avoid confusion with the utilities of those names. Moved the new
make_new_conformation into genbox.cpp because it is only used there.
Made two functions static. Removed unused (maybe broken?) NTB
parameter of the new make_new_box() function. Removed some debug
code that used a print function in a different compilation unit.
Change-Id: I33d15b2df63c9422ce241782a922145f4626b0fb
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2008, The GROMACS development team.
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
int
gmx_filter(int argc, char *argv[]);
-int
-gmx_genbox(int argc, char *argv[]);
-
int
gmx_genconf(int argc, char *argv[]);
#include "index.h"
#include "vec.h"
#include "typedefs.h"
-#include "gbutil.h"
+#include "gromacs/gmxlib/conformation-utilities.h"
#include "physics.h"
#include "atomprop.h"
#include "gromacs/fileio/tpxio.h"
* the research papers on the package. Check out http://www.gromacs.org.
*/
/* This file is completely threadsafe - keep it that way! */
+#include "conformation-utilities.h"
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "vec.h"
#include "gmx_fatal.h"
#include "pbc.h"
-#include "gbutil.h"
static real dist2(t_pbc *pbc, rvec x, rvec y)
{
return norm2(dx);
}
-real distance_to_z(rvec x)
+static real distance_to_z(rvec x)
{
return (sqr(x[XX])+sqr(x[YY]));
} /*distance_to_z()*/
}
}
-void orient(int natom, rvec *x, rvec *v, rvec angle, matrix box)
-{
- real longest, rij, rzi;
- int i, j, m, max_i = 0, max_j = 0;
- rvec origin;
- int temp;
- real alfa = 0, beta = 0, gamma = 0;
- t_pbc pbc;
-
- set_pbc(&pbc, -1, box);
-
- /*first i am going to look for the longest atom-atom distance*/
- longest = dist2(&pbc, x[0], x[1]);
- i = 0;
- j = 1;
- for (i = 0; (i < natom); i++)
- {
- for (j = 0; (j < natom); j++)
- {
- rij = dist2(&pbc, x[i], x[j]);
- if (rij > longest)
- {
- max_i = i;
- max_j = j;
- longest = rij;
- }
- }
- }
- /* first check if x[max_i]<x[max_j] else swap*/
- if (x[max_i][2] > x[max_j][2])
- {
- temp = max_i;
- max_i = max_j;
- max_j = temp;
- }
-
- /*set the origin to x[i]*/
- for (m = 0; (m < DIM); m++)
- {
- origin[m] = x[max_i][m];
- }
- for (i = 0; (i < natom); i++)
- {
- for (m = 0; (m < DIM); m++)
- {
- x[i][m] -= origin[m];
- }
- }
-
- /* calculate the rotation angles alfa(x_axis) and beta(y_axis)
- * the rotation angles must be calculated clockwise looking
- * along the rotation axis to the origin*
- * alfa (x-axis)
- */
- alfa = atan(x[max_j][ZZ]/x[max_j][YY])-M_PI_2;
- beta = M_PI_2-atan(x[max_j][ZZ]/x[max_j][XX]);
- rotate_conf(natom, x, v, alfa, beta, gamma);
-
- /* now search the longest distance for rotation along the z_axis */
- longest = distance_to_z(x[0]);
- max_i = 0;
- for (i = 1; (i < natom); i++)
- {
- rzi = distance_to_z(x[i]);
- if (rzi > longest)
- {
- longest = rzi;
- max_i = i;
- }
- }
- gamma = atan(x[max_i][YY]/x[max_i][XX])-M_PI_2;
- rotate_conf(natom, x, v, 0, 0, gamma);
- angle[0] = alfa;
- angle[1] = beta;
- angle[2] = gamma;
-} /*orient()*/
-
-
-void genconf(t_atoms *atoms, rvec *x, rvec *v, real *r, matrix box, ivec n_box)
-{
- int i, ix, iy, iz, m, j, imol, offset;
- rvec delta;
- int nmol;
-
- nmol = n_box[XX]*n_box[YY]*n_box[ZZ];
-
- /*print message*/
- fprintf(stderr, "Generating configuration\n");
- imol = 0;
- for (ix = 0; (ix < n_box[XX]); ix++)
- {
- delta[XX] = ix*box[XX][XX];
- for (iy = 0; (iy < n_box[YY]); iy++)
- {
- delta[YY] = iy*box[YY][YY];
- for (iz = 0; (iz < n_box[ZZ]); iz++)
- {
- delta[ZZ] = iz*box[ZZ][ZZ];
- offset = imol*atoms->nr;
- for (i = 0; (i < atoms->nr); i++)
- {
- for (m = 0; (m < DIM); m++)
- {
- x[offset+i][m] = delta[m]+x[i][m];
- }
- if (v)
- {
- for (m = 0; (m < DIM); m++)
- {
- v[offset+i][m] = v[i][m];
- }
- }
- r[offset+i] = r[i];
- }
- imol++;
- }
- }
- }
- for (i = 1; (i < nmol); i++)
- {
- int offs = i*atoms->nr;
- int offsres = i*atoms->nres;
- for (j = 0; (j < atoms->nr); j++)
- {
- atoms->atomname[offs+j] = atoms->atomname[j];
- atoms->atom[offs+j].resind = atoms->atom[j].resind + offsres;
- atoms->resinfo[atoms->atom[offs+j].resind] =
- atoms->resinfo[atoms->atom[j].resind];
- atoms->resinfo[atoms->atom[offs+j].resind].nr += offsres;
- }
- }
- atoms->nr *= nmol;
- atoms->nres *= nmol;
- for (i = 0; i < DIM; i++)
- {
- for (j = 0; j < DIM; j++)
- {
- box[j][i] *= n_box[j];
- }
- }
-} /*genconf()*/
-
-/*gen_box() generates a box around a configuration*/
-void gen_box(int NTB, int natoms, rvec *x, matrix box, rvec box_space,
- gmx_bool bCenter)
+/* Make a new box around a configuration*/
+void make_new_box(int natoms, rvec *x, matrix box, rvec box_space,
+ gmx_bool bCenter)
{
int i, m;
rvec xmin, xmax;
box[m][m] = xmax[m]-xmin[m]+2*box_space[m];
}
- /*calculate the box size if NTB=1 (truncated octahedron)*/
- if (NTB == 1)
- {
- max_box = box[0][0];
- for (m = 0; (m < DIM); m++)
- {
- max_box = max(max_box, box[m][m]);
- }
- for (m = 0; (m < DIM); m++)
- {
- box[m][m] = max_box;
- }
- }
-
/*move the molecule to the center of the box*/
if (bCenter)
{
}
}
}
-
-
-#ifdef DEBUG
- /* print data to check this */
- print_stat(x, natoms, box);
-#endif
-} /*gen_box()*/
+}
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2010, by the GROMACS development team, led by
+ * Copyright (c) 2010,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
+#ifndef GMX_CONFORMATION_UTILITIES_H
+#define GMX_CONFORMATION_UTILITIES_H
+
#include "typedefs.h"
#ifdef __cplusplus
void rotate_conf(int natom, rvec *x, rvec *v, real alfa, real beta, real gamma);
/*rotate() rotates a configuration alfa degrees around the x_axis and beta degrees around the y_axis, *v can be NULL */
-void orient(int natom, rvec *x, rvec *v, rvec angle, matrix box);
-/*orient() rotates a configuration until the largest atom-atom distance is
- * placed along the z-axis and the second largest distance is placed along
- * the y-axis. Finally the third longest distance is placed along the x-axis
- */
-
-void genconf(t_atoms *atoms, rvec *x, rvec *v, real *r, matrix box, ivec n_box);
-/*genconf() generates a new configuration by adding boxes*/
-void gen_box(int NTB, int natoms, rvec *x, matrix box, rvec box_space,
- gmx_bool bCenter);
-/* gen_box() generates a box around a configuration, box_space is optional
- * extra space around it. If NTB = 1 then a truncated octahedon will be
- * generated (don't!) if bCenter then coordinates will be centered in the
- * genereated box
+void make_new_box(int natoms, rvec *x, matrix box, rvec box_space,
+ gmx_bool bCenter);
+/* Generates a box around a configuration, box_space is optional extra
+ * space around it. If bCenter then coordinates will be centered in
+ * the generated box
*/
#ifdef __cplusplus
}
#endif
+
+#endif
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
+#include "genbox-addconf.h"
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "vec.h"
#include "macros.h"
#include "smalloc.h"
-#include "addconf.h"
#include "force.h"
-#include "gstat.h"
#include "names.h"
#include "nsgrid.h"
#include "mdatoms.h"
static t_forcerec *fr = NULL;
-void do_nsgrid(FILE *fp, gmx_bool bVerbose,
- matrix box, rvec x[], t_atoms *atoms, real rlong,
- const output_env_t oenv)
+static void do_nsgrid(FILE *fp, gmx_bool bVerbose,
+ matrix box, rvec x[], t_atoms *atoms, real rlong,
+ const output_env_t oenv)
{
gmx_mtop_t *mtop;
gmx_localtop_t *top;
}
}
-gmx_bool bXor(gmx_bool b1, gmx_bool b2)
+static gmx_bool bXor(gmx_bool b1, gmx_bool b2)
{
return (b1 && !b2) || (b2 && !b1);
}
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
+#ifndef GMX_GMXPREPROCESS_GENBOX_ADDCONF_H
+#define GMX_GMXPREPROCESS_GENBOX_ADDCONF_H
+
#include "typedefs.h"
#ifdef __cplusplus
#ifdef __cplusplus
}
#endif
+
+#endif
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
+#include "genbox.h"
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gmx_fatal.h"
#include "gromacs/commandline/pargs.h"
#include "vec.h"
-#include "gbutil.h"
-#include "addconf.h"
+#include "gromacs/gmxlib/conformation-utilities.h"
+#include "genbox-addconf.h"
#include "gromacs/fileio/pdbio.h"
#include "pbc.h"
-#include "gmx_ana.h"
#include "xvgr.h"
#ifdef DEBUG
-void print_stat(rvec *x, int natoms, matrix box)
+static void print_stat(rvec *x, int natoms, matrix box)
{
int i, m;
rvec xmin, xmax;
int res0;
} t_moltypes;
-void sort_molecule(t_atoms **atoms_solvt, rvec *x, rvec *v, real *r)
+static void sort_molecule(t_atoms **atoms_solvt, rvec *x, rvec *v, real *r)
{
int atnr, i, j, moltp = 0, nrmoltypes, resi_o, resi_n, resnr;
t_moltypes *moltypes;
sfree(moltypes);
}
-void rm_res_pbc(t_atoms *atoms, rvec *x, matrix box)
+static void rm_res_pbc(t_atoms *atoms, rvec *x, matrix box)
{
int i, start, n, d, nat;
rvec xcg;
}
}
-/* This is a (maybe) slow workaround to avoid the neighbor searching in addconf.c, which
- * leaks memory (May 2012). The function could be deleted as soon as the momory leaks
- * in addconf.c are fixed.
+/* This is a (maybe) slow workaround to avoid the neighbor searching in genbox_addconf.c, which
+ * leaks memory (May 2012). The function could be deleted as soon as the memory leaks
+ * there are fixed.
* However, when inserting a small molecule in a system containing not too many atoms,
- * allPairsDistOk is probably even faster than addconf.c
+ * allPairsDistOk is probably even faster than the other code.
*/
static gmx_bool
allPairsDistOk(t_atoms *atoms, rvec *x, real *r,
offset_x[XX] = box[XX][XX] * gmx_rng_uniform_real(rng);
offset_x[YY] = box[YY][YY] * gmx_rng_uniform_real(rng);
offset_x[ZZ] = box[ZZ][ZZ] * gmx_rng_uniform_real(rng);
- gen_box(0, atoms_insrt.nr, x_n, box_insrt, offset_x, TRUE);
+ make_new_box(atoms_insrt.nr, x_n, box_insrt, offset_x, TRUE);
if (!in_box(&pbc, x_n[0]) || !in_box(&pbc, x_n[atoms_insrt.nr-1]))
{
continue;
return title_insrt;
}
+/* Make a new configuration by adding boxes*/
+static void make_new_conformation(t_atoms *atoms, rvec *x, rvec *v, real *r, matrix box, ivec n_box)
+{
+ int i, ix, iy, iz, m, j, imol, offset;
+ rvec delta;
+ int nmol;
+
+ nmol = n_box[XX]*n_box[YY]*n_box[ZZ];
+
+ /*print message*/
+ fprintf(stderr, "Generating configuration\n");
+ imol = 0;
+ for (ix = 0; (ix < n_box[XX]); ix++)
+ {
+ delta[XX] = ix*box[XX][XX];
+ for (iy = 0; (iy < n_box[YY]); iy++)
+ {
+ delta[YY] = iy*box[YY][YY];
+ for (iz = 0; (iz < n_box[ZZ]); iz++)
+ {
+ delta[ZZ] = iz*box[ZZ][ZZ];
+ offset = imol*atoms->nr;
+ for (i = 0; (i < atoms->nr); i++)
+ {
+ for (m = 0; (m < DIM); m++)
+ {
+ x[offset+i][m] = delta[m]+x[i][m];
+ }
+ if (v)
+ {
+ for (m = 0; (m < DIM); m++)
+ {
+ v[offset+i][m] = v[i][m];
+ }
+ }
+ r[offset+i] = r[i];
+ }
+ imol++;
+ }
+ }
+ }
+ for (i = 1; (i < nmol); i++)
+ {
+ int offs = i*atoms->nr;
+ int offsres = i*atoms->nres;
+ for (j = 0; (j < atoms->nr); j++)
+ {
+ atoms->atomname[offs+j] = atoms->atomname[j];
+ atoms->atom[offs+j].resind = atoms->atom[j].resind + offsres;
+ atoms->resinfo[atoms->atom[offs+j].resind] =
+ atoms->resinfo[atoms->atom[j].resind];
+ atoms->resinfo[atoms->atom[offs+j].resind].nr += offsres;
+ }
+ }
+ atoms->nr *= nmol;
+ atoms->nres *= nmol;
+ for (i = 0; i < DIM; i++)
+ {
+ for (j = 0; j < DIM; j++)
+ {
+ box[j][i] *= n_box[j];
+ }
+ }
+}
+
static void add_solv(const char *fn, t_atoms *atoms, rvec **x, rvec **v, real **r,
int ePBC, matrix box,
gmx_atomprop_t aps,
srenew(r_solvt, atoms_solvt->nr*nmol);
/* generate a new solvent configuration */
- genconf(atoms_solvt, x_solvt, v_solvt, r_solvt, box_solvt, n_box);
+ make_new_conformation(atoms_solvt, x_solvt, v_solvt, r_solvt, box_solvt, n_box);
#ifdef DEBUG
print_stat(x_solvt, atoms_solvt->nr, box_solvt);
--- /dev/null
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+#ifndef GMX_GMXPREPROCESS_GENBOX_H
+#define GMX_GMXPREPROCESS_GENBOX_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#if 0
+}
+#endif
+
+int gmx_genbox(int argc, char *argv[]);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
#include "resall.h"
#include "pdb2top.h"
#include "ter_db.h"
-#include "gbutil.h"
+#include "gromacs/gmxlib/conformation-utilities.h"
#include "genhydro.h"
#include "readinp.h"
#include "atomprop.h"
clear_rvec(box_space);
if (box[0][0] == 0)
{
- gen_box(0, atoms->nr, x, box, box_space, FALSE);
+ make_new_box(atoms->nr, x, box, box_space, FALSE);
}
write_sto_conf(ftp2fn(efSTO, NFILE, fnm), title, atoms, x, NULL, ePBC, box);
#include "ns.h"
#include "mtop_util.h"
#include "pme.h"
-#include "gbutil.h"
+#include "gromacs/gmxlib/conformation-utilities.h"
#include "gromacs/fileio/confio.h"
#include "gromacs/fileio/gmxfio.h"
#include "gromacs/gmxana/gmx_ana.h"
#include "gromacs/gmxpreprocess/grompp.h"
+#include "gromacs/gmxpreprocess/genbox.h"
#include "gromacs/gmxpreprocess/pdb2gmx.h"
#include "gromacs/gmxpreprocess/protonate.h"
#include "gromacs/gmxpreprocess/x2top.h"