Skip to content

Commit

Permalink
Add Colvars module version 2024-03-12
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomofiorin committed Apr 25, 2024
1 parent 922e31f commit 116f406
Show file tree
Hide file tree
Showing 122 changed files with 51,759 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,10 @@ include(gmxManageLmfit)

include(gmxManageMuparser)

include(gmxManageColvars)

include(gmxManageLepton)

##################################################
# Process SIMD instruction settings
##################################################
Expand Down
6 changes: 6 additions & 0 deletions api/legacy/include/gromacs/mdtypes/inputrec.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ struct gmx_enfrot;
struct gmx_enfrotgrp;
struct pull_params_t;

class colvarproxy_gromacs;

namespace gmx
{
class Awh;
Expand Down Expand Up @@ -587,6 +589,10 @@ struct t_inputrec // NOLINT (clang-analyzer-optin.performance.Padding)

//! KVT for storing simulation parameters that are not part of the mdp file.
std::unique_ptr<gmx::KeyValueTreeObject> internalParameters;

/* COLVARS */
bool bColvars = false; /* Do we do colvars calculations ? */
colvarproxy_gromacs *colvars_proxy = nullptr; /* The object for the colvars calculations */
};

int tcouple_min_integration_steps(TemperatureCoupling etc);
Expand Down
67 changes: 67 additions & 0 deletions cmake/gmxManageColvars.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#
# 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 $<$<CXX_COMPILER_ID:MSVC>:/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_OBJECTS:colvars_objlib>)
target_include_directories(colvars SYSTEM INTERFACE $<BUILD_INTERFACE:${COLVARS_DIR}>)

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.
add_library(colvars INTERFACE)
endif()
endfunction()
36 changes: 36 additions & 0 deletions cmake/gmxManageLepton.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Add Lepton library, which is developed and distributed as part of OpenMM:
# https://github.com/openmm/openmm

gmx_option_multichoice(GMX_USE_LEPTON
"Build the Lepton library interfaced with GROMACS"
INTERNAL
INTERNAL NONE)
mark_as_advanced(GMX_USE_LEPTON)

function(gmx_manage_lepton)
if(GMX_USE_LEPTON STREQUAL "INTERNAL")

set(LEPTON_DIR "${CMAKE_SOURCE_DIR}/src/external/lepton")

file(GLOB LEPTON_SOURCES ${LEPTON_DIR}/src/*.cpp)
add_library(lepton_objlib OBJECT ${LEPTON_SOURCES})
target_include_directories(lepton_objlib PRIVATE ${LEPTON_DIR}/include)
# TODO support building as shared library
target_compile_options(lepton_objlib PRIVATE -DLEPTON_BUILDING_STATIC_LIBRARY)
set_target_properties(lepton_objlib PROPERTIES POSITION_INDEPENDENT_CODE ON)

add_library(lepton INTERFACE)
target_sources(lepton INTERFACE $<TARGET_OBJECTS:lepton_objlib>)
target_include_directories(lepton SYSTEM INTERFACE $<BUILD_INTERFACE:${LEPTON_DIR}>)

# Set flags so that Colvars can leverage Lepton functionality
# TODO handle the case when Lepton is built without Colvars?
target_include_directories(colvars_objlib PRIVATE ${LEPTON_DIR}/include)
target_compile_options(colvars_objlib PRIVATE -DLEPTON -DLEPTON_USE_STATIC_LIBRARIES)

else()

# Dummy target
add_library(lepton INTERFACE)
endif()
endfunction()
2 changes: 1 addition & 1 deletion cmake/gmxVersionInfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ set(REGRESSIONTEST_MD5SUM "e88c8ba9592d01d5cfe95f5d3b9836f9" CACHE INTERNAL "MD5
# If you are distributing a patch to GROMACS, then this change would
# be great as part of your patch. Otherwise for personal use, you can
# also just set a CMake cache variable.
set(GMX_VERSION_STRING_OF_FORK "" CACHE INTERNAL
set(GMX_VERSION_STRING_OF_FORK "Colvars-2024-03-12" CACHE INTERNAL
"Version string for forks of GROMACS to set to describe themselves")
mark_as_advanced(GMX_VERSION_STRING_OF_FORK)
if (GMX_VERSION_STRING_OF_FORK)
Expand Down
Loading

0 comments on commit 116f406

Please sign in to comment.