From 1e133618933739b9cc1d70572660b2fced3887af Mon Sep 17 00:00:00 2001 From: Berk Hess Date: Tue, 23 Jun 2020 12:54:12 +0000 Subject: [PATCH] Add virtual site with one constructing atom Also fixed the order of the function type update table in tpxio.cpp. --- .../functions/interaction-methods.rst | 14 ++++++++++++++ docs/release-notes/2021/major/features.rst | 6 ++++++ src/gromacs/fileio/tpxio.cpp | 9 ++++++--- src/gromacs/gmxlib/nrnb.cpp | 1 + src/gromacs/gmxlib/nrnb.h | 1 + src/gromacs/gmxpreprocess/convparm.cpp | 1 + src/gromacs/mdlib/vsite.cpp | 18 ++++++++++++++++++ src/gromacs/mdlib/vsite.h | 2 +- src/gromacs/topology/ifunc.cpp | 7 ++++--- src/gromacs/topology/ifunc.h | 1 + 10 files changed, 53 insertions(+), 7 deletions(-) diff --git a/docs/reference-manual/functions/interaction-methods.rst b/docs/reference-manual/functions/interaction-methods.rst index 25820ca0d1..4d88abfb07 100644 --- a/docs/reference-manual/functions/interaction-methods.rst +++ b/docs/reference-manual/functions/interaction-methods.rst @@ -197,6 +197,20 @@ below. Constructing atoms in virtual sites can be virtual sites themselves, but only if they are higher in the list, i.e. virtual sites can be constructed from “particles” that are simpler virtual sites. +- On top of an atom. This allows giving an atom multiple atom types and + with that also assigned multiple, different bonded interactions. This + can espically be of use in free-energy calculations. + +- The coordinates of the virtual site equal that of the constructing atom: + + .. math:: \mathbf{r}_s ~=~ \mathbf{r}_i + :label: eqnvsite1 + +- The force is moved to the constructing atom: + + .. math:: \mathbf{F}_i ~=~ \mathbf{F}_{s} + :label: eqnvsite1force + - As a linear combination of two atoms (:numref:`Fig. %s ` 2): diff --git a/docs/release-notes/2021/major/features.rst b/docs/release-notes/2021/major/features.rst index 82a35ba5d1..7a5626f7ca 100644 --- a/docs/release-notes/2021/major/features.rst +++ b/docs/release-notes/2021/major/features.rst @@ -7,6 +7,12 @@ New and improved features Also, please use the syntax :issue:`number` to reference issues on GitLab, without the a space between the colon and number! +Virtual site with single constructing atom +"""""""""""""""""""""""""""""""""""""""""" + +Added a virtual site that is constructed on top if its single constructing +atom. This can be useful for free-energy calculations. + Lower energy drift due to SETTLE """""""""""""""""""""""""""""""" diff --git a/src/gromacs/fileio/tpxio.cpp b/src/gromacs/fileio/tpxio.cpp index 68b4f3e95c..e207690390 100644 --- a/src/gromacs/fileio/tpxio.cpp +++ b/src/gromacs/fileio/tpxio.cpp @@ -131,6 +131,7 @@ enum tpxv tpxv_VSite2FD, /**< Added 2FD type virtual site */ tpxv_AddSizeField, /**< Added field with information about the size of the serialized tpr file in bytes, excluding the header */ tpxv_StoreNonBondedInteractionExclusionGroup, /**< Store the non bonded interaction exclusion group in the topology */ + tpxv_VSite1, /**< Added 1 type virtual site */ tpxv_Count /**< the total number of tpxv versions */ }; @@ -205,10 +206,13 @@ static const t_ftupd ftupd[] = { { 72, F_GBPOL_NOLONGERUSED }, { 72, F_NPSOLVATION_NOLONGERUSED }, { 93, F_LJ_RECIP }, + { 76, F_ANHARM_POL }, { 90, F_FBPOSRES }, + { tpxv_VSite1, F_VSITE1 }, + { tpxv_VSite2FD, F_VSITE2FD }, + { tpxv_GenericInternalParameters, F_DENSITYFITTING }, { 69, F_VTEMP_NOLONGERUSED }, { 66, F_PDISPCORR }, - { 76, F_ANHARM_POL }, { 79, F_DVDL_COUL }, { 79, @@ -220,8 +224,6 @@ static const t_ftupd ftupd[] = { }, { 79, F_DVDL_RESTRAINT }, { 79, F_DVDL_TEMPERATURE }, - { tpxv_GenericInternalParameters, F_DENSITYFITTING }, - { tpxv_VSite2FD, F_VSITE2FD }, }; #define NFTUPD asize(ftupd) @@ -1940,6 +1942,7 @@ static void do_iparams(gmx::ISerializer* serializer, t_functype ftype, t_iparams serializer->doReal(&iparams->settle.doh); serializer->doReal(&iparams->settle.dhh); break; + case F_VSITE1: break; // VSite1 has 0 parameters case F_VSITE2: case F_VSITE2FD: serializer->doReal(&iparams->vsite.a); break; case F_VSITE3: diff --git a/src/gromacs/gmxlib/nrnb.cpp b/src/gromacs/gmxlib/nrnb.cpp index 1fca45d7cd..1366d351e5 100644 --- a/src/gromacs/gmxlib/nrnb.cpp +++ b/src/gromacs/gmxlib/nrnb.cpp @@ -175,6 +175,7 @@ static const t_nrnb_data nbdata[eNRNB] = { { "Shake-Init", 10 }, { "Constraint-Vir", 24 }, { "Settle", 370 }, + { "Virtual Site 1", 1 }, { "Virtual Site 2", 23 }, { "Virtual Site 2fd", 63 }, { "Virtual Site 3", 37 }, diff --git a/src/gromacs/gmxlib/nrnb.h b/src/gromacs/gmxlib/nrnb.h index e5129fcdde..847c6cdb9d 100644 --- a/src/gromacs/gmxlib/nrnb.h +++ b/src/gromacs/gmxlib/nrnb.h @@ -155,6 +155,7 @@ enum eNR_SHAKE_RIJ, eNR_CONSTR_VIR, eNR_SETTLE, + eNR_VSITE1, eNR_VSITE2, eNR_VSITE2FD, eNR_VSITE3, diff --git a/src/gromacs/gmxpreprocess/convparm.cpp b/src/gromacs/gmxpreprocess/convparm.cpp index 9b4da4cce4..c9efb733cb 100644 --- a/src/gromacs/gmxpreprocess/convparm.cpp +++ b/src/gromacs/gmxpreprocess/convparm.cpp @@ -402,6 +402,7 @@ static int assign_param(t_functype ftype, t_iparams* newparam, gmx::ArrayRefsettle.doh = old[0]; newparam->settle.dhh = old[1]; break; + case F_VSITE1: case F_VSITE2: case F_VSITE2FD: case F_VSITE3: diff --git a/src/gromacs/mdlib/vsite.cpp b/src/gromacs/mdlib/vsite.cpp index f2c8b0ef66..aab8dffd74 100644 --- a/src/gromacs/mdlib/vsite.cpp +++ b/src/gromacs/mdlib/vsite.cpp @@ -334,6 +334,13 @@ static inline real inverseNorm(const rvec x) #ifndef DOXYGEN /* Vsite construction routines */ +static void constr_vsite1(const rvec xi, rvec x) +{ + copy_rvec(xi, x); + + /* TOTAL: 0 flops */ +} + static void constr_vsite2(const rvec xi, const rvec xj, rvec x, real a, const t_pbc* pbc) { real b = 1 - a; @@ -675,6 +682,7 @@ static void construct_vsites_thread(ArrayRef x, real b1, c1; switch (ftype) { + case F_VSITE1: constr_vsite1(x[ai], x[avsite]); break; case F_VSITE2: aj = ia[3]; constr_vsite2(x[ai], x[aj], x[avsite], a1, pbc_null2); @@ -857,6 +865,14 @@ void constructVirtualSites(ArrayRef x, ArrayRef ip, Array #ifndef DOXYGEN /* Force spreading routines */ +static void spread_vsite1(const t_iatom ia[], ArrayRef f) +{ + const int av = ia[1]; + const int ai = ia[2]; + + f[av] += f[ai]; +} + template static void spread_vsite2(const t_iatom ia[], real a, @@ -1761,6 +1777,7 @@ static void spreadForceForThread(ArrayRef x, /* Construct the vsite depending on type */ switch (ftype) { + case F_VSITE1: spread_vsite1(ia, f); break; case F_VSITE2: spread_vsite2(ia, a1, x, f, fshift, pbc_null2); break; @@ -2034,6 +2051,7 @@ void VirtualSitesHandler::Impl::spreadForces(ArrayRef x, dd_move_f_vsites(*domainInfo_.domdec_, f, fshift); } + inc_nrnb(nrnb, eNR_VSITE1, vsite_count(ilists_, F_VSITE1)); inc_nrnb(nrnb, eNR_VSITE2, vsite_count(ilists_, F_VSITE2)); inc_nrnb(nrnb, eNR_VSITE2FD, vsite_count(ilists_, F_VSITE2FD)); inc_nrnb(nrnb, eNR_VSITE3, vsite_count(ilists_, F_VSITE3)); diff --git a/src/gromacs/mdlib/vsite.h b/src/gromacs/mdlib/vsite.h index be1d8c9ebc..ae7c932b5e 100644 --- a/src/gromacs/mdlib/vsite.h +++ b/src/gromacs/mdlib/vsite.h @@ -74,7 +74,7 @@ class RangePartitioning; * This is used to avoid loops over all ftypes just to get the vsite entries. * (We should replace the fixed ilist array by only the used entries.) */ -static constexpr int c_ftypeVsiteStart = F_VSITE2; +static constexpr int c_ftypeVsiteStart = F_VSITE1; //! The start and end value of the vsite indices in the ftype enum static constexpr int c_ftypeVsiteEnd = F_VSITEN + 1; diff --git a/src/gromacs/topology/ifunc.cpp b/src/gromacs/topology/ifunc.cpp index 469d2bfbb1..e6b4028814 100644 --- a/src/gromacs/topology/ifunc.cpp +++ b/src/gromacs/topology/ifunc.cpp @@ -141,9 +141,10 @@ const t_interaction_function interaction_function[F_NRE] = { def_bonded("ANGRESZ", "Angle Rest. Z", 2, 3, 3), def_bonded("DIHRES", "Dih. Rest.", 4, 3, 3), def_nofc("DIHRESVIOL", "Dih. Rest. Viol."), /* obsolete */ def_shkcb("CONSTR", "Constraint", 2, 1, 1), def_shk("CONSTRNC", "Constr. No Conn.", 2, 1, 1), - def_shkcb("SETTLE", "Settle", 3, 2, 0), def_vsite("VSITE2", "Virtual site 2", 3, 1), - def_vsite("VSITE2FD", "Virtual site 2fd", 3, 1), def_vsite("VSITE3", "Virtual site 3", 4, 2), - def_vsite("VSITE3FD", "Virtual site 3fd", 4, 2), def_vsite("VSITE3FAD", "Virtual site 3fad", 4, 2), + def_shkcb("SETTLE", "Settle", 3, 2, 0), def_vsite("VSITE1", "Virtual site 1", 2, 0), + def_vsite("VSITE2", "Virtual site 2", 3, 1), def_vsite("VSITE2FD", "Virtual site 2fd", 3, 1), + def_vsite("VSITE3", "Virtual site 3", 4, 2), def_vsite("VSITE3FD", "Virtual site 3fd", 4, 2), + def_vsite("VSITE3FAD", "Virtual site 3fad", 4, 2), def_vsite("VSITE3OUT", "Virtual site 3out", 4, 3), def_vsite("VSITE4FD", "Virtual site 4fd", 5, 3), def_vsite("VSITE4FDN", "Virtual site 4fdn", 5, 3), def_vsite("VSITEN", "Virtual site N", 2, 2), def_nofc("COM_PULL", "COM Pull En."), def_nofc("DENSITYFIT", "Density fitting"), diff --git a/src/gromacs/topology/ifunc.h b/src/gromacs/topology/ifunc.h index 64cce55462..584c57f0b7 100644 --- a/src/gromacs/topology/ifunc.h +++ b/src/gromacs/topology/ifunc.h @@ -188,6 +188,7 @@ enum F_CONSTR, F_CONSTRNC, F_SETTLE, + F_VSITE1, F_VSITE2, F_VSITE2FD, F_VSITE3, -- 2.22.0