#include "gromacs/legacyheaders/typedefs.h"
#include "gromacs/legacyheaders/types/ifunc.h"
#include "gromacs/math/vec.h"
+#include "gromacs/pbcutil/boxutilities.h"
#include "gromacs/topology/block.h"
#include "gromacs/topology/mtop_util.h"
#include "gromacs/topology/symtab.h"
#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/mdlib/perf_est.h"
+#include "gromacs/pbcutil/pbc.h"
#include "gromacs/timing/walltime_accounting.h"
#include "gromacs/utility/arraysize.h"
#include "gromacs/utility/baseversion.h"
return state_local;
}
-static void do_box_rel(t_inputrec *ir, matrix box_rel, matrix b, gmx_bool bInit)
-{
- int d, d2;
-
- for (d = YY; d <= ZZ; d++)
- {
- for (d2 = XX; d2 <= (ir->epct == epctSEMIISOTROPIC ? YY : ZZ); d2++)
- {
- /* We need to check if this box component is deformed
- * or if deformation of another component might cause
- * changes in this component due to box corrections.
- */
- if (ir->deform[d][d2] == 0 &&
- !(d == ZZ && d2 == XX && ir->deform[d][YY] != 0 &&
- (b[YY][d2] != 0 || ir->deform[YY][d2] != 0)))
- {
- if (bInit)
- {
- box_rel[d][d2] = b[d][d2]/b[XX][XX];
- }
- else
- {
- b[d][d2] = b[XX][XX]*box_rel[d][d2];
- }
- }
- }
- }
-}
-
-void set_box_rel(t_inputrec *ir, t_state *state)
-{
- /* Make sure the box obeys the restrictions before we fix the ratios */
- correct_box(NULL, 0, state->box, NULL);
-
- clear_mat(state->box_rel);
-
- if (PRESERVE_SHAPE(*ir))
- {
- do_box_rel(ir, state->box_rel, state->box, TRUE);
- }
-}
-
-void preserve_box_shape(t_inputrec *ir, matrix box_rel, matrix b)
-{
- if (PRESERVE_SHAPE(*ir))
- {
- do_box_rel(ir, box_rel, b, FALSE);
- }
-}
-
-real max_cutoff(real cutoff1, real cutoff2)
-{
- if (cutoff1 == 0 || cutoff2 == 0)
- {
- return 0;
- }
- else
- {
- return std::max(cutoff1, cutoff2);
- }
-}
-
void init_df_history(df_history_t *dfhist, int nlambda)
{
int i;
#include "gromacs/mdlib/calc_verletbuf.h"
#include "gromacs/mdlib/compute_io.h"
#include "gromacs/mdlib/perf_est.h"
+#include "gromacs/pbcutil/boxutilities.h"
#include "gromacs/pbcutil/pbc.h"
#include "gromacs/random/random.h"
#include "gromacs/topology/mtop_util.h"
void copy_df_history(df_history_t * df_dest, df_history_t *df_source);
void done_state(t_state *state);
-void set_box_rel(struct t_inputrec *ir, t_state *state);
-/* Set state->box_rel used in mdrun to preserve the box shape */
-
-void preserve_box_shape(struct t_inputrec *ir, matrix box_rel, matrix b);
-/* Preserve the box shape, b can be box or boxv */
-
-real max_cutoff(real cutoff1, real cutoff2);
-/* Returns the maximum of the cut-off's, taking into account that 0=inf. */
-
#ifdef __cplusplus
}
#endif
swapstate_t;
-typedef struct
+typedef struct t_state
{
int natoms;
int ngtc;
#include <limits.h>
#include <cmath>
+
+#include <algorithm>
+
#ifdef GMX_NATIVE_WINDOWS
// for _BitScanReverse()
#include <intrin.h>
return -1;
#endif
}
+
+real max_cutoff(real cutoff1, real cutoff2)
+{
+ if (cutoff1 == 0 || cutoff2 == 0)
+ {
+ return 0;
+ }
+ else
+ {
+ return std::max(cutoff1, cutoff2);
+ }
+}
*/
int gmx_feenableexcept();
+/*! \brief Return cut-off to use
+ *
+ * Takes the max of two cut-offs. However a cut-off of 0
+ * signifies that the cut-off in fact is infinite, and
+ * this requires this special routine.
+ * \param[in] cutoff1 The first cutoff (e.g. coulomb)
+ * \param[in] cutoff2 The second cutoff (e.g. vdw)
+ * \return 0 if either is 0, the normal max of the two otherwise.
+ */
+real max_cutoff(real cutoff1, real cutoff2);
+
#ifdef __cplusplus
}
#endif
#include "gromacs/mdlib/mdrun.h"
#include "gromacs/mdlib/sim_util.h"
#include "gromacs/mdlib/update.h"
+#include "gromacs/pbcutil/boxutilities.h"
#include "gromacs/random/random.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/mdlib/mdrun.h"
#include "gromacs/mdlib/sim_util.h"
#include "gromacs/mdlib/tgroup.h"
+#include "gromacs/pbcutil/boxutilities.h"
#include "gromacs/pbcutil/mshift.h"
#include "gromacs/pbcutil/pbc.h"
#include "gromacs/pulling/pull.h"
--- /dev/null
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2015, 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.
+ */
+/*! \internal \file
+ * \brief
+ * Implements routines in boxutilities.h.
+ *
+ * Utility functions for handling boxes.
+ */
+#include "gmxpre.h"
+
+#include "boxutilities.h"
+
+#include <cmath>
+
+#include <algorithm>
+
+#include "gromacs/legacyheaders/types/inputrec.h"
+#include "gromacs/legacyheaders/types/state.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/math/vectypes.h"
+#include "gromacs/pbcutil/pbc.h"
+#include "gromacs/utility/basedefinitions.h"
+#include "gromacs/utility/real.h"
+
+/*! \brief Change box components to preserve the relative box shape
+ *
+ * Change box components to box[XX][XX]*box_rel to preserve the relative box shape
+ */
+static void do_box_rel(t_inputrec *ir, matrix box_rel, matrix b, gmx_bool bInit)
+{
+ int d, d2;
+
+ for (d = YY; d <= ZZ; d++)
+ {
+ for (d2 = XX; d2 <= (ir->epct == epctSEMIISOTROPIC ? YY : ZZ); d2++)
+ {
+ /* We need to check if this box component is deformed
+ * or if deformation of another component might cause
+ * changes in this component due to box corrections.
+ */
+ if (ir->deform[d][d2] == 0 &&
+ !(d == ZZ && d2 == XX && ir->deform[d][YY] != 0 &&
+ (b[YY][d2] != 0 || ir->deform[YY][d2] != 0)))
+ {
+ if (bInit)
+ {
+ box_rel[d][d2] = b[d][d2]/b[XX][XX];
+ }
+ else
+ {
+ b[d][d2] = b[XX][XX]*box_rel[d][d2];
+ }
+ }
+ }
+ }
+}
+
+void preserve_box_shape(t_inputrec *ir, matrix box_rel, matrix b)
+{
+ if (PRESERVE_SHAPE(*ir))
+ {
+ do_box_rel(ir, box_rel, b, FALSE);
+ }
+}
+
+void set_box_rel(t_inputrec *ir, t_state *state)
+{
+ /* Make sure the box obeys the restrictions before we fix the ratios */
+ correct_box(NULL, 0, state->box, NULL);
+
+ clear_mat(state->box_rel);
+
+ if (PRESERVE_SHAPE(*ir))
+ {
+ do_box_rel(ir, state->box_rel, state->box, TRUE);
+ }
+}
--- /dev/null
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2015, 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_PBCUTIL_BOXUTILITIES_H
+#define GMX_PBCUTIL_BOXUTILITIES_H
+
+#include <stdio.h>
+
+#include "gromacs/legacyheaders/types/inputrec.h"
+#include "gromacs/math/vectypes.h"
+#include "gromacs/utility/basedefinitions.h"
+#include "gromacs/utility/real.h"
+
+struct t_state;
+
+/*! \brief Make sure the relative box shape remains the same
+ *
+ * This function ensures that the relative box dimensions are
+ * preserved, which otherwise might diffuse away due to rounding
+ * errors in pressure coupling or the deform option.
+ *
+ * \param[in] ir Input record
+ * \param[in] box_rel Relative box
+ * \param[out] b The corrected box
+ */
+void preserve_box_shape(t_inputrec *ir, matrix box_rel, matrix b);
+
+/*! \brief Determine the relative box components
+ *
+ * Set state->box_rel used in mdrun to preserve the box shape
+ * \param[in] ir Input record
+ * \param[inout] state Structure containing the box
+ */
+void set_box_rel(struct t_inputrec *ir, t_state *state);
+
+#endif