Skip to content

Commit

Permalink
Merge branch 'python' into breaking_bonds
Browse files Browse the repository at this point in the history
  • Loading branch information
jngrad committed Feb 24, 2022
2 parents 57b0965 + d3bc970 commit 988981f
Show file tree
Hide file tree
Showing 334 changed files with 4,796 additions and 3,388 deletions.
6 changes: 4 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Checks: |
-clang-analyzer-optin.mpi.MPI-Checker,
-clang-analyzer-security.FloatLoopCounter,
bugprone-*,
-bugprone-easily-swappable-parameters,
-bugprone-implicit-widening-of-multiplication-result,
clang-analyzer-alpha.*,
modernize-deprecated-headers,
modernize-make-shared,
Expand Down Expand Up @@ -71,15 +73,15 @@ CheckOptions:
- key: modernize-make-shared.IgnoreMacros
value: '1'
- key: modernize-make-shared.IncludeStyle
value: '0'
value: 'llvm'
- key: modernize-make-shared.MakeSmartPtrFunction
value: 'std::make_shared'
- key: modernize-make-shared.MakeSmartPtrFunctionHeader
value: memory
- key: modernize-make-unique.IgnoreMacros
value: '1'
- key: modernize-make-unique.IncludeStyle
value: '0'
value: 'llvm'
- key: modernize-make-unique.MakeSmartPtrFunction
value: 'std::make_unique'
- key: modernize-make-unique.MakeSmartPtrFunctionHeader
Expand Down
9 changes: 9 additions & 0 deletions .cppcheck
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// clang-format off
constParameter
unusedFunction
missingIncludeSystem
noConstructor
noExplicitConstructor
redundantAssignment
uselessAssignmentPtrArg
preprocessorErrorDirective
2 changes: 1 addition & 1 deletion .github/actions/build_and_check/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ runs:
pip3 install numpy cython h5py scipy
shell: bash
- run: |
export myconfig=maxset with_cuda=false test_timeout=600 with_asan=${{ inputs.asan }} with_ubsan=${{ inputs.ubsan }} check_skip_long=${{ inputs.check_skip_long }}
export myconfig=maxset with_cuda=false test_timeout=800 with_asan=${{ inputs.asan }} with_ubsan=${{ inputs.ubsan }} check_skip_long=${{ inputs.check_skip_long }}
bash maintainer/CI/build_cmake.sh
shell: bash
# This is a workaround for the unfortunate interaction of MacOS and OpenMPI 4
Expand Down
16 changes: 8 additions & 8 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
image: docker.pkg.github.com/espressomd/docker/ubuntu-20.04:254edd4a9c6e4d7b557be73158e400f5794e4f99
image: ghcr.io/espressomd/docker/ubuntu-20.04:254edd4a9c6e4d7b557be73158e400f5794e4f99

stages:
- prepare
Expand Down Expand Up @@ -127,7 +127,7 @@ no_rotation:
ubuntu:wo-dependencies:
<<: *global_job_definition
stage: build
image: docker.pkg.github.com/espressomd/docker/ubuntu-wo-dependencies:9ef2166b82d4c0eb258d17f5ec29f7bc39991f5d
image: ghcr.io/espressomd/docker/ubuntu-wo-dependencies:9ef2166b82d4c0eb258d17f5ec29f7bc39991f5d
variables:
myconfig: 'maxset'
with_cuda: 'false'
Expand All @@ -145,7 +145,7 @@ ubuntu:wo-dependencies:
debian:10:
<<: *global_job_definition
stage: build
image: docker.pkg.github.com/espressomd/docker/debian:9ef2166b82d4c0eb258d17f5ec29f7bc39991f5d
image: ghcr.io/espressomd/docker/debian:9ef2166b82d4c0eb258d17f5ec29f7bc39991f5d
variables:
with_cuda: 'false'
myconfig: 'maxset'
Expand All @@ -160,7 +160,7 @@ debian:10:
fedora:34:
<<: *global_job_definition
stage: build
image: docker.pkg.github.com/espressomd/docker/fedora:9ef2166b82d4c0eb258d17f5ec29f7bc39991f5d
image: ghcr.io/espressomd/docker/fedora:9ef2166b82d4c0eb258d17f5ec29f7bc39991f5d
variables:
with_cuda: 'false'
myconfig: 'maxset'
Expand Down Expand Up @@ -201,7 +201,7 @@ clang-sanitizer:
fast_math:
<<: *global_job_definition
stage: build
image: docker.pkg.github.com/espressomd/docker/cuda:9ef2166b82d4c0eb258d17f5ec29f7bc39991f5d
image: ghcr.io/espressomd/docker/cuda:9ef2166b82d4c0eb258d17f5ec29f7bc39991f5d
variables:
CC: 'gcc-9'
CXX: 'g++-9'
Expand All @@ -222,7 +222,7 @@ fast_math:
cuda11-maxset:
<<: *global_job_definition
stage: build
image: docker.pkg.github.com/espressomd/docker/cuda:9ef2166b82d4c0eb258d17f5ec29f7bc39991f5d
image: ghcr.io/espressomd/docker/cuda:9ef2166b82d4c0eb258d17f5ec29f7bc39991f5d
variables:
CC: 'gcc-9'
CXX: 'g++-9'
Expand Down Expand Up @@ -488,7 +488,7 @@ run_doxygen:
- docker
- linux

