diff --git a/.github/workflows/backend-template.yml b/.github/workflows/backend-template.yml index 666441dbd..44e417405 100644 --- a/.github/workflows/backend-template.yml +++ b/.github/workflows/backend-template.yml @@ -63,9 +63,10 @@ jobs: test_backends: runs-on: ubuntu-latest env: - CCACHE_DIR: ${{ github.workspace }}/ccache_${{ inputs.container_name }} - # Silence OpenMPI warnings - PSM3_MULTI_EP: 1 + CCACHE_DIR: ~/ccache_${{ inputs.container_name }} + # OpenMPI transport settings suitable for GH VMs + OMPI_MCA_mtl: "^ofi" + OMPI_MCA_btl: "vader,self" steps: - name: Checkout Colvars @@ -78,7 +79,7 @@ jobs: uses: actions/cache@v3 with: path: | - ${{ github.workspace }}/ccache_${{ inputs.container_name }} + ~/ccache_${{ inputs.container_name }} key: ${{ runner.os }}-build-${{ inputs.backend_name }}-${{ github.sha }} restore-keys: | ${{ runner.os }}-build-${{ inputs.backend_name }}- @@ -126,8 +127,7 @@ jobs: shell: bash working-directory: devel-tools run: | - apptainer pull CentOS7-devel.sif oras://ghcr.io/Colvars/devel-containers:CentOS7-devel - apptainer pull CentOS9-devel.sif oras://ghcr.io/Colvars/devel-containers:CentOS9-devel + apptainer pull ${{ inputs.container_name }}.sif oras://ghcr.io/Colvars/devel-containers:${{ inputs.container_name }} - name: Update and build ${{ inputs.backend_name }} shell: bash @@ -135,9 +135,11 @@ jobs: OPENMM_SOURCE: ${{ github.workspace }}/openmm-source CMAKE_GENERATOR: Ninja run: | - apptainer exec devel-tools/${{ inputs.container_name }}.sif ./update-colvars-code.sh -f ${{ inputs.backend_name }}-source apptainer exec devel-tools/${{ inputs.container_name }}.sif \ - bash ${{ inputs.path_compile_script }} ${{ inputs.backend_name }}-source + ./update-colvars-code.sh -f ${{ inputs.backend_name }}-source + mkdir -p ${CCACHE_DIR} + apptainer exec devel-tools/${{ inputs.container_name }}.sif \ + bash ${{ inputs.path_compile_script }} ${{ inputs.backend_name }}-source # 2 types of tests can be performed with the MD engine: library & interface diff --git a/.github/workflows/test-backends.yml b/.github/workflows/test-backends.yml index aa691fbe5..6fb2013d1 100644 --- a/.github/workflows/test-backends.yml +++ b/.github/workflows/test-backends.yml @@ -1,6 +1,8 @@ name: "Backends" -on: [push, pull_request] +on: + push: + # These jobs call a template workflow `backend-template.yml`, which performs # all the necessary steps to run the regression tests of the backend. @@ -18,11 +20,8 @@ env: jobs: - lammps: - name: LAMMPS - if: | - (github.event_name == 'pull_request') || - (github.event_name == 'push' && (contains(github.event.head_commit.message, 'test-lammps') || github.event.base_ref == 'refs/heads/master')) + lammps-develop: + name: LAMMPS (develop) uses: ./.github/workflows/backend-template.yml with: backend_name: LAMMPS @@ -34,56 +33,28 @@ jobs: test_interface_directory: lammps/tests/interface rpath_exe: install/bin/lmp - namd: - name: NAMD + namd-devel: + name: NAMD (devel) # Prevent running this job on PRs across different accounts, because # secrets wouldn't be shared - if: | - (github.event_name == 'pull_request' && github.repository_owner == github.event.pull_request.head.repo.owner.login) || - (github.event_name == 'push' && (contains(github.event.head_commit.message, 'test-namd') || github.event.base_ref == 'refs/heads/master')) uses: ./.github/workflows/backend-template.yml with: backend_name: NAMD backend_repo: Colvars/namd - backend_repo_ref: master - container_name: CentOS7-devel - path_compile_script: devel-tools/compile-namd.sh - test_lib_directory: namd/tests/library - test_interface_directory: namd/tests/interface - rpath_exe: Linux-x86_64-g++.mpi/namd2 - secrets: - # Choice of license by UIUC prevents sharing the code, hence the secret - private_key: ${{ secrets.PULL_NAMD_KEY }} - - namd3: - name: NAMD3 (no CUDA) - # Prevent running this job on PRs across different accounts, because - # secrets wouldn't be shared - if: | - (github.event_name == 'pull_request' && github.repository_owner == github.event.pull_request.head.repo.owner.login) || - (github.event_name == 'push' && (contains(github.event.head_commit.message, 'test-namd') || github.event.base_ref == 'refs/heads/master')) - uses: ./.github/workflows/backend-template.yml - with: - backend_name: NAMD3 - backend_repo: Colvars/namd backend_repo_ref: devel path_compile_script: devel-tools/compile-namd.sh test_lib_directory: namd/tests/library - # Interface tests disabled until map variables are merged into NAMD3 - # test_interface_directory: namd/tests/interface + test_interface_directory: namd/tests/interface rpath_exe: Linux-x86_64-g++.mpi/namd3 container_name: CentOS7-devel secrets: # Choice of license by UIUC prevents sharing the code, hence the secret private_key: ${{ secrets.PULL_NAMD_KEY }} - vmd: + vmd-cvs: name: VMD # Prevent running this job on PRs across different accounts, because # secrets wouldn't be shared - if: | - (github.event_name == 'pull_request' && github.repository_owner == github.event.pull_request.head.repo.owner.login) || - (github.event_name == 'push' && (contains(github.event.head_commit.message, 'test-vmd') || github.event.base_ref == 'refs/heads/master')) uses: ./.github/workflows/backend-template.yml with: backend_name: VMD @@ -102,10 +73,7 @@ jobs: private_key_vmd_plugins: ${{ secrets.PULL_VMD_PLUGINS_KEY }} gromacs-2022: - name: GROMACS 2022 - if: | - (github.event_name == 'pull_request') || - (github.event_name == 'push' && (contains(github.event.head_commit.message, 'test-gromacs') || github.event.base_ref == 'refs/heads/master')) + name: GROMACS (release-2022) uses: ./.github/workflows/backend-template.yml with: backend_name: GROMACS-2022 @@ -117,10 +85,7 @@ jobs: rpath_exe: install/bin/gmx_d gromacs-2023: - name: GROMACS 2023 - if: | - (github.event_name == 'pull_request') || - (github.event_name == 'push' && (contains(github.event.head_commit.message, 'test-gromacs') || github.event.base_ref == 'refs/heads/master')) + name: GROMACS (release-2023) uses: ./.github/workflows/backend-template.yml with: backend_name: GROMACS-2023 @@ -131,14 +96,11 @@ jobs: test_lib_directory: gromacs/tests/library rpath_exe: install/bin/gmx_d - gromacs-devel: - name: GROMACS (MDModules) - if: | - (github.event_name == 'pull_request') || - (github.event_name == 'push' && (contains(github.event.head_commit.message, 'test-gromacs') || github.event.base_ref == 'refs/heads/master')) + gromacs-main: + name: GROMACS (main) uses: ./.github/workflows/backend-template.yml with: - backend_name: GROMACS-devel + backend_name: GROMACS-main backend_repo: gromacs/gromacs backend_repo_ref: main container_name: CentOS9-devel diff --git a/.github/workflows/test-library.yml b/.github/workflows/test-library.yml index bfc557faa..ad02a2415 100644 --- a/.github/workflows/test-library.yml +++ b/.github/workflows/test-library.yml @@ -1,6 +1,7 @@ name: "Library" -on: [push, pull_request] +on: + push: jobs: @@ -9,7 +10,6 @@ jobs: name: Basic checks runs-on: ubuntu-latest - if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository outputs: hassecrets: ${{ steps.checksecrets.outputs.hassecrets }} env: @@ -84,6 +84,13 @@ jobs: - name: Print ccache stats run: ccache -s -v + - name: Keep only one cache besides the one from this job + shell: bash + env: + GH_TOKEN: ${{ github.token }} + run: | + bash ${{ github.workspace }}/devel-tools/cleanup-gh-cache.sh ${{ runner.os }}-build-basic- + build-doc: name: Build documentation @@ -109,12 +116,36 @@ jobs: - name: Checkout website repository uses: actions/checkout@v4 with: + ssh-key: ${{ secrets.PULL_PUSH_COLVARS_GITHUB_IO }} repository: 'Colvars/colvars.github.io' path: 'website' - - name: Build doc + - name: Build doc for current branch + working-directory: doc + run: | + make clean-all + apptainer exec ${{ github.workspace }}/devel-tools/texlive.sif make + + - name: Install SSH key for access to website repository + if: contains(github.event.head_commit.message, '[update-doc]') + env: + WEBSITE_SSH_KEY: ${{ secrets.PULL_PUSH_COLVARS_GITHUB_IO }} + run: | + mkdir -p -m 700 ~/.ssh + echo "${WEBSITE_SSH_KEY}" > ~/.ssh/website + chmod 600 ~/.ssh/website + + - name: Push updated doc to website repository working-directory: doc - run: apptainer exec ${{ github.workspace }}/devel-tools/texlive.sif make + if: contains(github.event.head_commit.message, '[update-doc]') + env: + COLVARS_WEBSITE_TREE: ${{ github.workspace }}/website + run: | + apptainer exec ${{ github.workspace }}/devel-tools/texlive.sif make install + export GIT_SSH="ssh -i ~/.ssh/website" + git config --global user.email "noreply@github.com" + git config --global user.name "CI runner" + bash update_website.sh ${{ github.workspace }}/website codeql: @@ -267,7 +298,6 @@ jobs: name: Linux x86_64 (GCC, Clang) runs-on: ubuntu-latest needs: basicchecks - if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository env: CCACHE: ccache CMAKE_GENERATOR: Ninja @@ -478,7 +508,6 @@ jobs: name: Windows x86_64 (MSVC) runs-on: windows-latest needs: basicchecks - if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository steps: @@ -500,7 +529,6 @@ jobs: name: macOS x86_64 (AppleClang) runs-on: macos-latest needs: basicchecks - if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository steps: diff --git a/README.md b/README.md index a2a232847..32fc19ec5 100644 --- a/README.md +++ b/README.md @@ -2,17 +2,16 @@ A software module for molecular simulation and analysis that provides a high-performance implementation of sampling algorithms defined on a reduced space of continuously differentiable functions (aka collective variables). -First released in 2008 as part of the standard distribution of [NAMD](https://www.ks.uiuc.edu/Research/namd/) version 2.7b1, Colvars has also been integrated in [LAMMPS](https://lammps.sandia.gov/download.html) and [VMD](https://www.ks.uiuc.edu/Research/vmd/). In VMD, interactive use is possible both from the command line and through the [Dashboard](vmd/cv_dashboard/README.md) graphical user interface. +First released in 2008 as part of the standard distribution of [NAMD](https://www.ks.uiuc.edu/Research/namd/) version 2.7b1, Colvars has also been integrated in [LAMMPS](https://lammps.sandia.gov/download.html), [VMD](https://www.ks.uiuc.edu/Research/vmd/), [GROMACS](http://www.gromacs.org/), and [Tinker-HP](https://tinker-hp.org/). In VMD, interactive use is possible both from the command line and through the [Dashboard](vmd/cv_dashboard/README.md) graphical user interface. -Patched [releases](https://github.com/Colvars/gromacs) of [GROMACS](http://www.gromacs.org/) that contain Colvars are also available ([see below](#gromacs-colvars-releases)). - -The functionality provided by the Colvars library includes a variety of functions and algorithms, including free-energy estimators based on thermodynamic forces, non-equilibrium work and probability distributions. +The functionality provided to those packages by the Colvars library includes a variety of functions and algorithms, including free-energy estimators based on thermodynamic forces, non-equilibrium work and probability distributions. ## Obtaining and using The easiest way to obtain pre-compiled versions of Colvars is via one of following: - the molecular simulation program [LAMMPS](https://lammps.sandia.gov/download.html); - the molecular simulation program [NAMD](https://www.ks.uiuc.edu/Research/namd/); +- the molecular simulation program [Tinker-HP](https://tinker-hp.org/); - the molecular visualization program [VMD](https://www.ks.uiuc.edu/Research/vmd/). Please check [here](https://github.com/Colvars/colvars/wiki/List-of-Colvars-versions-included-in-simulation-and-analysis-packages) to see which version of Colvars is included with the round-number or "stable" versions of each code. @@ -21,9 +20,9 @@ For the molecular simulation program [GROMACS](http://www.gromacs.org/), code ma ## Documentation -The [Colvars webpage](https://colvars.github.io/) includes user documentation for the four codes, as well as a Doxygen-based [developer documentation](https://colvars.github.io/doxygen/html/). +The [Colvars webpage](https://colvars.github.io/) includes user documentation for all codes, as well as a Doxygen-based [developer documentation](https://colvars.github.io/doxygen/html/). -To reflect the different availability of features in each engine, the Colvars reference manual comes in several flavors: [GROMACS](https://colvars.github.io/colvars-refman-gromacs/colvars-refman-gromacs.html) [LAMMPS](https://colvars.github.io/colvars-refman-lammps/colvars-refman-lammps.html) [NAMD](https://colvars.github.io/colvars-refman-namd/colvars-refman-namd.html) [VMD](https://colvars.github.io/colvars-refman-vmd/colvars-refman-vmd.html) +To reflect the different availability of features in each engine, the Colvars reference manual comes in several flavors: [GROMACS](https://colvars.github.io/colvars-refman-gromacs/colvars-refman-gromacs.html) [LAMMPS](https://colvars.github.io/colvars-refman-lammps/colvars-refman-lammps.html) [NAMD](https://colvars.github.io/colvars-refman-namd/colvars-refman-namd.html) [Tinker-HP](https://colvars.github.io/colvars-refman-tinkerhp/colvars-refman-tinkerhp.html) [VMD](https://colvars.github.io/colvars-refman-vmd/colvars-refman-vmd.html) ## Citing @@ -52,10 +51,13 @@ cv configfile ``` fix Colvars all colvars configfile ``` -- In GROMACS: +- In GROMACS 2024 and later (mdp file): ``` -gmx mdrun -s topol.tpr -deffnm topol -colvars +colvars-active = yes +colvars-configfile = my_config.colvars ``` +- In Tinker-HP: +Create a Colvars configuration file with the same prefix as the `.key` file, and the extension `.colvars`. The contents of the configuration file are typically the same across all programs, for example: ``` @@ -100,7 +102,7 @@ and run the provided `update-colvars-code.sh` script against the unpacked source and recompile them. The `update-colvars-code.sh` script support patching the latest development version of each program: -- [GROMACS](https://github.com/gromacs/gromacs); +- [GROMACS](https://gitlab.com/gromacs/gromacs); - [LAMMPS](https://github.com/lammps/lammps); - [NAMD](https://gitlab.com/tcbgUIUC/namd); - [VMD and its plugins](https://www.ks.uiuc.edu/Research/vmd/doxygen/cvsget.html); note that starting from Colvars version 2023-06-23, some updates are needed to the VMD build script (see [here](https://colvars.github.io/README-c++11.html) for details). @@ -126,7 +128,7 @@ If using a patched release, please also reference the Colvars version: this is i ## Which version of Colvars is recommended? -The Git `master` branch is to be considered the "*stable*" release at any given time; any bugfixes are released through `master` first. The input syntax is near-completely *backward-compatible* and output files are *forward-compatible*. Feel free to download Colvars and update NAMD, VMD, LAMMPS or GROMACS as needed. +The Git `master` branch is to be considered the "*stable*" release at any given time; any bugfixes are released through `master` first. The input syntax is near-completely *backward-compatible* and output files are *forward-compatible*. Feel free to download Colvars and update NAMD, VMD, LAMMPS, GROMACS, or Tinker-HP as needed. Other branches are dedicated to the development of specific features: please use them at your own discretion. diff --git a/devel-tools/cleanup-gh-cache.sh b/devel-tools/cleanup-gh-cache.sh index f4029ddfb..486354d3a 100644 --- a/devel-tools/cleanup-gh-cache.sh +++ b/devel-tools/cleanup-gh-cache.sh @@ -1,6 +1,6 @@ #!/bin/bash -key=${1:-key Linux-build-} +key=${1:-Linux-build-} if [ -z "${key}" ] ; then echo "Error: please specify a cache key as argument." >& 2 @@ -9,7 +9,7 @@ fi gh actions-cache --help >& /dev/null || gh extension install actions/gh-actions-cache -# Keep at least one cache for each branch +# Keep at most one cache for each branch branches=$(gh actions-cache list --key ${key} | cut -f 3 | uniq) for branch in ${branches} ; do caches=($(gh actions-cache list --key ${key} --branch ${branch} | cut -f 1)) diff --git a/devel-tools/compile-gromacs.sh b/devel-tools/compile-gromacs.sh index e0afccf78..86f21c721 100755 --- a/devel-tools/compile-gromacs.sh +++ b/devel-tools/compile-gromacs.sh @@ -49,7 +49,7 @@ compile_gromacs_target() { if [ "${1,,}" = "debug" ]; then GMX_BUILD_TYPE=Debug GMX_BUILD_OPTS+=(-DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE=yes) - GMX_BUILD_OPTS+=(-DCOLVARS_DEBUG) + GMX_BUILD_OPTS+=(-DCOLVARS_DEBUG=ON) else GMX_INSTALL_DIR=${1} fi @@ -60,7 +60,7 @@ compile_gromacs_target() { GMX_BUILD_OPTS+=("-DGMX_MPI=ON") fi - # GMX_BUILD_OPTS+=("-DBUILD_OMP=yes") + GMX_BUILD_OPTS+=("-DGMX_OPENMP=yes") # Select FFT if [ "$(basename \"${CXX}\")" = "icpc" ] ; then diff --git a/devel-tools/compile-lammps.sh b/devel-tools/compile-lammps.sh index c406de140..3bdae1792 100755 --- a/devel-tools/compile-lammps.sh +++ b/devel-tools/compile-lammps.sh @@ -1,11 +1,9 @@ #!/bin/bash -source $(dirname $0)/load-recent-git.sh +source $(dirname $0)/load-openmpi.sh source $(dirname $0)/set-ccache.sh -source $(dirname $0)/load-openmpi.sh - compile_lammps_target() { @@ -75,6 +73,10 @@ compile_lammps_target() { LAMMPS_BUILD_OPTS+=("-DPKG_PYTHON=on") + if hash ccache >& /dev/null ; then + LAMMPS_BUILD_OPTS+=(-DCMAKE_{CXX,CC}_COMPILER_LAUNCHER=ccache) + fi + if hash ninja >& /dev/null ; then LAMMPS_BUILD_OPTS+=("-G" "Ninja") fi diff --git a/devel-tools/compile-namd.sh b/devel-tools/compile-namd.sh index 6afdac882..35b342c97 100755 --- a/devel-tools/compile-namd.sh +++ b/devel-tools/compile-namd.sh @@ -6,6 +6,11 @@ source $(dirname $0)/load-openmpi.sh source $(dirname $0)/set-ccache.sh +# Set explicit path for non-CMake targets +if [ -n "${CCACHE_HOME}" ] ; then + export PATH=${CCACHE_HOME}:${PATH} +fi + # Save path to be used later devel_tools_folder=$(realpath $(dirname $0)) diff --git a/devel-tools/compile-vmd.sh b/devel-tools/compile-vmd.sh index 40368f2cf..8cfba9b0c 100755 --- a/devel-tools/compile-vmd.sh +++ b/devel-tools/compile-vmd.sh @@ -4,6 +4,11 @@ source $(dirname $0)/load-recent-git.sh source $(dirname $0)/set-ccache.sh +# Set explicit path for non-CMake targets +if [ -n "${CCACHE_HOME}" ] ; then + export PATH=${CCACHE_HOME}:${PATH} +fi + detect_os() { # TODO This only works for RedHat-style Linux environments diff --git a/devel-tools/load-openmpi.sh b/devel-tools/load-openmpi.sh index 1b07d3289..320d41e2a 100644 --- a/devel-tools/load-openmpi.sh +++ b/devel-tools/load-openmpi.sh @@ -1,5 +1,7 @@ # Ensure that Lmod is properly initialized -source /etc/profile +if [ -f /etc/profile.d/modules.sh ] ; then + source /etc/profile.d/modules.sh +fi if declare -f module >& /dev/null ; then # Default modulefile in OpenMPI RPM package diff --git a/devel-tools/set-ccache.sh b/devel-tools/set-ccache.sh index cb73dd398..1f3f1e416 100644 --- a/devel-tools/set-ccache.sh +++ b/devel-tools/set-ccache.sh @@ -5,8 +5,6 @@ if [ -d /usr/lib64/ccache ] ; then export CCACHE_HOME=/usr/lib64/ccache fi -export PATH=${CCACHE_HOME}:${PATH} - if [ -z "${CCACHE_DIR}" ] || [ "x${CCACHE_DIR}" == "x/var/cache/ccache" ] ; then # Test for default setting in RHEL-like distributions if grep -sq 'CCACHE_DIR=/var/cache/ccache' /etc/profile.d/ccache.sh ; then @@ -18,4 +16,9 @@ if [ -z "${CCACHE_DIR}" ] || [ "x${CCACHE_DIR}" == "x/var/cache/ccache" ] ; then fi # Report cache statistics -ccache -sv +if ccache -sv >& /dev/null ; then + ccache -sv +else + # Old versions + ccache -s +fi diff --git a/devel-tools/version_functions.sh b/devel-tools/version_functions.sh index 8fd3abcad..5cbb76f3d 100644 --- a/devel-tools/version_functions.sh +++ b/devel-tools/version_functions.sh @@ -224,7 +224,7 @@ update_all_versions() { vmd/cv_dashboard/VERSION \ ${branch} \ && \ - git commit -m "Update version strings" + git commit -m "Update version strings" -m "[update-doc]" } diff --git a/doc/.gitignore b/doc/.gitignore index 44505fe7f..f30a05306 100644 --- a/doc/.gitignore +++ b/doc/.gitignore @@ -1,4 +1,6 @@ # Typical LaTeX intermediate files +*.4ct +*.4tc *.aux *.bbl *.blg @@ -7,16 +9,13 @@ *.fls *.fdb_latexmk *.idx +*.idv *.ilg *.ind *.log +*.lg *.out *.toc +*.tmp +*.xref *-eps-converted-to.pdf - -# Compiled documentation -colvars-refman-gromacs.pdf -colvars-refman-lammps.pdf -colvars-refman-namd.pdf -colvars-refman-tinkerhp.pdf -colvars-refman-vmd.pdf diff --git a/doc/Makefile b/doc/Makefile index 22385a7cb..52c871947 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -2,24 +2,6 @@ install clean clean-all \ update-code-refs update-cvscript-cmdline-doc updates -PDF = \ - colvars-refman-gromacs.pdf \ - colvars-refman-lammps.pdf \ - colvars-refman-namd.pdf \ - colvars-refman-tinkerhp.pdf \ - colvars-refman-vmd.pdf - -HTML = \ - colvars-refman-gromacs.html \ - colvars-refman-lammps.html \ - colvars-refman-namd.html \ - colvars-refman-tinkerhp.html \ - colvars-refman-vmd.html - -CSS = $(HTML:.html=.css) - -BIBTEX = colvars-refman.bib - ifeq ($(COLVARS_RELEASE),) # Unless defined otherwise, the release label is the name of the branch COLVARS_RELEASE = $(shell git symbolic-ref --short -q HEAD) @@ -27,15 +9,50 @@ endif ifeq ($(COLVARS_RELEASE),) # If we are not working on a branch, try a tag instead -COLVARS_RELEASE = $(git describe --tags --exact-match) +COLVARS_RELEASE = $(shell git describe --tags --exact-match) endif export COLVARS_RELEASE +# Check if this a release of a specific engine +COLVARS_RELEASE_PREFIX := $(firstword $(subst -, , $(COLVARS_RELEASE))) +# Only allow specific cases +ifeq ($(COLVARS_RELEASE_PREFIX),gromacs) + RELEASE_ENGINE := $(COLVARS_RELEASE_PREFIX) +endif +ifeq ($(COLVARS_RELEASE_PREFIX),lammps) + RELEASE_ENGINE := $(COLVARS_RELEASE_PREFIX) +endif +ifeq ($(COLVARS_RELEASE_PREFIX),namd) + RELEASE_ENGINE := $(COLVARS_RELEASE_PREFIX) +endif +ifeq ($(COLVARS_RELEASE_PREFIX),tinkerhp) + RELEASE_ENGINE := $(COLVARS_RELEASE_PREFIX) +endif +ifeq ($(COLVARS_RELEASE_PREFIX),vmd) + RELEASE_ENGINE := $(COLVARS_RELEASE_PREFIX) +endif +export RELEASE_ENGINE + -all: pdf html doxygen +ifeq ($(RELEASE_ENGINE),) +# Build doc for all engines +ENGINES = gromacs lammps namd tinkerhp vmd +else +ENGINES = $(RELEASE_ENGINE) +endif -updates: version-list update-code-refs update-cvscript-cmdline-doc +PDF = $(foreach _,${ENGINES},colvars-refman-$_.pdf) +HTML = $(foreach _,${ENGINES},colvars-refman-$_.html) + +CSS = $(HTML:.html=.css) +BIBTEX = colvars-refman.bib + +ifeq ($(COLVARS_RELEASE),"master") +all: pdf html doxygen +else +all: pdf html +endif pdf: $(PDF) html: $(HTML) @@ -58,11 +75,21 @@ HTLATEX_OPTS = "html5mjlatex.cfg, charset=utf-8" " -cunihtf -utf8" $(HTLATEX) $(notdir $<) $(HTLATEX_OPTS); \ bash postprocess_html.sh + +ifeq ($(COLVARS_RELEASE),"master") +all: pdf html doxygen +else +all: pdf html +endif + clean: rm -f *.fdb_latexmk *.fls *.aux *.bbl *.blg *.log *.toc *.out *.idx *.ilg *.ind *.brf *.4tc *.4ct *.dvi *.idv *.lg *.xref *.tmp eulerangles-512px.png clean-all: clean rm -f $(PDF) $(HTML) $(CSS) + rm -fr doxygen/html + @echo + @echo "Note: only removed files that this branch is set to build." version-list: ./print_engine_versions.sh > ../README-versions.md @@ -73,6 +100,7 @@ update-code-refs: update-cvscript-cmdline-doc: tclsh gen_cvscript_doc.tcl +updates: version-list update-code-refs update-cvscript-cmdline-doc doxygen: doxygen/html/index.html @@ -92,7 +120,9 @@ IMAGES = cover-512px.jpg eulerangles-512px.png # Install docs in the website tree, under the folder named $(COLVARS_RELEASE). # Note: to produce the documentation for a specific release of a MD engine, # check out the branch or tag corresponding to that version, clean and rebuild. -webpage: all images +ifeq ($(COLVARS_RELEASE),master) + +webpage: all images doxygen mkdir -p $(COLVARS_WEBSITE_TREE)/$(COLVARS_RELEASE) ; \ cp -p -f $(PDF) $(HTML) $(CSS) $(COLVARS_WEBSITE_TREE)/$(COLVARS_RELEASE)/ ; \ cp -p -f $(addprefix $(COLVARS_WEBSITE_TREE)/images/, $(IMAGES)) $(COLVARS_WEBSITE_TREE)/$(COLVARS_RELEASE)/ ; \ @@ -102,11 +132,22 @@ webpage: all images # Update HTML pages with older-style paths (without branch/release name) webpage-legacy: all images cp -p -f $(PDF) $(COLVARS_WEBSITE_TREE)/pdf ; \ - for engine in lammps namd tinkerhp vmd ; do \ + for engine in $(ENGINES) ; do \ cp -p -f colvars-refman-$${engine}.{html,css} $(COLVARS_WEBSITE_TREE)/colvars-refman-$${engine}/ ; \ cp -p -f $(addprefix $(COLVARS_WEBSITE_TREE)/images/, $(IMAGES)) $(COLVARS_WEBSITE_TREE)/colvars-refman-$${engine}/ ; \ done install: webpage webpage-legacy +else + +webpage: all images + mkdir -p $(COLVARS_WEBSITE_TREE)/$(COLVARS_RELEASE) ; \ + cp -p -f $(PDF) $(HTML) $(CSS) $(COLVARS_WEBSITE_TREE)/$(COLVARS_RELEASE)/ ; \ + cp -p -f $(addprefix $(COLVARS_WEBSITE_TREE)/images/, $(IMAGES)) $(COLVARS_WEBSITE_TREE)/$(COLVARS_RELEASE)/ + +install: webpage +endif + + endif diff --git a/doc/README.md b/doc/README.md index 1b48112c9..ff0b5461e 100644 --- a/doc/README.md +++ b/doc/README.md @@ -1,13 +1,35 @@ ## Building the documentation -This folder contains LaTeX files needed to build the Colvars documentation in PDF format. On a computer with a working LaTeX installation, use the following to build the PDF manuals for all supported backends in parallel: +This folder contains LaTeX files needed to build the Colvars documentation in PDF and HTML formats. Not all installation of TeXlive contain functional code, thus we highly recommend using the container used in development. ``` -$ make -j +$ apptainer pull texlive.sif oras://ghcr.io/Colvars/devel-containers:texlive +$ apptainer exec texlive.sif make all ``` -The HTML version of the doc is built from within a worktree of the [colvars.github.io](https://github.com/Colvars/colvars.github.io) repository, which is the GitHub Pages repository responsible for the main Colvars webpage. +Note: if the working folder is not under `/home`, Apptainer may not automatically bind it in the container: in that case, try using `--bind `. Likewise, adapt this step for different container engines (e.g. Docker, Podman, etc). + +The GNU Make variable `COLVARS_RELEASE` will be automatically taken from the Git branch or tag name. Alternatively, feel free to define it as environment variable, for example: +``` +$ export COLVARS_RELEASE=gromacs-2024 +$ apptainer exec texlive.sif make all +``` +Note that when the release is prefixed by the name of a specific engine, only the doc for that engine gets built. + + +## Updating the website + +To update the website, clone its [repository](https://github.com/Colvars/colvars.github.io) and set the environment variable accordingly before building the documentation: +``` +$ export COLVARS_WEBSITE_TREE= +$ make all +$ make install +``` + + +## LaTeX file organization The file `colvars-refman-main.tex` is the main file, which includes content that is conditionally rendered by LaTeX depending on the version of the documentation being generated. There are specific LaTeX files for each backend that include this file to generate the specific version of the doc, e.g. `colvars-refman-gromacs.tex` to generate the doc for Gromacs users. + ## Citations to software The file `colvars-code-refs.bib` contains BibTeX entries for all papers or preprints describing software implementations of specific features, either implemented within Colvars or outside (e.g. the publications of the back-end code and some of their features are included as well). One or more comment lines (preceded by `%`) describe the feature(s) associated to that publication. Descriptions must be short and unique, because they are used by the code to generate a citation report during a run. diff --git a/doc/colvars-engine-flags.tex b/doc/colvars-engine-flags.tex index 18004a804..38dbf9749 100644 --- a/doc/colvars-engine-flags.tex +++ b/doc/colvars-engine-flags.tex @@ -3,6 +3,7 @@ \cvgromacsonly{ \def\cvsimulationengine{1} % This backend is a simulation engine +\def\gromacsmdmodule{1} % This is the native interface (long-term support) } \cvlammpsonly{ diff --git a/doc/colvars-refman-main.tex b/doc/colvars-refman-main.tex index bed8e6479..b0946fd02 100644 --- a/doc/colvars-refman-main.tex +++ b/doc/colvars-refman-main.tex @@ -367,6 +367,7 @@ This version results in extremely fast updates. } % cvvmdonly dashboard + \cvsec{Enabling and controlling the Colvars module in \MDENGINE{}}{sec:colvarmodule} Here, we document the syntax of the commands and parameters used to set up and use the Colvars module in \MDENGINE{}\cvgromacsonly{ \cite{Abraham2015}}\cvlammpsonly{ \cite{Plimpton1995}}\cvnamdonly{ \cite{Phillips2020}}. @@ -374,11 +375,11 @@ \cvsubsec{Units in the Colvars module}{sec:units} -The ``internal units'' of the Colvars module are the units in which values are expected to be in the configuration file, and in which collective variable values, energies, etc. are expressed in the output and colvars trajectory files. +The ``internal units'' of the Colvars module are the units in which values are expressed in the configuration file, and in which collective variable values, energies, etc.\ are expressed in the output and colvars trajectory files. Generally \textbf{the Colvars module uses internally the same units as its back-end MD engine, with the exception of VMD}, where different unit sets are supported to allow for easy setup, visualization and analysis of Colvars simulations performed with any simulation engine. Note that \textbf{angles} are expressed in degrees, and derived quantities such as force constants are based on degrees as well. -Some colvar components have default values, expressed in \AA{}ngstr\"om in this documentation. They are converted to the current length unit as needed. +Some colvar components have default values, expressed in \AA{}ngstr\"om (\AA) in this documentation. They are converted to the current length unit, if different from \AA. Atomic coordinates read from \textbf{XYZ files} (and PDB files where applicable) are expected to be expressed in \AA{}ngstr\"om, no matter what unit system is in use by the back-end (\MDENGINE) or the Colvars Module. They are converted internally to the current length unit as needed. Note that force constants in \texttt{harmonic} and \texttt{harmonicWalls} biases (\ref{sec:colvarbias_harmonic}) are rescaled according to the \refkey{width}{colvar|width} parameter of colvars, so that they are formally in energy units, although if \refkey{width}{colvar|width} is given its default value of 1.0, force constants are effectively expressed in \energyunit/\textit{(colvar unit)}$^2$. @@ -457,7 +458,7 @@ \cvsubsec{LAMMPS keywords}{sec:colvars_mdengine_parameters} To enable a Colvars-based calculation, the following line must be added to the LAMMPS configuration file: -\begin{mdexampleinput}{} +\begin{mdexampleinput} fix~Colvars~all~colvars~\emph{configfile}~[\emph{keyword value pairs ...}] \end{mdexampleinput} where the fix ID is here set to the string ``\texttt{Colvars}'', because there can only be one instance of \texttt{fix colvars} in a LAMMPS run. @@ -530,8 +531,76 @@ \cvgromacsonly{ + \cvsubsec{Running Colvars in GROMACS}{sec:colvars_mdengine_parameters} +\ifdefined\gromacsmdmodule + +\textbf{Note:} \emph{the GROMACS keywords described here are only supported in GROMACS versions 2024 and later, where Colvars is supported natively.} + +To enable a simulation with Colvars, one or more options should be added to the typical \texttt{mdp} parameters, for example: +\begin{mdexampleinput} +\-;~MDP~file\\ +\-...\\ +\-colvars-active~=~yes\\ +\-colvars-configfile~=~my\_config.colvars\\ +\-...\\ +\-(other~MDP~options)\\ +\end{mdexampleinput} +When the \texttt{gmx grommp} command is called to create a TPR file, the contents of \texttt{my\_config.colvars} and of all files referenced by it are bundled in the TPR file as well. +In any run based on the same TPR file, \texttt{gmx mdrun} will not access any of the original files used to initialize Colvars. +Therefore to modify the Colvars configuration (e.g.\ adding or removing a bias), a new TPR file should be built as well. +To do this while also continuing a previous simulations, please see \ref{sec:change_config_restart}. + +\begin{itemize} + +\item % + \keydef{% + colvars-active}{% + MDP option}{% + Activate the Colvars module in GROMACS}{% + boolean}{% + \texttt{no}}{% + Activate Colvars computation in the current run. Requires that the Colvars library was compiled into GROMACS, which is the default. +} + +\item % + \key + {colvars-configfile}{% + MDP option}{% + Colvars configuration file}{% + string}{% + Name of the Colvars configuration file, which can be either an absolute path, or a path relative to the working directory when \texttt{gmx grompp} is called. +} + +\item % + \keydef{colvars-seed}{% + MDP option}{% + Random number generator seed}{% + integer}{% + -1}{% + Seed used to initialize the random generator associated with certain stochastic methods implemented within Colvars. The default value generates a random seed. +} + +\end{itemize} + +\noindent{}Then, create the \texttt{tpr} and launch the simulation using a standard \texttt{gmx mdrun} command line: +\begin{mdexampleinput} +\-gmx~grompp~-f~system.mdp~-p~system.top~-c~init.gro~-o~test.tpr\\ +\-gmx~mdrun~-s~test.tpr +\end{mdexampleinput} + +\noindent{}Continuing from a previous simulation is done using the \texttt{-cpi} parameter for the checkpoint file (e.g.\ ``\texttt{state.cpt}''). This file holds the required information to restart the Colvars-based simulation. +\begin{mdexampleinput} +\-gmx~convert-tpr~-s~test.tpr~-nsteps~\${NUMSTEPS}~-o~test\_restart.tpr\\ +\-gmx~mdrun~-s~test\_restart.tpr~-cpi~state.cpt +\end{mdexampleinput} + +Other output files (not needed for restarting) will be written using as prefix the value of the \texttt{-e} flag of \texttt{gmx mdrun} (see \ref{sec:colvars_output)}). + +\else + +\textbf{Note:} \emph{This section describes how to use Colvars in GROMACS versions until 2023, using patched GROMACS source code. This interface is now deprecated: whenever possible, please consider using GROMACS 2024 and later versions, which support and include Colvars natively.} To enable a Colvars-based calculation, just specify one or more Colvars configuration files with the \texttt{-colvars} command-line parameter to \texttt{gmx mdrun}: \begin{mdexampleinput} @@ -550,16 +619,14 @@ For the output files, the prefix of Colvars output files will use the \texttt{-defnnm} option of mdrun, or be the same as the GROMACS log file if the option is not set. Otherwise, the prefix will be \emph{output}. -\textbf{Note on PBC wrapping in GROMACS.} Internally, GROMACS handles only PBC-wrapped atom coordinates, which may break the calculation of some variables if their atom groups become split across PBCs. -To prevent this, Colvars unwraps coordinates throughout the simulation, by assuming that each atom group is intact in the initial coordinates, and canceling any later jumps across the periodic box. -This information is propagated across restarts, and communicated between replicas when GROMACS is used for replica-exchange simulations. Thus, Colvars is compatible with native replica-exchange in GROMACS. +\fi } % \cvgromacsonly \cvtinkerhponly{ \cvsubsec{Running Colvars in Tinker-HP}{sec:colvars_mdengine_parameters} To enable Colvars within a Tinker-HP run, just provide a Colvars configuration file with the same prefix as the \texttt{.key} file, and the extension \texttt{.colvars}. -Tcl-scripted variables and biases Tcl callbacks may be defined by sourcing a script file using the \refkey{sourceTclFile}{Colvars-global|sourceTclFile} option. +Tcl-scripted variables and biases may be defined by sourcing a script file using the \refkey{sourceTclFile}{Colvars-global|sourceTclFile} option. }% \cvtinkerhponly @@ -578,13 +645,13 @@ \begin{enumerate} \item Provide an updated value for the \textbf{parameters of the fix} listed in \ref{sec:colvars_mdengine_parameters}: this behavior is similar to that of several other LAMMPS fix styles, and follows the same argument parsing rules. For example, multiple keywords can be provided together: -\begin{mdexampleinput}{% -}fix\_modify~Colvars~\texttt{seed}~111111~\texttt{tstat}~\texttt{NPT} +\begin{mdexampleinput} +\-fix\_modify~Colvars~\texttt{seed}~111111~\texttt{tstat}~\texttt{NPT} \end{mdexampleinput} \item Use one of the \textbf{scripting functions} described in this section; the arguments provided as strings are passed to Colvars. LAMMPS variables referenced by their string representation, ``\texttt{\$\{variable\}}'', will be expanded immediately. Additionally, variable expansion \emph{will also happen within quotes}, similar to what the \texttt{mdi} command provides in a LAMMPS script: this feature makes it possible to use the values of certain LAMMPS variables in Colvars configuration strings (see \ref{sec:cv_command_init}). -\begin{mdexampleinput}{% -}variable~freq~index~10000\\ +\begin{mdexampleinput} +\-variable~freq~index~10000\\ \-dump~myDump~all~atom/zstd~\$\{freq\}~dump.atom.zstd\\ \-fix\_modify~Colvars~config~"colvarsTrajFrequency~\$\{freq\}" \end{mdexampleinput} @@ -672,7 +739,7 @@ The vast majority of the syntax in Colvars is backward-compatible, adding keywords when new features are introduced. However, when using multiple versions simultaneously it may be useful to test within the script whether the version is recent enough to support the desired feature. The ``\texttt{version}'' can be used to get the Colvars version for this use: -\begin{mdexampleinput}{} +\begin{mdexampleinput} \-if~\{~[cv~version]~>=~"2020-02-25"~\}~\{\\ \-~~cv~config~"(use~a~recent~feature)"\\ \-\} @@ -698,7 +765,7 @@ \-structure~newsystem.psf\\ \-reinitatoms~$<$snapshot$>$\\ \-cv~reset\\ -\-cv~configfile~...\\ +\-cv~configfile~$<$new\_config$>$\\ \-cv~load~$<$snapshot$>$ \end{mdexampleinput} } % \cvnamdonly @@ -708,6 +775,7 @@ Because not only a state file (used to continue simulations) but also other data files (used to analyze the trajectory) are written, it is generally recommended to call the \texttt{save} method using a prefix, rather than a complete file name: \cvscriptexampleinputcv{save}{"$<$job$>$"} + \cvsubsubsec{Accessing atomic data}{sec:cv_command_atomic_data} For computational efficiency the Colvars module keeps internal copies of the numeric IDs, masses, charges, positions, and optionally total forces of the atoms requested for a Colvars computation. @@ -825,7 +893,7 @@ \cvnamdonly{Another circumstance when ``\texttt{update}'' may be called e.g.{} as part of the function invoked by \refkey{scriptedColvarForces}{Colvars-global|scriptedColvarForces}, it is executed before any biasing forces are applied to the variables, thus allowing to modify them. This use of ``\texttt{update}'' is often used e.g.{} in the definition of custom bias-exchange algorithms as part of the \MDENGINE{} script. Because a restraint is a relatively light-weight object, the easiest way to change the configuration of an existing bias is deleting it and re-creating it: -\begin{mdexampleinput}{} +\begin{mdexampleinput} \-{\bfseries\#~Delete~the~restraint~"harmonic\_xi"}\\ \-cv~bias~harmonic\_xi~delete\\ \-{\bfseries\#~Re-define~it,~but~using~an~updated~restraint~center}\\ @@ -838,7 +906,7 @@ \-cv~bias~harmonic\_xi~update \end{mdexampleinput} It is also possible to make the change subject to a condition on the energy of the new bias: -\begin{mdexampleinput}{} +\begin{mdexampleinput} \-...\\ \-cv~bias~harmonic\_xi~update\\ \-if~\{~[cv~bias~harmonic\_xi~energy]~<~\$\{E\_accept\}~\}~\{\\ @@ -846,7 +914,7 @@ \-\} \end{mdexampleinput} } % \cvnamdonly - + \cvsubsubsec{Loading and saving the state of individual biases}{sec:cv_command_bias_loadsave} @@ -857,7 +925,9 @@ \cvscriptexampleinputbias{load}{"old"}{"metadynamics1"} A corresponding ``\texttt{save}'' function is also available: \cvscriptexampleinputbias{save}{"new"}{"metadynamics1"} -\noindent{}This pair of functions is also used internally by Colvars to implement e.g.{} multiple-walker metadynamics (\ref{sec:colvarbias_meta_mr}), but they can be called from a scripted function to implement alternative coupling schemes. +\noindent{}Please note that the file above must contain only the state information for that particular bias: \emph{loading a state file for the whole module is not allowed.} + +This pair of functions is also used internally by Colvars to implement e.g.{} multiple-walker metadynamics (\ref{sec:colvarbias_meta_mr}), but they can be called from a scripted function to implement alternative coupling schemes. \ifdefined\cvscriptcmdapi{See \ref{sec:cvscript_cmdline_bias} for a complete list of scripting commands used to manage biases.}\fi @@ -915,11 +985,13 @@ global}{% Colvar module restart frequency}{% positive integer}{% - \cvnamdonly{NAMD parameter \texttt{restartFreq}}\cvlammpsonly{LAMMPS \texttt{restart} frequency when defined}\cvvmdonly{0}}{% - The state file and any other output files produced by Colvars are written every these many steps (the trajectory file is still written every \refkey{colvarsTrajFrequency}{Colvars-global|colvarsTrajFrequency} steps). + \cvgromacsonly{0}\cvnamdonly{NAMD parameter \texttt{restartFreq}}\cvlammpsonly{LAMMPS \texttt{restart} frequency when defined}\cvvmdonly{0}}{% + When this value is non-zero, a state file suitable for restarting will be written every these many steps. + Additionally, any other output files produced by Colvars are written as well (except the trajectory file, which is written every \refkey{colvarsTrajFrequency}{Colvars-global|colvarsTrajFrequency} steps). \cvvmdonly{In VMD, the simulation step is not progressed and this parameter is effectively ignored.} It is generally a good idea to leave this parameter at its default value, unless needed for special cases or to disable automatic writing of output files altogether. - Writing can still be invoked at any time via the command \texttt{cv save}.} + \cvgromacsonly{(The default value of 0 in GROMACS reflects this.)} + \ifdefined\cvscriptapi{If neeed, writing of all output files can still be triggered at any time via the \texttt{save} scripting function}.\fi} \item % \labelkey{Colvars-global|indexFile} @@ -973,34 +1045,43 @@ \item Formatted, i.e.\ \emph{``text''} format, which takes more space and is slower to to load/save but is also portable across different platforms and even different simulation engines (save for changes in physical units). This format is used by default, unless explicitly requested otherwise. -\item Unformatted, i.e.\ \emph{``binary''} format, which is both space-efficient and quick to load/save, but requires that the same \MDENGINE{} build was used to write the file and that the Colvars configuration remains the same. This format is supported by Colvars versions starting 2023-09-25. -Colvars state files are written in binary format by setting the environment variable ``\texttt{COLVARS\_BINARY\_RESTART}'' to 1. +\item Unformatted, i.e.\ \emph{``binary''} format, which is both space-efficient and quick to load/save, but requires that the same \MDENGINE{} build was used to write the file and that the Colvars configuration remains the same. This format is supported by Colvars versions starting 2023-09-25\cvgromacsonly{ (GROMACS versions 2024 and later)}. +Colvars state files can be written in binary format by setting the environment variable ``\texttt{COLVARS\_BINARY\_RESTART}'' to 1. \end{itemize} -\cvsubsubsec{Contents of the state file.}{} +% \cvsubsubsec{Contents of the state file.}{} + In either format, the state file contains accumulated data as well as the step number at the end of the run. The step number read from a state file overrides any value that \MDENGINE{} provides, and will be incremented if the simulation proceeds. This means that the step number used internally by Colvars may not always match the step number reported by \MDENGINE{}. \cvnamdonly{This is particularly inmportant in NAMD, which represents step numbers as a 32-bit integers that overflows after $\sim$ 2 billion steps, effectively negating the usefulness of the \texttt{firstTimeStep} keyword. However, step numbers are implemented correctly in the Colvars state file.} \cvgromacsonly{\cvsubsubsec{Restarting in GROMACS.}{} + \ifdefined\gromacsmdmodule Beginning with GROMACS 2024, all information necessary to restart Colvars is included in the checkpoint ``\texttt{.cpt}'' file. No special provisions are therefore needed compared to a GROMACS simulation without Colvars enabled. + \else + For the GROMACS patched versions until 2023, Colvars can be restarted by providing the \texttt{-colvars\_restart} option to \texttt{gmx mdrun}: +\begin{mdexampleinput} +\-gmx~mdrun~-s~test\_restart.tpr~-deffnm~md~-cpi~state.cpt~\textbackslash\\ +\-~~~~-colvars~config.colvars.dat~-colvars\_restart~md.colvars.state.dat +\end{mdexampleinput} + \fi } \cvlammpsonly{\cvsubsubsec{Restarting in LAMMPS.}{} For continuing a Colvars-based simulation, the recommended method is using the standard LAMMPS \texttt{read\_restart} command, which reads the Colvars state data from the LAMMPS restart file (in binary format). -\begin{mdexampleinput}{} +\begin{mdexampleinput} \-read\_restart~\emph{filename} \end{mdexampleinput} Alternatively, restarting from a Colvars-specific state file is also possible by providing the \texttt{input} keyword to the \texttt{fix colvars} command: -\begin{mdexampleinput}{} +\begin{mdexampleinput} \-fix~Colvars~all~colvars~\emph{configfile}~input~\emph{input\_prefix} \end{mdexampleinput} When the ``\texttt{input}'' keyword is used, the contents of the file \texttt{$<$\emph{input\_prefix}$>$.colvar.state} override the information read from the LAMMPS restart file. Finally, a state file may also be loaded after initialization through the ``\texttt{fix\_modify}'' command: -\begin{mdexampleinput}{% -}fix\_modify~Colvars~\texttt{input}~\emph{new\_input\_prefix} +\begin{mdexampleinput} +\-fix\_modify~Colvars~\texttt{input}~\emph{new\_input\_prefix} \end{mdexampleinput} } % end \cvlammpsonly @@ -1012,7 +1093,7 @@ } % end \cvnamdonly -\cvsubsubsec{Changing configuration upon restarting.}{} +\cvsubsubsec{Changing configuration upon restarting.}{sec:change_config_restart} In some cases, it is useful to modify the configuration of variables or biases between consecutive runs, for example by adding or removing a restraint. Some special provisions will happen in that case. @@ -1021,12 +1102,12 @@ Please note that these checks are performed based only on the \emph{names} of variables and biases: it is your responsibility to ensure that these names have \emph{consistent definitions between runs.} The flexibility just described carries some limitations: namely, it is only supported when reading \emph{text-format} Colvars state files. -Instead, restarting from binary files\cvlammpsonly{ (such as the LAMMPS restart file)}\cvgromacsonly{ (such as the GROMACS checkpoint file)} after a configuration change will trigger an error. +Instead, restarting from binary files\cvlammpsonly{ (such as the LAMMPS restart file)}\cvgromacsonly{\ifdefined\gromacsmdmodule{} (such as the GROMACS checkpoint file)\fi} after a configuration change will trigger an error. It is also important to remind that when switching to a different build of \MDENGINE, the binary format may change slightly, even if the release version is the same. To work around the potential issues just described, a text-format Colvars state file should be loaded. \ifdefined\cvvmdornamd{This is the default in \MDENGINE{} unless the ``\texttt{COLVARS\_BINARY\_RESTART}'' is set to 1, and this information is only provided here for troubleshooting purposes.}\fi\cvlammpsonly{This can be achieved by providing an explicit \texttt{input} keyword when initializing the Colvars fix (see \ref{sec:colvars_mdengine_parameters}), which will instruct Colvars to use the given filename, instead of the LAMMPS restart file. - Furthermore, the \texttt{fix\_modify} scripting command allows to load a Colvars file after initialization (\ref{sec:cv_command_loadsave}).}\cvgromacsonly{Loading such state file requires an exception to the standard behavior in GROMACS (i.e.\ loading a checkpoint file): this exception is supported by the following Colvars configuration: + Furthermore, the \texttt{fix\_modify} scripting command allows to load a Colvars file after initialization (\ref{sec:cv_command_loadsave}).}\cvgromacsonly{\ifdefined\gromacsmdmodule{}Loading such state file requires an exception to the standard behavior in GROMACS (i.e.\ loading a checkpoint file): this exception is supported by the following Colvars configuration: \begin{itemize} \item % \labelkey{Colvars-global|defaultInputStateFile} @@ -1040,23 +1121,24 @@ When a Colvars configuration featuring \texttt{defaultInputStateFile} is processed into a TPR file, and a GROMACS simulation is started from this TPR file but without providing a checkpoint, Colvars will load its state from the file named by \texttt{defaultInputStateFile}. Later, when that same simulation is continued by providing a checkpoint file to GROMACS, Colvars will ignore \texttt{defaultInputStateFile} and will read its data from the checkpoint file. For the sake of clarity, we recommend that as soon as a suitable GROMACS checkpoint is available, the \texttt{defaultInputStateFile} is removed \emph{removed}, and a new TPR file is produced accordingly. +\fi % end \ifdefined\gromacsmdmodule } \cvsubsec{Output files}{sec:colvars_output} -If the output prefix \outputName{} is defined\cvgromacsonly{ (in GROMACS, this is defined by the value of the \texttt{-e} flag of \texttt{mdrun})}, the following output files are written during a simulation run: +When the output prefix \outputName{} is defined\cvgromacsonly{ (in GROMACS, this is automatically set to the value of the \ifdefined\gromacsmdmodule{}\texttt{-e}\else{}\texttt{-g}\fi flag of \texttt{mdrun})}, the following output files are written during a simulation run: \begin{itemize} \item A \emph{state file}, named \outputName\texttt{.colvars.state}, which is written at the end of the specified run\cvscriptonly{, and can also be written at any time with the scripting command \texttt{save} (\ref{sec:cv_command_loadsave})}. This file is in plain text format by default\cvnamdonly{, regardless of the value of \texttt{binaryOutput} of the NAMD coordinate and velocity files}, or in binary format if the environment variable \texttt{COLVARS\_BINARY\_RESTART} is set to a non-zero integer. -The state file is used to continue a simulation, and is required to restart a simulation unless the engine supports embedding information into their checkpoint file (as GROMACS or LAMMPS currently do). +The state file can be used to continue a simulation: unless its contents are embedded in the checkpoint file of the MD engine itself (currently, GROMACS and LAMMPS support this), instructions for loading the Colvars state file will be required in the simulation script (see \ref{sec:colvars_input}). -\item If the parameter \refkey{colvarsRestartFrequency}{Colvars-global|colvarsRestartFrequency} is larger than zero and \restartName{} is defined\cvgromacsonly{ (this is \emph{not} the case in GROMACS)}, a \emph{restart file} is written every that many steps: this file is fully equivalent to the final state file. +\item If the parameter \refkey{colvarsRestartFrequency}{Colvars-global|colvarsRestartFrequency} is larger than zero and the \restartName{} prefix is defined\cvgromacsonly{ (note: this is \emph{not} the case in GROMACS)}, a \emph{restart file} is written every that many steps: this file is fully equivalent to the final state file. The name of this file is \restartName\texttt{.colvars.state}. -\item If the parameter \refkey{colvarsTrajFrequency}{Colvars-global|colvarsTrajFrequency} is greater than 0 (default value: 100 steps), a \emph{trajectory file}, named \outputName\texttt{.colvars.traj}, is written during the simulation. Unlike the state file, this file is not needed to restart a simulation, but can be used for post-processing and analysis. The format of this file is described in sec.~\ref{sec:colvars_traj_format}. +\item If the parameter \refkey{colvarsTrajFrequency}{Colvars-global|colvarsTrajFrequency} is greater than 0 (default value: 100 steps), a \emph{trajectory file}, named \outputName\texttt{.colvars.traj}, is written during the simulation. Unlike a state file, this file is not needed to restart a simulation, but can be used for post-processing and analysis. The format of this file is described in sec.~\ref{sec:colvars_traj_format}. \item Additionally, certain features, when enabled, can emit output files with a specific purpose: for example, potentials of mean force (PMFs) can be written to file to be analyzed or plotted. These files are described in the respective sections, but as a general rule they all use names beginning with the \outputName{} prefix. Like the trajectory file, these additional files are needed only for analyzing a simulation's results, but not to continue it. @@ -1075,7 +1157,7 @@ \emph{Configuration files} are text files that are generally read as input by \MDENGINE{}\cvscriptonly{, and may be optionally inlined in a \MDENGINE{} script (see \ref{sec:cv_command_init})}. Starting from version 2017-02-01, changes in newline encodings are handled transparently, i.e.\ it is possible to typeset a configuration file in Windows (CR-LF newlines) and then use it with Linux or macOS (LF-only newlines). -\emph{State files}, although not written manually, follow otherwise the same text format as configuration files. +\emph{Formatted state files}, although not written manually, follow otherwise the same text format as configuration files. \texttt{Binary state files} can only be read by the Colvars code itself. \cvsubsubsec{Index (NDX) files}{sec:colvars_ndx_format} @@ -1118,6 +1200,8 @@ \noindent{}where $N$ is the number of atomic coordinates in the file and $E_i$ is the chemical element of the $i$-th atom. Because $E_i$ is not used in Colvars, any string that does not contain tabs or spaces is acceptable. +\textbf{Note:} all XYZ coordinates are assumed to be expressed in \AA{} units\cvgromacsonly{; it is advisable to obtain them from a PDB file, or using VMD and/or the Colvars Dashboard to avoid inconstencies with GROMACS\' nm units}\cvlammpsonly{, regardless of the units currently used by LAMMPS}. + An XYZ file may contain either one of the following scenarios: \begin{enumerate} \item[\emph{(i)}] The file contains as many coordinates as the atoms that they are being read for: all coordinates will be read from the file following the same order as the atoms appear in the selection generated using the keywords listed in section \ref{sec:colvar_atom_groups}. @@ -1407,7 +1491,7 @@ {group1}{% \texttt{distance}}{% First group of atoms}{% - Block \texttt{group1 \{...\}}}{% + \hyperref[sec:colvar_atom_groups]{Atom group}}{% First group of atoms.} \item % @@ -1472,7 +1556,7 @@ {main}{% \texttt{distanceZ}}{% Main group of atoms}{% - Block \texttt{main \{...\}}}{% + \hyperref[sec:colvar_atom_groups]{Atom group}}{% Group of atoms whose position $\bm{r}$ is measured.} \item % @@ -1482,7 +1566,7 @@ \texttt{distanceZ}}{% Reference group of atoms}{% - Block \texttt{ref \{...\}}}{% + \hyperref[sec:colvar_atom_groups]{Atom group}}{% Reference group of atoms. The position of its center of mass is noted $\bm{r}_1$ below.} @@ -1493,7 +1577,7 @@ \texttt{distanceZ}}{% Secondary reference group}{% - Block \texttt{ref2 \{...\}}}{% + \hyperref[sec:colvar_atom_groups]{Atom group}}{% none}{% Optional group of reference atoms, whose position $\bm{r}_2$ can be used to define a dynamic projection axis: $\bm{e}=(\| \bm{r}_2 @@ -1724,8 +1808,8 @@ \key {atoms}{% \texttt{polarPhi}}{% - Atom group}{% - \texttt{atoms~\{...\}} block}{% + Group of atoms defining this function}{% + \hyperref[sec:colvar_atom_groups]{Atom group}}{% Defines the group of atoms for the COM of which the angle should be calculated. } \end{cvcoptions} @@ -1753,8 +1837,8 @@ \key {atoms}{% \texttt{polarPhi}}{% - Atom group}{% - \texttt{atoms~\{...\}} block}{% + Group of atoms defining this function}{% + \hyperref[sec:colvar_atom_groups]{Atom group}}{% Defines the group of atoms for the COM of which the angle should be calculated. } \end{cvcoptions} @@ -2007,8 +2091,8 @@ \key {atoms}{% \texttt{rmsd}}{% - Atom group}{% - \texttt{atoms~\{...\}} block}{% + Group of atoms defining this function}{% + \hyperref[sec:colvar_atom_groups]{Atom group}}{% Defines the group of atoms of which the RMSD should be calculated. Optimal fit options (such as \texttt{refPositions} and \texttt{rotateToReference}) should typically NOT be set within this @@ -2937,7 +3021,7 @@ {atoms}{% \texttt{cartesian}}{% Group of atoms}{% - Block \texttt{atoms \{...\}}}{% + \hyperref[sec:colvar_atom_groups]{Atom group}}{% Defines the atoms whose coordinates make up the value of the component. If \texttt{rotateToReference}, \texttt{centerToReference}, or \texttt{centerToOrigin} are defined, coordinates are evaluated within the moving frame of reference.} @@ -2988,7 +3072,7 @@ {atoms}{% \texttt{gspath} and \texttt{gzpath}}{% Group of atoms}{% - Block \texttt{atoms \{...\}}}{% + \hyperref[sec:colvar_atom_groups]{Atom group}}{% Defines the atoms whose coordinates make up the value of the component.} \item % @@ -3383,7 +3467,7 @@ {atoms}{% \texttt{aspath} and \texttt{azpath}}{% Group of atoms}{% - Block \texttt{atoms \{...\}}}{% + \hyperref[sec:colvar_atom_groups]{Atom group}}{% Defines the atoms whose coordinates make up the value of the component.} \item % @@ -3605,10 +3689,10 @@ Given a function of the Cartesian coordinates $\phi(\mathbf{x}) = \phi(x, y, z)$, a \texttt{mapTotal} collective variable component $\Phi(\mathbf{X})$ is defined as the sum of the values of the function $\phi(\mathbf{x})$ evaluated at the coordinates of each atom, $\mathbf{x}_{i}$: \begin{equation} \label{eq:cvc_map_total} - \Phi(\mathbf{X}) = \sum_{i=1}^{N} w_i \phi(\mathbf{x}_{i}) + \Phi\left(\mathbf{X}\right) = \sum_{i=1}^{N} w_i \phi\left(\mathbf{x}_{i}\right) \end{equation} \noindent{}where $w_i$ are weights assigned to each variable (1 by default). -This formulation allows, for example, to ``count'' the number of atoms within a region of space by using a positive-valued function $\phi(\mathbf{x})$, such as for example the number of water molecules in a hydrophobic cavity \cite{Fiorin2020}.\\ +This formulation allows, for example, to ``count'' the number of atoms within a region of space by using a positive-valued function $\phi\left(\mathbf{x}\right)$, such as for example the number of water molecules in a hydrophobic cavity \cite{Fiorin2020}.\\ Because the volumetric map itself and the atoms affected by it are defined externally to Colvars, this component has a very limited number of keywords. @@ -3643,8 +3727,8 @@ \key {atoms}{% \texttt{mapTotal}}{% - Atom group}{% - \texttt{atoms~\{...\}} block}{% + Group of atoms defining this function}{% + \hyperref[sec:colvar_atom_groups]{Atom group}}{% If defined, this option allows defining the set of atoms to be aligned onto the volumetric map following the syntax described in section \ref{sec:colvar_atom_groups}. This also allows, for instance, to express the volumetric map in a rotated frame of reference (see \ref{sec:colvar_atom_groups_ref_frame}). \cvvmdonly{In VMD, this definition is required, otherwise the \texttt{mapTotal} value is identically zero.} @@ -3711,7 +3795,7 @@ The ``Multi-Map'' progress variable \cite{Fiorin2020} uses a weight sum of these components, using linearly-increasing weights: \begin{equation} \label{eq:cvc_multi_map} - \xi\left(\mathbf{X}\right) = \sum_{k=1}^{K} k \Phi_{k}(\mathbf{X}) = \sum_{k=1}^{K} k \sum_{i=1}^{N}\phi_{k}(\mathbf{x}_{i}) + \xi\left(\mathbf{X}\right) = \sum_{k=1}^{K} k \Phi_{k}\left(\mathbf{X}\right) = \sum_{k=1}^{K} k \sum_{i=1}^{N}\phi_{k}\left(\mathbf{x}_{i}\right) \end{equation} \noindent{}where $K$ is the number of maps employed and each $\Phi_k$ is a \texttt{mapTotal} component. @@ -4609,20 +4693,36 @@ \cvsec{Selecting atoms}{sec:colvar_atom_groups} -To define collective variables, atoms are usually selected as groups. Each group is defined using an identifier that is unique in the context of the specific colvar component (e.g.~for a distance component, the two groups are \texttt{group1} and \texttt{group2}). -The identifier is followed by a brace-delimited block containing selection keywords and other parameters, including an optional \texttt{name}: +To define collective variables, atoms are usually selected as groups. Each group is defined using an identifying keyword that is unique in the context of the specific colvar component (e.g.~for a distance component, the two groups are identified by the \texttt{group1} and \texttt{group2} keywords). +The group's identifying keyword is followed by a brace-delimited block containing selection keywords and other parameters, one of which is \texttt{name}: \begin{itemize} \item \key {name}{% atom group}{% Unique name for the atom group}{% string}{% - This parameter defines a unique name for this atom group, which can be referred to + This parameter defines a globally unique name for this atom group, which can be referred to in the definition of other atom groups (including in other colvars) by invoking - \texttt{atomsOfGroup} as a selection keyword.} + \texttt{atomsOfGroup} as a selection keyword. + This has two benefits: (1) it can make the configuration shorter and more legible, and (2) several + related atom groups can be defined using a common set of atoms, so that this selection can be + changed in one place, keeping all related groups synchronized with the same atom set.} \end{itemize} +Other keywords are documented in the following sections. +In the example below, the \texttt{gyration} component uses the identifying keyword \texttt{atoms} to define its associated group, which is defined based on the index group named ``\texttt{Protein-H}''. Optionally, the group is also given the unique name ``\texttt{my\_protein}'', so that atom groups defined later in the Colvars configuration may refer to it. +\begin{cvexampleinput} +\-colvar~\{\\ +\-~~name~rgyr\\ +\-~~gyration~\{\\ +\-~~~~atoms~\{\\ +\-~~~~~~name~my\_protein\\ +\-~~~~~~indexGroup~Protein-H\\ +\-~~~~\}\\ +\-~~\}\\ +\-\} +\end{cvexampleinput} \cvsubsec{Atom selection keywords}{sec:colvar_atom_groups_sel} @@ -4884,7 +4984,7 @@ {fittingGroup}{% atom group}{% Use an alternate set of atoms to define the roto-translation}{% - Block \texttt{fittingGroup \{ ... \}}}{% + \hyperref[sec:colvar_atom_groups]{Atom group}}{% This atom group itself}{% If either \texttt{centerToReference} or \texttt{rotateToReference} is defined, this keyword defines an alternate atom group to calculate the optimal roto-translation. Use this option to define a continuous rotation if the structure of the group involved changes significantly (a typical symptom would be the message ``Warning: discontinuous rotation!''). @@ -4922,7 +5022,7 @@ \end{cvexampleinput} } -The following two options have default values appropriate for the vast majority of applications, and are only provided to support rare, special cases. +The following options have default values appropriate for the vast majority of applications, and are only provided to support rare, special cases. \begin{itemize} \item % @@ -4948,35 +5048,39 @@ \cvsubsec{Treatment of periodic boundary conditions.}{sec:colvar_atom_groups_wrapping} +In simulations with periodic boundary conditions (PBCs), Colvars computes all distances between two points following the nearest-image convention, using PBC parameters provided by \MDENGINE. +However, many common variables rely on a consistent definition of the center of mass or geometry of a group of atoms. +This requires the use of \emph{unwrapped} coordinates, which are not subject to ``jumps'' when they diffuse across periodic boundaries. + \cvnamdonly{ - In simulations with periodic boundary conditions, NAMD maintains + When PBCs are defined, NAMD maintains the coordinates of all the atoms within a molecule contiguous to - each other (i.e.~there are no spurious ``jumps'' in the molecular - bonds). The Colvars module relies on this when calculating a group's - center of geometry, but this condition may fail if the group spans + each other (i.e.\ there are no spurious ``jumps'' in the molecular + bonds). However, this condition may fail if the group spans different molecules. In that case, writing the NAMD output and restart files using \texttt{wrapAll} or \texttt{wrapWater} could produce wrong results when a simulation run is continued from a previous one. The user should then determine, according to which type of colvars are being calculated, whether \texttt{wrapAll} or - \texttt{wrapWater} can be enabled. - - In general, internal coordinate wrapping by NAMD does not affect the calculation of colvars if each atom group satisfies one or more of the following: + \texttt{wrapWater} can be enabled while ensuring that the input coordinates for each + run contain all atom groups in one piece. } -\cvlammpsonly{ -In simulations with periodic boundary conditions, many of the implemented colvar components rely on the fact that each position within a group of atoms is at the nearest periodic image from the center of geometry of the group itself. -However, due to the internal wrapping of individual atomic positions done by LAMMPS, this assumption is broken if the group straddles one of the unit cell's boundaries. -For this reason, within the Colvars module all coordinates are unwrapped by default to avoid discontinuities (see \texttt{unwrap} keyword in \ref{sec:colvars_mdengine_parameters}). -The user should determine whether maintaining the default value of \texttt{unwrap}, depending on the specifics of each system. -In general, internal coordinate wrapping by LAMMPS does not affect the calculation of colvars if each atom group satisfies one or more of the following: +\cvlammpsonly{ +LAMMPS controls the internal availability of unwrapped coordinates using the \texttt{unwrap} keyword in \ref{sec:colvars_mdengine_parameters}, which defaults to \texttt{yes}. +The user should determine whether it is appropriate to maintain the default value of \texttt{unwrap}, depending on the specifics of each system. } -\cvvmdonly{ - When periodic boundary conditions are defined, the Colvars module requires that the coordinates of each molecular fragment are contiguous, without ``jumps'' when a fragment is partially wrapped near a periodic boundary. - The Colvars module relies on this assumption when calculating a group's center of geometry, but the condition may fail if the group spans different molecules. - In general, coordinate wrapping does not affect the calculation of colvars if each atom group satisfies one or more of the following: + +\cvgromacsonly{ +Internally, GROMACS wraps individual atom coordinates into a single periodic cell, which may break the calculation of some variables if their atom groups become split across PBCs. +To prevent this, Colvars unwraps coordinates throughout the simulation, by assuming that each atom group is intact in the initial coordinates, and canceling any later jumps across the periodic box. +This information is propagated across restarts using a checkpoint (\texttt{cpt}) file. + +Whenever preparing a new simulation input with \texttt{gmx grompp}, users should provide input coordinates such that the atoms involved in collective variables will not be artificially moved across the boundary conditions, but occupy their relevant positions relative to each other -- usually the nearest ones. +Unwrapped coordinates are communicated between replicas when GROMACS is used for replica-exchange simulations. Thus, Colvars is compatible with native replica-exchange in GROMACS. } +In general, internal coordinate wrapping by \MDENGINE{} does not affect the calculation of colvars if each atom group satisfies one or more of the following: \begin{enumerate} \item[\emph{i)}] it is composed by only one atom; \item[\emph{ii)}] it is used by a colvar component which does not make use of its center of geometry, but only of pairwise distances (\texttt{distanceInv}, \texttt{coordNum}, \texttt{hBond}, \texttt{alpha}, \texttt{dihedralPC}); @@ -4984,27 +5088,34 @@ \item[\emph{iv)}] it has all of its atoms within the same molecular fragment% }. \end{enumerate} -\cvvmdonly{If none of these conditions are met, wrapping may affect the calculation of collective variables: a possible solution is to use \texttt{pbc wrap} or \texttt{pbc unwrap} prior to processing a trajectory with the Colvars module.} +\cvvmdonly{If none of these conditions are met, wrapping may affect the calculation of collective variables: a possible solution is to use \texttt{pbc wrap} or \texttt{pbc unwrap} (or the alternative \texttt{qwrap} or \texttt{qunwrap}: \url{https://github.com/jhenin/qwrap}) prior to processing a trajectory with the Colvars module.} \cvsubsec{Performance of a Colvars calculation based on group size.}{sec:colvar_atom_groups_scaling} -In simulations performed with message-passing programs (such as NAMD or LAMMPS), the calculation of energy and forces is distributed (i.e., parallelized) across multiple nodes, as well as over the processor cores of each node. -When Colvars is enabled, certain atomic coordinates are collected on a single node, where the calculation of collective variables and of their biases is executed. -This means that for simulations over large numbers of nodes, a Colvars calculation may produce a significant overhead, coming from the costs of transmitting atomic coordinates to one node and of processing them. +In simulations performed with MD simulation engines such as GROMACS, LAMMPS or NAMD, the computation of energy and forces is distributed (i.e., parallelized) over multiple nodes, as well as over the CPU/GPU cores of each node. +When Colvars is enabled, atomic coordinates are collected on a single CPU core, where collective variables and their biases are computed. +This means that in the case of simulations that are already being run over large numbers of nodes, or inside a GPU, a Colvars calculation may produce a significant overhead. +This overhead comes from the combined cost of two operation: transmitting atomic coordinates, and computing functions of the same. \cvnamdonly{The latency-tolerant design and dynamic load balancing of NAMD may alleviate both factors, but a noticeable performance impact may be observed.} Performance can be improved in multiple ways: + \begin{itemize} + +\item As a general rule, the size of atom groups should be kept relatively small (up to a few thousands of atoms, depending on the size of the entire system in comparison). + For example, restraining a protein through a RMSD colvar defined over all of its atoms is only marginally different than one defined over only the $\alpha$ carbon atoms, but the difference in computational cost is much higher. +To gain an estimate of the computational cost of a specific Colvars configuration, one may use a test calculation of the same colvar in VMD (hint: use the \texttt{time} Tcl command to measure the cost of running \texttt{cv update}). + \item The calculation of variables, components and biases can be distributed over the processor cores of the node where the Colvars module is executed. Currently, an equal weight is assigned to each colvar, or to each component of those colvars that include more than one component. The performance of simulations that use many colvars or components is improved automatically. For simulations that use a single large colvar, it may be advisable to partition it in multiple components, which will be then distributed across the available cores. - \cvnamdonly{In NAMD, this feature is enabled in all binaries compiled using SMP builds of Charm++ with the CkLoop extension.} + \cvnamdonly{In NAMD, this feature is enabled in all binaries compiled using SMP builds of Charm++ with the CkLoop extension (including ``multicore'' builds).} \cvlammpsonly{In LAMMPS, this feature is supported automatically when LAMMPS is compiled with OpenMP support.} \cvgromacsonly{In GROMACS, this feature is supported automatically when GROMACS is compiled with OpenMP support.} - If printed, the message ``SMP parallelism is available.'' indicates the availability of the option\cvvmdonly{ (will be supported in a future release of VMD)}. - If available, the option is turned on by default, but may be disabled using the keyword \refkey{smp}{Colvars-global|smp} if required for debugging. + The messages ``SMP parallelism is available'' or ``SMP parallelism is enabled'', printed by Colvars at initialization time, indicate the availability or status of this feature\cvvmdonly{ (will be supported in a future release of VMD)}. + If available, the option is turned on by default, but may be disabled using the keyword \refkey{smp}{Colvars-global|smp} if required for debugging or troubleshooting. \cvnamdonly{ % Use the following command to identify them: @@ -5014,8 +5125,6 @@ When supported, the message ``Will enable scalable calculation for group \ldots'' is printed for each group. } -\item As a general rule, the size of atom groups should be kept relatively small (up to a few thousands of atoms, depending on the size of the entire system in comparison). -To gain an estimate of the computational cost of a large colvar, one can use a test calculation of the same colvar in VMD (hint: use the \texttt{time} Tcl command to measure the cost of running \texttt{cv update}). \end{itemize} @@ -7329,13 +7438,6 @@ \end{itemize} -\noindent{}An up-to-date version of this manual for the latest version of Colvars may be accessed % -\cvgromacsonly{\href{https://colvars.github.io/\cvreleaselabel/colvars-refman-gromacs.html}{here}}% -\cvlammpsonly{\href{https://colvars.github.io/\cvreleaselabel/colvars-refman-lammps.html}{here}}% -\cvnamdonly{\href{https://colvars.github.io/\cvreleaselabel/colvars-refman-namd.html}{here}}% -\cvvmdonly{\href{https://colvars.github.io/\cvreleaselabel/colvars-refman-vmd.html}{here}}. - - \cvsec{Compilation notes}{sec:compilation_notes} @@ -7345,11 +7447,11 @@ \begin{itemize} -\item Scripting commands using the Tcl language (\url{https://www.tcl.tk}) are supported in VMD and NAMD. All precompiled builds of each code include Tcl, and it is highly recommended to enable Tcl support in any custom build, using precompiled Tcl libraries from the UIUC website. +\item Scripting commands using the Tcl language (\url{https://www.tcl.tk}) are supported in VMD, NAMD, and Tinker-HP. All precompiled builds of NAMD and VMD include Tcl, and it is highly recommended to enable Tcl support in any custom build, using precompiled Tcl libraries from the UIUC website. -\item The Lepton library (\url{https://simtk.org/projects/lepton}) used to implement the \texttt{customFunction} feature is currently included only in NAMD (always on), in LAMMPS (on by default) and in the Colvars-patched GROMACS releases. For VMD, a \href{https://github.com/giacomofiorin/vmd-patches}{patch} that allows to link Lepton is available. +\item The Lepton library (\url{https://simtk.org/projects/lepton}) used to implement the \texttt{customFunction} feature is currently included only in NAMD (always on), in LAMMPS (on by default) and in the Colvars-patched GROMACS releases (but currently, not in the standard releases). For VMD, a \href{https://github.com/giacomofiorin/vmd-patches}{patch} that allows to link Lepton is available. -\item Colvars requires the C++11 language standard, which is either supported (VMD) or required (GROMACS, LAMMPS, NAMD) by all the engines. However, many of the VMD official builds are produced on very old architectures. For details please see:\\ +\item Colvars requires the C++11 language standard or higher, which is either supported (VMD) or required (GROMACS, LAMMPS, NAMD) by all the engines. However, many of the VMD official builds are produced on very old architectures, where C++11 features are disabled at build time, thus limiting functionality. For details please see:\\ \url{https://colvars.github.io/README-c++11.html} \end{itemize} diff --git a/doc/colvars-refman.tex b/doc/colvars-refman.tex index 02780c697..001a46d00 100644 --- a/doc/colvars-refman.tex +++ b/doc/colvars-refman.tex @@ -48,11 +48,10 @@ \definecolor{mdexample-border-color}{rgb}{1.0,0.6,0.1} \definecolor{mdexample-background-color}{rgb}{1.0,0.96,0.9} -\newenvironment{mdexampleinput}[1]{% +\newenvironment{mdexampleinput}{% \begin{mdframed}[% linecolor=mdexample-border-color,linewidth=2pt,% backgroundcolor=mdexample-background-color] - \textbf{#1} \ifdefined\HCode\HCode{
}\else\begin{ttfamily}\fi}{%
   \ifdefined\HCode\HCode{
}\else\end{ttfamily}\fi \end{mdframed} @@ -69,22 +68,29 @@ \end{mdframed} } +% Note: the Python version is currently not built yet \newcommand{\cvscriptexampleinputcv}[2]{% +% CLI interface \def\cvscriptargsep{~} -\begin{mdexampleinput}{\ifdefined\cvscriptpyapi\textbf{With the ``\texttt{\cvscriptcmd{}}'' command:}\\\fi}% +\ifdefined\cvscriptpyapi% +\textbf{With the ``\texttt{\cvscriptcmd{}}'' command:}\\\fi +\begin{mdexampleinput} \noindent\cvscriptcmd{}~#1~#2 -\end{mdexampleinput}\ifdefined\cvscriptpyapi{% +\end{mdexampleinput} +% Python interface +\ifdefined\cvscriptpyapi% +\textbf{With the Python interface:}\\ \def\cvscriptargsep{,~} -\begin{mdexampleinput}{\textbf{With the Python interface:}\\}% +\begin{mdexampleinput} from colvars import Colvarscript\\ cv = Colvarscript()\\ cv.#1(#2) -\end{mdexampleinput}}\fi +\end{mdexampleinput}\fi % end \ifdefined\cvscriptpyapi } \newcommand{\cvscriptexampleinputcolvar}[3]{% \def\cvscriptargsep{~} -\begin{mdexampleinput}{} +\begin{mdexampleinput} \noindent\cvscriptcmd{}~colvar~#3~#1~#2 \end{mdexampleinput} } @@ -203,31 +209,22 @@ % use macros with context field to document keywords \newcommand{\key}[5]{% - {\bf Keyword} \index{#2!\texttt{#1}}% - \colorbox{cvkeyword-background-color}{\large \tt #1} $\langle\,$#3$\,\rangle$\\% - {\bf Context: } #2 \\% - {\bf Acceptable values: } #4 \\% - {\bf Description: } #5% -} + \colorbox{cvkeyword-background-color}{\index{#2!\texttt{#1}}\texttt{#1}} --- \emph{#3}\vspace{1ex}\\% + $[$~#4, context: #2~$]$\vspace{1ex}\\% + #5} \newcommand{\keydef}[6]{% - {\bf Keyword} \index{#2!\texttt{#1}}% - \colorbox{cvkeyword-background-color}{\large \tt #1} $\langle\,$#3$\,\rangle$\\% - {\bf Context: } #2 \\% - {\bf Acceptable values: } #4 \\% - {\bf Default value: } #5 \\% - {\bf Description: } #6 -} + \colorbox{cvkeyword-background-color}{\index{#2!\texttt{#1}}\texttt{#1}} --- \emph{#3}\vspace{1ex}\\% + Default: #5\ $[$~#4, context: #2~$]$\vspace{1ex}\\% + #6} -\newcommand{\labelkey}[1]{\hypertarget{#1}{~}\label{#1}} +\newcommand{\labelkey}[1]{\hypertarget{#1}{}\label{#1}} \newcommand{\refkey}[2]{\hyperlink{#2}{\texttt{#1}}} \newcommand{\dupkey}[4]{% - {\bf Keyword} \index{#2!\texttt{#1}}% - \colorbox{cvkeyword-background-color}{\large \tt #1}: see definition of \hyperlink{#3}{\texttt{#1}} (#4)% + \colorbox{cvkeyword-background-color}{\index{#2!\texttt{#1}}\texttt{#1}} --- same definition as \hyperlink{#3}{\texttt{#1}} (#4)% } \newcommand{\simkey}[3]{% - \index{#2!\texttt{#1}}% - \colorbox{cvkeyword-background-color}{\large \tt #1}: analogous to \texttt{#3}% + \colorbox{cvkeyword-background-color}{\index{#2!\texttt{#1}}\texttt{#1}} --- analogous to \texttt{#3}% } \newcommand{\gradx}{\mbox{\boldmath$\nabla_{\!\!x}\,$}} diff --git a/doc/cv_version.tex b/doc/cv_version.tex index 6cfa54b8b..950ebd65e 100644 --- a/doc/cv_version.tex +++ b/doc/cv_version.tex @@ -1 +1 @@ -\newcommand{\cvversion}{2023-11-15} +\newcommand{\cvversion}{2023-12-05} diff --git a/doc/update_website.sh b/doc/update_website.sh new file mode 100755 index 000000000..1ab48f304 --- /dev/null +++ b/doc/update_website.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +COLVARS_WEBSITE_TREE=${1} +if [ -z "${COLVARS_WEBSITE_TREE}" ] ; then + echo "Error: need the full path to the website repository as argument." >&2 + exit 1 +fi + +if grep -sq colvars ${COLVARS_WEBSITE_TREE}/index.html ; then + export COLVARS_WEBSITE_TREE +else + echo "Error: ${COLVARS_WEBSITE_TREE} does not seem to contain a Colvars webpage repository." >&2 + exit 1 +fi + +# If needed, initialize COLVARS_RELEASE in the same way as Makefile would +if [ -z "${COLVARS_RELEASE}" ] ; then + COLVARS_RELEASE=$(git symbolic-ref --short -q HEAD) +fi +if [ -z "${COLVARS_RELEASE}" ] ; then + # If we are not working on a branch, try a tag instead + COLVARS_RELEASE=$(git describe --tags --exact-match) +fi +if [ -z "${COLVARS_RELEASE}" ] ; then + echo "Error: ${COLVARS_RELEASE} is undefined and could not be configured from a Git branch or tag." >&2 + exit 1 +fi + +if make install && pushd ${COLVARS_WEBSITE_TREE} ; then + git add ${COLVARS_RELEASE} + if [ "x${COLVARS_RELEASE}" == "xmaster" ] ; then + git add doxygen + git add colvars-refman-* + fi + git commit -m "Update doc for version \"${COLVARS_RELEASE}\"" + # Hard-code the website repository + git pull --rebase git@github.com:Colvars/colvars.github.io master + git push git@github.com:Colvars/colvars.github.io master + popd +fi diff --git a/gromacs/gromacs-2020.x/colvarproxy_gromacs.cpp b/gromacs/gromacs-2020.x/colvarproxy_gromacs.cpp index 2db82a776..a2203f562 100644 --- a/gromacs/gromacs-2020.x/colvarproxy_gromacs.cpp +++ b/gromacs/gromacs-2020.x/colvarproxy_gromacs.cpp @@ -88,8 +88,7 @@ void colvarproxy_gromacs::init(t_inputrec *ir, int64_t step,gmx_mtop_t *mtop, { colvars_restart = true; input_prefix_str = filename_restart; - input_prefix_str.erase(input_prefix_str.rfind(".dat")); - input_prefix_str.erase(input_prefix_str.rfind(".colvars.state")); + // Don't strip the input_prefix_str because colvarmodule.cpp doesn't know that restart file from GROMACS needs the .dat extension. } // Retrieve masses and charges from input file @@ -391,7 +390,6 @@ void colvarproxy_gromacs::update_data(const t_commrec *cr, int64_t const step, t if (first_timestep) { first_timestep = false; } else { - // Use the time step number inherited from GROMACS if ( step - previous_gmx_step == 1 ) colvars->it++; // Other cases? diff --git a/gromacs/gromacs-2020.x/colvarproxy_gromacs.h b/gromacs/gromacs-2020.x/colvarproxy_gromacs.h index ab26c549f..186dd0fa3 100644 --- a/gromacs/gromacs-2020.x/colvarproxy_gromacs.h +++ b/gromacs/gromacs-2020.x/colvarproxy_gromacs.h @@ -32,7 +32,7 @@ class colvarproxy_gromacs : public colvarproxy, public gmx::IForceProvider { bool colvars_restart; std::string config_file; size_t restart_frequency_s; - int previous_gmx_step; + int64_t previous_gmx_step; double bias_energy; bool gmx_bNS; // Is this a neighbor-search step? Eventually will become unnecessary diff --git a/gromacs/gromacs-2021.x/colvarproxy_gromacs.cpp b/gromacs/gromacs-2021.x/colvarproxy_gromacs.cpp index 3ae4a69f2..0dfaac12a 100644 --- a/gromacs/gromacs-2021.x/colvarproxy_gromacs.cpp +++ b/gromacs/gromacs-2021.x/colvarproxy_gromacs.cpp @@ -87,8 +87,7 @@ void colvarproxy_gromacs::init(t_inputrec *ir, int64_t step,gmx_mtop_t *mtop, { colvars_restart = true; input_prefix_str = filename_restart; - input_prefix_str.erase(input_prefix_str.rfind(".dat")); - input_prefix_str.erase(input_prefix_str.rfind(".colvars.state")); + // Don't strip the input_prefix_str because colvarmodule.cpp doesn't know that restart file from GROMACS needs the .dat extension. } // Retrieve masses and charges from input file @@ -393,7 +392,6 @@ void colvarproxy_gromacs::update_data(const t_commrec *cr, int64_t const step, t if (first_timestep) { first_timestep = false; } else { - // Use the time step number inherited from GROMACS if ( step - previous_gmx_step == 1 ) colvars->it++; // Other cases? diff --git a/gromacs/gromacs-2021.x/colvarproxy_gromacs.h b/gromacs/gromacs-2021.x/colvarproxy_gromacs.h index ab26c549f..186dd0fa3 100644 --- a/gromacs/gromacs-2021.x/colvarproxy_gromacs.h +++ b/gromacs/gromacs-2021.x/colvarproxy_gromacs.h @@ -32,7 +32,7 @@ class colvarproxy_gromacs : public colvarproxy, public gmx::IForceProvider { bool colvars_restart; std::string config_file; size_t restart_frequency_s; - int previous_gmx_step; + int64_t previous_gmx_step; double bias_energy; bool gmx_bNS; // Is this a neighbor-search step? Eventually will become unnecessary diff --git a/gromacs/gromacs-2022.x/colvarproxy_gromacs.cpp b/gromacs/gromacs-2022.x/colvarproxy_gromacs.cpp index 02b673f02..07cc387a9 100644 --- a/gromacs/gromacs-2022.x/colvarproxy_gromacs.cpp +++ b/gromacs/gromacs-2022.x/colvarproxy_gromacs.cpp @@ -87,8 +87,7 @@ void colvarproxy_gromacs::init(t_inputrec *ir, int64_t step, const gmx_mtop_t &m { colvars_restart = true; input_prefix_str = filename_restart; - input_prefix_str.erase(input_prefix_str.rfind(".dat")); - input_prefix_str.erase(input_prefix_str.rfind(".colvars.state")); + // Don't strip the input_prefix_str because colvarmodule.cpp doesn't know that restart file from GROMACS needs the .dat extension. } // Retrieve masses and charges from input file @@ -393,7 +392,6 @@ void colvarproxy_gromacs::update_data(const t_commrec *cr, int64_t const step, t if (first_timestep) { first_timestep = false; } else { - // Use the time step number inherited from GROMACS if ( step - previous_gmx_step == 1 ) colvars->it++; // Other cases? diff --git a/gromacs/gromacs-2022.x/colvarproxy_gromacs.h b/gromacs/gromacs-2022.x/colvarproxy_gromacs.h index 3f331e82d..4aeb7bc5e 100644 --- a/gromacs/gromacs-2022.x/colvarproxy_gromacs.h +++ b/gromacs/gromacs-2022.x/colvarproxy_gromacs.h @@ -32,7 +32,7 @@ class colvarproxy_gromacs : public colvarproxy, public gmx::IForceProvider { bool colvars_restart; std::string config_file; size_t restart_frequency_s; - int previous_gmx_step; + int64_t previous_gmx_step; double bias_energy; bool gmx_bNS; // Is this a neighbor-search step? Eventually will become unnecessary diff --git a/gromacs/gromacs-2023.x/colvarproxy_gromacs.cpp b/gromacs/gromacs-2023.x/colvarproxy_gromacs.cpp index d9eba8713..3a3cd1d08 100644 --- a/gromacs/gromacs-2023.x/colvarproxy_gromacs.cpp +++ b/gromacs/gromacs-2023.x/colvarproxy_gromacs.cpp @@ -87,8 +87,7 @@ void colvarproxy_gromacs::init(t_inputrec *ir, int64_t step, const gmx_mtop_t &m { colvars_restart = true; input_prefix_str = filename_restart; - input_prefix_str.erase(input_prefix_str.rfind(".dat")); - input_prefix_str.erase(input_prefix_str.rfind(".colvars.state")); + // Don't strip the input_prefix_str because colvarmodule.cpp doesn't know that restart file from GROMACS needs the .dat extension. } // Retrieve masses and charges from input file @@ -393,7 +392,6 @@ void colvarproxy_gromacs::update_data(const t_commrec *cr, int64_t const step, t if (first_timestep) { first_timestep = false; } else { - // Use the time step number inherited from GROMACS if ( step - previous_gmx_step == 1 ) colvars->it++; // Other cases? diff --git a/gromacs/gromacs-2023.x/colvarproxy_gromacs.h b/gromacs/gromacs-2023.x/colvarproxy_gromacs.h index 3f331e82d..4aeb7bc5e 100644 --- a/gromacs/gromacs-2023.x/colvarproxy_gromacs.h +++ b/gromacs/gromacs-2023.x/colvarproxy_gromacs.h @@ -32,7 +32,7 @@ class colvarproxy_gromacs : public colvarproxy, public gmx::IForceProvider { bool colvars_restart; std::string config_file; size_t restart_frequency_s; - int previous_gmx_step; + int64_t previous_gmx_step; double bias_energy; bool gmx_bNS; // Is this a neighbor-search step? Eventually will become unnecessary diff --git a/gromacs/gromacs-mdmodules/applied_forces/colvars/colvarsoptions.cpp b/gromacs/gromacs-mdmodules/applied_forces/colvars/colvarsoptions.cpp index 88c91466d..6e53b5726 100644 --- a/gromacs/gromacs-mdmodules/applied_forces/colvars/colvarsoptions.cpp +++ b/gromacs/gromacs-mdmodules/applied_forces/colvars/colvarsoptions.cpp @@ -270,7 +270,8 @@ void ColvarsOptions::processEdrFilename(const EdrOutputFilename& filename) // Provided name should not be empty GMX_RELEASE_ASSERT(!filename.edrOutputFilename_.empty(), "Empty name for the *.edr output file"); - outputPrefix_ = stripExtension(std::filesystem::path(filename.edrOutputFilename_).filename()); + outputPrefix_ = + stripExtension(std::filesystem::path(filename.edrOutputFilename_).filename()).u8string(); } diff --git a/gromacs/gromacs-mdmodules/cmake/gmxManageColvars.cmake b/gromacs/gromacs-mdmodules/cmake/gmxManageColvars.cmake deleted file mode 100644 index 907782216..000000000 --- a/gromacs/gromacs-mdmodules/cmake/gmxManageColvars.cmake +++ /dev/null @@ -1,62 +0,0 @@ -# -# This file is part of the GROMACS molecular simulation package. -# -# Copyright 2023- The GROMACS Authors -# and the project initiators Erik Lindahl, Berk Hess and David van der Spoel. -# Consult the AUTHORS/COPYING files and https://www.gromacs.org for details. -# -# GROMACS is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public License -# as published by the Free Software Foundation; either version 2.1 -# of the License, or (at your option) any later version. -# -# GROMACS is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with GROMACS; if not, see -# https://www.gnu.org/licenses, or write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# -# If you want to redistribute modifications to GROMACS, please -# consider that scientific software is very special. Version -# control is crucial - bugs must be traceable. We will be happy to -# consider code for inclusion in the official distribution, but -# derived work must not be called official GROMACS. Details are found -# in the README & COPYING files - if they are missing, get the -# official version at https://www.gromacs.org. -# -# To help us fund GROMACS development, we humbly ask that you cite -# the research papers on the package. Check out https://www.gromacs.org. - -# Build Colvars library as bundled in a GROMACS worktree; not supporting external linkage yet -gmx_option_multichoice(GMX_USE_COLVARS - "Build the collective variables (Colvars) library interfaced with GROMACS" - INTERNAL - INTERNAL NONE) -mark_as_advanced(GMX_USE_COLVARS) - -function(gmx_manage_colvars) - if(GMX_USE_COLVARS STREQUAL "INTERNAL") - # Create an object library for the colvars sources - set(COLVARS_DIR "${CMAKE_SOURCE_DIR}/src/external/colvars") - file(GLOB COLVARS_SOURCES ${COLVARS_DIR}/*.cpp) - add_library(colvars_objlib OBJECT ${COLVARS_SOURCES}) - # Set correctly the value of __cplusplus, which MSVC doesn't do by default - target_compile_options(colvars_objlib PRIVATE $<$:/Zc:__cplusplus>) - # Ensure that colvars_objlib can be used in both STATIC and SHARED libraries. - set_target_properties(colvars_objlib PROPERTIES POSITION_INDEPENDENT_CODE ON) - - # Create an INTERFACE library for colvars with the object library as a dependency - add_library(colvars INTERFACE) - target_sources(colvars INTERFACE $) - target_include_directories(colvars SYSTEM INTERFACE $) - - else() - # Create a dummy link target so the calling code doesn't need to know - # whether colvars support is being compiled. - add_library(colvars INTERFACE) - endif() -endfunction() diff --git a/gromacs/gromacs-mdmodules/gmxManageColvars.cmake.diff b/gromacs/gromacs-mdmodules/gmxManageColvars.cmake.diff new file mode 100644 index 000000000..5d25e94b8 --- /dev/null +++ b/gromacs/gromacs-mdmodules/gmxManageColvars.cmake.diff @@ -0,0 +1,16 @@ +diff --git a/cmake/gmxManageColvars.cmake b/cmake/gmxManageColvars.cmake +index 90778221..645b23b5 100644 +--- a/cmake/gmxManageColvars.cmake ++++ b/cmake/gmxManageColvars.cmake +@@ -54,6 +54,11 @@ function(gmx_manage_colvars) + target_sources(colvars INTERFACE $) + target_include_directories(colvars SYSTEM INTERFACE $) + ++ if(GMX_OPENMP) ++ target_compile_options(colvars_objlib PRIVATE ${OpenMP_CXX_FLAGS}) ++ target_link_libraries(colvars_objlib PRIVATE OpenMP::OpenMP_CXX) ++ endif() ++ + else() + # Create a dummy link target so the calling code doesn't need to know + # whether colvars support is being compiled. diff --git a/gromacs/src/colvarproxy_gromacs_version.h b/gromacs/src/colvarproxy_gromacs_version.h index b3a6f1e83..21077698c 100644 --- a/gromacs/src/colvarproxy_gromacs_version.h +++ b/gromacs/src/colvarproxy_gromacs_version.h @@ -1,3 +1,3 @@ #ifndef COLVARPROXY_VERSION -#define COLVARPROXY_VERSION "2023-11-15" +#define COLVARPROXY_VERSION "2023-12-05" #endif diff --git a/gromacs/tests/library/run_tests.sh b/gromacs/tests/library/run_tests.sh index c9f8142ed..8d77478d7 100755 --- a/gromacs/tests/library/run_tests.sh +++ b/gromacs/tests/library/run_tests.sh @@ -171,7 +171,7 @@ for dir in ${DIRLIST} ; do if [ "${basename}" == "test" ] ; then ${BINARY} grompp -f ../Common/test.mdp -c ../Common/da.pdb -p ../Common/da.top -t ../Common/da.trr -o ${basename}.tpr >& ${basename}.grompp.out - ${BINARY} mdrun -s ${basename}.tpr -ntomp 1 -deffnm ${basename} >& ${basename}.out + ${BINARY} mdrun -s ${basename}.tpr -ntomp 2 -deffnm ${basename} >& ${basename}.out RETVAL=$? fi @@ -194,7 +194,7 @@ for dir in ${DIRLIST} ; do echo "init-step = 20" >> ${NEW_MDP} ${BINARY} grompp -f ${NEW_MDP} -c ../Common/da.pdb -p ../Common/da.top -t ${basename%.restart}.cpt -o ${basename}.tpr >& ${basename}.grompp.out rm -f ${NEW_MDP} ${NEW_CVCONF} - ${BINARY} mdrun -s ${basename}.tpr -ntomp 1 -deffnm ${basename} -noappend >& ${basename}.out + ${BINARY} mdrun -s ${basename}.tpr -ntomp 2 -deffnm ${basename} -noappend >& ${basename}.out RETVAL=$? output=${basename}.part0001 @@ -207,7 +207,7 @@ for dir in ${DIRLIST} ; do # Restart both GROMACS and Colvars using the GROMACS checkpoint file ${BINARY} convert-tpr -s ${basename%.restart}.tpr -nsteps 40 -o ${basename}.tpr >& ${basename}.grompp.out - ${BINARY} mdrun -s ${basename}.tpr -ntomp 1 -deffnm ${basename} -noappend -cpi ${basename%.restart}.cpt >& ${basename}.out + ${BINARY} mdrun -s ${basename}.tpr -ntomp 2 -deffnm ${basename} -noappend -cpi ${basename%.restart}.cpt >& ${basename}.out RETVAL=$? output=${basename}.part0002 diff --git a/lammps/COLVARS.cmake.diff b/lammps/COLVARS.cmake.diff new file mode 100644 index 000000000..7b989d4bf --- /dev/null +++ b/lammps/COLVARS.cmake.diff @@ -0,0 +1,17 @@ +diff --git a/cmake/Modules/Packages/COLVARS.cmake b/cmake/Modules/Packages/COLVARS.cmake +index 745c1de026..b943a0345e 100644 +--- a/cmake/Modules/Packages/COLVARS.cmake ++++ b/cmake/Modules/Packages/COLVARS.cmake +@@ -24,6 +24,12 @@ target_include_directories(colvars PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/colvars) + target_include_directories(colvars PRIVATE ${LAMMPS_SOURCE_DIR}) + target_link_libraries(lammps PRIVATE colvars) + ++if(BUILD_OMP) ++ # Enable OpenMP for Colvars as well ++ target_compile_options(colvars PRIVATE ${OpenMP_CXX_FLAGS}) ++ target_link_libraries(colvars PRIVATE OpenMP::OpenMP_CXX) ++endif() ++ + if(COLVARS_DEBUG) + # Need to export the define publicly to be valid in interface code + target_compile_definitions(colvars PUBLIC -DCOLVARS_DEBUG) diff --git a/lammps/src/COLVARS/colvarproxy_lammps.h b/lammps/src/COLVARS/colvarproxy_lammps.h index 5cad6a247..80939a1c1 100644 --- a/lammps/src/COLVARS/colvarproxy_lammps.h +++ b/lammps/src/COLVARS/colvarproxy_lammps.h @@ -34,7 +34,7 @@ class colvarproxy_lammps : public colvarproxy { // state of LAMMPS properties double bias_energy; - int previous_step; + cvm::step_number previous_step; bool first_timestep; bool do_exit; diff --git a/lammps/src/COLVARS/colvarproxy_lammps_version.h b/lammps/src/COLVARS/colvarproxy_lammps_version.h index b3a6f1e83..21077698c 100644 --- a/lammps/src/COLVARS/colvarproxy_lammps_version.h +++ b/lammps/src/COLVARS/colvarproxy_lammps_version.h @@ -1,3 +1,3 @@ #ifndef COLVARPROXY_VERSION -#define COLVARPROXY_VERSION "2023-11-15" +#define COLVARPROXY_VERSION "2023-12-05" #endif diff --git a/lammps/tests/library/run_tests.sh b/lammps/tests/library/run_tests.sh index b1fa99365..3d342e327 100755 --- a/lammps/tests/library/run_tests.sh +++ b/lammps/tests/library/run_tests.sh @@ -37,6 +37,9 @@ fi NUM_TASKS=${NUM_TASKS:-4} if $BINARY -h >& /dev/null ; then + if $BINARY -h 2> /dev/null | grep -q '^OPENMP package API: OpenMP' ; then + BINARY="$BINARY -pk omp 2" + fi if $BINARY -h 2> /dev/null | grep ^MPI | grep -q STUBS ; then MPI_BUILD=no else @@ -50,6 +53,8 @@ else exit 1 fi +echo "Running LAMMPS as: $BINARY" + SPIFF=$(${TOPDIR}/devel-tools/get_spiff) if [ $? != 0 ] ; then echo "Error: spiff is not available and could not be downloaded/built." >& 2 diff --git a/namd/colvars/Make.depends b/namd/colvars/Make.depends index 5598fd149..aadcdf0c1 100644 --- a/namd/colvars/Make.depends +++ b/namd/colvars/Make.depends @@ -16,13 +16,8 @@ obj/colvar.o: \ colvars/src/colvarproxy_volmaps.h \ colvars/src/colvardeps.h \ colvars/src/colvar.h \ - colvars/src/colvar_arithmeticpath.h \ colvars/src/colvar_geometricpath.h \ - colvars/src/colvarscript.h \ colvars/src/colvarbias.h \ - colvars/src/colvarscript_commands.h \ - colvars/src/colvarscript_commands_colvar.h \ - colvars/src/colvarscript_commands_bias.h \ colvars/src/colvars_memstream.h $(CXX) $(COLVARSCXXFLAGS) $(COPTO)obj/colvar.o $(COPTC) colvars/src/colvar.cpp obj/colvaratoms.o: \ @@ -50,17 +45,18 @@ obj/colvarbias.o: \ colvars/src/colvars_version.h \ colvars/src/colvarproxy.h \ colvars/src/colvartypes.h \ - colvars/src/colvarvalue.h \ colvars/src/colvarproxy_io.h \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ colvars/src/colvarproxy_volmaps.h \ + colvars/src/colvarvalue.h \ colvars/src/colvarbias.h \ colvars/src/colvar.h \ colvars/src/colvarparse.h \ colvars/src/colvarparams.h \ colvars/src/colvardeps.h \ - colvars/src/colvargrid.h + colvars/src/colvargrid.h \ + colvars/src/colvars_memstream.h $(CXX) $(COLVARSCXXFLAGS) $(COPTO)obj/colvarbias.o $(COPTC) colvars/src/colvarbias.cpp obj/colvarbias_abf.o: \ obj/.exists \ @@ -81,7 +77,8 @@ obj/colvarbias_abf.o: \ colvars/src/colvarproxy_volmaps.h \ colvars/src/colvarbias.h \ colvars/src/colvargrid.h \ - colvars/src/colvar_UIestimator.h + colvars/src/colvar_UIestimator.h \ + colvars/src/colvars_memstream.h $(CXX) $(COLVARSCXXFLAGS) $(COPTO)obj/colvarbias_abf.o $(COPTC) colvars/src/colvarbias_abf.cpp obj/colvarbias_alb.o: \ obj/.exists \ @@ -90,13 +87,13 @@ obj/colvarbias_alb.o: \ colvars/src/colvars_version.h \ colvars/src/colvarproxy.h \ colvars/src/colvartypes.h \ - colvars/src/colvarvalue.h \ colvars/src/colvarproxy_io.h \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ colvars/src/colvarproxy_volmaps.h \ colvars/src/colvarbias.h \ colvars/src/colvar.h \ + colvars/src/colvarvalue.h \ colvars/src/colvarparse.h \ colvars/src/colvarparams.h \ colvars/src/colvardeps.h \ @@ -109,18 +106,19 @@ obj/colvarbias_histogram.o: \ colvars/src/colvars_version.h \ colvars/src/colvarproxy.h \ colvars/src/colvartypes.h \ - colvars/src/colvarvalue.h \ colvars/src/colvarproxy_io.h \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ colvars/src/colvarproxy_volmaps.h \ colvars/src/colvar.h \ + colvars/src/colvarvalue.h \ colvars/src/colvarparse.h \ colvars/src/colvarparams.h \ colvars/src/colvardeps.h \ colvars/src/colvarbias_histogram.h \ colvars/src/colvarbias.h \ - colvars/src/colvargrid.h + colvars/src/colvargrid.h \ + colvars/src/colvars_memstream.h $(CXX) $(COLVARSCXXFLAGS) $(COPTO)obj/colvarbias_histogram.o $(COPTC) colvars/src/colvarbias_histogram.cpp obj/colvarbias_histogram_reweight_amd.o: \ obj/.exists \ @@ -141,7 +139,8 @@ obj/colvarbias_histogram_reweight_amd.o: \ colvars/src/colvarproxy_io.h \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ - colvars/src/colvarproxy_volmaps.h + colvars/src/colvarproxy_volmaps.h \ + colvars/src/colvars_memstream.h $(CXX) $(COLVARSCXXFLAGS) $(COPTO)obj/colvarbias_histogram_reweight_amd.o $(COPTC) colvars/src/colvarbias_histogram_reweight_amd.cpp obj/colvarbias_meta.o: \ obj/.exists \ @@ -150,18 +149,19 @@ obj/colvarbias_meta.o: \ colvars/src/colvars_version.h \ colvars/src/colvarproxy.h \ colvars/src/colvartypes.h \ - colvars/src/colvarvalue.h \ colvars/src/colvarproxy_io.h \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ colvars/src/colvarproxy_volmaps.h \ colvars/src/colvar.h \ + colvars/src/colvarvalue.h \ colvars/src/colvarparse.h \ colvars/src/colvarparams.h \ colvars/src/colvardeps.h \ colvars/src/colvarbias_meta.h \ colvars/src/colvarbias.h \ - colvars/src/colvargrid.h + colvars/src/colvargrid.h \ + colvars/src/colvars_memstream.h $(CXX) $(COLVARSCXXFLAGS) $(COPTO)obj/colvarbias_meta.o $(COPTC) colvars/src/colvarbias_meta.cpp obj/colvarbias_restraint.o: \ obj/.exists \ @@ -170,11 +170,11 @@ obj/colvarbias_restraint.o: \ colvars/src/colvars_version.h \ colvars/src/colvarproxy.h \ colvars/src/colvartypes.h \ - colvars/src/colvarvalue.h \ colvars/src/colvarproxy_io.h \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ colvars/src/colvarproxy_volmaps.h \ + colvars/src/colvarvalue.h \ colvars/src/colvarbias_restraint.h \ colvars/src/colvarbias.h \ colvars/src/colvar.h \ @@ -200,7 +200,6 @@ obj/colvarcomp.o: \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ colvars/src/colvarproxy_volmaps.h \ - colvars/src/colvar_arithmeticpath.h \ colvars/src/colvar_geometricpath.h $(CXX) $(COLVARSCXXFLAGS) $(COPTO)obj/colvarcomp.o $(COPTC) colvars/src/colvarcomp.cpp obj/colvarcomp_angles.o: \ @@ -221,7 +220,6 @@ obj/colvarcomp_angles.o: \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ colvars/src/colvarproxy_volmaps.h \ - colvars/src/colvar_arithmeticpath.h \ colvars/src/colvar_geometricpath.h $(CXX) $(COLVARSCXXFLAGS) $(COPTO)obj/colvarcomp_angles.o $(COPTC) colvars/src/colvarcomp_angles.cpp obj/colvarcomp_alchlambda.o: \ @@ -231,9 +229,9 @@ obj/colvarcomp_alchlambda.o: \ colvars/src/colvars_version.h \ colvars/src/colvarvalue.h \ colvars/src/colvartypes.h \ + colvars/src/colvar.h \ colvars/src/colvarparse.h \ colvars/src/colvarparams.h \ - colvars/src/colvar.h \ colvars/src/colvardeps.h \ colvars/src/colvarcomp.h \ colvars/src/colvaratoms.h \ @@ -242,19 +240,18 @@ obj/colvarcomp_alchlambda.o: \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ colvars/src/colvarproxy_volmaps.h \ - colvars/src/colvar_arithmeticpath.h \ colvars/src/colvar_geometricpath.h $(CXX) $(COLVARSCXXFLAGS) $(COPTO)obj/colvarcomp_alchlambda.o $(COPTC) colvars/src/colvarcomp_alchlambda.cpp obj/colvarcomp_apath.o: \ obj/.exists \ colvars/src/colvarcomp_apath.cpp \ + colvars/src/colvarvalue.h \ colvars/src/colvarmodule.h \ colvars/src/colvars_version.h \ - colvars/src/colvarvalue.h \ colvars/src/colvartypes.h \ + colvars/src/colvar.h \ colvars/src/colvarparse.h \ colvars/src/colvarparams.h \ - colvars/src/colvar.h \ colvars/src/colvardeps.h \ colvars/src/colvarcomp.h \ colvars/src/colvaratoms.h \ @@ -263,28 +260,27 @@ obj/colvarcomp_apath.o: \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ colvars/src/colvarproxy_volmaps.h \ - colvars/src/colvar_arithmeticpath.h \ - colvars/src/colvar_geometricpath.h + colvars/src/colvar_geometricpath.h \ + colvars/src/colvar_arithmeticpath.h $(CXX) $(COLVARSCXXFLAGS) $(COPTO)obj/colvarcomp_apath.o $(COPTC) colvars/src/colvarcomp_apath.cpp obj/colvarcomp_coordnums.o: \ obj/.exists \ colvars/src/colvarcomp_coordnums.cpp \ colvars/src/colvarmodule.h \ colvars/src/colvars_version.h \ - colvars/src/colvarparse.h \ - colvars/src/colvarvalue.h \ - colvars/src/colvartypes.h \ - colvars/src/colvarparams.h \ colvars/src/colvaratoms.h \ colvars/src/colvarproxy.h \ + colvars/src/colvartypes.h \ colvars/src/colvarproxy_io.h \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ colvars/src/colvarproxy_volmaps.h \ + colvars/src/colvarparse.h \ + colvars/src/colvarvalue.h \ + colvars/src/colvarparams.h \ colvars/src/colvardeps.h \ colvars/src/colvar.h \ colvars/src/colvarcomp.h \ - colvars/src/colvar_arithmeticpath.h \ colvars/src/colvar_geometricpath.h $(CXX) $(COLVARSCXXFLAGS) $(COPTO)obj/colvarcomp_coordnums.o $(COPTC) colvars/src/colvarcomp_coordnums.cpp obj/colvarcomp_distances.o: \ @@ -294,9 +290,9 @@ obj/colvarcomp_distances.o: \ colvars/src/colvars_version.h \ colvars/src/colvarvalue.h \ colvars/src/colvartypes.h \ + colvars/src/colvar.h \ colvars/src/colvarparse.h \ colvars/src/colvarparams.h \ - colvars/src/colvar.h \ colvars/src/colvardeps.h \ colvars/src/colvarcomp.h \ colvars/src/colvaratoms.h \ @@ -305,7 +301,6 @@ obj/colvarcomp_distances.o: \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ colvars/src/colvarproxy_volmaps.h \ - colvars/src/colvar_arithmeticpath.h \ colvars/src/colvar_geometricpath.h \ colvars/src/colvar_rotation_derivative.h $(CXX) $(COLVARSCXXFLAGS) $(COPTO)obj/colvarcomp_distances.o $(COPTC) colvars/src/colvarcomp_distances.cpp @@ -316,9 +311,9 @@ obj/colvarcomp_gpath.o: \ colvars/src/colvars_version.h \ colvars/src/colvarvalue.h \ colvars/src/colvartypes.h \ + colvars/src/colvar.h \ colvars/src/colvarparse.h \ colvars/src/colvarparams.h \ - colvars/src/colvar.h \ colvars/src/colvardeps.h \ colvars/src/colvarcomp.h \ colvars/src/colvaratoms.h \ @@ -327,7 +322,6 @@ obj/colvarcomp_gpath.o: \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ colvars/src/colvarproxy_volmaps.h \ - colvars/src/colvar_arithmeticpath.h \ colvars/src/colvar_geometricpath.h $(CXX) $(COLVARSCXXFLAGS) $(COPTO)obj/colvarcomp_gpath.o $(COPTC) colvars/src/colvarcomp_gpath.cpp obj/colvarcomp_protein.o: \ @@ -337,9 +331,9 @@ obj/colvarcomp_protein.o: \ colvars/src/colvars_version.h \ colvars/src/colvarvalue.h \ colvars/src/colvartypes.h \ + colvars/src/colvar.h \ colvars/src/colvarparse.h \ colvars/src/colvarparams.h \ - colvars/src/colvar.h \ colvars/src/colvardeps.h \ colvars/src/colvarcomp.h \ colvars/src/colvaratoms.h \ @@ -348,7 +342,6 @@ obj/colvarcomp_protein.o: \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ colvars/src/colvarproxy_volmaps.h \ - colvars/src/colvar_arithmeticpath.h \ colvars/src/colvar_geometricpath.h $(CXX) $(COLVARSCXXFLAGS) $(COPTO)obj/colvarcomp_protein.o $(COPTC) colvars/src/colvarcomp_protein.cpp obj/colvarcomp_rotations.o: \ @@ -358,9 +351,9 @@ obj/colvarcomp_rotations.o: \ colvars/src/colvars_version.h \ colvars/src/colvarvalue.h \ colvars/src/colvartypes.h \ + colvars/src/colvar.h \ colvars/src/colvarparse.h \ colvars/src/colvarparams.h \ - colvars/src/colvar.h \ colvars/src/colvardeps.h \ colvars/src/colvarcomp.h \ colvars/src/colvaratoms.h \ @@ -369,7 +362,6 @@ obj/colvarcomp_rotations.o: \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ colvars/src/colvarproxy_volmaps.h \ - colvars/src/colvar_arithmeticpath.h \ colvars/src/colvar_geometricpath.h \ colvars/src/colvar_rotation_derivative.h $(CXX) $(COLVARSCXXFLAGS) $(COPTO)obj/colvarcomp_rotations.o $(COPTC) colvars/src/colvarcomp_rotations.cpp @@ -380,9 +372,9 @@ obj/colvarcomp_volmaps.o: \ colvars/src/colvars_version.h \ colvars/src/colvarvalue.h \ colvars/src/colvartypes.h \ + colvars/src/colvar.h \ colvars/src/colvarparse.h \ colvars/src/colvarparams.h \ - colvars/src/colvar.h \ colvars/src/colvardeps.h \ colvars/src/colvarcomp.h \ colvars/src/colvaratoms.h \ @@ -391,7 +383,6 @@ obj/colvarcomp_volmaps.o: \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ colvars/src/colvarproxy_volmaps.h \ - colvars/src/colvar_arithmeticpath.h \ colvars/src/colvar_geometricpath.h $(CXX) $(COLVARSCXXFLAGS) $(COPTO)obj/colvarcomp_volmaps.o $(COPTC) colvars/src/colvarcomp_volmaps.cpp obj/colvarcomp_combination.o: \ @@ -403,17 +394,16 @@ obj/colvarcomp_combination.o: \ colvars/src/colvaratoms.h \ colvars/src/colvarproxy.h \ colvars/src/colvartypes.h \ - colvars/src/colvarvalue.h \ colvars/src/colvarproxy_io.h \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ colvars/src/colvarproxy_volmaps.h \ colvars/src/colvarparse.h \ + colvars/src/colvarvalue.h \ colvars/src/colvarparams.h \ colvars/src/colvardeps.h \ colvars/src/colvar.h \ - colvars/src/colvar_arithmeticpath.h \ - colvars/src/colvar_geometricpath.h + colvars/src/colvar_geometricpath.h $(CXX) $(COLVARSCXXFLAGS) $(COPTO)obj/colvarcomp_combination.o $(COPTC) colvars/src/colvarcomp_combination.cpp obj/colvarcomp_torchann.o: \ obj/.exists \ @@ -441,9 +431,9 @@ obj/colvarcomp_neuralnetwork.o: \ colvars/src/colvars_version.h \ colvars/src/colvarvalue.h \ colvars/src/colvartypes.h \ + colvars/src/colvar.h \ colvars/src/colvarparse.h \ colvars/src/colvarparams.h \ - colvars/src/colvar.h \ colvars/src/colvardeps.h \ colvars/src/colvarcomp.h \ colvars/src/colvaratoms.h \ @@ -452,7 +442,6 @@ obj/colvarcomp_neuralnetwork.o: \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ colvars/src/colvarproxy_volmaps.h \ - colvars/src/colvar_arithmeticpath.h \ colvars/src/colvar_geometricpath.h \ colvars/src/colvar_neuralnetworkcompute.h $(CXX) $(COLVARSCXXFLAGS) $(COPTO)obj/colvarcomp_neuralnetwork.o $(COPTC) colvars/src/colvarcomp_neuralnetwork.cpp @@ -479,13 +468,13 @@ obj/colvardeps.o: \ colvars/src/colvars_version.h \ colvars/src/colvarproxy.h \ colvars/src/colvartypes.h \ - colvars/src/colvarvalue.h \ colvars/src/colvarproxy_io.h \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ colvars/src/colvarproxy_volmaps.h \ colvars/src/colvardeps.h \ colvars/src/colvarparse.h \ + colvars/src/colvarvalue.h \ colvars/src/colvarparams.h $(CXX) $(COLVARSCXXFLAGS) $(COPTO)obj/colvardeps.o $(COPTC) colvars/src/colvardeps.cpp obj/colvargrid.o: \ @@ -499,17 +488,14 @@ obj/colvargrid.o: \ colvars/src/colvarparams.h \ colvars/src/colvar.h \ colvars/src/colvardeps.h \ - colvars/src/colvarcomp.h \ - colvars/src/colvaratoms.h \ + colvars/src/colvargrid.h \ + colvars/src/colvargrid_def.h \ colvars/src/colvarproxy.h \ colvars/src/colvarproxy_io.h \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ colvars/src/colvarproxy_volmaps.h \ - colvars/src/colvar_arithmeticpath.h \ - colvars/src/colvar_geometricpath.h \ - colvars/src/colvargrid.h \ - colvars/src/colvargrid_def.h + colvars/src/colvars_memstream.h $(CXX) $(COLVARSCXXFLAGS) $(COPTO)obj/colvargrid.o $(COPTC) colvars/src/colvargrid.cpp obj/colvarmodule.o: \ obj/.exists \ @@ -542,8 +528,8 @@ obj/colvarmodule.o: \ colvars/src/colvarscript_commands_bias.h \ colvars/src/colvaratoms.h \ colvars/src/colvarcomp.h \ - colvars/src/colvar_arithmeticpath.h \ colvars/src/colvar_geometricpath.h \ + colvars/src/colvars_memstream.h \ colvars/src/colvarmodule_refs.h $(CXX) $(COLVARSCXXFLAGS) $(COPTO)obj/colvarmodule.o $(COPTC) colvars/src/colvarmodule.cpp obj/colvarparams.o: \ @@ -573,21 +559,20 @@ obj/colvarproxy.o: \ colvars/src/colvars_version.h \ colvars/src/colvarproxy.h \ colvars/src/colvartypes.h \ - colvars/src/colvarvalue.h \ colvars/src/colvarproxy_io.h \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ colvars/src/colvarproxy_volmaps.h \ - colvars/src/colvarscript.h \ - colvars/src/colvarbias.h \ colvars/src/colvar.h \ + colvars/src/colvarvalue.h \ colvars/src/colvarparse.h \ colvars/src/colvarparams.h \ colvars/src/colvardeps.h \ + colvars/src/colvarbias.h \ + colvars/src/colvarscript.h \ colvars/src/colvarscript_commands.h \ colvars/src/colvarscript_commands_colvar.h \ colvars/src/colvarscript_commands_bias.h \ - colvars/src/colvaratoms.h \ colvars/src/colvarmodule_utils.h $(CXX) $(COLVARSCXXFLAGS) $(COPTO)obj/colvarproxy.o $(COPTC) colvars/src/colvarproxy.cpp obj/colvarproxy_io.o: \ @@ -604,7 +589,6 @@ obj/colvarproxy_replicas.o: \ colvars/src/colvars_version.h \ colvars/src/colvarproxy.h \ colvars/src/colvartypes.h \ - colvars/src/colvarvalue.h \ colvars/src/colvarproxy_io.h \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ @@ -625,13 +609,13 @@ obj/colvarproxy_tcl.o: \ colvars/src/colvars_version.h \ colvars/src/colvarproxy.h \ colvars/src/colvartypes.h \ - colvars/src/colvarvalue.h \ colvars/src/colvarproxy_io.h \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ colvars/src/colvarproxy_volmaps.h \ colvars/src/colvaratoms.h \ colvars/src/colvarparse.h \ + colvars/src/colvarvalue.h \ colvars/src/colvarparams.h \ colvars/src/colvardeps.h $(CXX) $(COLVARSCXXFLAGS) $(COPTO)obj/colvarproxy_tcl.o $(COPTC) colvars/src/colvarproxy_tcl.cpp @@ -650,17 +634,15 @@ obj/colvarscript.o: \ colvars/src/colvarmodule.h \ colvars/src/colvars_version.h \ colvars/src/colvartypes.h \ - colvars/src/colvarvalue.h \ colvars/src/colvarproxy_io.h \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ colvars/src/colvarproxy_volmaps.h \ colvars/src/colvardeps.h \ colvars/src/colvarparse.h \ + colvars/src/colvarvalue.h \ colvars/src/colvarparams.h \ colvars/src/colvarscript.h \ - colvars/src/colvarbias.h \ - colvars/src/colvar.h \ colvars/src/colvarscript_commands.h \ colvars/src/colvarscript_commands_colvar.h \ colvars/src/colvarscript_commands_bias.h @@ -668,21 +650,21 @@ obj/colvarscript.o: \ obj/colvarscript_commands.o: \ obj/.exists \ colvars/src/colvarscript_commands.cpp \ - colvars/src/colvarproxy.h \ + colvars/src/colvar.h \ colvars/src/colvarmodule.h \ colvars/src/colvars_version.h \ - colvars/src/colvartypes.h \ colvars/src/colvarvalue.h \ + colvars/src/colvartypes.h \ + colvars/src/colvarparse.h \ + colvars/src/colvarparams.h \ + colvars/src/colvardeps.h \ + colvars/src/colvarbias.h \ + colvars/src/colvarproxy.h \ colvars/src/colvarproxy_io.h \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ colvars/src/colvarproxy_volmaps.h \ - colvars/src/colvardeps.h \ - colvars/src/colvarparse.h \ - colvars/src/colvarparams.h \ colvars/src/colvarscript.h \ - colvars/src/colvarbias.h \ - colvars/src/colvar.h \ colvars/src/colvarscript_commands.h \ colvars/src/colvarscript_commands_colvar.h \ colvars/src/colvarscript_commands_bias.h @@ -694,17 +676,17 @@ obj/colvarscript_commands_bias.o: \ colvars/src/colvarmodule.h \ colvars/src/colvars_version.h \ colvars/src/colvartypes.h \ - colvars/src/colvarvalue.h \ colvars/src/colvarproxy_io.h \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ colvars/src/colvarproxy_volmaps.h \ - colvars/src/colvardeps.h \ + colvars/src/colvarbias.h \ + colvars/src/colvar.h \ + colvars/src/colvarvalue.h \ colvars/src/colvarparse.h \ colvars/src/colvarparams.h \ + colvars/src/colvardeps.h \ colvars/src/colvarscript.h \ - colvars/src/colvarbias.h \ - colvars/src/colvar.h \ colvars/src/colvarscript_commands.h \ colvars/src/colvarscript_commands_colvar.h \ colvars/src/colvarscript_commands_bias.h @@ -712,21 +694,20 @@ obj/colvarscript_commands_bias.o: \ obj/colvarscript_commands_colvar.o: \ obj/.exists \ colvars/src/colvarscript_commands_colvar.cpp \ - colvars/src/colvarproxy.h \ + colvars/src/colvar.h \ colvars/src/colvarmodule.h \ colvars/src/colvars_version.h \ - colvars/src/colvartypes.h \ colvars/src/colvarvalue.h \ + colvars/src/colvartypes.h \ + colvars/src/colvarparse.h \ + colvars/src/colvarparams.h \ + colvars/src/colvardeps.h \ + colvars/src/colvarproxy.h \ colvars/src/colvarproxy_io.h \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ colvars/src/colvarproxy_volmaps.h \ - colvars/src/colvardeps.h \ - colvars/src/colvarparse.h \ - colvars/src/colvarparams.h \ colvars/src/colvarscript.h \ - colvars/src/colvarbias.h \ - colvars/src/colvar.h \ colvars/src/colvarscript_commands.h \ colvars/src/colvarscript_commands_colvar.h \ colvars/src/colvarscript_commands_bias.h @@ -746,15 +727,15 @@ obj/colvartypes.o: \ colvars/src/colvarmodule.h \ colvars/src/colvars_version.h \ colvars/src/colvartypes.h \ - colvars/src/colvarparse.h \ - colvars/src/colvarvalue.h \ - colvars/src/colvarparams.h \ colvars/src/colvaratoms.h \ colvars/src/colvarproxy.h \ colvars/src/colvarproxy_io.h \ colvars/src/colvarproxy_system.h \ colvars/src/colvarproxy_tcl.h \ colvars/src/colvarproxy_volmaps.h \ + colvars/src/colvarparse.h \ + colvars/src/colvarvalue.h \ + colvars/src/colvarparams.h \ colvars/src/colvardeps.h \ colvars/src/colvar_rotation_derivative.h \ colvars/src/nr_jacobi.h diff --git a/namd/src/colvarproxy_namd.C b/namd/src/colvarproxy_namd.C index 63324012c..554e2d4a8 100644 --- a/namd/src/colvarproxy_namd.C +++ b/namd/src/colvarproxy_namd.C @@ -24,6 +24,7 @@ #include "ScriptTcl.h" #include "NamdState.h" #include "Controller.h" +#include "PatchData.h" #ifdef NAMD_TCL #include @@ -34,6 +35,8 @@ #include "DataExchanger.h" #include "colvarmodule.h" +#include "colvar.h" +#include "colvarbias.h" #include "colvaratoms.h" #include "colvarproxy.h" #include "colvarproxy_namd.h" @@ -45,7 +48,13 @@ colvarproxy_namd::colvarproxy_namd() engine_name_ = "NAMD"; version_int = get_version_from_string(COLVARPROXY_VERSION); - +#if CMK_TRACE_ENABLED + if ( 0 == CkMyPe() ) { + traceRegisterUserEvent("GM COLVAR item", GLOBAL_MASTER_CKLOOP_CALC_ITEM); + traceRegisterUserEvent("GM COLVAR bias", GLOBAL_MASTER_CKLOOP_CALC_BIASES ); + traceRegisterUserEvent("GM COLVAR scripted bias", GLOBAL_MASTER_CKLOOP_CALC_SCRIPTED_BIASES ); + } +#endif first_timestep = true; requestTotalForce(total_force_requested); @@ -129,6 +138,12 @@ colvarproxy_namd::colvarproxy_namd() reduction = ReductionMgr::Object()->willSubmit(REDUCTIONS_BASIC); + #ifdef NODEGROUP_FORCE_REGISTER + CProxy_PatchData cpdata(CkpvAccess(BOCclass_group).patchData); + PatchData *patchData = cpdata.ckLocalBranch(); + nodeReduction = patchData->reduction; + #endif + if (cvm::debug()) iout << "Info: done initializing the colvars proxy object.\n" << endi; } @@ -573,7 +588,13 @@ void colvarproxy_namd::calculate() #endif // send MISC energy + #ifdef NODEGROUP_FORCE_REGISTER + if(!simparams->CUDASOAintegrate) { + reduction->submit(); + } + #else reduction->submit(); + #endif // NAMD does not destruct GlobalMaster objects, so we must remember // to write all output files at the end of a run @@ -631,7 +652,15 @@ int colvarproxy_namd::run_colvar_gradient_callback( void colvarproxy_namd::add_energy(cvm::real energy) { + #ifdef NODEGROUP_FORCE_REGISTER + if (simparams->CUDASOAintegrate) { + nodeReduction->item(REDUCTION_MISC_ENERGY) += energy; + } else { + reduction->item(REDUCTION_MISC_ENERGY) += energy; + } + #else reduction->item(REDUCTION_MISC_ENERGY) += energy; + #endif } void colvarproxy_namd::request_total_force(bool yesno) @@ -697,6 +726,12 @@ int colvarproxy_namd::check_atom_id(int atom_number) } +int colvarproxy_namd::check_atom_name_selections_available() +{ + return COLVARS_OK; +} + + int colvarproxy_namd::init_atom(int atom_number) { // save time by checking first whether this atom has been requested before @@ -1265,6 +1300,13 @@ int colvarproxy_namd::set_unit_system(std::string const &units_in, bool /*check_ #if NAMD_VERSION_NUMBER >= 34471681 + +int colvarproxy_namd::check_volmaps_available() +{ + return COLVARS_OK; +} + + int colvarproxy_namd::init_volmap_by_id(int volmap_id) { for (size_t i = 0; i < volmaps_ids.size(); i++) { @@ -1453,11 +1495,22 @@ int colvarproxy_namd::compute_volmap(int flags, #if CMK_SMP && USE_CKLOOP // SMP only +int colvarproxy_namd::check_smp_enabled() +{ + if (b_smp_active) { + return COLVARS_OK; + } + return COLVARS_ERROR; +} + + void calc_colvars_items_smp(int first, int last, void *result, int paramNum, void *param) { colvarproxy_namd *proxy = (colvarproxy_namd *) param; colvarmodule *cv = proxy->colvars; - +#if CMK_TRACE_ENABLED + double before = CmiWallTimer(); +#endif cvm::increase_depth(); for (int i = first; i <= last; i++) { colvar *x = (*(cv->variables_active_smp()))[i]; @@ -1471,6 +1524,9 @@ void calc_colvars_items_smp(int first, int last, void *result, int paramNum, voi x->calc_cvcs(x_item, 1); } cvm::decrease_depth(); +#if CMK_TRACE_ENABLED + traceUserBracketEvent(GLOBAL_MASTER_CKLOOP_CALC_ITEM,before,CmiWallTimer()); +#endif } @@ -1488,7 +1544,9 @@ void calc_cv_biases_smp(int first, int last, void *result, int paramNum, void *p { colvarproxy_namd *proxy = (colvarproxy_namd *) param; colvarmodule *cv = proxy->colvars; - +#if CMK_TRACE_ENABLED + double before = CmiWallTimer(); +#endif cvm::increase_depth(); for (int i = first; i <= last; i++) { colvarbias *b = (*(cv->biases_active()))[i]; @@ -1501,6 +1559,9 @@ void calc_cv_biases_smp(int first, int last, void *result, int paramNum, void *p b->update(); } cvm::decrease_depth(); +#if CMK_TRACE_ENABLED + traceUserBracketEvent(GLOBAL_MASTER_CKLOOP_CALC_BIASES,before,CmiWallTimer()); +#endif } @@ -1517,11 +1578,17 @@ void calc_cv_scripted_forces(int paramNum, void *param) { colvarproxy_namd *proxy = (colvarproxy_namd *) param; colvarmodule *cv = proxy->colvars; +#if CMK_TRACE_ENABLED + double before = CmiWallTimer(); +#endif if (cvm::debug()) { cvm::log("["+cvm::to_str(proxy->smp_thread_id())+"/"+cvm::to_str(proxy->smp_num_threads())+ "]: calc_cv_scripted_forces()\n"); } cv->calc_scripted_forces(); +#if CMK_TRACE_ENABLED + traceUserBracketEvent(GLOBAL_MASTER_CKLOOP_CALC_SCRIPTED_BIASES,before,CmiWallTimer()); +#endif } diff --git a/namd/src/colvarproxy_namd.h b/namd/src/colvarproxy_namd.h index d2551c544..7572780e4 100644 --- a/namd/src/colvarproxy_namd.h +++ b/namd/src/colvarproxy_namd.h @@ -29,6 +29,10 @@ #include "colvarproxy.h" #include "colvarvalue.h" +#define GLOBAL_MASTER_CKLOOP_CALC_ITEM 2000 +#define GLOBAL_MASTER_CKLOOP_CALC_BIASES 2001 +#define GLOBAL_MASTER_CKLOOP_CALC_SCRIPTED_BIASES 2002 + /// \brief Communication between colvars and NAMD (implementation of /// \link colvarproxy \endlink) class colvarproxy_namd : public colvarproxy, public GlobalMaster { @@ -46,10 +50,13 @@ class colvarproxy_namd : public colvarproxy, public GlobalMaster { Random random; bool first_timestep; - size_t previous_NAMD_step; + cvm::step_number previous_NAMD_step; /// Used to submit restraint energy as MISC SubmitReduction *reduction; +#ifdef NODEGROUP_FORCE_REGISTER + NodeReduction *nodeReduction; +#endif /// Accelerated MD reweighting factor bool accelMDOn; @@ -113,13 +120,7 @@ class colvarproxy_namd : public colvarproxy, public GlobalMaster { } #if CMK_SMP && USE_CKLOOP - int smp_enabled() override - { - if (b_smp_active) { - return COLVARS_OK; - } - return COLVARS_ERROR; - } + int check_smp_enabled() override; int smp_colvars_loop() override; @@ -173,6 +174,7 @@ class colvarproxy_namd : public colvarproxy, public GlobalMaster { int replica_comm_recv(char* msg_data, int buf_len, int src_rep) override; int replica_comm_send(char* msg_data, int msg_len, int dest_rep) override; + int check_atom_name_selections_available() override; int init_atom(int atom_number) override; int check_atom_id(int atom_number) override; int init_atom(cvm::residue_id const &residue, @@ -211,6 +213,8 @@ class colvarproxy_namd : public colvarproxy, public GlobalMaster { #if NAMD_VERSION_NUMBER >= 34471681 + int check_volmaps_available() override; + int init_volmap_by_id(int volmap_id) override; int init_volmap_by_name(const char *volmap_name) override; diff --git a/namd/src/colvarproxy_namd_version.h b/namd/src/colvarproxy_namd_version.h index b3a6f1e83..21077698c 100644 --- a/namd/src/colvarproxy_namd_version.h +++ b/namd/src/colvarproxy_namd_version.h @@ -1,3 +1,3 @@ #ifndef COLVARPROXY_VERSION -#define COLVARPROXY_VERSION "2023-11-15" +#define COLVARPROXY_VERSION "2023-12-05" #endif diff --git a/src/colvar.cpp b/src/colvar.cpp index c62cbf50d..55bc33787 100644 --- a/src/colvar.cpp +++ b/src/colvar.cpp @@ -18,13 +18,17 @@ #include "colvarparse.h" #include "colvarcomp.h" #include "colvar.h" -#include "colvarscript.h" +#include "colvarbias.h" #include "colvars_memstream.h" -std::map> + +std::map> colvar::global_cvc_map = - std::map>(); + std::map>(); + +std::map colvar::global_cvc_desc_map = + std::map(); colvar::colvar() @@ -748,19 +752,18 @@ int colvar::init_output_flags(std::string const &conf) template -int colvar::init_components_type(std::string const &, char const * /* def_desc */, - char const *def_config_key) +void colvar::add_component_type(char const *def_description, char const *def_config_key) { - global_cvc_map[def_config_key] = [](const std::string &cvc_conf) { - return new def_class_name(cvc_conf); - }; - // TODO: maybe it is better to do more check to avoid duplication in the map? - return COLVARS_OK; + if (global_cvc_map.count(def_config_key) == 0) { + global_cvc_map[def_config_key] = [](const std::string &cvc_conf) { + return new def_class_name(cvc_conf); + }; + global_cvc_desc_map[def_config_key] = std::string(def_description); + } } -int colvar::init_components_type_from_global_map(const std::string& conf, - const char* def_config_key) { +int colvar::init_components_type(const std::string& conf, const char* def_config_key) { size_t def_count = 0; std::string def_conf = ""; size_t pos = 0; @@ -831,86 +834,87 @@ int colvar::init_components_type_from_global_map(const std::string& conf, } -int colvar::init_components(std::string const &conf) +void colvar::define_component_types() { - int error_code = COLVARS_OK; - size_t i = 0, j = 0; + colvarproxy *proxy = cvm::main()->proxy; + + add_component_type("distance", "distance"); + add_component_type("distance vector", "distanceVec"); + add_component_type("Cartesian coordinates", "cartesian"); + add_component_type("distance vector direction", "distanceDir"); + add_component_type("distance projection on an axis", "distanceZ"); + add_component_type("distance projection on a plane", "distanceXY"); + add_component_type("spherical polar angle theta", "polarTheta"); + add_component_type("spherical azimuthal angle phi", "polarPhi"); + add_component_type("average distance weighted by inverse power", "distanceInv"); + add_component_type("N1xN2-long vector of pairwise distances", "distancePairs"); + add_component_type("dipole magnitude", "dipoleMagnitude"); + add_component_type("coordination number", "coordNum"); + add_component_type("self-coordination number", "selfCoordNum"); + add_component_type("group-coordination number", "groupCoord"); + add_component_type("angle", "angle"); + add_component_type("dipole angle", "dipoleAngle"); + add_component_type("dihedral", "dihedral"); + add_component_type("hydrogen bond", "hBond"); + + if (proxy->check_atom_name_selections_available() == COLVARS_OK) { + add_component_type("alpha helix", "alpha"); + add_component_type("dihedral principal component", "dihedralPC"); + } + + add_component_type("orientation", "orientation"); + add_component_type("orientation angle", "orientationAngle"); + add_component_type("orientation projection", "orientationProj"); + add_component_type("tilt", "tilt"); + add_component_type("spin angle", "spinAngle"); + add_component_type("RMSD", "rmsd"); + add_component_type("radius of gyration", "gyration"); + add_component_type("moment of inertia", "inertia"); + add_component_type("moment of inertia around an axis", "inertiaZ"); + add_component_type("eigenvector", "eigenvector"); + add_component_type("alchemical coupling parameter", "alchLambda"); + add_component_type("force on alchemical coupling parameter", "alchFLambda"); + add_component_type("arithmetic path collective variables (s)", "aspath"); + add_component_type("arithmetic path collective variables (z)", "azpath"); + add_component_type("geometrical path collective variables (s)", "gspath"); + add_component_type("geometrical path collective variables (z)", "gzpath"); + add_component_type("linear combination of other collective variables", "linearCombination"); + add_component_type("geometrical path collective variables (s) for other CVs", "gspathCV"); + add_component_type("geometrical path collective variables (z) for other CVs", "gzpathCV"); + add_component_type("arithmetic path collective variables (s) for other CVs", "aspathCV"); + add_component_type("arithmetic path collective variables (s) for other CVs", "azpathCV"); + add_component_type("euler phi angle of the optimal orientation", "eulerPhi"); + add_component_type("euler psi angle of the optimal orientation", "eulerPsi"); + add_component_type("euler theta angle of the optimal orientation", "eulerTheta"); - // in the non-C++11 case, the components are initialized directly by init_components_type; - // in the C++11 case, the components are stored in the global_cvc_map at first - // by init_components_type, and then the map is iterated to initialize all components. - error_code |= init_components_type(conf, "distance", "distance"); - error_code |= init_components_type(conf, "distance vector", "distanceVec"); - error_code |= init_components_type(conf, "Cartesian coordinates", "cartesian"); - error_code |= init_components_type(conf, "distance vector " - "direction", "distanceDir"); - error_code |= init_components_type(conf, "distance projection " - "on an axis", "distanceZ"); - error_code |= init_components_type(conf, "distance projection " - "on a plane", "distanceXY"); - error_code |= init_components_type(conf, "spherical polar angle theta", - "polarTheta"); - error_code |= init_components_type(conf, "spherical azimuthal angle phi", - "polarPhi"); - error_code |= init_components_type(conf, "average distance " - "weighted by inverse power", "distanceInv"); - error_code |= init_components_type(conf, "N1xN2-long vector " - "of pairwise distances", "distancePairs"); - error_code |= init_components_type(conf, "dipole magnitude", - "dipoleMagnitude"); - error_code |= init_components_type(conf, "coordination " - "number", "coordNum"); - error_code |= init_components_type(conf, "self-coordination " - "number", "selfCoordNum"); - error_code |= init_components_type(conf, "group-coordination " - "number", "groupCoord"); - error_code |= init_components_type(conf, "angle", "angle"); - error_code |= init_components_type(conf, "dipole angle", "dipoleAngle"); - error_code |= init_components_type(conf, "dihedral", "dihedral"); - error_code |= init_components_type(conf, "hydrogen bond", "hBond"); - error_code |= init_components_type(conf, "alpha helix", "alpha"); - error_code |= init_components_type(conf, "dihedral " - "principal component", "dihedralPC"); - error_code |= init_components_type(conf, "orientation", "orientation"); - error_code |= init_components_type(conf, "orientation " - "angle", "orientationAngle"); - error_code |= init_components_type(conf, "orientation " - "projection", "orientationProj"); - error_code |= init_components_type(conf, "tilt", "tilt"); - error_code |= init_components_type(conf, "spin angle", "spinAngle"); - error_code |= init_components_type(conf, "RMSD", "rmsd"); - error_code |= init_components_type(conf, "radius of " - "gyration", "gyration"); - error_code |= init_components_type(conf, "moment of " - "inertia", "inertia"); - error_code |= init_components_type(conf, "moment of inertia around an axis", "inertiaZ"); - error_code |= init_components_type(conf, "eigenvector", "eigenvector"); - error_code |= init_components_type(conf, "alchemical coupling parameter", "alchLambda"); - error_code |= init_components_type(conf, "force on alchemical coupling parameter", "alchFLambda"); - error_code |= init_components_type(conf, "arithmetic path collective variables (s)", "aspath"); - error_code |= init_components_type(conf, "arithmetic path collective variables (z)", "azpath"); - error_code |= init_components_type(conf, "geometrical path collective variables (s)", "gspath"); - error_code |= init_components_type(conf, "geometrical path collective variables (z)", "gzpath"); - error_code |= init_components_type(conf, "linear combination of other collective variables", "linearCombination"); - error_code |= init_components_type(conf, "geometrical path collective variables (s) for other CVs", "gspathCV"); - error_code |= init_components_type(conf, "geometrical path collective variables (z) for other CVs", "gzpathCV"); - error_code |= init_components_type(conf, "arithmetic path collective variables (s) for other CVs", "aspathCV"); - error_code |= init_components_type(conf, "arithmetic path collective variables (s) for other CVs", "azpathCV"); - error_code |= init_components_type(conf, "euler phi angle of the optimal orientation", "eulerPhi"); - error_code |= init_components_type(conf, "euler psi angle of the optimal orientation", "eulerPsi"); - error_code |= init_components_type(conf, "euler theta angle of the optimal orientation", "eulerTheta"); #ifdef LEPTON - error_code |= init_components_type(conf, "CV with support of the lepton custom function", "customColvar"); + add_component_type("CV with support of the Lepton custom function", "customColvar"); #endif - error_code |= init_components_type(conf, "neural network CV for other CVs", "NeuralNetwork"); + + add_component_type("neural network CV for other CVs", "neuralNetwork"); + #ifdef TORCH - error_code |= init_components_type(conf, "CV defined by PyTorch artifical neural network models", "torchANN"); + add_component_type("CV defined by PyTorch artifical neural network models", "torchANN"); #endif - error_code |= init_components_type(conf, "total value of atomic map", "mapTotal"); + + if (proxy->check_volmaps_available() == COLVARS_OK) { + add_component_type("total value of atomic map", "mapTotal"); + } +} + + +int colvar::init_components(std::string const &conf) +{ + int error_code = COLVARS_OK; + size_t i = 0, j = 0; + + if (global_cvc_map.empty()) { + define_component_types(); + } // iterate over all available CVC in the map for (auto it = global_cvc_map.begin(); it != global_cvc_map.end(); ++it) { - error_code |= init_components_type_from_global_map(conf, it->first.c_str()); + error_code |= init_components_type(conf, it->first.c_str()); // TODO: is it better to check the error code here? if (error_code != COLVARS_OK) { cvm::log("Failed to initialize " + it->first + " with the following configuration:\n"); @@ -920,34 +924,38 @@ int colvar::init_components(std::string const &conf) } } - if (!cvcs.size() || (error_code != COLVARS_OK)) { - cvm::error("Error: no valid components were provided " - "for this collective variable.\n", - COLVARS_INPUT_ERROR); - return COLVARS_INPUT_ERROR; + if (!cvcs.size()) { + std::string msg("Error: no valid components were provided for this collective variable.\n"); + msg += "Currently available component types are: \n"; + for (auto it = global_cvc_desc_map.begin(); it != global_cvc_desc_map.end(); ++it) { + msg += " " + it->first + " -- " + it->second + "\n"; + } + msg += "\nPlease note that some of the above types may still be unavailable, irrespective of this error.\n"; + error_code |= cvm::error(msg, COLVARS_INPUT_ERROR); } // Check for uniqueness of CVC names (esp. if user-provided) for (i = 0; i < cvcs.size(); i++) { - for (j = i+1; j < cvcs.size(); j++) { + for (j = i + 1; j < cvcs.size(); j++) { if (cvcs[i]->name == cvcs[j]->name) { - cvm::error("Components " + cvm::to_str(i) + " and " + cvm::to_str(j) +\ - " cannot have the same name \"" + cvcs[i]->name+ "\".\n", COLVARS_INPUT_ERROR); - return COLVARS_INPUT_ERROR; + error_code |= cvm::error("Components " + cvm::to_str(i) + " and " + cvm::to_str(j) + + " cannot have the same name \"" + cvcs[i]->name + "\".\n", + COLVARS_INPUT_ERROR); } } } - n_active_cvcs = cvcs.size(); - - // Store list of children cvcs for dependency checking purposes - for (i = 0; i < cvcs.size(); i++) { - add_child(cvcs[i]); + if (error_code == COLVARS_OK) { + // Store list of children cvcs for dependency checking purposes + for (i = 0; i < cvcs.size(); i++) { + add_child(cvcs[i]); + } + // By default all CVCs are active at the start + n_active_cvcs = cvcs.size(); + cvm::log("All components initialized.\n"); } - cvm::log("All components initialized.\n"); - - return COLVARS_OK; + return error_code; } diff --git a/src/colvar.h b/src/colvar.h index 00231984d..2d6cfb628 100644 --- a/src/colvar.h +++ b/src/colvar.h @@ -11,6 +11,7 @@ #define COLVAR_H #include +#include #include #include @@ -249,6 +250,9 @@ class colvar : public colvarparse, public colvardeps { /// Main init function int init(std::string const &conf); + /// Populate the map of available CVC types + void define_component_types(); + /// Parse the CVC configuration and allocate their data int init_components(std::string const &conf); @@ -269,15 +273,12 @@ class colvar : public colvarparse, public colvardeps { private: - /// Parse the CVC configuration for all components of a certain type - template int init_components_type(std::string const & conf, - char const *def_desc, - char const *def_config_key); + /// Declare an available CVC type and its description, register them in the global map + template + void add_component_type(char const *description, char const *config_key); - /// The names of all available components are registered in the global map - /// at first, and then the CVC configuration is parsed by this function - int init_components_type_from_global_map(const std::string& conf, - const char* def_config_key); + /// Initialize any CVC objects matching the given key + int init_components_type(const std::string &conf, const char *config_key); public: @@ -689,9 +690,12 @@ class colvar : public colvarparse, public colvardeps { #endif /// A global mapping of cvc names to the cvc constructors - static std::map> + static std::map> global_cvc_map; + /// A global mapping of cvc names to the corresponding descriptions + static std::map global_cvc_desc_map; + /// Volmap numeric IDs, one for each CVC (-1 if not available) std::vector volmap_ids_; diff --git a/src/colvarbias.cpp b/src/colvarbias.cpp index 169fc073b..2609a6469 100644 --- a/src/colvarbias.cpp +++ b/src/colvarbias.cpp @@ -447,12 +447,18 @@ int colvarbias::bin_count(int /* bin_index */) cvm::error("Error: bin_count() not implemented.\n"); return COLVARS_NOT_IMPLEMENTED; } + int colvarbias::replica_share() { cvm::error("Error: replica_share() not implemented.\n"); return COLVARS_NOT_IMPLEMENTED; } +size_t colvarbias::replica_share_freq() const +{ + return 0; +} + std::string const colvarbias::get_state_params() const { diff --git a/src/colvarbias.h b/src/colvarbias.h index 9a51f9d51..d59746dab 100644 --- a/src/colvarbias.h +++ b/src/colvarbias.h @@ -93,9 +93,13 @@ class colvarbias //// Give the count at a given bin index. // FIXME this is currently 1D only virtual int bin_count(int bin_index); + //// Share information between replicas, whatever it may be. virtual int replica_share(); + /// Report the frequency at which this bias needs to communicate with replicas + virtual size_t replica_share_freq() const; + /// Perform analysis tasks virtual void analyze() {} diff --git a/src/colvarbias_abf.cpp b/src/colvarbias_abf.cpp index dcf58a319..94d41e767 100644 --- a/src/colvarbias_abf.cpp +++ b/src/colvarbias_abf.cpp @@ -106,12 +106,6 @@ int colvarbias_abf::init(std::string const &conf) } cvm::log("shared ABF will be applied among "+ cvm::to_str(proxy->num_replicas()) + " replicas.\n"); - if (cvm::proxy->smp_enabled() == COLVARS_OK) { - cvm::error("Error: shared ABF is currently not available with SMP parallelism; " - "please set \"SMP off\" at the top of the Colvars configuration file.\n", - COLVARS_NOT_IMPLEMENTED); - return COLVARS_NOT_IMPLEMENTED; - } // If shared_freq is not set, we default to output_freq get_keyval(conf, "sharedFreq", shared_freq, output_freq); @@ -599,6 +593,12 @@ int colvarbias_abf::replica_share() { } +size_t colvarbias_abf::replica_share_freq() const +{ + return shared_freq; +} + + template int colvarbias_abf::write_grid_to_file(T const *grid, std::string const &filename, bool close) { diff --git a/src/colvarbias_abf.h b/src/colvarbias_abf.h index 635e0fbfd..ede514d6e 100644 --- a/src/colvarbias_abf.h +++ b/src/colvarbias_abf.h @@ -133,9 +133,12 @@ class colvarbias_abf : public colvarbias { bool shared_on; size_t shared_freq; cvm::step_number shared_last_step; + // Share between replicas -- may be called independently of update virtual int replica_share(); + virtual size_t replica_share_freq() const; + // Store the last set for shared ABF colvar_grid_gradient *last_gradients; colvar_grid_count *last_samples; diff --git a/src/colvarbias_alb.cpp b/src/colvarbias_alb.cpp index b432659bf..1e8eb52d6 100644 --- a/src/colvarbias_alb.cpp +++ b/src/colvarbias_alb.cpp @@ -9,7 +9,6 @@ #include #include -#include #include "colvarmodule.h" #include "colvarproxy.h" diff --git a/src/colvarbias_meta.cpp b/src/colvarbias_meta.cpp index 3a2bf6b59..905cd1788 100644 --- a/src/colvarbias_meta.cpp +++ b/src/colvarbias_meta.cpp @@ -7,8 +7,6 @@ // If you wish to distribute your changes, please submit them to the // Colvars repository at GitHub. -#include -#include #include #include #include @@ -64,7 +62,6 @@ colvarbias_meta::colvarbias_meta(char const *key) ebmeta_equil_steps = 0L; - replica_update_freq = 0; replica_id.clear(); } @@ -985,9 +982,9 @@ void colvarbias_meta::recount_hills_off_grid(colvarbias_meta::hill_iter h_first int colvarbias_meta::replica_share() { int error_code = COLVARS_OK; - colvarproxy *proxy = cvm::proxy; // sync with the other replicas (if needed) if (comm == multiple_replicas) { + colvarproxy *proxy = cvm::main()->proxy; // reread the replicas registry error_code |= update_replicas_registry(); // empty the output buffer @@ -998,6 +995,12 @@ int colvarbias_meta::replica_share() } +size_t colvarbias_meta::replica_share_freq() const +{ + return replica_update_freq; +} + + int colvarbias_meta::update_replicas_registry() { int error_code = COLVARS_OK; diff --git a/src/colvarbias_meta.h b/src/colvarbias_meta.h index f85bb0fdc..a765a60c7 100644 --- a/src/colvarbias_meta.h +++ b/src/colvarbias_meta.h @@ -52,6 +52,7 @@ class colvarbias_meta virtual int update_bias(); virtual int update_grid_data(); virtual int replica_share(); + virtual size_t replica_share_freq() const; virtual int calc_energy(std::vector const *values); virtual int calc_forces(std::vector const *values); @@ -261,7 +262,7 @@ class colvarbias_meta std::vector replicas; /// \brief Frequency at which data the "mirror" biases are updated - size_t replica_update_freq; + size_t replica_update_freq = 0; /// List of replicas (and their output list files): contents are /// copied into replicas_registry for convenience diff --git a/src/colvarcomp.h b/src/colvarcomp.h index 5f50de066..dd5b59b8d 100644 --- a/src/colvarcomp.h +++ b/src/colvarcomp.h @@ -19,8 +19,6 @@ // this can be done straightforwardly by using the macro: // simple_scalar_dist_functions (derived_class) -#include -#include #include #include "colvarmodule.h" diff --git a/src/colvarcomp_alchlambda.cpp b/src/colvarcomp_alchlambda.cpp index 9f18bec77..dbb1ece45 100644 --- a/src/colvarcomp_alchlambda.cpp +++ b/src/colvarcomp_alchlambda.cpp @@ -12,7 +12,6 @@ #include "colvarmodule.h" #include "colvarvalue.h" -#include "colvarparse.h" #include "colvar.h" #include "colvarcomp.h" diff --git a/src/colvarcomp_apath.cpp b/src/colvarcomp_apath.cpp index 38c570add..1a8b94550 100644 --- a/src/colvarcomp_apath.cpp +++ b/src/colvarcomp_apath.cpp @@ -9,13 +9,11 @@ #include #include -#include #include #include #include #include "colvarvalue.h" -#include "colvarparse.h" #include "colvar.h" #include "colvarcomp.h" #include "colvar_arithmeticpath.h" diff --git a/src/colvarcomp_coordnums.cpp b/src/colvarcomp_coordnums.cpp index 3d618ff80..66a45594c 100644 --- a/src/colvarcomp_coordnums.cpp +++ b/src/colvarcomp_coordnums.cpp @@ -8,7 +8,6 @@ // Colvars repository at GitHub. #include "colvarmodule.h" -#include "colvarparse.h" #include "colvaratoms.h" #include "colvarvalue.h" #include "colvar.h" diff --git a/src/colvarcomp_distances.cpp b/src/colvarcomp_distances.cpp index 451bd0d3b..589519e40 100644 --- a/src/colvarcomp_distances.cpp +++ b/src/colvarcomp_distances.cpp @@ -11,7 +11,6 @@ #include "colvarmodule.h" #include "colvarvalue.h" -#include "colvarparse.h" #include "colvar.h" #include "colvarcomp.h" #include "colvar_rotation_derivative.h" diff --git a/src/colvarcomp_gpath.cpp b/src/colvarcomp_gpath.cpp index ba7b11f92..0b9a18c43 100644 --- a/src/colvarcomp_gpath.cpp +++ b/src/colvarcomp_gpath.cpp @@ -10,13 +10,11 @@ #include #include #include -#include #include #include #include "colvarmodule.h" #include "colvarvalue.h" -#include "colvarparse.h" #include "colvar.h" #include "colvarcomp.h" diff --git a/src/colvarcomp_neuralnetwork.cpp b/src/colvarcomp_neuralnetwork.cpp index e8ad629b1..e3550a5af 100644 --- a/src/colvarcomp_neuralnetwork.cpp +++ b/src/colvarcomp_neuralnetwork.cpp @@ -9,7 +9,6 @@ #include "colvarmodule.h" #include "colvarvalue.h" -#include "colvarparse.h" #include "colvar.h" #include "colvarcomp.h" #include "colvar_neuralnetworkcompute.h" diff --git a/src/colvarcomp_protein.cpp b/src/colvarcomp_protein.cpp index 80ef9b855..0f3830614 100644 --- a/src/colvarcomp_protein.cpp +++ b/src/colvarcomp_protein.cpp @@ -11,7 +11,6 @@ #include "colvarmodule.h" #include "colvarvalue.h" -#include "colvarparse.h" #include "colvar.h" #include "colvarcomp.h" diff --git a/src/colvarcomp_rotations.cpp b/src/colvarcomp_rotations.cpp index 3a19d5ca7..d59f2c93e 100644 --- a/src/colvarcomp_rotations.cpp +++ b/src/colvarcomp_rotations.cpp @@ -9,7 +9,6 @@ #include "colvarmodule.h" #include "colvarvalue.h" -#include "colvarparse.h" #include "colvar.h" #include "colvarcomp.h" #include "colvar_rotation_derivative.h" diff --git a/src/colvarcomp_volmaps.cpp b/src/colvarcomp_volmaps.cpp index 00c7206bc..a95f15bcb 100644 --- a/src/colvarcomp_volmaps.cpp +++ b/src/colvarcomp_volmaps.cpp @@ -9,7 +9,6 @@ #include "colvarmodule.h" #include "colvarvalue.h" -#include "colvarparse.h" #include "colvar.h" #include "colvarcomp.h" diff --git a/src/colvargrid.cpp b/src/colvargrid.cpp index 7bdaa5af5..5aefbb8c4 100644 --- a/src/colvargrid.cpp +++ b/src/colvargrid.cpp @@ -8,13 +8,11 @@ // Colvars repository at GitHub. #include -#include #include "colvarmodule.h" #include "colvarvalue.h" #include "colvarparse.h" #include "colvar.h" -#include "colvarcomp.h" #include "colvargrid.h" #include "colvargrid_def.h" diff --git a/src/colvarmodule.cpp b/src/colvarmodule.cpp index 58d493237..0b905bd13 100644 --- a/src/colvarmodule.cpp +++ b/src/colvarmodule.cpp @@ -7,13 +7,9 @@ // If you wish to distribute your changes, please submit them to the // Colvars repository at GitHub. -#include -#include -#include #include #include -#include -#include +#include #include #include "colvarmodule.h" @@ -110,8 +106,14 @@ colvarmodule::colvarmodule(colvarproxy *proxy_in) " https://doi.org/10.1080/00268976.2013.813594\n" "as well as all other papers listed below for individual features used.\n"); - if (proxy->smp_enabled() == COLVARS_OK) { - cvm::log("SMP parallelism is enabled; if needed, use \"smp off\" to override this.\n"); + if (proxy->check_smp_enabled() == COLVARS_NOT_IMPLEMENTED) { + cvm::log("SMP parallelism is not available in this build.\n"); + } else { + if (proxy->check_smp_enabled() == COLVARS_OK) { + cvm::log("SMP parallelism is enabled (num threads = " + to_str(proxy->smp_num_threads()) + ").\n"); + } else { + cvm::log("SMP parallelism is available in this build but not enabled.\n"); + } } #if (__cplusplus >= 201103L) @@ -900,7 +902,7 @@ int colvarmodule::calc_colvars() } // if SMP support is available, split up the work - if (proxy->smp_enabled() == COLVARS_OK) { + if (proxy->check_smp_enabled() == COLVARS_OK) { // first, calculate how much work (currently, how many active CVCs) each colvar has @@ -982,8 +984,15 @@ int colvarmodule::calc_biases() } } - // if SMP support is available, split up the work - if (proxy->smp_enabled() == COLVARS_OK) { + bool biases_need_io = false; + for (bi = biases_active()->begin(); bi != biases_active()->end(); bi++) { + if (((*bi)->replica_share_freq() > 0) && (step_absolute() % (*bi)->replica_share_freq() == 0)) { + biases_need_io = true; + } + } + + // If SMP support is available, split up the work (unless biases need to use main thread's memory) + if (proxy->check_smp_enabled() == COLVARS_OK && !biases_need_io) { if (use_scripted_forces && !scripting_after_biases) { // calculate biases and scripted forces in parallel @@ -999,10 +1008,12 @@ int colvarmodule::calc_biases() error_code |= calc_scripted_forces(); } + // Straight loop over biases on a single thread cvm::increase_depth(); for (bi = biases_active()->begin(); bi != biases_active()->end(); bi++) { error_code |= (*bi)->update(); if (cvm::get_error()) { + cvm::decrease_depth(); return error_code; } } @@ -1954,7 +1965,7 @@ size_t & colvarmodule::depth() { // NOTE: do not call log() or error() here, to avoid recursion colvarmodule *cv = cvm::main(); - if (proxy->smp_enabled() == COLVARS_OK) { + if (proxy->check_smp_enabled() == COLVARS_OK) { int const nt = proxy->smp_num_threads(); if (int(cv->depth_v.size()) != nt) { proxy->smp_lock(); diff --git a/src/colvarmodule.h b/src/colvarmodule.h index be39ae062..f3224502d 100644 --- a/src/colvarmodule.h +++ b/src/colvarmodule.h @@ -10,7 +10,7 @@ #ifndef COLVARMODULE_H #define COLVARMODULE_H -#include +#include #include "colvars_version.h" @@ -35,16 +35,15 @@ Please note that this documentation is only supported for the master branch, and /// shared between all object instances) to be accessed from other /// objects. +#include +#include #include #include -#include -#include class colvarparse; class colvar; class colvarbias; class colvarproxy; -class colvarscript; class colvarvalue; @@ -82,8 +81,6 @@ class colvarmodule { } friend class colvarproxy; - // TODO colvarscript should be unaware of colvarmodule's internals - friend class colvarscript; /// Use a 64-bit integer to store the step number typedef long long step_number; diff --git a/src/colvarparse.cpp b/src/colvarparse.cpp index c189a9e89..76b5c694c 100644 --- a/src/colvarparse.cpp +++ b/src/colvarparse.cpp @@ -8,7 +8,6 @@ // Colvars repository at GitHub. #include -#include #include #include "colvarmodule.h" diff --git a/src/colvarparse.h b/src/colvarparse.h index 0ac9c1117..105a0857a 100644 --- a/src/colvarparse.h +++ b/src/colvarparse.h @@ -11,6 +11,7 @@ #define COLVARPARSE_H #include +#include #include #include "colvarmodule.h" diff --git a/src/colvarproxy.cpp b/src/colvarproxy.cpp index 2f262bfdc..dbea53265 100644 --- a/src/colvarproxy.cpp +++ b/src/colvarproxy.cpp @@ -13,8 +13,9 @@ #include "colvarmodule.h" #include "colvarproxy.h" +#include "colvar.h" +#include "colvarbias.h" #include "colvarscript.h" -#include "colvaratoms.h" #include "colvarmodule_utils.h" @@ -73,6 +74,12 @@ int colvarproxy_atoms::check_atom_id(int /* atom_number */) } +int colvarproxy_atoms::check_atom_name_selections_available() +{ + return COLVARS_NOT_IMPLEMENTED; +} + + int colvarproxy_atoms::init_atom(cvm::residue_id const & /* residue */, std::string const & /* atom_name */, std::string const & /* segment_id */) @@ -282,7 +289,7 @@ colvarproxy_smp::~colvarproxy_smp() } -int colvarproxy_smp::smp_enabled() +int colvarproxy_smp::check_smp_enabled() { #if defined(_OPENMP) if (b_smp_active) { @@ -486,8 +493,8 @@ colvarproxy::~colvarproxy() bool colvarproxy::io_available() { - return (smp_enabled() == COLVARS_OK && smp_thread_id() == 0) || - (smp_enabled() != COLVARS_OK); + return (check_smp_enabled() == COLVARS_OK && smp_thread_id() == 0) || + (check_smp_enabled() != COLVARS_OK); } diff --git a/src/colvarproxy.h b/src/colvarproxy.h index 387548ad8..d68b038ed 100644 --- a/src/colvarproxy.h +++ b/src/colvarproxy.h @@ -12,7 +12,6 @@ #include "colvarmodule.h" #include "colvartypes.h" -#include "colvarvalue.h" #include "colvarproxy_io.h" #include "colvarproxy_system.h" #include "colvarproxy_tcl.h" @@ -56,6 +55,9 @@ class colvarproxy_atoms { /// corresponding atom yet virtual int check_atom_id(int atom_number); + /// Check whether it is possible to select atoms by residue number name + virtual int check_atom_name_selections_available(); + /// Select this atom for collective variables calculation, using name and /// residue number. Not all programs support this: leave this function as /// is in those cases. @@ -477,7 +479,7 @@ class colvarproxy_smp { bool b_smp_active; /// Whether threaded parallelization is available (TODO: make this a cvm::deps feature) - virtual int smp_enabled(); + virtual int check_smp_enabled(); /// Distribute calculation of colvars (and their components) across threads virtual int smp_colvars_loop(); diff --git a/src/colvarproxy_io.cpp b/src/colvarproxy_io.cpp index 61295b165..4cfdfeec2 100644 --- a/src/colvarproxy_io.cpp +++ b/src/colvarproxy_io.cpp @@ -134,7 +134,9 @@ int colvarproxy_io::rename_file(char const *filename, char const *newfilename) int error_code = COLVARS_OK; #if defined(_WIN32) && !defined(__CYGWIN__) // On straight Windows, must remove the destination before renaming it - error_code |= remove_file(newfilename); + if (_access(newfilename, 00) == 0) { + error_code |= remove_file(newfilename); + } #endif int rename_exit_code = 0; while ((rename_exit_code = std::rename(filename, newfilename)) != 0) { diff --git a/src/colvarproxy_io.h b/src/colvarproxy_io.h index 68f8482bc..726f915c9 100644 --- a/src/colvarproxy_io.h +++ b/src/colvarproxy_io.h @@ -10,9 +10,10 @@ #ifndef COLVARPROXY_IO_H #define COLVARPROXY_IO_H +#include +#include #include #include -#include /// Methods for data input/output diff --git a/src/colvarproxy_tcl.cpp b/src/colvarproxy_tcl.cpp index 5bf97a0d9..fa06b7a3c 100644 --- a/src/colvarproxy_tcl.cpp +++ b/src/colvarproxy_tcl.cpp @@ -83,7 +83,7 @@ int colvarproxy_tcl::tcl_run_file(std::string const &fileName) Tcl_Interp *const interp = get_tcl_interp(); int err = Tcl_EvalFile(interp, fileName.c_str()); if (err != TCL_OK) { - cvm::log("Error while executing Tcl script file" + fileName + ":\n"); + cvm::log("Error while executing Tcl script file \"" + fileName + "\":\n"); cvm::error(Tcl_GetStringResult(interp)); return COLVARS_ERROR; } diff --git a/src/colvarproxy_volmaps.cpp b/src/colvarproxy_volmaps.cpp index 6c1f11e32..3d02d8085 100644 --- a/src/colvarproxy_volmaps.cpp +++ b/src/colvarproxy_volmaps.cpp @@ -21,7 +21,7 @@ colvarproxy_volmaps::colvarproxy_volmaps() colvarproxy_volmaps::~colvarproxy_volmaps() {} -int colvarproxy_volmaps::volmaps_available() +int colvarproxy_volmaps::check_volmaps_available() { return COLVARS_NOT_IMPLEMENTED; } diff --git a/src/colvarproxy_volmaps.h b/src/colvarproxy_volmaps.h index f8c9ba853..6e1ffcc7c 100644 --- a/src/colvarproxy_volmaps.h +++ b/src/colvarproxy_volmaps.h @@ -18,8 +18,8 @@ class colvarproxy_volmaps { /// Clear volumetric map data int reset(); - /// \brief Whether this implementation has capability to use volumetric maps - virtual int volmaps_available(); + /// Test whether this implementation can use volumetric maps as CVs + virtual int check_volmaps_available(); /// Create a slot for a volumetric map not requested yet int add_volmap_slot(int volmap_id); diff --git a/src/colvars_version.h b/src/colvars_version.h index ea2858bed..d9ce48e8e 100644 --- a/src/colvars_version.h +++ b/src/colvars_version.h @@ -1,3 +1,3 @@ #ifndef COLVARS_VERSION -#define COLVARS_VERSION "2023-11-15" +#define COLVARS_VERSION "2023-12-05" #endif diff --git a/src/colvarscript.cpp b/src/colvarscript.cpp index 0a04dd682..085319bd4 100644 --- a/src/colvarscript.cpp +++ b/src/colvarscript.cpp @@ -7,8 +7,6 @@ // If you wish to distribute your changes, please submit them to the // Colvars repository at GitHub. -#include -#include #include #include "colvarproxy.h" @@ -769,7 +767,7 @@ extern "C" int tcl_run_colvarscript_command(ClientData /* clientData */, int colvarscript::set_result_text_from_str(std::string const &x_str, unsigned char *obj) { if (obj) { - strcpy(reinterpret_cast(obj), x_str.c_str()); + std::memcpy(reinterpret_cast(obj), x_str.c_str(), x_str.size()); } else { set_result_str(x_str); } diff --git a/src/colvarscript.h b/src/colvarscript.h index 540f56b65..229fe0ff3 100644 --- a/src/colvarscript.h +++ b/src/colvarscript.h @@ -16,7 +16,6 @@ #include "colvarmodule.h" #include "colvarvalue.h" -#include "colvarbias.h" #include "colvarproxy.h" @@ -25,6 +24,8 @@ #define COLVARSCRIPT_OK 0 +class colvardeps; + class colvarscript { private: diff --git a/src/colvarscript_commands.cpp b/src/colvarscript_commands.cpp index c0a28825b..5db3b96f0 100644 --- a/src/colvarscript_commands.cpp +++ b/src/colvarscript_commands.cpp @@ -8,9 +8,9 @@ // Colvars repository at GitHub. #include -#include -#include +#include "colvar.h" +#include "colvarbias.h" #include "colvarproxy.h" #include "colvardeps.h" #include "colvarscript.h" diff --git a/src/colvarscript_commands_bias.cpp b/src/colvarscript_commands_bias.cpp index 2a94efb07..0efab64a5 100644 --- a/src/colvarscript_commands_bias.cpp +++ b/src/colvarscript_commands_bias.cpp @@ -9,11 +9,9 @@ #include -#include -#include -#include #include "colvarproxy.h" +#include "colvarbias.h" #include "colvardeps.h" #include "colvarscript.h" #include "colvarscript_commands.h" diff --git a/src/colvarscript_commands_colvar.cpp b/src/colvarscript_commands_colvar.cpp index da1f74d11..0d03baaa8 100644 --- a/src/colvarscript_commands_colvar.cpp +++ b/src/colvarscript_commands_colvar.cpp @@ -11,8 +11,8 @@ #include #include #include -#include +#include "colvar.h" #include "colvarproxy.h" #include "colvardeps.h" #include "colvarscript.h" diff --git a/src/colvartypes.cpp b/src/colvartypes.cpp index b75bef8ea..f51791d01 100644 --- a/src/colvartypes.cpp +++ b/src/colvartypes.cpp @@ -7,12 +7,8 @@ // If you wish to distribute your changes, please submit them to the // Colvars repository at GitHub. -#include -#include - #include "colvarmodule.h" #include "colvartypes.h" -#include "colvarparse.h" #include "colvaratoms.h" #include "colvar_rotation_derivative.h" diff --git a/src/colvarvalue.cpp b/src/colvarvalue.cpp index 64436db98..3b8077d2e 100644 --- a/src/colvarvalue.cpp +++ b/src/colvarvalue.cpp @@ -8,8 +8,6 @@ // Colvars repository at GitHub. #include -#include -#include #include "colvarmodule.h" #include "colvarvalue.h" diff --git a/src/colvarvalue.h b/src/colvarvalue.h index 5670906cd..e8a6a849d 100644 --- a/src/colvarvalue.h +++ b/src/colvarvalue.h @@ -10,6 +10,8 @@ #ifndef COLVARVALUE_H #define COLVARVALUE_H +#include + #include "colvarmodule.h" #include "colvartypes.h" diff --git a/update-colvars-code.sh b/update-colvars-code.sh index 5dd72a6a3..d479406d6 100755 --- a/update-colvars-code.sh +++ b/update-colvars-code.sh @@ -335,6 +335,10 @@ then condcopy "${src}" "${target}/src/COLVARS/${tgt}" done + if [ -f ${source}/lammps/COLVARS.cmake.diff ] ; then + patch -p1 -N -d ${target} < ${source}/lammps/COLVARS.cmake.diff + fi + downloaded_pdf=0 # Copy PDF of the user manual if [ ! -f ${source}/doc/colvars-refman-lammps.pdf ] ; then @@ -540,8 +544,8 @@ then echo "" if [ -d ${target_folder} ] then - echo "Your ${target} source tree seems to have already been patched." - echo "Update with the last Colvars source." + echo "${target} source tree seems to have already been patched." + echo "Updating to the current Colvars sources." else mkdir ${target_folder} fi @@ -554,7 +558,7 @@ then condcopy "${src}" "${target_folder}/${tgt}" done else - # Starting from GROMACS 2022, colvar library is in `external` and proxy files are in `src/gromacs/applied_forces/colvarproxy` + # Starting from GROMACS 2022, the Colvars library is under `external` and proxy files are in `src/gromacs/applied_forces/colvarproxy` # Library files for src in ${source}/src/*.h ${source}/src/*.cpp do \ @@ -565,8 +569,8 @@ then target_folder=${target}/src/gromacs/applied_forces/colvars if [ -d ${target_folder} ] then - echo "Your ${target} source tree seems to have already been patched." - echo "Update with the last Colvars source." + echo "${target} source tree seems to have already been patched." + echo "Updating to the current Colvars sources." else mkdir ${target_folder} fi @@ -635,8 +639,8 @@ then echo "" if [ -d ${target_folder} ] then - echo "Your ${target} source tree seems to have already been patched." - echo "Update with the last Colvars source." + echo "${target} source tree seems to have already been patched." + echo "Updating to the current Colvars sources." else mkdir ${target_folder} fi @@ -649,20 +653,18 @@ then done echo "" - # Copy CMake files - for src in ${source}/gromacs/gromacs-mdmodules/cmake/*.cmake - do \ - tgt=$(basename ${src}) - condcopy "${src}" "${target}/cmake/${tgt}" - done - echo "" + # Patch CMake build recipe + if [ -f ${source}/gromacs/gromacs-mdmodules/gmxManageColvars.cmake.diff ] ; then + patch -p1 -N -d ${target} < ${source}/gromacs/gromacs-mdmodules/gmxManageColvars.cmake.diff + fi + echo # Copy MDModules files to the "src/gromacs/applied_forces/colvars" folder target_folder=${target}/src/gromacs/applied_forces/colvars if [ -d ${target_folder} ] then - echo "Your ${target} source tree seems to have already been patched." - echo "Update with the last Colvars source." + echo "${target} source tree seems to have already been patched." + echo "Updating to the current Colvars sources." else mkdir ${target_folder} mkdir -p ${target_folder}/tests/refdata diff --git a/vmd/src/colvarproxy_vmd.C b/vmd/src/colvarproxy_vmd.C index ae6a6e8b3..fba7096d6 100644 --- a/vmd/src/colvarproxy_vmd.C +++ b/vmd/src/colvarproxy_vmd.C @@ -651,6 +651,12 @@ int colvarproxy_vmd::check_atom_id(int atom_number) } +int colvarproxy_vmd::check_atom_name_selections_available() +{ + return COLVARS_OK; +} + + int colvarproxy_vmd::init_atom(int atom_number) { // save time by checking first whether this atom has been requested before @@ -752,6 +758,12 @@ int colvarproxy_vmd::init_atom(cvm::residue_id const &resid, } +int colvarproxy_vmd::check_volmaps_available() +{ + return COLVARS_OK; +} + + int colvarproxy_vmd::init_volmap_by_id(int volmap_id) { for (size_t i = 0; i < volmaps_ids.size(); i++) { diff --git a/vmd/src/colvarproxy_vmd.h b/vmd/src/colvarproxy_vmd.h index 539bc31cb..31f534e68 100644 --- a/vmd/src/colvarproxy_vmd.h +++ b/vmd/src/colvarproxy_vmd.h @@ -91,6 +91,9 @@ class colvarproxy_vmd : public colvarproxy { std::string const &pdb_field, double const pdb_field_value = 0.0); + + virtual int check_atom_name_selections_available(); + virtual int init_atom(int atom_number); virtual int check_atom_id(int atom_number); @@ -103,6 +106,8 @@ class colvarproxy_vmd : public colvarproxy { std::string const &atom_name, std::string const &segment_id); + virtual int check_volmaps_available(); + virtual int init_volmap_by_id(int volmap_id); virtual int check_volmap_by_id(int volmap_id); diff --git a/vmd/src/colvarproxy_vmd_version.h b/vmd/src/colvarproxy_vmd_version.h index b3a6f1e83..21077698c 100644 --- a/vmd/src/colvarproxy_vmd_version.h +++ b/vmd/src/colvarproxy_vmd_version.h @@ -1,3 +1,3 @@ #ifndef COLVARPROXY_VERSION -#define COLVARPROXY_VERSION "2023-11-15" +#define COLVARPROXY_VERSION "2023-12-05" #endif diff --git a/vmd/tests/interface/002_error_output/AutoDiff/test.colvars.err b/vmd/tests/interface/002_error_output/AutoDiff/test.colvars.err index 3a9e80273..f5ff7b389 100644 --- a/vmd/tests/interface/002_error_output/AutoDiff/test.colvars.err +++ b/vmd/tests/interface/002_error_output/AutoDiff/test.colvars.err @@ -6,13 +6,11 @@ Command "cv" returned the following errors: Error: atom group "group1" has no definition. Error: atom group "group2" is required. Error: in setting up component "distance". - Error: no valid components were provided for this collective variable. Error parsing configuration string Command "cv" returned the following errors: Error: invalid atom number specified, 1000 Error: in definition of atom group "atoms". Error: in setting up component "rmsd". - Error: no valid components were provided for this collective variable. Error parsing configuration string