Add function to get residue start and end
[gromacs.git] / src / gromacs / ewald / ewald_utils.h
blob9f77967c377a927c5a7ab55a0d0ec59218a14db2
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2004, The GROMACS development team.
6 * Copyright (c) 2013,2014,2017,2019, by the GROMACS development team, led by
7 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
8 * and including many others, as listed in the AUTHORS file in the
9 * top-level source directory and at http://www.gromacs.org.
11 * GROMACS is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public License
13 * as published by the Free Software Foundation; either version 2.1
14 * of the License, or (at your option) any later version.
16 * GROMACS is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with GROMACS; if not, see
23 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 * If you want to redistribute modifications to GROMACS, please
27 * consider that scientific software is very special. Version
28 * control is crucial - bugs must be traceable. We will be happy to
29 * consider code for inclusion in the official distribution, but
30 * derived work must not be called official GROMACS. Details are found
31 * in the README & COPYING files - if they are missing, get the
32 * official version at http://www.gromacs.org.
34 * To help us fund GROMACS development, we humbly ask that you cite
35 * the research papers on the package. Check out http://www.gromacs.org.
37 /*! \libinternal \file
39 * \brief Declares utility functions related to Ewald.
41 * \author Mark Abraham <mark.j.abraham@gmail.com>
42 * \author Szilárd Páll <pall.szilard@gmail.com>
44 * \inlibraryapi
45 * \ingroup module_ewald
47 #ifndef GMX_EWALD_UTILS_H
48 #define GMX_EWALD_UTILS_H
50 #include "gromacs/math/vec.h"
51 #include "gromacs/mdtypes/inputrec.h"
52 #include "gromacs/pbcutil/pbc.h"
53 #include "gromacs/utility/gmxassert.h"
54 #include "gromacs/utility/real.h"
56 /*! \brief Computes the Ewald splitting coefficient for Coulomb
58 * Returns a value of beta that satisfies rtol > erfc(beta * rc)
59 * (and is very close to equality). That value is used the same way in
60 * all Coulomb-based Ewald methods.
62 * \param[in] rc Cutoff radius
63 * \param[in] rtol Required maximum value of the short-ranged
64 * potential at the cutoff (ie. ewald-rtol)
65 * \return The value of the splitting coefficient that
66 * produces the required dtol at rc.
68 real calc_ewaldcoeff_q(real rc, real rtol);
70 /*! \brief Computes the Ewald splitting coefficient for LJ
72 * Returns a value of beta that satisfies dtol > erfc(beta * rc) * (1
73 * + beta^2 * rc^2 + 0.5 * beta^4 * rc^4) (and is very close to
74 * equality), which is used in LJ-PME.
76 * \param[in] rc Cutoff radius
77 * \param[in] rtol Required maximum value of the short-ranged
78 * potential at the cutoff (ie. ewald-rtol-lj)
79 * \return The value of the splitting coefficient that
80 * produces the required dtol at rc.
82 real calc_ewaldcoeff_lj(real rc, real rtol);
85 /*! \libinternal \brief Class to handle box scaling for Ewald and PME.
87 * At construction contents of inputrec determine whether scaling is necessary
88 * as well as the scaling factor used. Later, the scaleBox method can be used
89 * to apply the appropriate scaling (if needed) for Ewald-based methods.
92 class EwaldBoxZScaler
95 private:
96 bool scaleWithWalls_; /**< True if the simulation uses two walls and the box needs to be scaled in PME */
97 real scalingFactor_; /**< Box The scaling factor PME uses with walls */
99 public:
100 EwaldBoxZScaler() = delete;
102 /*! \brief Constructor that takes the input record to initialize Ewald box scaling appropriately. */
103 EwaldBoxZScaler(const t_inputrec& ir)
105 if (inputrecPbcXY2Walls(&ir))
107 scaleWithWalls_ = true;
108 scalingFactor_ = ir.wall_ewald_zfac;
110 else
112 scaleWithWalls_ = false;
113 scalingFactor_ = 1;
117 /*! \brief Copy and scale the box for PME.
119 * When PME is used with 2D periodicity and two walls, the
120 * copy of the \p box passed is scaled with the Z scaling factor.
122 * \param[in] box The current box matrix
123 * \param[out] scaledBox Scaled copy of the box matrix.
125 void scaleBox(const matrix box, matrix scaledBox)
127 GMX_ASSERT(box, "invalid source box pointer");
128 GMX_ASSERT(scaledBox, "invalid target box pointer");
130 copy_mat(box, scaledBox);
131 if (scaleWithWalls_)
133 svmul(scalingFactor_, scaledBox[ZZ], scaledBox[ZZ]);
138 #endif