check_cuda_maxset_no_gpu:
maxset_no_gpu:
<<: *global_job_definition
stage: additional_checks
when: on_success
Expand All @@ -502,7 +502,7 @@ check_cuda_maxset_no_gpu:
- docker
- linux

check_with_odd_no_of_processors:
maxset_3_cores:
<<: *global_job_definition
stage: additional_checks
when: on_success
Expand Down
55 changes: 49 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ option(WITH_STOKESIAN_DYNAMICS "Build with Stokesian Dynamics" OFF)
option(WITH_BENCHMARKS "Enable benchmarks" OFF)
option(WITH_VALGRIND_INSTRUMENTATION
"Build with valgrind instrumentation markers" OFF)
option(WITH_CPPCHECK "Run Cppcheck during compilation" OFF)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
option(WITH_CLANG_TIDY "Run Clang-Tidy during compilation" OFF)
endif()
Expand All @@ -97,6 +98,7 @@ endif()
option(WARNINGS_ARE_ERRORS "Treat warnings as errors during compilation" OFF)
option(WITH_CCACHE "Use ccache compiler invocation." OFF)
option(WITH_PROFILER "Enable profiler annotations." OFF)
option(INSIDE_DOCKER "Enable when running inside Docker." OFF)
set(TEST_TIMEOUT "300" CACHE STRING
"Timeout in seconds for each testsuite test")

Expand Down Expand Up @@ -126,18 +128,22 @@ include(MyConfig)

include(CheckCXXSourceCompiles)

set(__PRETTYFUNC__ __func__)
foreach(func_name __PRETTY_FUNCTION__ __FUNCTION__)
# cross-platform macro to print the function name in error messages
set(PRETTY_FUNCTION_EXTENSION __func__)

# search for a supported compiler extension that prints the function name as
# well as its list of arguments, return type and namespace
foreach(func_name __PRETTY_FUNCTION__ __FUNCSIG__ __FUNCTION__)
check_cxx_source_compiles(
"
#include <string>
int main() { std::string(${func_name}); }
" result${func_name})
if(result${func_name})
set(__PRETTYFUNC__ ${func_name})
set(PRETTY_FUNCTION_EXTENSION ${func_name})
break()
endif(result${func_name})
endforeach(func_name __PRETTY_FUNCTION__ __FUNCTION__)
endforeach()

#
# Libraries
Expand Down Expand Up @@ -270,6 +276,32 @@ endif(WITH_VALGRIND_INSTRUMENTATION)
#

find_package(MPI 3.0 REQUIRED)
find_package(MpiexecBackend)

# OpenMPI checks the number of processes against the number of CPUs
if("${MPIEXEC_BACKEND_NAME}" STREQUAL "OpenMPI" AND "${MPIEXEC_BACKEND_VERSION}"
VERSION_GREATER_EQUAL 2.0.0)
set(MPIEXEC_OVERSUBSCRIBE "-oversubscribe")
else()
set(MPIEXEC_OVERSUBSCRIBE "")
endif()

# OpenMPI cannot run two jobs in parallel in a Docker container, because the
# same base folder is used to store the process ids of multiple jobs. Since the
# base folder is deleted upon completion of a job, other jobs will fail when
# attempting to create subdirectories in the base folder.
# https://github.com/open-mpi/ompi/issues/8510
if("${MPIEXEC_BACKEND_NAME}" STREQUAL "OpenMPI" AND INSIDE_DOCKER)
cmake_host_system_information(RESULT hostname QUERY HOSTNAME)
function(set_mpiexec_tmpdir)
set(MPIEXEC_TMPDIR --mca orte_tmpdir_base
"/tmp/ompi.${hostname}.$ENV{USER}.${ARGV0}" PARENT_SCOPE)
endfunction()
else()
function(set_mpiexec_tmpdir)
set(MPIEXEC_TMPDIR "" PARENT_SCOPE)
endfunction()
endif()

#
# Boost
Expand Down Expand Up @@ -322,9 +354,7 @@ target_compile_options(
# disable warnings from -Wextra
-Wno-sign-compare
-Wno-unused-function
-Wno-unused-variable
-Wno-unused-parameter
-Wno-missing-braces
$<$<CXX_COMPILER_ID:GNU>:-Wno-clobbered>
$<$<CXX_COMPILER_ID:Intel>:-wd592>)

Expand Down Expand Up @@ -421,6 +451,19 @@ if(WITH_CLANG_TIDY)
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE};--extra-arg=--cuda-host-only")
endif()

