Skip to content

Commit

Permalink
Merge branch 'python' into nonbonded_refactor_new
Browse files Browse the repository at this point in the history
  • Loading branch information
jngrad committed Sep 20, 2022
2 parents 2d279f5 + 9a0bff0 commit 8840065
Show file tree
Hide file tree
Showing 309 changed files with 866 additions and 763 deletions.
6 changes: 1 addition & 5 deletions .github/actions/build_and_check/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ inputs:
description: 'Whether to build with undefined behavior sanitizer'
required: true
default: 'false'
check_skip_long: # id of input
description: 'Whether to skip long python tests'
required: true
default: 'false'
runs:
using: "composite"
steps:
Expand All @@ -22,7 +18,7 @@ runs:
pip3 install numpy cython h5py scipy
shell: bash
- run: |
export myconfig=maxset with_cuda=false test_timeout=800 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=true
bash maintainer/CI/build_cmake.sh
shell: bash
# This is a workaround for the unfortunate interaction of MacOS and OpenMPI 4
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/push_pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ jobs:
with:
asan: false
ubsan: false
check_skip_long: false

sanitizer_check:
runs-on: macos-latest
Expand All @@ -39,7 +38,6 @@ jobs:
with:
asan: true
ubsan: true
check_skip_long: true
- name: Setting job link variable
if: ${{ failure() }}
run: |
Expand Down
4 changes: 2 additions & 2 deletions cmake/MyConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ if(NOT MYCONFIG_FILE)
endif()

configure_file(${MYCONFIG_FILE}
${CMAKE_BINARY_DIR}/src/config/myconfig-final.hpp COPYONLY)
${CMAKE_BINARY_DIR}/src/config/include/config/myconfig-final.hpp COPYONLY)
add_custom_target(myconfig
DEPENDS ${CMAKE_BINARY_DIR}/src/config/myconfig-final.hpp)
DEPENDS ${CMAKE_BINARY_DIR}/src/config/include/config/myconfig-final.hpp)
message(STATUS "Config file: ${MYCONFIG_FILE}")
# Clear variable, otherwise cmake must be run by hand to detect myconfig.
# Also prevents find_file from skipping when variable is already set.
Expand Down
8 changes: 5 additions & 3 deletions cmake/version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ if(GIT_EXECUTABLE)

endif(GIT_EXECUTABLE)

configure_file(${PROJECT_SOURCE_DIR}/src/config/version.hpp.in version.hpp.tmp)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different version.hpp.tmp
version.hpp)
configure_file(${PROJECT_SOURCE_DIR}/src/config/include/config/version.hpp.in
${CMAKE_BINARY_DIR}/include/config/version.hpp.tmp)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_BINARY_DIR}/include/config/version.hpp.tmp
${CMAKE_BINARY_DIR}/include/config/version.hpp)
9 changes: 5 additions & 4 deletions doc/sphinx/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,23 @@ CUDA SDK to make use of GPU computation:
sudo apt install nvidia-cuda-toolkit
Later in the installation instructions, you will see CMake commands of the
form ``cmake ..`` with optional arguments, such as ``cmake .. -D WITH_CUDA=ON``
to activate CUDA. These commands may need to be adapted depending on which
operating system and CUDA version you are using.

On Ubuntu 22.04, the default GCC compiler is too recent for nvcc and will fail
to compile sources that rely on ``std::function``. You can either use GCC 10:

.. code-block:: bash
CC=gcc-10 CXX=g++-10 cmake .. -D WITH_CUDA=ON
make -j
or alternatively install Clang 12 as a replacement for nvcc and GCC:

.. code-block:: bash
CC=clang-12 CXX=clang++-12 cmake .. -D WITH_CUDA=ON -D WITH_CUDA_COMPILER=clang
make -j
On Ubuntu 20.04, the default GCC compiler is also too recent for nvcc and will
generate compiler errors. You can either install an older version of GCC and
Expand All @@ -133,15 +136,13 @@ specific one by providing custom paths to the compiler and toolkit:
CUDACXX=/usr/local/cuda-11.0/bin/nvcc \
cmake .. -D WITH_CUDA=ON -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-11.0
make -j
Alternatively for Clang:

.. code-block:: bash
CC=clang-12 CXX=clang++-12 CUDACXX=clang++-12 CUDAToolkit_ROOT=/usr/local/cuda-11.0 \
cmake .. -DWITH_CUDA=ON -DWITH_CUDA_COMPILER=clang -DCMAKE_CXX_FLAGS=--cuda-path=/usr/local/cuda-11.0
make -j
.. _Requirements for building the documentation:

