Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a8a52bc
cleanup: Remove unused flag
giacomofiorin Nov 13, 2025
c36e645
fix: try fixing the crash
HanatoK Nov 25, 2025
c65a47a
opt: Do not invalidate NAMD GlobalMaster arrays when not needed
giacomofiorin Dec 7, 2025
3874c86
fix: Update atoms_map in NAMD proxy after requesting new atoms
giacomofiorin Dec 7, 2025
2b838f2
test: force the boundary checks to reveal the bug
HanatoK Dec 7, 2025
28dadf8
fix: reset the atoms_map to -1 instead of clearing it
HanatoK Dec 8, 2025
e8a7da2
test: try the 003_reinitatoms test on ARM64
HanatoK Dec 8, 2025
72f50ed
test: remove the skip_test.sh and try the test with ARM64 again
HanatoK Dec 8, 2025
f3789ce
test: revert the previous commits to disable ARM64 test again
HanatoK Dec 8, 2025
1c072e6
fix: Track when total forces from the engine are valid or not
giacomofiorin Dec 9, 2025
da9a81f
test: Update regtest reference file to remove nan
giacomofiorin Dec 9, 2025
e364f83
test: Re-enable 003_reinitatoms test in ARM64
giacomofiorin Dec 9, 2025
2c13dda
doc: Set bug error flag upon bug occurrence
giacomofiorin Dec 9, 2025
67a26da
fix: Backport changes from LAMMPS repository
giacomofiorin Dec 9, 2025
fa8dcfa
test: Try downloading container a couple of times before raising error
giacomofiorin Dec 9, 2025
e1c3d4f
fix: Fix container name in CI job
giacomofiorin Dec 9, 2025
3608b68
fix: Access colvarproxy_lammps object from correct rank
giacomofiorin Dec 10, 2025
095031c
fix: skip the total force calc in the GPU code path if unavailable
HanatoK Dec 10, 2025
38aae72
refactor: Invalidate colvar total force from a function used also by …
giacomofiorin Dec 10, 2025
803caa5
refactor: Define accessor to reset the colvar total force
giacomofiorin Dec 11, 2025
7d1d30d
fix: Apply consistent check between total-force compute / collect steps
giacomofiorin Dec 11, 2025
c92b32c
refactor: When atomic total forces are invalid, ensure colvar total f…
giacomofiorin Dec 11, 2025
480a613
fix: Ensure that reported colvar total force is zeroed immediately
giacomofiorin Dec 12, 2025
1e3d569
fix: ensure that total forces are reset before calc_colvar_properties if
HanatoK Dec 12, 2025
45ea12a
fix: fix the typos in previous rebase
HanatoK Dec 12, 2025
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
5 changes: 1 addition & 4 deletions .github/workflows/backend-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,7 @@ jobs:
sudo apt install -y apptainer-suid

- name: Get container images for build dependencies
shell: bash
working-directory: devel-tools
run: |
apptainer pull ${{ inputs.container_name }}.sif oras://ghcr.io/colvars/devel-containers:${{ inputs.container_name }}
run: devel-tools/get_container ${{ inputs.container_name }}

- name: Update and build ${{ inputs.backend_name }}
shell: bash
Expand Down
32 changes: 7 additions & 25 deletions .github/workflows/test-library.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@ jobs:
sudo apt install -y apptainer-suid

- name: Get container image
shell: bash
working-directory: devel-tools
run: |
apptainer pull texlive.sif oras://ghcr.io/colvars/devel-containers:texlive
run: devel-tools/get_container texlive

- name: Checkout website repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -191,10 +188,7 @@ jobs:
sudo apt install -y apptainer-suid

- name: Get container images for build dependencies
shell: bash
working-directory: devel-tools
run: |
apptainer pull CentOS9-devel.sif oras://ghcr.io/colvars/devel-containers:CentOS9-devel
run: devel-tools/get_container CentOS9-devel

- name: Run build with Clang static analyser
env:
Expand Down Expand Up @@ -252,10 +246,7 @@ jobs:
sudo apt install -y apptainer-suid

- name: Get container images for build dependencies
shell: bash
working-directory: devel-tools
run: |
apptainer pull CentOS9-devel.sif oras://ghcr.io/colvars/devel-containers:CentOS9-devel
run: devel-tools/get_container CentOS9-devel

- name: Build with Clang and address sanitizer
env:
Expand Down Expand Up @@ -307,11 +298,8 @@ jobs:
sudo apt update
sudo apt install -y apptainer-suid

- name: Get container images for build environment
shell: bash
working-directory: devel-tools
run: |
apptainer pull CentOS9-devel.sif oras://ghcr.io/colvars/devel-containers:CentOS9-devel
- name: Get container images for build dependencies
run: devel-tools/get_container CentOS9-devel

- name: GCC 11, C++11 (CentOS 9)
env:
Expand Down Expand Up @@ -447,10 +435,7 @@ jobs:
sudo apt install -y apptainer-suid

