Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
5763181
build: Generate VMD dependency file automatically
giacomofiorin Feb 13, 2026
b4050b1
refactor: Move coordNum classes' definitions to a dedicated header (w…
giacomofiorin Jan 20, 2026
fb30105
refactor: Move coordNum switching function to dedicated header (with …
giacomofiorin Jan 21, 2026
ac3c7fd
cleanup: Remove unused parameter
giacomofiorin Jan 21, 2026
a22b673
cleanup: Use vector cutoff for coordNum even in the isotropic case
giacomofiorin Jan 21, 2026
bcae74b
cleanup: Inherit selfCoordNum to coordNum to reuse its init function
giacomofiorin Jan 21, 2026
83804f2
cleanup: Remove redundant check
giacomofiorin Jan 21, 2026
a1a9200
cleanup: Derive groupCoord from coordNum
giacomofiorin Jan 22, 2026
a8feb7f
feat: Support group1CenterOnly, consolidate cases including groupCoord
giacomofiorin Jan 22, 2026
878be36
refactor: Make selfCoordNum use a template function rather than a macro
giacomofiorin Jan 23, 2026
1e69f9d
opt: Manage pairlist outside of switching function kernel
giacomofiorin Jan 23, 2026
1b9e2d6
cleanup: Condense initialization of cutoff-related fields
giacomofiorin Jan 23, 2026
4710fe5
build: Use spiff directly when available to support out-of-tree builds
giacomofiorin Jan 23, 2026
1880753
refactor: Split computation of scaled distance and switching function
giacomofiorin Jan 23, 2026
91131f0
opt: Skip computation of switching function if the distance is too hi…
giacomofiorin Jan 23, 2026
32a9da3
cleanup: Make pairlist buffer a C++ object
giacomofiorin Jan 24, 2026
88690d1
perf: inline compute_pair_coordnum and switching_function
HanatoK Jan 26, 2026
557014e
opt: Make pairlist a C array again
giacomofiorin Jan 28, 2026
3b900cb
opt: Make sequential-loop template functions explicitly inline
giacomofiorin Jan 28, 2026
afa4e94
opt: Make internal PBC distance computation callable directly
giacomofiorin Jan 30, 2026
87c002c
opt: Support internal PBC functions in coordNum kernels
giacomofiorin Jan 30, 2026
4c92cf9
opt: Use constexpr where possible
giacomofiorin Jan 30, 2026
e3b3c3c
doc: Document group1CenterOnly
giacomofiorin Jan 30, 2026
44daa0c
refactor: Use a dedicated class to store system boundaries
giacomofiorin Feb 12, 2026
9ed046c
refactor: Use boundary conditions object in coordNum
giacomofiorin Feb 12, 2026
a187e63
refactor: Get unit cell from MD engines (also fix LAMMPS and support …
giacomofiorin Feb 12, 2026
2dae1d2
fix: Handle mininum-image for triclinic cells with moderate tilt in i…
giacomofiorin Feb 13, 2026
b713a84
chore: Update clang-format config to keep return type with function
giacomofiorin Feb 13, 2026
a0c0c88
opt: Stop using the proxy directly to compute distances
giacomofiorin Feb 13, 2026
9722e54
fix: Silence warning regarding shadowing of class member
giacomofiorin Feb 14, 2026
9e888b3
debug: Print debug statements only from within host code
giacomofiorin Feb 16, 2026
aea8a59
opt: Remove now obsoleted internalPBC flag
giacomofiorin Feb 16, 2026
ad26fa8
opt: Compute shifts regardless of periodic flags (they are zero witho…
giacomofiorin Feb 16, 2026
a10c029
doc: Rename function to clarify it depends on engine
giacomofiorin Feb 16, 2026
efc32d9
build: Add script to create patches to GROMACS interface files
giacomofiorin Feb 16, 2026
73243b5
build: Remove obsolete files
giacomofiorin Feb 16, 2026
8bde692
feat: Support forceNoPBC for all variables
giacomofiorin Feb 16, 2026
8f4b4fd
doc: Document handling of boundary conditions
giacomofiorin Feb 16, 2026
4b02b63
cleanup: Remove now redundant logic in CVC compute functions
giacomofiorin Feb 16, 2026
f7326a1
fix: Update VMD proxy function to reflect name change
giacomofiorin Feb 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/backend-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ jobs:
ref: 'master'
path: 'devel-tools/packages'

- name: Test build recipes
run: bash devel-tools/check_build_recipes

- name: Build and test standalone library
run: cmake -P devel-tools/build_test_library.cmake

Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/test-library.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ jobs:
# run: |
# sudo apt -y install ccache

- name: Test build recipes
run: bash devel-tools/check_build_recipes

- name: Convert BibTeX references to code
shell: bash
working-directory: doc
Expand Down
26 changes: 0 additions & 26 deletions devel-tools/check_build_recipes

This file was deleted.

4 changes: 2 additions & 2 deletions devel-tools/compile-gromacs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ compile_gromacs_target() {
while [ $# -ge 1 ]; do
if [ "${1,,}" = "debug" ]; then
GMX_BUILD_TYPE=Debug
GMX_BUILD_OPTS+=(-DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE=yes)
GMX_BUILD_OPTS+=(-DCOLVARS_DEBUG=ON)
GMX_BUILD_OPTS+=(-DCMAKE_VERBOSE_MAKEFILE=yes)
GMX_BUILD_OPTS+=(-DCMAKE_CXX_FLAGS="-DCOLVARS_DEBUG=1")
else
GMX_INSTALL_DIR=${1}
fi
Expand Down
4 changes: 3 additions & 1 deletion devel-tools/generate-namd-makefile.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/bash

set -e

# Generate a file suitable for inclusion by the NAMD Makefile

if [ -f "${2}" ] ; then
echo "Usage: ${0} <sources_var_name> <sources_path> <objs_var_name> <obj_path> [... source files ...]" >& 1
echo "Usage: ${0} <sources_var_name> <sources_path> <objs_var_name> <obj_path> [... source files ...]" >& 2
exit 1
fi

Expand Down
87 changes: 87 additions & 0 deletions devel-tools/generate-vmd-makefile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash

set -e

# Generate the file colvars_files.pl used by VMD (i.e. a poor person's version of a dependency file)

if [ ! -f "${1}" ] ; then
echo "Usage: ${0} [... source files ...] [... header files ...]" >& 2
exit 1
fi

all_files=("${@}")


canonize_filename() {
local file=$1
if [ "${file%.cpp}" != "${file}" ] ; then
basename "${file%.cpp}.C"
else
basename "${file}"
fi
}

source_files=()
header_files=()
cuda_files=()
for file in "${all_files[@]}" ; do
if [ "${file%.cpp}" != "${file}" ] ; then
source_files+=($(canonize_filename "${file}"))
elif [ "${file%.C}" != "${file}" ] ; then
source_files+=($(canonize_filename "${file}"))
elif [ "${file%.h}" != "${file}" ] ; then
header_files+=($(canonize_filename "${file}"))
elif [ "${file%.cu}" != "${file}" ] ; then
echo "Error: building of Colvars CUDA files with VMD is not supported yet" >&2
# cuda_files+=($(canonize_filename "${file}"))
else
echo "Error: file ${file} has an unsupported extension" >&2
exit 1
fi
done

cat <<EOF
# List of files for the Colvars module

our ( \$colvars_defines );

our ( @colvars_cc );
our ( @colvars_cu );
our ( @colvars_ccpp );
our ( @colvars_h );

\$colvars_defines = " -DVMDCOLVARS";

@colvars_cc = ();
EOF


print_list() {
local var_name=$1
shift
local -a files=($(echo "${@}" | tr ' ' '\n' | sort | xargs))
echo "@${var_name} = ("
for file in "${files[@]:0:${#files[@]}-1}" ; do
echo " '${file}',"
done
echo " '${files[${#files[@]}-1]}'"
echo " );"
}

if [ -n "${cuda_files}" ] ; then
print_list "colvars_cu" "${cuda_files[@]}"
else
echo "@colvars_cu = ();"
fi

if [ -n "${source_files}" ] ; then
print_list "colvars_ccpp" "${source_files[@]}"
else
echo "@colvars_ccpp = ();"
fi

if [ -n "${header_files}" ] ; then
print_list "colvars_h" "${header_files[@]}"
else
echo "@colvars_h = ();"
fi
36 changes: 25 additions & 11 deletions doc/colvars-refman-main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1495,15 +1495,16 @@

\cvsubsec{Treatment of periodic boundary conditions}{sec:cvc_pbcs}

In all colvar components described below, the following rules apply concerning periodic boundary
conditions (PBCs):
When copying over atomic coordinates from \MDENGINE, Colvars also copies its boundary conditions and unit cell vectors. Periodic or non-periodic boundary conditions are supported for each direction independently, thus allowing for mixed-periodicity conditions if \MDENGINE{} allows them. When using triclinic unit cells, tilt factors up to 1/2 are supported by looping over one additional layer of adjacent periodic images around the simulation cell to find the minimum image. The use of tilt factors beyond 1/2 is \emph{not recommended}, and may lead to slower performance\cvlammpsonly{ (LAMMPS will also print warnings to that sense)}.

For all colvar components implemented by Colvars internal code, the following rules apply:
\begin{enumerate}
\item Distance vectors between two coordinates
$\mathbf{d}_{i,j} = \left(\mathbf{x}_1 - \mathbf{x}_2\right)$, are calculated following the
minimum-image convention by default, unless \refkey{forceNoPBC}{colvar|cvc|forceNoPBC} is enabled.
($\mathbf{x}_1$ and $\mathbf{x}_2$ may be either individual atomic coordinates, or centers of mass
of two groups.)
\item For all other functions of individual atomic coordinates,
\item For all other functions of multiple atomic coordinates,
$f\left(\mathbf{x}_1, \mathbf{x}_2, \ldots\right)$, it is assumed that all atoms that are part of
the same group are in the same periodic unit cell (see \ref{sec:colvar_atom_groups_wrapping}).
\end{enumerate}
Expand Down Expand Up @@ -1966,6 +1967,19 @@
12}{%
This number defines the $m$ exponent for the switching function.}

\item %
\labelkey{colvar|coordNum|group1CenterOnly}
\keydef
{group1CenterOnly}{%
\texttt{coordNum}}{%
Use only \texttt{group1}'s center of
mass}{%
boolean}{%
\texttt{off}}{%
If this option is \texttt{on}, only contacts between the center of mass of \texttt{group1} and atoms of \texttt{group2} are calculated (by default, the sum extends over all pairs of atoms in \texttt{group1} and \texttt{group2}).
If \texttt{group1} is a \texttt{dummyAtom}, this option is set to \texttt{yes} by default.
}

\item %
\labelkey{colvar|coordNum|group2CenterOnly}
\keydef
Expand All @@ -1976,7 +1990,7 @@
boolean}{%
\texttt{off}}{%
If this option is \texttt{on}, only contacts between each atoms in \texttt{group1} and the center of mass of \texttt{group2} are calculated (by default, the sum extends over all pairs of atoms in \texttt{group1} and \texttt{group2}).
If \texttt{group2} is a \texttt{dummyAtom}, this option is set to \texttt{yes} by default.
If \texttt{group2} is a \texttt{dummyAtom}, this option is set to \texttt{yes} by default.
}

\item %
Expand All @@ -1998,15 +2012,12 @@
positive integer}{%
100}{This controls the pairlist feature, dictating how many steps are taken between regenerating pair lists if the tolerance is greater than 0.
}

\end{cvcoptions}

This component returns a dimensionless number, which ranges from
approximately 0 (all interatomic distances are much larger than the
cutoff) to $N_{\mathtt{group1}} \times N_{\mathtt{group2}}$ (all distances
are less than the cutoff), or $N_{\mathtt{group1}}$ if
\texttt{group2CenterOnly} is used. For performance reasons, at least
one of \texttt{group1} and \texttt{group2} should be of limited size or \texttt{group2CenterOnly} should be used: the cost of the loop over all pairs grows as $N_{\mathtt{group1}} \times N_{\mathtt{group2}}$.
Setting $\mathtt{tolerance} > 0$ ameliorates this to some degree, although every pair is still checked to regenerate the pair list.
This component returns a dimensionless number, which ranges from 0 (all interatomic distances are much larger than the cutoff) to $N_{\mathtt{group1}} \times N_{\mathtt{group2}}$ (all possible pairwise distances are much smaller than the cutoff).
The computational cost also grows with the number of pairwise distances calculated, unless either \texttt{group1CenterOnly} or \texttt{group2CenterOnly} are used.
Setting $\mathtt{tolerance} > 0$ could mitigate this by looping over pairs less frequently than every step.



Expand Down Expand Up @@ -8201,6 +8212,9 @@
The legacy keyword \texttt{disableForces} for atom groups is now deprecated and will be discontinued in a future release.
Atom groups now have an automated way to save computation if forces are not used, and enabling this option otherwise would lead to incorrect behavior.

\item \textbf{Colvars version 2026-XX-XX or later.}\\
Periodic boundary conditions are handled internally, rather than using code by \MDENGINE{} to compute the minimum-image convention (see \ref{sec:cvc_pbcs}).

\end{itemize}


Expand Down
16 changes: 13 additions & 3 deletions gromacs/src/applied_forces/colvars/colvarproxygromacs.cpp.patch
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
diff --git a/src/gromacs/applied_forces/colvars/colvarproxygromacs.cpp b/src/gromacs/applied_forces/colvars/colvarproxygromacs.cpp
index 76b350c611..37e5b53647 100644
index 76b350c611..3876022dd3 100644
--- a/src/gromacs/applied_forces/colvars/colvarproxygromacs.cpp
+++ b/src/gromacs/applied_forces/colvars/colvarproxygromacs.cpp
@@ -79,9 +79,6 @@ ColvarProxyGromacs::ColvarProxyGromacs(const std::string& colvarsConfigString,
// Retrieve masses and charges from input file
updated_masses_ = updated_charges_ = true;

- // User-scripted forces are not available in GROMACS
- have_scripts = false;
-
angstrom_value_ = 0.1;

// From Gnu units
@@ -281,7 +278,8 @@ ColvarProxyGromacs::~ColvarProxyGromacs()
}


-cvm::rvector ColvarProxyGromacs::position_distance(cvm::atom_pos const& pos1, cvm::atom_pos const& pos2) const
+cvm::rvector ColvarProxyGromacs::position_distance_engine(cvm::atom_pos const& pos1,
+ cvm::atom_pos const& pos2) const
{
rvec r1, r2, dr;
r1[0] = pos1.x;
13 changes: 0 additions & 13 deletions gromacs/src/applied_forces/colvars/colvarproxygromacs.h.diff

This file was deleted.

15 changes: 15 additions & 0 deletions gromacs/src/applied_forces/colvars/colvarproxygromacs.h.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/src/gromacs/applied_forces/colvars/colvarproxygromacs.h b/src/gromacs/applied_forces/colvars/colvarproxygromacs.h
index 32b1e8d0d7..3c0a0dee9a 100644
--- a/src/gromacs/applied_forces/colvars/colvarproxygromacs.h
+++ b/src/gromacs/applied_forces/colvars/colvarproxygromacs.h
@@ -146,8 +146,8 @@ public:
*/
int check_atom_id(int atomNumber) override;

- //! Compute the minimum distance with respect to the PBC between 2 atoms.
- cvm::rvector position_distance(cvm::atom_pos const& pos1, cvm::atom_pos const& pos2) const override;
+ //! Compute the minimum distance with respect to the PBCs between 2 positions using GROMACS code
+ cvm::rvector position_distance_engine(cvm::atom_pos const& pos1, cvm::atom_pos const& pos2) const override;
};

} // namespace gmx
12 changes: 0 additions & 12 deletions gromacs/src/applied_forces/colvars/colvarsMDModule.cpp.diff

This file was deleted.

55 changes: 55 additions & 0 deletions gromacs/src/applied_forces/colvars/colvarsforceprovider.cpp.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
diff --git a/src/gromacs/applied_forces/colvars/colvarsforceprovider.cpp b/src/gromacs/applied_forces/colvars/colvarsforceprovider.cpp
index 5860eed790..bc34e6ccaa 100644
--- a/src/gromacs/applied_forces/colvars/colvarsforceprovider.cpp
+++ b/src/gromacs/applied_forces/colvars/colvarsforceprovider.cpp
@@ -337,15 +337,47 @@ void ColvarsForceProvider::calculateForces(const ForceProviderInput& forceProvid
ForceProviderOutput* forceProviderOutput)
{

- // Construct t_pbc struct
- set_pbc(&gmxPbc_, pbcType_, forceProviderInput.box_);
+ auto const& box = forceProviderInput.box_;
+
+ // Set PBC struct for use in ColvarProxyGromacs::position_distance()
+ set_pbc(&gmxPbc_, pbcType_, box);
+
+ // Share PBCs with the library as well
+ switch (pbcType_)
+ {
+ case PbcType::Unset:
+ GMX_RELEASE_ASSERT(false, "PBC type not set when being used by ColvarsForceProvider.");
+ break;
+ case PbcType::XY:
+ boundaries_.set_boundaries(true,
+ true,
+ false,
+ cvm::rvector{ box[0][0], box[0][1], box[0][2] },
+ cvm::rvector{ box[1][0], box[1][1], box[1][2] },
+ cvm::rvector{ 0.0, 0.0, 0.0 });
+ break;
+ case PbcType::Xyz:
+ boundaries_.set_boundaries(true,
+ true,
+ true,
+ cvm::rvector{ box[0][0], box[0][1], box[0][2] },
+ cvm::rvector{ box[1][0], box[1][1], box[1][2] },
+ cvm::rvector{ box[2][0], box[2][1], box[2][2] });
+ break;
+ case PbcType::Screw:
+ boundaries_.reset();
+ boundaries_.set_type(cvm::system_boundary_conditions::types::unsupported);
+ break;
+ case PbcType::No: boundaries_.reset(); break;
+ default:
+ GMX_RELEASE_ASSERT(false, "Invalid pbcType in ColvarsForceProvider::calculateForces");
+ }

const MpiComm& mpiComm = forceProviderInput.mpiComm_;
// Local atom coords
const gmx::ArrayRef<const gmx::RVec> x = forceProviderInput.x_;
// Local atom coords (coerced into into old gmx type)
const rvec* xPointer = &(x.data()->as_vec());
- const auto& box = forceProviderInput.box_;

colvars->it = forceProviderInput.step_;

21 changes: 21 additions & 0 deletions gromacs/update_patches_from_git.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

GROMACS_SOURCE=${1}
if [ -n "${GROMACS_SOURCE}" ] ; then
GROMACS_SOURCE=$(git -C ${GROMACS_SOURCE} rev-parse --show-toplevel)
fi

if [ $? != 0 ] || [ ! -s ${GROMACS_SOURCE}/src/gromacs/version.h.cmakein ] ; then
echo >&2
echo "Usage: $0 <path_to_GROMACS_tree>" >& 2
exit 1
fi

COLVARS_SOURCE=$(dirname $(realpath $0))
COLVARS_SOURCE=$(git -C ${COLVARS_SOURCE} rev-parse --show-toplevel)

modified_files=($(git -C ${GROMACS_SOURCE} ls-files -m src/gromacs/applied_forces/colvars))

for file in ${modified_files[@]} ; do
git -C ${GROMACS_SOURCE} diff ${file} > ${COLVARS_SOURCE}/gromacs/src/${file#src\/gromacs\/}.patch
done
Loading
Loading