if(WITH_CPPCHECK)
find_program(CMAKE_CXX_CPPCHECK NAMES cppcheck)
if(NOT CMAKE_CXX_CPPCHECK)
message(FATAL_ERROR "Could not find the program cppcheck.")
endif()
list(APPEND CMAKE_CXX_CPPCHECK "--enable=all"
"--std=c++${CMAKE_CXX_STANDARD}" "--quiet" "--inline-suppr"
"--suppressions-list=${CMAKE_CURRENT_SOURCE_DIR}/.cppcheck")
if(WARNINGS_ARE_ERRORS)
list(APPEND CMAKE_CXX_CPPCHECK "--error-exitcode=2")
endif()
endif()

#
# Testing
#
Expand Down
48 changes: 48 additions & 0 deletions cmake/FindMpiexecBackend.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#
# Copyright (C) 2022 The ESPResSo project
#
# This file is part of ESPResSo.
#
# ESPResSo is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ESPResSo 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

# Find the MPI backend.
#
# This code sets the following variables:
#
# MPIEXEC_BACKEND_NAME MPIEXEC_BACKEND_VERSION

set(MPIEXEC_BACKEND_NAME "unknown")
set(MPIEXEC_BACKEND_VERSION 0.0.0)

execute_process(
COMMAND ${MPIEXEC} --version RESULT_VARIABLE mpi_version_result
OUTPUT_VARIABLE mpi_version_output ERROR_VARIABLE mpi_version_output)
if(mpi_version_result EQUAL 0)
if(mpi_version_output MATCHES "Intel\\(R\\) MPI Library")
set(MPIEXEC_BACKEND_NAME "Intel")
string(REGEX REPLACE ".*Build ([0-9]+).*" "\\1" MPIEXEC_BACKEND_VERSION ${mpi_version_output})
endif()
if(mpi_version_output MATCHES "HYDRA")
set(MPIEXEC_BACKEND_NAME "MPICH")
string(REGEX REPLACE ".*Version: +([0-9\\.]+).*" "\\1" MPIEXEC_BACKEND_VERSION ${mpi_version_output})
endif()
if(mpi_version_output MATCHES "\\(Open(RTE| MPI)\\)")
set(MPIEXEC_BACKEND_NAME "OpenMPI")
string(REGEX REPLACE ".*\\(Open(RTE| MPI)\\) ([0-9\\.]+).*" "\\2" MPIEXEC_BACKEND_VERSION ${mpi_version_output})
endif()
endif()

include( FindPackageHandleStandardArgs )
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MpiexecBackend REQUIRED_VARS MPIEXEC)
4 changes: 2 additions & 2 deletions cmake/FindPythonHeaders.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
# find the Python C++ headers
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c
"import distutils.sysconfig as cg; print(cg.get_python_inc())"
"import sysconfig; print(sysconfig.get_path('include'))"
OUTPUT_VARIABLE PYTHON_INCLUDE_DIRS OUTPUT_STRIP_TRAILING_WHITESPACE)
# find Python installation directory
if(NOT PYTHON_INSTDIR)
execute_process(
COMMAND
${PYTHON_EXECUTABLE} -c
"import distutils.sysconfig as cg; print(cg.get_python_lib(prefix='${CMAKE_INSTALL_PREFIX}', plat_specific=True, standard_lib=False).replace('${CMAKE_INSTALL_PREFIX}/', '', 1))"
"import sysconfig; print(sysconfig.get_path('purelib', vars={'base': ''}).lstrip('/'))"
OUTPUT_VARIABLE PYTHON_INSTDIR OUTPUT_STRIP_TRAILING_WHITESPACE)
endif(NOT PYTHON_INSTDIR)