Expand Down
15 changes: 0 additions & 15 deletions doc/sphinx/inter_non-bonded.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,13 @@ Tabulated interaction
Feature ``TABULATED`` required.
The interface for tabulated interactions are implemented in the
:class:`~espressomd.interactions.TabulatedNonBonded` class. They can be configured
via the following syntax::

system.non_bonded_inter[type1, type2].tabulated.set_params(
min='min', max='max', energy='energy', force='force')


This defines an interaction between particles of the types ``type1`` and
``type2`` according to an arbitrary tabulated pair potential by linear interpolation.
``force`` specifies the tabulated forces and ``energy`` the energies as a function of the
Expand Down Expand Up @@ -664,19 +662,6 @@ and involved types.

The samples folder contains the script :file:`/samples/drude_bmimpf6.py` with a
fully polarizable, coarse grained ionic liquid where this approach is applied.
To use the script, compile espresso with the following features:

.. code-block:: c++

#define EXTERNAL_FORCES
#define MASS
#define THERMOSTAT_PER_PARTICLE
#define ROTATION
#define ROTATIONAL_INERTIA
#define ELECTROSTATICS
#define VIRTUAL_SITES_RELATIVE
#define LENNARD_JONES
#define THOLE

.. _Anisotropic non-bonded interactions:

