pull_calc_coms(nullptr, pull_work, md, &pbc, t_start, x, nullptr);
- int groupThatFailsPbc = pullCheckPbcWithinGroups(*pull_work, x, pbc);
+ int groupThatFailsPbc = pullCheckPbcWithinGroups(*pull_work, x, pbc, c_pullGroupPbcMargin);
if (groupThatFailsPbc >= 0)
{
char buf[STRLEN];
const rvec x[],
rvec *xp);
-/*! \brief Margin for checking PBC distances compared to half the box size in pullCheckPbcWithinGroups() */
+/*! \brief Margin for checking pull group PBC distances compared to half the box size */
static constexpr real c_pullGroupPbcMargin = 0.9;
/*! \brief Checks whether all groups that use a reference atom are within PBC restrictions
* atoms within half the box size from the PBC atom. The box size is used
* per dimension for rectangular boxes, but can be a combination of
* dimensions for triclinic boxes, depending on which dimensions are
- * involved in the pull coordinates a group is involved in.
+ * involved in the pull coordinates a group is involved in. A margin is specified
+ * to ensure that atoms are not too close to the maximum distance.
*
* Should be called without MPI parallelization and after pull_calc_coms()
* has been called at least once.
*
- * \param[in] pull The pull data structure
- * \param[in] x The coordinates
- * \param[in] pbc Information struct about periodicity
+ * \param[in] pull The pull data structure
+ * \param[in] x The coordinates
+ * \param[in] pbc Information struct about periodicity
+ * \param[in] pbcMargin The minimum margin (as a fraction) to half the box size
* \returns -1 when all groups obey PBC or the first group index that fails PBC
*/
int pullCheckPbcWithinGroups(const pull_t &pull,
const rvec *x,
- const t_pbc &pbc);
+ const t_pbc &pbc,
+ real pbcMargin);
/*! \brief Returns if we have pull coordinates with potential pulling.
*
const BoolVec &dimUsed,
const rvec *x,
const t_pbc &pbc,
- const gmx::RVec &x_pbc)
+ const gmx::RVec &x_pbc,
+ const real pbcMargin)
{
/* Determine which dimensions are relevant for PBC */
BoolVec dimUsesPbc = { false, false, false };
/* Use margins for dimensions independently */
for (int d = 0; d < pbc.ndim_ePBC; d++)
{
- marginPerDim[d] = c_pullGroupPbcMargin*pbc.hbox_diag[d];
+ marginPerDim[d] = pbcMargin*pbc.hbox_diag[d];
}
}
else
{
if (dimUsesPbc[d])
{
- marginDistance2 += c_pullGroupPbcMargin*gmx::square(0.5)*norm2(pbc.box[d]);
+ marginDistance2 += pbcMargin*gmx::square(0.5)*norm2(pbc.box[d]);
}
}
}
int pullCheckPbcWithinGroups(const pull_t &pull,
const rvec *x,
- const t_pbc &pbc)
+ const t_pbc &pbc,
+ real pbcMargin)
{
if (pbc.ePBC == epbcNONE)
{
{
const pull_group_work_t &group = pull.group[g];
if (group.epgrppbc == epgrppbcREFAT &&
- !pullGroupObeysPbcRestrictions(group, dimUsed[g], x, pbc, pull.comm.pbcAtomBuffer[g]))
+ !pullGroupObeysPbcRestrictions(group, dimUsed[g], x, pbc, pull.comm.pbcAtomBuffer[g], pbcMargin))
{
return g;
}