- name: Get container images for build dependencies
shell: bash
working-directory: devel-tools
run: |
apptainer pull CentOS9-oneAPI.sif oras://ghcr.io/colvars/devel-containers:CentOS9-oneAPI
run: devel-tools/get_container CentOS9-oneAPI

- name: Intel oneAPI 2024.2, C++11
shell: bash
Expand Down Expand Up @@ -573,10 +558,7 @@ jobs:
sudo apt install -y apptainer-suid

- name: Get container images for build dependencies
shell: bash
working-directory: devel-tools
run: |
apptainer pull CentOS9-devel-arm64.sif oras://ghcr.io/colvars/devel-containers:CentOS9-devel-arm64
run: devel-tools/get_container CentOS9-devel-arm64

- name: GCC 11, C++20 (CentOS 9)
env:
Expand Down
20 changes: 20 additions & 0 deletions devel-tools/get_container
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

DOWNLOAD_DIR=$(dirname $0)

label=$1
if [ -n "${label}" ] ; then
if [ ! -f "${DOWNLOAD_DIR}/${label}.sif" ] ; then
echo "Downloading container image \"${label}\"..."
for try in {1..3}; do
apptainer pull "${DOWNLOAD_DIR}/${label}.sif" oras://ghcr.io/colvars/devel-containers:"${label}" && break
retcode=$?
if [ ${retcode} != 0 ] ; then
echo "(download failed, retrying...)"
sleep 15s
fi
done
fi
fi

exit ${retcode}
14 changes: 14 additions & 0 deletions gromacs/src/applied_forces/colvars/colvarproxygromacs.cpp.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/src/gromacs/applied_forces/colvars/colvarproxygromacs.cpp b/src/gromacs/applied_forces/colvars/colvarproxygromacs.cpp
index 76b350c611..37e5b53647 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
11 changes: 11 additions & 0 deletions lammps/src/COLVARS/colvarproxy_lammps.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,18 @@ class colvarproxy_lammps : public colvarproxy {
cvm::real rand_gaussian() override;

int init_atom(int atom_number) override;
int init_atom(cvm::residue_id const &residue, std::string const &atom_name,
std::string const &segment_id) override
{
return colvarproxy::init_atom(residue, atom_name, segment_id);
}

int check_atom_id(int atom_number) override;
int check_atom_id(cvm::residue_id const &residue, std::string const &atom_name,
std::string const &segment_id) override
{
return colvarproxy::check_atom_id(residue, atom_name, segment_id);
}

inline std::vector<int> *modify_atom_types() { return &atoms_types; }
};
Expand Down
59 changes: 28 additions & 31 deletions lammps/src/COLVARS/fix_colvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
------------------------------------------------------------------------- */

#include "fix_colvars.h"
#include "inthash.h"

#include "atom.h"
#include "citeme.h"
Expand Down Expand Up @@ -61,7 +60,6 @@ struct LAMMPS_NS::commdata {

using namespace LAMMPS_NS;
using namespace FixConst;
using namespace IntHash_NS;

// initialize static class members
int FixColvars::instances = 0;
Expand Down Expand Up @@ -122,7 +120,6 @@ FixColvars::FixColvars(LAMMPS *lmp, int narg, char **arg) :
comm_buf = nullptr;
taglist = nullptr;
force_buf = nullptr;
idmap = nullptr;

script_args[0] = reinterpret_cast<unsigned char *>(utils::strdup("fix_modify"));

Expand Down Expand Up @@ -227,11 +224,6 @@ FixColvars::~FixColvars()

if (proxy) delete proxy;

if (idmap) {
inthash_destroy(idmap);
delete idmap;
}

if (root2root != MPI_COMM_NULL)
MPI_Comm_free(&root2root);

Expand Down Expand Up @@ -349,16 +341,11 @@ void FixColvars::init_taglist()

std::vector<int> const &tl = *(proxy->get_atom_ids());

if (idmap) {
delete idmap;
idmap = nullptr;
}

idmap = new inthash_t;
inthash_init(idmap, num_coords);
idmap.clear();
idmap.reserve(num_coords);
for (int i = 0; i < num_coords; ++i) {
taglist[i] = tl[i];
inthash_insert(idmap, tl[i], i);
idmap[tl[i]] = i;
}
}

Expand Down Expand Up @@ -497,7 +484,6 @@ void FixColvars::setup(int vflag)

std::vector<int> &tp = *(proxy->modify_atom_types());
std::vector<cvm::atom_pos> &cd = *(proxy->modify_atom_positions());
std::vector<cvm::rvector> &of = *(proxy->modify_atom_total_forces());
std::vector<cvm::real> &m = *(proxy->modify_atom_masses());
std::vector<cvm::real> &q = *(proxy->modify_atom_charges());