Expand Down
10 changes: 5 additions & 5 deletions doc/tutorials/constant_pH/constant_pH.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"source": [
"### The constant pH method\n",
"\n",
"The constant $\\mathrm{pH}$ method <a href='#[Reed1992]'>[Reed1992]</a> has been designed to simulate an acid-base ionization reaction at a given $\\mathrm{pH}$. It assumes that $\\mathrm{pH}$ in the system is constant, independent of the ionization degree. In a real solution, the ionization reaction generates an $\\mathrm{H^+}$ ion, that immediately reacts with the the buffer that has been added to the solution in order to keep the $\\mathrm{pH}$ (approximately) constant. Effectively, the net reaction that can be written as \n",
"The constant $\\mathrm{pH}$ method <a href='#[Reed1992]'>[Reed1992]</a> has been designed to simulate an acid-base ionization reaction at a given $\\mathrm{pH}$. It assumes that $\\mathrm{pH}$ in the system is constant, independent of the ionization degree. In a real solution, the ionization reaction generates an $\\mathrm{H^+}$ ion, that immediately reacts with the buffer that has been added to the solution in order to keep the $\\mathrm{pH}$ (approximately) constant. Effectively, the net reaction can be written as \n",
"$$\\mathrm{HA} \\Leftrightarrow \\mathrm{A}^- + \\mathrm{B}^+ ,$$\n",
"where we use $\\mathrm{B}^+$ to denote a generic neutralizing counterion that could be either the $\\mathrm{H}^+$ ion, or another cation that is generated by the reaction of the $\\mathrm{H}^+$ ion with the buffer.\n",
"In the literature, this counterion is often denoted as $\\mathrm{H^+}$, however, this may lead to confusion because then the actual number of $\\mathrm{H^+}$ ions in the box does not correspond to their concentration implied by the fixed value of the $\\mathrm{pH}$.\n",
Expand Down Expand Up @@ -240,7 +240,7 @@
"### Set the key physical parameters that uniquely define the system\n",
"\n",
"We want to simulate a solution of polyelectrolyte chains composed of weak acidic groups. \n",
"The chains are is characterized by the number of acidic groups, their $\\mathrm{p}K_{\\mathrm{A}}$ and their concentration in the solution.\n",
"The chains are characterized by the number of acidic groups, their $\\mathrm{p}K_{\\mathrm{A}}$ and their concentration in the solution.\n",
"The polyelectrolytes are dissolved in an aqueous solution of NaCl, further characterized by the salt concentration and by the $\\mathrm{pH}$ value.\n",
"\n",
"To specify the system properties, we to define the total number of titratable units `N_ACID`, their concentration `C_ACID` and the salt concentration `C_SALT`. We set the dissociation constant of the acid to $\\mathrm{p}K_\\mathrm{A}=4.88$, that is the acidity constant of propionic acid. The structure of propionic acid resembles the repeating unit of poly(acrylic acid), the most commonly used weak polyacid."
Expand All @@ -256,7 +256,7 @@
"N_ACID = 20\n",
"C_ACID = 1e-3 * ureg.molar\n",
"C_SALT = 2 * C_ACID\n",
"pKa = 4.88 # acidity constant\n",
"pKa = 4.88 # acidity constant\n",
"pKw = 14.0 # autoprotolysis constant of water"
]
},
Expand Down Expand Up @@ -294,7 +294,7 @@
"\n",
"To be able to compare our results to the analytical solutions for ideal systems and to obtain results very quickly, we begin with all non-bonded interactions turned off. In the next runs, we will add the steric repulsion and electrostatic interactions to observe their effect on the ionization.\n",
"\n",
"Because it is an interactive tutorial, we want it to be completed within few minutes. Therefore, we choose the Debye-Hückel potential for electrostatics by default. It produces results that are similar to the full electrostatics calculated by the P3M method but we gain about a factor of 5 in the simulation runtime. In this way, we sacrifice accuracy for speed. Such thing is definitely not recommended for production simulations."
"Because it is an interactive tutorial, we want it to be completed within few minutes. Therefore, we choose the Debye-Hückel potential for electrostatics by default. It produces results that are similar to the full electrostatics calculated by the P3M method but we gain about a factor of 5 in the simulation runtime. In this way, we sacrifice accuracy for speed. It's definitely not recommended for production simulations."
]
},
{
Expand All @@ -321,7 +321,7 @@
"source": [
"#### Set the number of samples to be collected\n",
"\n",
"For error analysis we specify the number of blocks `N_BLOCKS` and the desired number of samples per block `DESIRED_BLOCK_SIZE`. From that we can estimate the total number of statistically independent samples that we want to collect `NUM_SAMPLES`. Note that samples collected in our simulations are not really statistically independent, so the actual number of independent samples is always lower than `NUM_SAMPLES`. \n",
"For the error analysis we specify the number of blocks `N_BLOCKS` and the desired number of samples per block `DESIRED_BLOCK_SIZE`. From that we can estimate the total number of statistically independent samples that we want to collect `NUM_SAMPLES`. Note that samples collected in our simulations are not really statistically independent, so the actual number of independent samples is always lower than `NUM_SAMPLES`. \n",
"Therefore, the actual number of independent samples depends on the properties of the simulated system and needs to be estimated at the end of the simulation.\n",
"We keep the number of samples rather low, so that the tutorial completes fast. If you want to obtain data with a better statistical quality, we encourage you to increase the number of samples."
]
Expand Down
34 changes: 21 additions & 13 deletions src/config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,50 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

configure_file(${CMAKE_SOURCE_DIR}/cmake/cmake_config.cmakein cmake_config.hpp)
add_subdirectory(include/config)
add_subdirectory(src)

configure_file(${CMAKE_SOURCE_DIR}/cmake/cmake_config.cmakein
${CMAKE_CURRENT_BINARY_DIR}/include/config/cmake_config.hpp)

add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/config-features.hpp
${CMAKE_CURRENT_BINARY_DIR}/config-features.cpp
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/config/config-features.hpp
${CMAKE_CURRENT_BINARY_DIR}/src/config-features.cpp
COMMAND
${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gen_featureconfig.py
${CMAKE_CURRENT_SOURCE_DIR}/features.def
${CMAKE_CURRENT_BINARY_DIR}/config-features.hpp
${CMAKE_CURRENT_BINARY_DIR}/config-features.cpp
${CMAKE_CURRENT_BINARY_DIR}/include/config/config-features.hpp
${CMAKE_CURRENT_BINARY_DIR}/src/config-features.cpp
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/features.def
${CMAKE_CURRENT_SOURCE_DIR}/gen_featureconfig.py)
add_custom_target(
generate_config_features
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/config-features.hpp
${CMAKE_CURRENT_BINARY_DIR}/config-features.cpp)
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/include/config/config-features.hpp
${CMAKE_CURRENT_BINARY_DIR}/src/config-features.cpp)