Expand Down
10 changes: 6 additions & 4 deletions cmake/cmake_config.cmakein
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@

#define PACKAGE_NAME "${PROJECT_NAME}"

#define __PRETTYFUNC__ @__PRETTYFUNC__@



/**
* @brief Compiler-specific macro containing the demangled name
* of the function in the current scope. When the current compiler
* doesn't provide such an extension, defaults to @c __func__.
*/
#define PRETTY_FUNCTION_EXTENSION @PRETTY_FUNCTION_EXTENSION@
19 changes: 3 additions & 16 deletions cmake/unit_test.cmake
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
if(EXISTS ${MPIEXEC})
# OpenMPI 2.0 and higher checks the number of processes against the number of
# CPUs
execute_process(
COMMAND ${MPIEXEC} --version RESULT_VARIABLE mpi_version_result
OUTPUT_VARIABLE mpi_version_output ERROR_VARIABLE mpi_version_output)
if(mpi_version_result EQUAL 0 AND mpi_version_output MATCHES
"\\(Open(RTE| MPI)\\) ([2-9]\\.|1[0-9])")
set(MPIEXEC_OVERSUBSCRIBE "-oversubscribe")
else()
set(MPIEXEC_OVERSUBSCRIBE "")
endif()
endif()

# unit_test function
function(UNIT_TEST)
cmake_parse_arguments(TEST "" "NAME;NUM_PROC" "SRC;DEPENDS" ${ARGN})
Expand All @@ -30,10 +16,11 @@ function(UNIT_TEST)
if(${TEST_NUM_PROC} GREATER ${TEST_NP})
set(TEST_NUM_PROC ${TEST_NP})
endif()

set_mpiexec_tmpdir("${TEST_NAME}")
add_test(${TEST_NAME} ${MPIEXEC} ${MPIEXEC_OVERSUBSCRIBE}
${MPIEXEC_NUMPROC_FLAG} ${TEST_NUM_PROC} ${MPIEXEC_PREFLAGS}
${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME} ${MPIEXEC_POSTFLAGS})
${MPIEXEC_TMPDIR} ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}
${MPIEXEC_POSTFLAGS})
else()
add_test(${TEST_NAME} ${TEST_NAME})
endif()
Expand Down
9 changes: 5 additions & 4 deletions doc/sphinx/advanced_methods.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,7 @@ In the *forward* reaction, the appropriate number of reactants (given by
:math:`\nu_i`) is removed from the system, and the concomitant number of
products is inserted into the system. In the *backward* reaction,
reactants and products exchange their roles. The acceptance probability
:math:`P^{\xi}` for move from state :math:`o` to :math:`n` reaction
:math:`P^{\xi}` for a move from state :math:`o` to :math:`n` in the reaction
ensemble is given by the criterion :cite:`smith94c`

.. math::
Expand All @@ -1718,10 +1718,11 @@ ensemble is given by the criterion :cite:`smith94c`
where :math:`\Delta E=E_\mathrm{new}-E_\mathrm{old}` is the change in potential energy,
:math:`V` is the simulation box volume,
and :math:`\beta=1/k_\mathrm{B}T`.
The extent of reaction, :math:`\xi=1` for the forward, and
:math:`\beta=1/k_\mathrm{B}T` is the Boltzmann factor, and
:math:`\xi` is the extent of reaction, with :math:`\xi=1` for the forward and
:math:`\xi=-1` for the backward direction.
The parameter :math:`\Gamma` proportional to the reaction constant. It is defined as

:math:`\Gamma` is proportional to the reaction constant. It is defined as

.. math::
Expand Down
4 changes: 2 additions & 2 deletions doc/sphinx/inter_bonded.rst
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,13 @@ A virtual bond can be instantiated via
:class:`espressomd.interactions.Virtual`::

import espressomd.interactions
tab = espressomd.interactions.Virtual()
vb = espressomd.interactions.Virtual()


This creates a virtual bond type identifier for a pair bond
without associated potential or force. It can be used to specify topologies
and for some analysis that rely on bonds, or for bonds that should be
displayed in the visualization.
displayed in the visualizer.



Expand Down
Loading

0 comments on commit 988981f

Please sign in to comment.