Expand All @@ -508,8 +494,6 @@ void FixColvars::setup(int vflag)
const tagint k = atom->map(taglist[i]);
if ((k >= 0) && (k < nlocal)) {

of[i].x = of[i].y = of[i].z = 0.0;

if (unwrap_flag) {
const int ix = (image[k] & IMGMASK) - IMGMAX;
const int iy = (image[k] >> IMGBITS & IMGMASK) - IMGMAX;
Expand Down Expand Up @@ -545,10 +529,9 @@ void FixColvars::setup(int vflag)
ndata /= size_one;

for (int k=0; k<ndata; ++k) {

const int j = inthash_lookup(idmap, comm_buf[k].tag);

if (j != HASH_FAIL) {
auto search = idmap.find(comm_buf[k].tag);
if (search != idmap.end()) {
const int j = search->second;

tp[j] = comm_buf[k].type;

Expand All @@ -558,11 +541,14 @@ void FixColvars::setup(int vflag)

m[j] = comm_buf[k].m;
q[j] = comm_buf[k].q;

of[j].x = of[j].y = of[j].z = 0.0;
}
}
}

if (proxy->total_forces_enabled()) {
proxy->set_total_forces_invalid();
}

} else { // me != 0

// copy coordinate data into communication buffer
Expand Down Expand Up @@ -701,8 +687,10 @@ void FixColvars::post_force(int /*vflag*/)
ndata /= size_one;

for (int k=0; k<ndata; ++k) {
const int j = inthash_lookup(idmap, comm_buf[k].tag);
if (j != HASH_FAIL) {
auto search = idmap.find(comm_buf[k].tag);
if (search != idmap.end()) {
const int j = search->second;

cd[j].x = comm_buf[k].x;
cd[j].y = comm_buf[k].y;
cd[j].z = comm_buf[k].z;
Expand Down Expand Up @@ -826,8 +814,10 @@ void FixColvars::end_of_step()
const tagint k = atom->map(taglist[i]);
if ((k >= 0) && (k < nlocal)) {

const int j = inthash_lookup(idmap, tag[k]);
if (j != HASH_FAIL) {
auto search = idmap.find(tag[k]);
if (search != idmap.end()) {
const int j = search->second;

of[j].x = f[k][0];
of[j].y = f[k][1];
of[j].z = f[k][2];
Expand All @@ -845,15 +835,21 @@ void FixColvars::end_of_step()
ndata /= size_one;

for (int k=0; k<ndata; ++k) {
const int j = inthash_lookup(idmap, comm_buf[k].tag);
if (j != HASH_FAIL) {
auto search = idmap.find(comm_buf[k].tag);
if (search != idmap.end()) {
const int j = search->second;

of[j].x = comm_buf[k].x;
of[j].y = comm_buf[k].y;
of[j].z = comm_buf[k].z;
}
}
}

if (proxy->total_forces_enabled()) {
proxy->set_total_forces_valid();
}

} else { // me != 0
/* copy total force data into communication buffer */
nme = 0;
Expand All @@ -871,6 +867,7 @@ void FixColvars::end_of_step()
MPI_Recv(&tmp, 0, MPI_INT, 0, 0, world, MPI_STATUS_IGNORE);
MPI_Rsend(comm_buf, nme*size_one, MPI_BYTE, 0, 0, world);
}

}
}

Expand Down
6 changes: 2 additions & 4 deletions lammps/src/COLVARS/fix_colvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ FixStyle(colvars,FixColvars);
#define LMP_FIX_COLVARS_H

#include "fix.h"
#include <unordered_map>

// Forward declarations
namespace IntHash_NS {
struct inthash_t;
}
class colvarproxy_lammps;

namespace LAMMPS_NS {
Expand Down Expand Up @@ -87,7 +85,7 @@ class FixColvars : public Fix {
/// Arguments passed from fix_modify to the Colvars script interface
unsigned char *script_args[100];

IntHash_NS::inthash_t *idmap; // hash for mapping atom indices to consistent order.
std::unordered_map<int, int> idmap; // for mapping atom indices to consistent order.

int nlevels_respa; // flag to determine respa levels.
int store_forces; // flag to determine whether to store total forces
Expand Down
10 changes: 10 additions & 0 deletions namd/src/GlobalMasterColvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ class GlobalMasterColvars : public GlobalMaster {
return modifyAppliedForces();
}

inline ResizeArray<AtomIDList> const &getRequestedGroups() const
{
return reqGroups;
}

inline ResizeArray<AtomIDList> &modifyRequestedGroupsPublic()
{
return modifyRequestedGroups();
Expand All @@ -49,6 +54,11 @@ class GlobalMasterColvars : public GlobalMaster {
return modifyGroupForces();
}

inline IntList const &getRequestedGridObjects() const
{
return reqGridObjs;
}

inline IntList &modifyRequestedGridObjectsPublic()
{
return modifyRequestedGridObjects();
Expand Down
Loading
Loading