add_custom_target(
check_myconfig
COMMAND
${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/check_myconfig.py
${CMAKE_CXX_COMPILER} ${CMAKE_CURRENT_SOURCE_DIR}/features.def
${CMAKE_CURRENT_BINARY_DIR}/myconfig-final.hpp cmake_config.hpp
${CMAKE_CURRENT_BINARY_DIR}/include/config/myconfig-final.hpp
${CMAKE_CURRENT_BINARY_DIR}/include/config/cmake_config.hpp
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/features.def myconfig)

execute_process(
COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gen_sampleconfig.py
${CMAKE_CURRENT_SOURCE_DIR}/features.def
OUTPUT_FILE ${CMAKE_BINARY_DIR}/myconfig-sample.hpp)

add_library(espresso_config SHARED config-features.cpp)
add_library(espresso_config SHARED src/config-features.cpp)
add_library(espresso::config ALIAS espresso_config)
add_dependencies(espresso_config myconfig check_myconfig
generate_config_features)
install(TARGETS espresso_config
LIBRARY DESTINATION ${ESPRESSO_INSTALL_PYTHON}/espressomd)
target_include_directories(espresso_config PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(
espresso_config PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/include)

find_package(Git)
# Parse repository info from git if available Run this at build time to avoid
Expand All @@ -66,6 +72,8 @@ add_custom_target(
-DPROJECT_VERSION=${PROJECT_VERSION} -DGIT_EXECUTABLE=${GIT_EXECUTABLE}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -P
${PROJECT_SOURCE_DIR}/cmake/version.cmake)
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES version.hpp
version.hpp.tmp)
set_property(
DIRECTORY APPEND
PROPERTY ADDITIONAL_MAKE_CLEAN_FILES include/config/version.hpp
include/config/version.hpp.tmp)
add_dependencies(espresso_config version)
10 changes: 5 additions & 5 deletions src/config/gen_featureconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
/* Handle definitions from CMake */
/*********************************/
#include "cmake_config.hpp"
#include "myconfig-final.hpp"
#include "config/cmake_config.hpp"
#include "config/myconfig-final.hpp"
""")
external_template = string.Template("""
// $feature is external
Expand All @@ -75,7 +75,7 @@

# Include definitions from CMake
hfile.write("""
#include "cmake_config.hpp"
#include "config/cmake_config.hpp"
""")

Expand Down Expand Up @@ -132,8 +132,8 @@

cfile.write(disclaimer)
cfile.write(f"""
#include "config-features.hpp"
#include "config.hpp"
#include "config/config-features.hpp"
#include "config/config.hpp"
/***********************/
/* Handle requirements */
Expand Down
1 change: 1 addition & 0 deletions src/config/include/config/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#define MPICH_SKIP_MPICXX
#endif

#include "config-features.hpp"
#include "config/config-features.hpp"

/** P3M: Default for offset of first mesh point from the origin (left
* down corner of the simulation box).
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions src/config/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 1 addition & 1 deletion src/core/EspressoSystemInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define ESPRESSOSYSTEMINTERFACE_H

#include "SystemInterface.hpp"
#include "config.hpp"
#include "config/config.hpp"
#include "cuda_interface.hpp"

#include <utils/Vector.hpp>
Expand Down
2 changes: 1 addition & 1 deletion src/core/EspressoSystemStandAlone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "config.hpp"
#include "config/config.hpp"

#include "EspressoSystemStandAlone.hpp"
#include "MpiCallbacks.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/core/Observable_stat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "Observable_stat.hpp"

#include "config.hpp"
#include "config/config.hpp"

#include "bonded_interactions/bonded_interaction_data.hpp"
#include "communication.hpp"
Expand Down
5 changes: 3 additions & 2 deletions src/core/Particle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#ifndef ESPRESSO_CORE_PARTICLE_HPP
#define ESPRESSO_CORE_PARTICLE_HPP

#include "config.hpp"
#include "config/config.hpp"

#include "BondList.hpp"

Expand Down Expand Up @@ -492,8 +492,10 @@ struct Particle { // NOLINT(bugprone-exception-escape)
auto &torque() { return f.torque; }
auto const &omega() const { return m.omega; }
auto &omega() { return m.omega; }
#ifdef EXTERNAL_FORCES
auto const &ext_torque() const { return p.ext_torque; }
auto &ext_torque() { return p.ext_torque; }
#endif // EXTERNAL_FORCES
auto calc_director() const { return r.calc_director(); }
#else // ROTATION
bool can_rotate() const { return false; }
Expand Down Expand Up @@ -556,7 +558,6 @@ struct Particle { // NOLINT(bugprone-exception-escape)
}
auto const &ext_force() const { return p.ext_force; }
auto &ext_force() { return p.ext_force; }

#else // EXTERNAL_FORCES
constexpr bool has_fixed_coordinates() const { return false; }
constexpr bool is_fixed_along(int const) const { return false; }
Expand Down
2 changes: 1 addition & 1 deletion src/core/SystemInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "SystemInterface.hpp"
#include "config.hpp"
#include "config/config.hpp"
2 changes: 1 addition & 1 deletion src/core/SystemInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#ifndef SYSTEMINTERFACE_H
#define SYSTEMINTERFACE_H

#include "config.hpp"
#include "config/config.hpp"

#include <utils/Vector.hpp>

Expand Down
Loading

0 comments on commit 8840065

Please sign in to comment.