From d7e14b03d81b34641ae20a1da682f61ae2ba9cc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-No=C3=ABl=20Grad?= Date: Tue, 4 Feb 2025 20:15:27 +0100 Subject: [PATCH] WIP --- .github/actions/build_and_check/action.yml | 6 +- .github/workflows/push_pull.yml | 21 +++-- .gitlab-ci.yml | 38 ++++---- CMakeLists.txt | 24 +++-- doc/sphinx/Readme.rst | 3 +- doc/sphinx/ek.rst | 2 +- doc/sphinx/installation.rst | 13 ++- doc/sphinx/lb.rst | 2 +- doc/sphinx/running.rst | 4 +- doc/tutorials/CMakeLists.txt | 85 ++++++++++-------- doc/tutorials/active_matter/CMakeLists.txt | 10 +-- doc/tutorials/charged_system/CMakeLists.txt | 6 +- doc/tutorials/constant_pH/CMakeLists.txt | 6 +- doc/tutorials/convert.py | 3 +- doc/tutorials/electrodes/CMakeLists.txt | 13 ++- doc/tutorials/electrokinetics/CMakeLists.txt | 8 +- .../electrokinetics/electrokinetics.ipynb | 10 +-- doc/tutorials/error_analysis/CMakeLists.txt | 13 ++- doc/tutorials/ferrofluid/CMakeLists.txt | 22 +++-- .../CMakeLists.txt | 14 ++- .../langevin_dynamics/CMakeLists.txt | 7 +- .../lattice_boltzmann/CMakeLists.txt | 20 ++--- doc/tutorials/lennard_jones/CMakeLists.txt | 7 +- doc/tutorials/mlip/CMakeLists.txt | 6 +- doc/tutorials/polymers/CMakeLists.txt | 8 +- doc/tutorials/polymers/polymers.ipynb | 35 ++------ .../raspberry_electrophoresis/CMakeLists.txt | 14 ++- doc/tutorials/visualization/CMakeLists.txt | 6 +- doc/tutorials/widom_insertion/CMakeLists.txt | 9 +- maintainer/CI/build_cmake.sh | 30 ++++--- maintainer/format/clang-format.sh | 2 +- requirements.txt | 2 +- samples/diffusion_coefficient.py | 3 +- src/core/electrostatics/scafacos_impl.cpp | 5 +- src/python/CMakeLists.txt | 11 --- src/python/pypresso.cmakein | 2 +- src/walberla_bridge/CMakeLists.txt | 8 +- testsuite/python/collision_detection.py | 89 +------------------ testsuite/python/coulomb_interface.py | 7 +- .../python/rotational-diffusion-aniso.py | 26 ++---- testsuite/python/save_checkpoint.py | 4 - testsuite/python/sigint.py | 11 ++- testsuite/python/tests_common.py | 7 +- 43 files changed, 241 insertions(+), 381 deletions(-) diff --git a/.github/actions/build_and_check/action.yml b/.github/actions/build_and_check/action.yml index 9b647ec349b..cadb2890ee8 100644 --- a/.github/actions/build_and_check/action.yml +++ b/.github/actions/build_and_check/action.yml @@ -3,13 +3,9 @@ description: 'Build espresso and run checks' runs: using: "composite" steps: - - run: | - brew install boost boost-mpi fftw - pip3 install -c requirements.txt "cython<3.0" numpy scipy packaging - shell: bash - if: runner.os == 'macOS' - run: | export myconfig=maxset with_cuda=false with_gsl=false with_hdf5=false test_timeout=800 check_skip_long=true + if test -d venv; then . venv/bin/activate; fi bash maintainer/CI/build_cmake.sh shell: bash # This is a workaround for the unfortunate interaction of MacOS and OpenMPI 4 diff --git a/.github/workflows/push_pull.yml b/.github/workflows/push_pull.yml index 46851d5c33b..281e8d21383 100644 --- a/.github/workflows/push_pull.yml +++ b/.github/workflows/push_pull.yml @@ -9,7 +9,7 @@ permissions: jobs: macos: - runs-on: macos-14 + runs-on: macos-15 if: ${{ github.repository == 'espressomd/espresso' }} steps: - name: Checkout @@ -19,12 +19,15 @@ jobs: with: key: macos save: ${{ github.ref == 'refs/heads/python' }} - - name: Setup Python environment - uses: actions/setup-python@v5.1.0 - with: - python-version: '3.12' - name: Get runner specifications run: system_profiler SPHardwareDataType + - run: | + brew install boost boost-mpi fftw + python3 -m venv venv + . venv/bin/activate + pip3 install -c requirements.txt "cython<3.0.10" numpy scipy packaging + deactivate + shell: bash - name: Build and check uses: ./.github/actions/build_and_check env: @@ -35,7 +38,7 @@ jobs: debian: runs-on: ubuntu-latest container: - image: ghcr.io/espressomd/docker/debian:f7f8ef2c0ca93c67aa16b9f91785492fb04ecc1b-base-layer + image: ghcr.io/jngrad/espresso-docker/debian:b65fb07658b6217546a1da19cde4fcbf89e2ecee-base-layer credentials: username: ${{ github.actor }} password: ${{ secrets.github_token }} @@ -57,6 +60,8 @@ jobs: env: build_procs: 4 check_procs: 4 + CC: 'gcc-12' + CXX: 'g++-12' myconfig: 'maxset' with_ccache: 'true' with_cuda: 'false' @@ -74,7 +79,7 @@ jobs: runs-on: ubuntu-latest if: ${{ github.repository == 'espressomd/espresso' }} container: - image: ghcr.io/espressomd/docker/ubuntu-wo-dependencies:f7f8ef2c0ca93c67aa16b9f91785492fb04ecc1b-base-layer + image: ghcr.io/jngrad/espresso-docker/ubuntu-wo-dependencies:b65fb07658b6217546a1da19cde4fcbf89e2ecee-base-layer credentials: username: ${{ github.actor }} password: ${{ secrets.github_token }} @@ -96,6 +101,8 @@ jobs: env: build_procs: 4 check_procs: 4 + CC: 'gcc-13' + CXX: 'g++-13' myconfig: 'maxset' with_ccache: 'true' with_cuda: 'false' diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 741c73f29b2..170b4880f68 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: ghcr.io/espressomd/docker/ubuntu:f7f8ef2c0ca93c67aa16b9f91785492fb04ecc1b +image: ghcr.io/jngrad/espresso-docker/ubuntu:b65fb07658b6217546a1da19cde4fcbf89e2ecee stages: - prepare @@ -17,7 +17,7 @@ stages: .notification_job_template: ¬ification_job_definition <<: *global_job_definition - image: ghcr.io/espressomd/docker/fedora:f7f8ef2c0ca93c67aa16b9f91785492fb04ecc1b + image: ghcr.io/jngrad/espresso-docker/fedora:b65fb07658b6217546a1da19cde4fcbf89e2ecee variables: GET_SOURCES_ATTEMPTS: 3 before_script: @@ -77,9 +77,9 @@ default: <<: *global_job_definition stage: build variables: - CC: 'gcc-13' - CXX: 'g++-13' - GCOV: 'gcov-13' + CC: 'gcc-14' + CXX: 'g++-14' + GCOV: 'gcov-14' with_cuda: 'false' myconfig: 'default' with_coverage: 'true' @@ -98,9 +98,9 @@ maxset: <<: *global_job_definition stage: build variables: - CC: 'gcc-13' - CXX: 'g++-13' - GCOV: 'gcov-13' + CC: 'gcc-14' + CXX: 'g++-14' + GCOV: 'gcov-14' with_cuda: 'false' myconfig: 'maxset' with_coverage: 'true' @@ -122,9 +122,9 @@ no_rotation: <<: *global_job_definition stage: build variables: - CC: 'gcc-13' - CXX: 'g++-13' - GCOV: 'gcov-13' + CC: 'gcc-14' + CXX: 'g++-14' + GCOV: 'gcov-14' with_cuda: 'false' myconfig: 'no_rotation' with_coverage: 'true' @@ -138,10 +138,10 @@ no_rotation: - no-cuda - numa -fedora:40: +fedora:41: <<: *global_job_definition stage: build - image: ghcr.io/espressomd/docker/fedora:f7f8ef2c0ca93c67aa16b9f91785492fb04ecc1b + image: ghcr.io/jngrad/espresso-docker/fedora:b65fb07658b6217546a1da19cde4fcbf89e2ecee variables: with_cuda: 'false' with_gsl: 'false' @@ -163,9 +163,9 @@ clang-sanitizer: <<: *global_job_definition stage: build variables: - CC: 'clang-18' - CXX: 'clang++-18' - CUDACXX: 'clang++-18' + CC: 'clang-19' + CXX: 'clang++-19' + CUDACXX: 'clang++-19' myconfig: 'maxset' with_cuda: 'true' with_cuda_compiler: 'clang' @@ -411,9 +411,9 @@ empty: <<: *global_job_definition stage: build variables: - CC: 'clang-18' - CXX: 'clang++-18' - CUDACXX: 'clang++-18' + CC: 'clang-19' + CXX: 'clang++-19' + CUDACXX: 'clang++-19' myconfig: 'empty' with_cuda: 'true' with_cuda_compiler: 'clang' diff --git a/CMakeLists.txt b/CMakeLists.txt index 64f7ff7e13f..ed25425dc2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,10 @@ if(POLICY CMP0167) # use BoostConfig.cmake shipped with Boost 1.70+ instead of the one in CMake cmake_policy(SET CMP0167 NEW) endif() +if(POLICY CMP0169) + # use deprecated FetchContent_Populate function for h5xx dependency + cmake_policy(SET CMP0169 OLD) +endif() message(STATUS "CMake version: ${CMAKE_VERSION}") # CMake modules/macros are in a subdirectory to keep this file cleaner set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) @@ -48,9 +52,9 @@ macro(espresso_minimal_compiler_version) endif() endmacro() -espresso_minimal_compiler_version("GNU" 10.5.0) -espresso_minimal_compiler_version("Clang" 14.0.0) -espresso_minimal_compiler_version("AppleClang" 14.0.0) +espresso_minimal_compiler_version("GNU" 12.2.0) +espresso_minimal_compiler_version("Clang" 18.1.0) +espresso_minimal_compiler_version("AppleClang" 16.0.0) espresso_minimal_compiler_version("IntelLLVM" 2023.1) set(UNSUPPORTED_COMPILERS "Intel;MSVC") @@ -117,7 +121,7 @@ FetchContent_Declare( FetchContent_Declare( caliper GIT_REPOSITORY https://github.com/LLNL/Caliper.git - GIT_TAG v2.12.0 + GIT_TAG v2.12.1 ) # cmake-format: on @@ -237,8 +241,6 @@ if(ESPRESSO_BUILD_WITH_CUDA) include(CheckLanguage) enable_language(CUDA) check_language(CUDA) - espresso_minimal_compiler_version("GNU" 11.4.0) - espresso_minimal_compiler_version("Clang" 17.0.0) set(CMAKE_CUDA_STANDARD 20) set(CMAKE_CUDA_STANDARD_REQUIRED ON) set(ESPRESSO_MINIMAL_CUDA_VERSION 12.0) @@ -767,15 +769,21 @@ if(ESPRESSO_BUILD_WITH_WALBERLA) set(BUILD_SHARED_LIBS ${ESPRESSO_BUILD_SHARED_LIBS_DEFAULT}) set(CMAKE_SHARED_LIBRARY_PREFIX "${ESPRESSO_SHARED_LIBRARY_PREFIX}") endif() + # patching + target_compile_options( + blockforest + PRIVATE + $<$,$,14>>:-Wno-alloc-size> + ) set(WALBERLA_LIBS walberla::core walberla::domain_decomposition walberla::blockforest walberla::boundary walberla::field walberla::lbm walberla::timeloop walberla::vtk) if(WALBERLA_BUILD_WITH_FFTW) - set(WALBERLA_LIBS ${WALBERLA_LIBS} walberla::fft) + list(APPEND WALBERLA_LIBS walberla::fft) endif() if(WALBERLA_BUILD_WITH_CUDA) - set(WALBERLA_LIBS ${WALBERLA_LIBS} walberla::gpu) + list(APPEND WALBERLA_LIBS walberla::gpu) endif() set(WALBERLA_LIBS_EXPORT ${WALBERLA_LIBS} diff --git a/doc/sphinx/Readme.rst b/doc/sphinx/Readme.rst index db222645150..8ca774b37b7 100644 --- a/doc/sphinx/Readme.rst +++ b/doc/sphinx/Readme.rst @@ -5,7 +5,8 @@ How to get started with Sphinx .. code-block:: bash - pip3 install --user --upgrade 'sphinx>=2.3.0,!=3.0.0' 'sphinxcontrib-bibtex>=0.3.5' + python3 -m pip install -c requirements.txt \ + sphinx sphinx-toggleprompt sphinxcontrib-bibtex numpydoc pybtex #. Compile the ``sphinx`` target in your build directory (that can take some time since we depend on finishing the build of the interface): diff --git a/doc/sphinx/ek.rst b/doc/sphinx/ek.rst index b5fba56ed88..c1ff1e7f6c8 100644 --- a/doc/sphinx/ek.rst +++ b/doc/sphinx/ek.rst @@ -426,7 +426,7 @@ Start by installing the code generator dependencies: .. code-block:: bash - python3 -m pip install --user -c requirements.txt numpy sympy lbmpy pystencils islpy + python3 -m pip install -c requirements.txt numpy sympy lbmpy pystencils islpy Next, edit the code generator script to configure new kernels, then execute it: diff --git a/doc/sphinx/installation.rst b/doc/sphinx/installation.rst index 142c96146c6..dbf6c89a7b9 100644 --- a/doc/sphinx/installation.rst +++ b/doc/sphinx/installation.rst @@ -132,7 +132,7 @@ To install the ZnDraw visualizer: .. code-block:: bash - python3 -m pip install --user -c requirements.txt 'zndraw==0.4.6' + python3 -m pip install -c requirements.txt 'zndraw==0.4.6' .. _Nvidia GPU acceleration: @@ -207,7 +207,7 @@ To generate the Sphinx documentation, install the following packages: .. code-block:: bash - python3 -m pip install --user -c requirements.txt \ + python3 -m pip install -c requirements.txt \ sphinx sphinxcontrib-bibtex sphinx-toggleprompt To generate the Doxygen documentation, install the following packages: @@ -250,15 +250,14 @@ to use, we recommend installing JupyterLab: .. code-block:: bash - python3 -m pip install --user -c requirements.txt \ - nbformat nbconvert jupyterlab + python3 -m pip install -c requirements.txt \ + jupyterlab>=4.3 nbformat nbconvert lxml[html_clean] -If you prefer the look and feel of Jupyter Classic, install the following: +If you prefer the look and feel of Jupyter Classic, install the following extra package: .. code-block:: bash - python3 -m pip install --user -c requirements.txt \ - nbformat nbconvert jupyterlab nbclassic + python3 -m pip install -c requirements.txt nbclassic Alternatively, to use VS Code Jupyter, install the following extensions: diff --git a/doc/sphinx/lb.rst b/doc/sphinx/lb.rst index 195bf41ce5a..bbbe6396715 100644 --- a/doc/sphinx/lb.rst +++ b/doc/sphinx/lb.rst @@ -533,7 +533,7 @@ Start by installing the code generator dependencies: .. code-block:: bash - python3 -m pip install --user -c requirements.txt numpy sympy lbmpy pystencils islpy + python3 -m pip install -c requirements.txt numpy sympy lbmpy pystencils islpy Next, edit the code generator script to configure new kernels, then execute it: diff --git a/doc/sphinx/running.rst b/doc/sphinx/running.rst index bc4eb4823bd..ad77b6f4a52 100644 --- a/doc/sphinx/running.rst +++ b/doc/sphinx/running.rst @@ -906,7 +906,7 @@ Valgrind .. code-block:: bash sudo apt install valgrind kcachegrind graphviz - python3 -m pip install --user gprof2dot + python3 -m pip install gprof2dot The Valgrind [2]_ :cite:`nethercote07a,nethercote03a` framework brings several tools to examine a program runtime performance. @@ -1066,7 +1066,7 @@ kernprof .. code-block:: bash - python3 -m pip install --user line_profiler + python3 -m pip install line_profiler kernprof [8]_ :cite:`misc-kernprof` is a low-overhead Python profiler. It supports two instrumentation modes: ``line_profile`` and ``cProfile``. diff --git a/doc/tutorials/CMakeLists.txt b/doc/tutorials/CMakeLists.txt index fe94a23785b..80e3a715b2d 100644 --- a/doc/tutorials/CMakeLists.txt +++ b/doc/tutorials/CMakeLists.txt @@ -19,47 +19,50 @@ # along with this program. If not, see . # -# Register a new tutorial target that depends on a list of files that need to be -# copied from the source directory to the build directory. Make the tutorial -# target a dependency of target `tutorials`. -function(configure_tutorial_target) - cmake_parse_arguments(CONFIGURE "" "TARGET" "DEPENDS" ${ARGN}) - set(TARGET_DEPENDENCIES "") - foreach(filepath ${CONFIGURE_DEPENDS}) - list(APPEND TARGET_DEPENDENCIES "${CMAKE_CURRENT_BINARY_DIR}/${filepath}") - add_custom_command( - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${filepath}" - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${filepath}" - COMMAND - ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/${filepath}" - "${CMAKE_CURRENT_BINARY_DIR}/${filepath}") - endforeach(filepath) - add_custom_target(${CONFIGURE_TARGET} DEPENDS ${TARGET_DEPENDENCIES}) - add_dependencies(tutorials ${CONFIGURE_TARGET}) -endfunction(configure_tutorial_target) +add_custom_target(tutorials) +add_custom_target(tutorials_html) +add_custom_target(tutorials_python) + +configure_file(Readme.md ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) +configure_file(convert.py ${CMAKE_CURRENT_BINARY_DIR}) # Convert a tutorial to the Python and HTML formats. Make these files # dependencies of targets `tutorials_html` and `tutorials_python`. -function(NB_EXPORT) +function(ESPRESSO_ADD_TUTORIAL) cmake_parse_arguments(NB_EXPORT "HTML_RUN" "FILE;TARGET;SUFFIX" - "VAR_SUBST;ADD_SCRIPTS" ${ARGN}) + "VAR_SUBST;ADD_SCRIPTS;DEPENDS" ${ARGN}) + + # create target if it doesn't already exist + set(TUTORIAL_TARGET ${NB_EXPORT_TARGET}) + if(NOT TARGET ${TUTORIAL_TARGET}) + add_custom_target(${TUTORIAL_TARGET}) + endif() - set(NB_FILE "${CMAKE_CURRENT_BINARY_DIR}/${NB_EXPORT_FILE}") + # deploy dependencies + set(TARGET_DEPENDENCIES "") + foreach(RELPATH ${NB_EXPORT_DEPENDS}) + configure_file(${RELPATH} ${RELPATH} COPYONLY) + list(APPEND TARGET_DEPENDENCIES ${CMAKE_CURRENT_BINARY_DIR}/${RELPATH}) + endforeach() + + set(NB_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${NB_EXPORT_FILE}) + set(IPYNB_FILE ${CMAKE_CURRENT_BINARY_DIR}/${NB_EXPORT_FILE}) set(DEPENDENCY_OF_TARGET "${NB_EXPORT_TARGET}") - if(NOT "${NB_EXPORT_SUFFIX}" STREQUAL "") + if(DEFINED NB_EXPORT_SUFFIX AND NOT "${NB_EXPORT_SUFFIX}" STREQUAL "") set(NB_EXPORT_TARGET "${NB_EXPORT_TARGET}_${NB_EXPORT_SUFFIX}") endif() cmake_path(GET NB_FILE STEM NB_FILE_STEM) cmake_path(GET NB_FILE EXTENSION NB_FILE_EXT) - set(HTML_FILE "${NB_FILE_STEM}.html") - set(PY_FILE "${NB_FILE_STEM}.py") + set(HTML_FILE "${CMAKE_CURRENT_BINARY_DIR}/${NB_FILE_STEM}.html") + set(PY_FILE "${CMAKE_CURRENT_BINARY_DIR}/${NB_FILE_STEM}.py") if(NB_EXPORT_HTML_RUN) set(NB_FILE_RUN "${NB_FILE_STEM}.run${NB_FILE_EXT}") add_custom_command( OUTPUT ${NB_FILE_RUN} - DEPENDS - "${NB_FILE};${NB_EXPORT_ADD_SCRIPTS};${CMAKE_BINARY_DIR}/doc/tutorials/convert.py;${CMAKE_BINARY_DIR}/testsuite/scripts/importlib_wrapper.py" + DEPENDS ${NB_FILE} ${NB_EXPORT_ADD_SCRIPTS} ${CMAKE_BINARY_DIR}/pypresso + ${CMAKE_BINARY_DIR}/doc/tutorials/convert.py + ${CMAKE_BINARY_DIR}/testsuite/scripts/importlib_wrapper.py COMMAND ${CMAKE_BINARY_DIR}/pypresso ${CMAKE_BINARY_DIR}/doc/tutorials/convert.py ci --execute @@ -71,7 +74,16 @@ function(NB_EXPORT) endif() add_custom_command( - OUTPUT ${HTML_FILE} DEPENDS ${NB_FILE_RUN};${NB_EXPORT_ADD_SCRIPTS} + OUTPUT ${IPYNB_FILE} + DEPENDS ${NB_FILE} ${CMAKE_BINARY_DIR}/pypresso + ${CMAKE_BINARY_DIR}/doc/tutorials/convert.py + COMMAND ${CMAKE_COMMAND} -E copy ${NB_FILE} ${IPYNB_FILE} + COMMAND + ${CMAKE_BINARY_DIR}/pypresso ${CMAKE_BINARY_DIR}/doc/tutorials/convert.py + cells --to-md ${IPYNB_FILE}) + + add_custom_command( + OUTPUT ${HTML_FILE} DEPENDS ${NB_FILE_RUN} ${NB_EXPORT_ADD_SCRIPTS} COMMAND ${IPYTHON_EXECUTABLE} nbconvert --to "html" --output ${HTML_FILE} ${NB_FILE_RUN}) @@ -80,17 +92,17 @@ function(NB_EXPORT) COMMAND ${IPYTHON_EXECUTABLE} nbconvert --to "python" --output ${PY_FILE} ${NB_FILE}) + add_custom_target("${NB_EXPORT_TARGET}_deps" DEPENDS ${TARGET_DEPENDENCIES} + ${IPYNB_FILE}) add_custom_target("${NB_EXPORT_TARGET}_html" DEPENDS ${HTML_FILE} - ${DEPENDENCY_OF_TARGET}) - add_custom_target("${NB_EXPORT_TARGET}_python" - DEPENDS ${PY_FILE} ${DEPENDENCY_OF_TARGET}) + ${TUTORIAL_TARGET}) + add_custom_target("${NB_EXPORT_TARGET}_python" DEPENDS ${PY_FILE} + ${TUTORIAL_TARGET}) + add_dependencies(${TUTORIAL_TARGET} "${NB_EXPORT_TARGET}_deps") + add_dependencies(tutorials ${TUTORIAL_TARGET}) add_dependencies(tutorials_html "${NB_EXPORT_TARGET}_html") add_dependencies(tutorials_python "${NB_EXPORT_TARGET}_python") -endfunction(NB_EXPORT) - -add_custom_target(tutorials) -add_custom_target(tutorials_html) -add_custom_target(tutorials_python) +endfunction() # Here: add new directory add_subdirectory(lennard_jones) @@ -109,6 +121,3 @@ add_subdirectory(widom_insertion) add_subdirectory(electrodes) add_subdirectory(grand_canonical_monte_carlo) add_subdirectory(mlip) - -configure_file(Readme.md ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) -configure_file(convert.py ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/doc/tutorials/active_matter/CMakeLists.txt b/doc/tutorials/active_matter/CMakeLists.txt index f5354c859aa..a46f119a6e4 100644 --- a/doc/tutorials/active_matter/CMakeLists.txt +++ b/doc/tutorials/active_matter/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2017-2022 The ESPResSo project +# Copyright (C) 2017-2025 The ESPResSo project # # This file is part of ESPResSo. # @@ -17,8 +17,6 @@ # along with this program. If not, see . # -configure_tutorial_target( - TARGET tutorial_am DEPENDS active_matter.ipynb figures/friction.svg - figures/pusher-puller.svg figures/geometry.svg) - -nb_export(TARGET tutorial_am FILE "active_matter.ipynb" HTML_RUN) +espresso_add_tutorial( + TARGET tutorial_am FILE "active_matter.ipynb" HTML_RUN DEPENDS + figures/friction.svg figures/pusher-puller.svg figures/geometry.svg) diff --git a/doc/tutorials/charged_system/CMakeLists.txt b/doc/tutorials/charged_system/CMakeLists.txt index a0f79f50b1f..067ef9a7b9e 100644 --- a/doc/tutorials/charged_system/CMakeLists.txt +++ b/doc/tutorials/charged_system/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2022 The ESPResSo project +# Copyright (C) 2016-2025 The ESPResSo project # # This file is part of ESPResSo. # @@ -17,6 +17,4 @@ # along with this program. If not, see . # -configure_tutorial_target(TARGET tutorial_crg DEPENDS charged_system.ipynb) - -nb_export(TARGET tutorial_crg FILE "charged_system.ipynb" HTML_RUN) +espresso_add_tutorial(TARGET tutorial_crg FILE "charged_system.ipynb" HTML_RUN) diff --git a/doc/tutorials/constant_pH/CMakeLists.txt b/doc/tutorials/constant_pH/CMakeLists.txt index 7e7464fdeda..c3298628108 100644 --- a/doc/tutorials/constant_pH/CMakeLists.txt +++ b/doc/tutorials/constant_pH/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2019-2022 The ESPResSo project +# Copyright (C) 2019-2025 The ESPResSo project # # This file is part of ESPResSo. # @@ -17,6 +17,4 @@ # along with this program. If not, see . # -configure_tutorial_target(TARGET tutorial_cph DEPENDS constant_pH.ipynb) - -nb_export(TARGET tutorial_cph SUFFIX "" FILE "constant_pH.ipynb" HTML_RUN) +espresso_add_tutorial(TARGET tutorial_cph FILE "constant_pH.ipynb" HTML_RUN) diff --git a/doc/tutorials/convert.py b/doc/tutorials/convert.py index 7625ee01447..c366b8b967f 100644 --- a/doc/tutorials/convert.py +++ b/doc/tutorials/convert.py @@ -32,7 +32,6 @@ import sys import uuid sys.path.append('@CMAKE_SOURCE_DIR@/testsuite/scripts') -import importlib_wrapper as iw SOLUTION_CELL_TOKEN = "# SOLUTION CELL" @@ -186,6 +185,7 @@ def execute_notebook(nb, src, cell_separator, notebook_filepath): the notebook in a CI environment. """ import nbconvert.preprocessors + import importlib_wrapper as iw notebook_dirname = os.path.dirname(notebook_filepath) # disable OpenGL GUI src_no_gui = iw.mock_es_visualization(src) @@ -224,6 +224,7 @@ def handle_ci_case(args): disable_plot_interactivity(nb) if args.substitutions or args.execute: + import importlib_wrapper as iw # substitute global variables cell_separator = f'\n##{uuid.uuid4().hex}\n' src = cell_separator.join(get_code_cells(nb)) diff --git a/doc/tutorials/electrodes/CMakeLists.txt b/doc/tutorials/electrodes/CMakeLists.txt index 4ba4352845b..d0b17671a6f 100644 --- a/doc/tutorials/electrodes/CMakeLists.txt +++ b/doc/tutorials/electrodes/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2020-2022 The ESPResSo project +# Copyright (C) 2020-2025 The ESPResSo project # # This file is part of ESPResSo. # @@ -17,10 +17,7 @@ # along with this program. If not, see . # -configure_tutorial_target(TARGET tutorial_electrodes DEPENDS - electrodes_part1.ipynb electrodes_part2.ipynb) - -nb_export(TARGET tutorial_electrodes SUFFIX "1" FILE "electrodes_part1.ipynb" - HTML_RUN) -nb_export(TARGET tutorial_electrodes SUFFIX "2" FILE "electrodes_part2.ipynb" - HTML_RUN) +espresso_add_tutorial(TARGET tutorial_electrodes SUFFIX "1" FILE + "electrodes_part1.ipynb" HTML_RUN) +espresso_add_tutorial(TARGET tutorial_electrodes SUFFIX "2" FILE + "electrodes_part2.ipynb" HTML_RUN) diff --git a/doc/tutorials/electrokinetics/CMakeLists.txt b/doc/tutorials/electrokinetics/CMakeLists.txt index cf2099bada2..6d10288e06f 100644 --- a/doc/tutorials/electrokinetics/CMakeLists.txt +++ b/doc/tutorials/electrokinetics/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2022 The ESPResSo project +# Copyright (C) 2016-2025 The ESPResSo project # # This file is part of ESPResSo. # @@ -17,7 +17,5 @@ # along with this program. If not, see . # -configure_tutorial_target(TARGET tutorial_ek DEPENDS electrokinetics.ipynb - figures/schlitzpore_3d.png) - -nb_export(TARGET tutorial_ek SUFFIX "" FILE "electrokinetics.ipynb" HTML_RUN) +espresso_add_tutorial(TARGET tutorial_ek FILE "electrokinetics.ipynb" HTML_RUN + DEPENDS figures/schlitzpore_3d.png) diff --git a/doc/tutorials/electrokinetics/electrokinetics.ipynb b/doc/tutorials/electrokinetics/electrokinetics.ipynb index 3fe674686ee..8f404c631b1 100644 --- a/doc/tutorials/electrokinetics/electrokinetics.ipynb +++ b/doc/tutorials/electrokinetics/electrokinetics.ipynb @@ -1288,7 +1288,7 @@ "\n", "# set the background color for the quiver plot\n", "bg_colors = np.copy(boundary_mask).astype(float)\n", - "bg_colors[boundary_mask] = np.NaN\n", + "bg_colors[boundary_mask] = np.nan\n", "ax4.imshow(bg_colors, cmap=cmap_quiver, **imshow_kwargs)\n", "\n", "for ax, title in zip(\n", @@ -1319,10 +1319,10 @@ " p = np.copy(product_species[0][:, :, 0].density)\n", " \n", " # apply the mask for the boundary\n", - " e1[boundary_mask] = np.NaN\n", - " e2[boundary_mask] = np.NaN\n", - " p[boundary_mask] = np.NaN\n", - " flowfield[boundary_mask] = np.NaN\n", + " e1[boundary_mask] = np.nan\n", + " e2[boundary_mask] = np.nan\n", + " p[boundary_mask] = np.nan\n", + " flowfield[boundary_mask] = np.nan\n", "\n", " ax1.imshow(e1, cmap=cmap, vmin=0., vmax=source_boundary.density, **imshow_kwargs)\n", " ax2.imshow(e2, cmap=cmap, vmin=0., vmax=source_boundary.density, **imshow_kwargs)\n", diff --git a/doc/tutorials/error_analysis/CMakeLists.txt b/doc/tutorials/error_analysis/CMakeLists.txt index b1391fb0851..d773f261f9f 100644 --- a/doc/tutorials/error_analysis/CMakeLists.txt +++ b/doc/tutorials/error_analysis/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2021-2022 The ESPResSo project +# Copyright (C) 2021-2025 The ESPResSo project # # This file is part of ESPResSo. # @@ -17,10 +17,7 @@ # along with this program. If not, see . # -configure_tutorial_target(TARGET tutorial_err DEPENDS - error_analysis_part1.ipynb error_analysis_part2.ipynb) - -nb_export(TARGET tutorial_err SUFFIX "1" FILE "error_analysis_part1.ipynb" - HTML_RUN) -nb_export(TARGET tutorial_err SUFFIX "2" FILE "error_analysis_part2.ipynb" - HTML_RUN) +espresso_add_tutorial(TARGET tutorial_err SUFFIX "1" FILE + "error_analysis_part1.ipynb" HTML_RUN) +espresso_add_tutorial(TARGET tutorial_err SUFFIX "2" FILE + "error_analysis_part2.ipynb" HTML_RUN) diff --git a/doc/tutorials/ferrofluid/CMakeLists.txt b/doc/tutorials/ferrofluid/CMakeLists.txt index e59bce4913f..2c3e620e362 100644 --- a/doc/tutorials/ferrofluid/CMakeLists.txt +++ b/doc/tutorials/ferrofluid/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2018-2022 The ESPResSo project +# Copyright (C) 2018-2025 The ESPResSo project # # This file is part of ESPResSo. # @@ -17,12 +17,7 @@ # along with this program. If not, see . # -configure_tutorial_target( - TARGET tutorial_fe DEPENDS ferrofluid_part1.ipynb ferrofluid_part2.ipynb - ferrofluid_part3.ipynb figures/Electro-Steric_Stabilization.jpg - figures/Ferrofluid_Magnet_under_glass_edit.jpg figures/headtotailconf.png) - -nb_export( +espresso_add_tutorial( TARGET tutorial_fe SUFFIX @@ -32,11 +27,14 @@ nb_export( HTML_RUN VAR_SUBST "EQUIL_STEPS=100;EQUIL_ROUNDS=10;\"CI_DP3M_PARAMS={'cao':3,'r_cut':8.34,'mesh':[8,8,8],'alpha':0.2115,'tune':False}\"" -) -nb_export(TARGET tutorial_fe SUFFIX "2" FILE "ferrofluid_part2.ipynb" HTML_RUN - VAR_SUBST - "equil_steps=100;equil_rounds=10;alphas=[0,1,2,3,4.5,8];loops=100") -nb_export( + DEPENDS + figures/Electro-Steric_Stabilization.jpg + figures/Ferrofluid_Magnet_under_glass_edit.jpg + figures/headtotailconf.png) +espresso_add_tutorial( + TARGET tutorial_fe SUFFIX "2" FILE "ferrofluid_part2.ipynb" HTML_RUN + VAR_SUBST "equil_steps=100;equil_rounds=10;alphas=[0,1,2,3,4.5,8];loops=100") +espresso_add_tutorial( TARGET tutorial_fe SUFFIX "3" FILE "ferrofluid_part3.ipynb" HTML_RUN VAR_SUBST "equil_steps=100;equil_rounds=10;alphas=[0,0.5,1,2,4,8];loops=200;loops_m=100" diff --git a/doc/tutorials/grand_canonical_monte_carlo/CMakeLists.txt b/doc/tutorials/grand_canonical_monte_carlo/CMakeLists.txt index a1981aabe09..c6e446c0c51 100644 --- a/doc/tutorials/grand_canonical_monte_carlo/CMakeLists.txt +++ b/doc/tutorials/grand_canonical_monte_carlo/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2023 The ESPResSo project +# Copyright (C) 2023-2025 The ESPResSo project # # This file is part of ESPResSo. # @@ -17,10 +17,8 @@ # along with this program. If not, see . # -configure_tutorial_target( - TARGET tutorial_grand_canonical_monte_carlo DEPENDS - grand_canonical_monte_carlo.ipynb figures/schematic.svg) - -nb_export(TARGET tutorial_grand_canonical_monte_carlo SUFFIX "" FILE - "grand_canonical_monte_carlo.ipynb" HTML_RUN VAR_SUBST - "\"p3m_params={'mesh':10,'cao':6,'r_cut':8.22}\"") +espresso_add_tutorial( + TARGET tutorial_grand_canonical_monte_carlo FILE + "grand_canonical_monte_carlo.ipynb" HTML_RUN VAR_SUBST + "\"p3m_params={'mesh':10,'cao':6,'r_cut':8.22}\"" DEPENDS + figures/schematic.svg) diff --git a/doc/tutorials/langevin_dynamics/CMakeLists.txt b/doc/tutorials/langevin_dynamics/CMakeLists.txt index 80aefdf6ff3..279f00d86e6 100644 --- a/doc/tutorials/langevin_dynamics/CMakeLists.txt +++ b/doc/tutorials/langevin_dynamics/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2021-2022 The ESPResSo project +# Copyright (C) 2021-2025 The ESPResSo project # # This file is part of ESPResSo. # @@ -17,6 +17,5 @@ # along with this program. If not, see . # -configure_tutorial_target(TARGET tutorial_ld DEPENDS langevin_dynamics.ipynb) - -nb_export(TARGET tutorial_ld SUFFIX "" FILE "langevin_dynamics.ipynb" HTML_RUN) +espresso_add_tutorial(TARGET tutorial_ld FILE "langevin_dynamics.ipynb" + HTML_RUN) diff --git a/doc/tutorials/lattice_boltzmann/CMakeLists.txt b/doc/tutorials/lattice_boltzmann/CMakeLists.txt index ecc9304382d..5b8ea7ee00a 100644 --- a/doc/tutorials/lattice_boltzmann/CMakeLists.txt +++ b/doc/tutorials/lattice_boltzmann/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2022 The ESPResSo project +# Copyright (C) 2016-2025 The ESPResSo project # # This file is part of ESPResSo. # @@ -17,15 +17,11 @@ # along with this program. If not, see . # -configure_tutorial_target( - TARGET tutorial_lb DEPENDS lattice_boltzmann_theory.ipynb - lattice_boltzmann_poiseuille_flow.ipynb lattice_boltzmann_sedimentation.ipynb - figures/latticeboltzmann-grid.png +espresso_add_tutorial( + TARGET tutorial_lb SUFFIX "1" FILE "lattice_boltzmann_theory.ipynb" HTML_RUN + DEPENDS figures/latticeboltzmann-grid.png figures/latticeboltzmann-momentumexchange.png) - -nb_export(TARGET tutorial_lb SUFFIX "1" FILE "lattice_boltzmann_theory.ipynb" - HTML_RUN) -nb_export(TARGET tutorial_lb SUFFIX "2" FILE - "lattice_boltzmann_poiseuille_flow.ipynb" HTML_RUN) -nb_export(TARGET tutorial_lb SUFFIX "3" FILE - "lattice_boltzmann_sedimentation.ipynb" HTML_RUN) +espresso_add_tutorial(TARGET tutorial_lb SUFFIX "2" FILE + "lattice_boltzmann_poiseuille_flow.ipynb" HTML_RUN) +espresso_add_tutorial(TARGET tutorial_lb SUFFIX "3" FILE + "lattice_boltzmann_sedimentation.ipynb" HTML_RUN) diff --git a/doc/tutorials/lennard_jones/CMakeLists.txt b/doc/tutorials/lennard_jones/CMakeLists.txt index 346a611ef2b..aa736298823 100644 --- a/doc/tutorials/lennard_jones/CMakeLists.txt +++ b/doc/tutorials/lennard_jones/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2022 The ESPResSo project +# Copyright (C) 2016-2025 The ESPResSo project # # This file is part of ESPResSo. # @@ -17,7 +17,4 @@ # along with this program. If not, see . # -configure_tutorial_target(TARGET tutorial_lj DEPENDS lennard_jones.ipynb) - -nb_export(TARGET tutorial_lj SUFFIX "" FILE "lennard_jones.ipynb" HTML_RUN - VAR_SUBST) +espresso_add_tutorial(TARGET tutorial_lj FILE "lennard_jones.ipynb" HTML_RUN) diff --git a/doc/tutorials/mlip/CMakeLists.txt b/doc/tutorials/mlip/CMakeLists.txt index a98cbf654ac..5c0d1d7841d 100644 --- a/doc/tutorials/mlip/CMakeLists.txt +++ b/doc/tutorials/mlip/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2024 The ESPResSo project +# Copyright (C) 2024-2025 The ESPResSo project # # This file is part of ESPResSo. # @@ -17,6 +17,4 @@ # along with this program. If not, see . # -configure_tutorial_target(TARGET tutorial_mlip DEPENDS mlip.ipynb) - -nb_export(TARGET tutorial_mlip SUFFIX "" FILE "mlip.ipynb") +espresso_add_tutorial(TARGET tutorial_mlip FILE "mlip.ipynb") diff --git a/doc/tutorials/polymers/CMakeLists.txt b/doc/tutorials/polymers/CMakeLists.txt index e5ab69ab57a..3f1c013a0f4 100644 --- a/doc/tutorials/polymers/CMakeLists.txt +++ b/doc/tutorials/polymers/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2020-2022 The ESPResSo project +# Copyright (C) 2020-2025 The ESPResSo project # # This file is part of ESPResSo. # @@ -17,7 +17,5 @@ # along with this program. If not, see . # -configure_tutorial_target(TARGET tutorial_polymers DEPENDS polymers.ipynb) - -nb_export(TARGET tutorial_polymers SUFFIX "" FILE "polymers.ipynb" HTML_RUN - VAR_SUBST "STEPS=200;BOX_L=16;N_MONOMERS=[6,8,10,12,14]") +espresso_add_tutorial(TARGET tutorial_polymers FILE "polymers.ipynb" HTML_RUN + VAR_SUBST "STEPS=200;BOX_L=16;N_MONOMERS=[6,8,10,12,14]") diff --git a/doc/tutorials/polymers/polymers.ipynb b/doc/tutorials/polymers/polymers.ipynb index 024449f5759..35e39402290 100644 --- a/doc/tutorials/polymers/polymers.ipynb +++ b/doc/tutorials/polymers/polymers.ipynb @@ -224,14 +224,6 @@ " p_previous = p" ] }, - { - "cell_type": "code", - "execution_count": null, - "id": "a3ad343c", - "metadata": {}, - "outputs": [], - "source": [] - }, { "cell_type": "markdown", "id": "6a6d2d2f", @@ -268,14 +260,6 @@ " return com_vel_cor" ] }, - { - "cell_type": "code", - "execution_count": null, - "id": "c1457b56", - "metadata": {}, - "outputs": [], - "source": [] - }, { "cell_type": "markdown", "id": "e04c8781", @@ -330,6 +314,7 @@ "import sys\n", "\n", "import numpy as np\n", + "import scipy.integrate\n", "import scipy.optimize\n", "\n", "import espressomd\n", @@ -337,7 +322,7 @@ "import espressomd.accumulators\n", "import espressomd.observables\n", "import espressomd.polymer\n", - "import espressomd.zn \n", + "import espressomd.zn\n", "\n", "logging.basicConfig(level=logging.INFO, stream=sys.stdout)\n", "\n", @@ -401,16 +386,6 @@ "rg_results = []" ] }, - { - "cell_type": "code", - "execution_count": null, - "id": "cc807f20-5f3c-412a-a06d-6816256e6ee6", - "metadata": {}, - "outputs": [], - "source": [ - "### System visualization " - ] - }, { "cell_type": "code", "execution_count": null, @@ -418,14 +393,14 @@ "metadata": {}, "outputs": [], "source": [ - "print(\"Simulation video for polymer of size :\", N_MONOMERS[2])\n", + "print(f\"Simulation video for polymer of size : {N_MONOMERS[2]}\")\n", "\n", "# Visualizer Parameters\n", "color = {0: \"blue\"} # Particle color by type\n", "radii = {0: LJ_SIGMA/2.0} # Particle size by type\n", "\n", "# Initializing Visualizer\n", - "vis = espressomd.zn.Visualizer(system, colors=color, radii=radii, bonds=True)\n" + "vis = espressomd.zn.Visualizer(system, colors=color, radii=radii, bonds=True)" ] }, { @@ -949,7 +924,7 @@ "fig = plt.figure(figsize=(10, 6))\n", "for N, tau, acf in zip(N_MONOMERS, com_vel_tau_results, com_vel_acf_results):\n", " x = np.arange(2, 28)\n", - " y = [1 / 3 * np.trapz(acf[:j], tau[:j]) for j in x]\n", + " y = [1 / 3 * scipy.integrate.trapezoid(acf[:j], tau[:j]) for j in x]\n", " plt.plot(tau[x], y, label=rf'$D(\\tau_{{\\mathrm{{int}}}})$ for $N = {N}$')\n", " diffusion_gk.append(np.mean(y[10:]))\n", "plt.xlabel(r'$\\tau_{\\mathrm{int}}$')\n", diff --git a/doc/tutorials/raspberry_electrophoresis/CMakeLists.txt b/doc/tutorials/raspberry_electrophoresis/CMakeLists.txt index c485bff0787..22383b41463 100644 --- a/doc/tutorials/raspberry_electrophoresis/CMakeLists.txt +++ b/doc/tutorials/raspberry_electrophoresis/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2022 The ESPResSo project +# Copyright (C) 2016-2025 The ESPResSo project # # This file is part of ESPResSo. # @@ -17,18 +17,14 @@ # along with this program. If not, see . # -configure_tutorial_target( - TARGET tutorial_eph DEPENDS raspberry_electrophoresis.ipynb - figures/raspberry_snapshot.png posVsTime_sample.dat) - -nb_export( +espresso_add_tutorial( TARGET tutorial_eph - SUFFIX - "" FILE raspberry_electrophoresis.ipynb HTML_RUN VAR_SUBST "num_iterations=20;num_steps_per_iteration=20;'trajectory_file=\"posVsTime_sample.dat\"'" -) + DEPENDS + figures/raspberry_snapshot.png + posVsTime_sample.dat) diff --git a/doc/tutorials/visualization/CMakeLists.txt b/doc/tutorials/visualization/CMakeLists.txt index 9b8b4c5d971..dc37eae28d3 100644 --- a/doc/tutorials/visualization/CMakeLists.txt +++ b/doc/tutorials/visualization/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2022 The ESPResSo project +# Copyright (C) 2016-2025 The ESPResSo project # # This file is part of ESPResSo. # @@ -17,6 +17,4 @@ # along with this program. If not, see . # -configure_tutorial_target(TARGET tutorial_viz DEPENDS visualization.ipynb) - -nb_export(TARGET tutorial_viz SUFFIX "" FILE "visualization.ipynb" HTML_RUN) +espresso_add_tutorial(TARGET tutorial_viz FILE "visualization.ipynb" HTML_RUN) diff --git a/doc/tutorials/widom_insertion/CMakeLists.txt b/doc/tutorials/widom_insertion/CMakeLists.txt index 424fed5b85c..376b8c24b22 100644 --- a/doc/tutorials/widom_insertion/CMakeLists.txt +++ b/doc/tutorials/widom_insertion/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2022 The ESPResSo project +# Copyright (C) 2022-2025 The ESPResSo project # # This file is part of ESPResSo. # @@ -17,7 +17,6 @@ # along with this program. If not, see . # -configure_tutorial_target(TARGET tutorial_widom DEPENDS widom_insertion.ipynb) - -nb_export(TARGET tutorial_widom SUFFIX "" FILE "widom_insertion.ipynb" HTML_RUN - VAR_SUBST "\"ci_params={'mesh':(12,12,12),'cao':6}\"") +espresso_add_tutorial( + TARGET tutorial_widom FILE "widom_insertion.ipynb" HTML_RUN VAR_SUBST + "\"ci_params={'mesh':(12,12,12),'cao':6}\"") diff --git a/maintainer/CI/build_cmake.sh b/maintainer/CI/build_cmake.sh index 9b371153904..b766cc3515a 100755 --- a/maintainer/CI/build_cmake.sh +++ b/maintainer/CI/build_cmake.sh @@ -200,20 +200,24 @@ echo "Creating ${builddir}..." mkdir -p "${builddir}" cd "${builddir}" -# load MPI module if necessary +# load modules if [ -f "/etc/os-release" ]; then - grep -q "suse" /etc/os-release && . /etc/profile.d/modules.sh && module load gnu-openmpi - grep -q "rhel\|fedora" /etc/os-release && for f in /etc/profile.d/*module*.sh; do . "${f}"; done && module load mpi -fi - -# setup environment -if grep -q "Ubuntu" /etc/os-release; then - default_gcov="$(which "gcov")" - custom_gcov="$(which "${GCOV:-gcov}")" - if [ ! "${custom_gcov}" = "${default_gcov}" ] && [ -d "${HOME}/.local/var/lib/alternatives" ]; then - update-alternatives --altdir "${HOME}/.local/etc/alternatives" \ - --admindir "${HOME}/.local/var/lib/alternatives" \ - --install "${HOME}/.local/bin/gcov" "gcov" "${custom_gcov}" 10 + if grep -qP 'NAME="(openSUSE|SLES|SLED)' /etc/os-release; then + . /etc/profile.d/modules.sh + module load gnu-openmpi + elif grep -qP 'NAME="(Fedora|Red Hat Enterprise) Linux"' /etc/os-release; then + for f in /etc/profile.d/*module*.sh; do + . "${f}" + done + module load mpi + elif grep -q 'NAME="Ubuntu"' /etc/os-release; then + default_gcov="$(which "gcov")" + custom_gcov="$(which "${GCOV:-gcov}")" + if [ ! "${custom_gcov}" = "${default_gcov}" ] && [ -d "${HOME}/.local/var/lib/alternatives" ]; then + update-alternatives --altdir "${HOME}/.local/etc/alternatives" \ + --admindir "${HOME}/.local/var/lib/alternatives" \ + --install "${HOME}/.local/bin/gcov" "gcov" "${custom_gcov}" 10 + fi fi fi diff --git a/maintainer/format/clang-format.sh b/maintainer/format/clang-format.sh index 347c9cbb879..d58a2ac96bc 100755 --- a/maintainer/format/clang-format.sh +++ b/maintainer/format/clang-format.sh @@ -18,7 +18,7 @@ # along with this program. If not, see . # -CLANG_FORMAT_VER=18.1 +CLANG_FORMAT_VER=19.1 if hash clang-format-${CLANG_FORMAT_VER} 2>/dev/null; then CLANGFORMAT="$(which clang-format-${CLANG_FORMAT_VER})" elif hash clang-format-${CLANG_FORMAT_VER%.*} 2>/dev/null; then diff --git a/requirements.txt b/requirements.txt index 937dc09a81b..bd93db11435 100644 --- a/requirements.txt +++ b/requirements.txt @@ -32,7 +32,7 @@ sphinxcontrib-bibtex>=2.6.2 numpydoc>=1.6.0 pybtex>=0.24.0 # jupyter dependencies -jupyterlab>=3.5 +jupyterlab>=4.0 ipykernel>=6.29.3 nbformat==5.9.1 nbconvert==6.5.3 diff --git a/samples/diffusion_coefficient.py b/samples/diffusion_coefficient.py index 94f3a61e9fd..4c25b033804 100644 --- a/samples/diffusion_coefficient.py +++ b/samples/diffusion_coefficient.py @@ -27,6 +27,7 @@ import espressomd import espressomd.accumulators import espressomd.observables +import scipy.integrate import numpy as np gamma = 2.4 @@ -72,7 +73,7 @@ # D= 1/3 int_0^infty dt # Integrate with trapezoidal rule -I = np.trapz(vacf[:, 2], vacf[:, 0]) +I = scipy.integrate.trapezoid(vacf[:, 2], vacf[:, 0]) ratio = 1. / 3. * I / (kT / gamma) print("Ratio of measured and expected diffusion coefficients from Green-Kubo:", ratio) diff --git a/src/core/electrostatics/scafacos_impl.cpp b/src/core/electrostatics/scafacos_impl.cpp index 0700bb14ba9..f15e0ebb54a 100644 --- a/src/core/electrostatics/scafacos_impl.cpp +++ b/src/core/electrostatics/scafacos_impl.cpp @@ -121,10 +121,9 @@ void CoulombScafacosImpl::tune_r_cut() { break; } + r_min += dr; if (t_mid > t_min) { - r_max = r_min += dr; - } else { - r_min += dr; + r_max = r_min; } } assert(r_opt >= 0.); diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index 811e703942e..72d6ef56ca2 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -21,17 +21,6 @@ set(ESPRESSO_PYTHON_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(ESPRESSO_PYTHON_FRONTEND ${Python_EXECUTABLE}) -if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - execute_process( - COMMAND "${ESPRESSO_PYTHON_FRONTEND}" "-c" - "import sysconfig; print(sysconfig.get_config_var('exec_prefix'))" - OUTPUT_VARIABLE DARWIN_EXEC_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE) - set(ESPRESSO_PYTHON_FRONTEND_TMP - "${DARWIN_EXEC_PREFIX}/Resources/Python.app/Contents/MacOS/Python") - if(EXISTS ${ESPRESSO_PYTHON_FRONTEND_TMP}) - set(ESPRESSO_PYTHON_FRONTEND ${ESPRESSO_PYTHON_FRONTEND_TMP}) - endif() -endif() configure_file(pypresso.cmakein ${CMAKE_BINARY_DIR}/pypresso @ONLY) if(IPYTHON_EXECUTABLE) diff --git a/src/python/pypresso.cmakein b/src/python/pypresso.cmakein index 70856604d52..e1e08515893 100755 --- a/src/python/pypresso.cmakein +++ b/src/python/pypresso.cmakein @@ -93,7 +93,7 @@ case "$1" in ;; --coverage) shift - exec @Python_EXECUTABLE@ -m coverage run --source=@CMAKE_BINARY_DIR@/testsuite/ --rcfile="@PROJECT_SOURCE_DIR@/.coveragerc" "$@" + exec "@Python_EXECUTABLE@" -m coverage run --source="@CMAKE_BINARY_DIR@/testsuite/" --rcfile="@PROJECT_SOURCE_DIR@/.coveragerc" "$@" ;; --valgrind) shift diff --git a/src/walberla_bridge/CMakeLists.txt b/src/walberla_bridge/CMakeLists.txt index 3277ec43a73..771e51fe302 100644 --- a/src/walberla_bridge/CMakeLists.txt +++ b/src/walberla_bridge/CMakeLists.txt @@ -90,11 +90,17 @@ function(espresso_configure_walberla_target) LIBRARY DESTINATION ${ESPRESSO_INSTALL_PYTHON}/espressomd) endfunction() +add_library(espresso_walberla_cpp_flags_overrides INTERFACE) +target_compile_options( + espresso_walberla_cpp_flags_overrides + INTERFACE + $<$,$,14>>:-Wno-alloc-size> +) add_library(espresso_walberla_cpp_flags INTERFACE) add_library(espresso::walberla::cpp_flags ALIAS espresso_walberla_cpp_flags) target_link_libraries( espresso_walberla_cpp_flags - INTERFACE espresso::cpp_flags + INTERFACE espresso::cpp_flags espresso_walberla_cpp_flags_overrides $<$:espresso::avx_flags>) add_library(espresso_walberla_cuda_flags INTERFACE) add_library(espresso::walberla::cuda_flags ALIAS espresso_walberla_cuda_flags) diff --git a/testsuite/python/collision_detection.py b/testsuite/python/collision_detection.py index fa68dc47e49..4d64fe55b0e 100644 --- a/testsuite/python/collision_detection.py +++ b/testsuite/python/collision_detection.py @@ -186,19 +186,8 @@ def verify_state_after_bind_at_poc_triplet(self, expected_np): # We traverse particles. We look for a vs with a bond to find the other vs. # From the two vs we find the two non-virtual particles for p in system.part: - # Skip non-virtual - if not p.is_virtual(): - continue - # Skip vs that doesn't have a bond - if p.bonds == (): - continue - if p.id == 1: - # Parse the bond - self.assertEqual(len(p.bonds), 2) - # Bond type - self.assertEqual(p.bonds[0][0], self.bond_pair) - self.assertEqual(p.bonds[1][0], self.bond_vs) - else: + # Skip non-vs and vs that don't have a bond + if p.is_virtual() and p.bonds != (): # Parse the bond self.assertEqual(len(p.bonds), 1) # Bond type @@ -678,80 +667,6 @@ def test_glue_to_surface_random(self): # Tidy system.non_bonded_inter[0, 0].lennard_jones.deactivate() - def verify_triangle_binding(self, distance, first_bond, angle_res): - system = self.system - # Gather pairs - n = len(system.part) - angle_res = angle_res - 1 - - expected_pairs = [] - for i in range(n): - for j in range(i + 1, n, 1): - if system.distance(system.part.by_id(i), - system.part.by_id(j)) <= distance: - expected_pairs.append((i, j)) - - # Find triangles - # Each element is a particle id, a bond id and two bond partners in - # ascending order - expected_angle_bonds = [] - for i in range(n): - for j in range(i + 1, n, 1): - for k in range(j + 1, n, 1): - # Ref to particles - p_i, p_j, p_k = system.part.by_ids([i, j, k]) - - # Normalized distance vectors - d_ij = np.copy(p_j.pos - p_i.pos) - d_ik = np.copy(p_k.pos - p_i.pos) - d_jk = np.copy(p_k.pos - p_j.pos) - d_ij /= np.linalg.norm(d_ij) - d_ik /= np.linalg.norm(d_ik) - d_jk /= np.linalg.norm(d_jk) - - if system.distance(p_i, p_j) <= distance and system.distance( - p_i, p_k) <= distance: - id_i = first_bond._bond_id + \ - int(np.round( - np.arccos(np.dot(d_ij, d_ik)) * angle_res / np.pi)) - expected_angle_bonds.append((i, id_i, j, k)) - - if system.distance(p_i, p_j) <= distance and system.distance( - p_j, p_k) <= distance: - id_j = first_bond._bond_id + \ - int(np.round( - np.arccos(np.dot(-d_ij, d_jk)) * angle_res / np.pi)) - expected_angle_bonds.append((j, id_j, i, k)) - if system.distance(p_i, p_k) <= distance and system.distance( - p_j, p_k) <= distance: - id_k = first_bond._bond_id + \ - int(np.round( - np.arccos(np.dot(-d_ik, -d_jk)) * angle_res / np.pi)) - expected_angle_bonds.append((k, id_k, i, j)) - - # Gather actual pairs and actual triangles - found_pairs = [] - found_angle_bonds = [] - for i in range(n): - for b in system.part.by_id(i).bonds: - self.assertIn( - len(b), (2, 3), msg="There should only be 2- and 3-particle bonds") - if len(b) == 2: - self.assertEqual(b[0]._bond_id, self.bond_center._bond_id) - found_pairs.append(tuple(sorted((i, b[1])))) - elif len(b) == 3: - partners = sorted(b[1:]) - found_angle_bonds.append( - (i, b[0]._bond_id, partners[0], partners[1])) - - # The order between expected and found bonds does not always match - # because collisions occur in random order. Sort stuff - found_pairs = sorted(found_pairs) - found_angle_bonds = sorted(found_angle_bonds) - expected_angle_bonds = sorted(expected_angle_bonds) - self.assertEqual(found_pairs, expected_pairs) - self.assertEqual(found_angle_bonds, expected_angle_bonds) - if __name__ == "__main__": ut.main() diff --git a/testsuite/python/coulomb_interface.py b/testsuite/python/coulomb_interface.py index 55b89100b60..310b2853d9e 100644 --- a/testsuite/python/coulomb_interface.py +++ b/testsuite/python/coulomb_interface.py @@ -110,9 +110,14 @@ def test_mmm1d_cpu(self): with self.assertRaisesRegex(ValueError, f"Parameter '{key}' must be > 0"): espressomd.electrostatics.MMM1D(**invalid_params) + @utx.skipIfMissingFeatures(["P3M"]) + def test_solvers_rollback(self): # swapping two solvers should safely rollback to last valid solver + self.system.periodicity = [False, False, True] + self.system.cell_system.set_n_square() self.assertEqual(abs(self.system.analysis.energy()["coulomb"]), 0.) - mmm1d = espressomd.electrostatics.MMM1D(**valid_params) + mmm1d = espressomd.electrostatics.MMM1D( + prefactor=1., maxPWerror=1e-3, far_switch_radius=1.) self.system.electrostatics.solver = mmm1d ref_energy = self.system.analysis.energy()["coulomb"] with self.assertRaisesRegex(RuntimeError, "CoulombP3M: requires periodicity"): diff --git a/testsuite/python/rotational-diffusion-aniso.py b/testsuite/python/rotational-diffusion-aniso.py index c580d0b60b7..104639ab5ec 100644 --- a/testsuite/python/rotational-diffusion-aniso.py +++ b/testsuite/python/rotational-diffusion-aniso.py @@ -210,9 +210,7 @@ def check_rot_diffusion(self): dcosjj_validate[2] = np.exp(-(D[0] + D[1]) * self.system.time) dcosjj_dev = np.absolute( dcosjj - dcosjj_validate) / dcosjj_validate - for j in range(3): - if np.absolute(dcosjj_validate[j]) < min_value: - dcosjj_dev[j] = 0.0 + dcosjj_dev[np.nonzero(dcosjj_validate < min_value)] = 0.0 # Eq. (24) [Perrin1936]. dcosijpp_validate[0, 1] = np.exp( @@ -229,10 +227,7 @@ def check_rot_diffusion(self): -(4 * D[0] + D[2] + D[1]) * self.system.time) dcosijpp_dev = np.absolute( dcosijpp - dcosijpp_validate) / dcosijpp_validate - for i in range(3): - for j in range(3): - if np.absolute(dcosijpp_validate[i, j]) < min_value: - dcosijpp_dev[i, j] = 0.0 + dcosijpp_dev[np.nonzero(dcosijpp_validate < min_value)] = 0.0 # Eq. (25) [Perrin1936]. dcosijnn_validate[0, 1] = np.exp(-(D[1] + D[0]) * self.system.time) @@ -243,10 +238,7 @@ def check_rot_diffusion(self): dcosijnn_validate[2, 1] = np.exp(-(D[2] + D[1]) * self.system.time) dcosijnn_dev = np.absolute( dcosijnn - dcosijnn_validate) / dcosijnn_validate - for i in range(3): - for j in range(3): - if np.absolute(dcosijnn_validate[i, j]) < min_value: - dcosijnn_dev[i, j] = 0.0 + dcosijnn_dev[np.nonzero(dcosijnn_validate < min_value)] = 0.0 # Eq. (30) [Perrin1936]. D0 = sum(D[:]) / 3.0 @@ -258,8 +250,7 @@ def check_rot_diffusion(self): D1D1 /= 6.0 # Technical workaround of a digital arithmetic issue for isotropic # particle - if np.absolute((D0**2 - D1D1) / (D0**2 + D1D1) - ) < self.round_error_prec: + if np.abs((D0**2 - D1D1) / (D0**2 + D1D1)) < self.round_error_prec: D1D1 *= (1.0 - 2.0 * self.round_error_prec) # Eq. (32) [Perrin1936]. dcosjj2_validate = 1. / 3. + (1. / 3.) * (1. + (D - D0) / (2. * np.sqrt(D0**2 - D1D1))) \ @@ -268,9 +259,7 @@ def check_rot_diffusion(self): * np.exp(-6. * (D0 + np.sqrt(D0**2 - D1D1)) * self.system.time) dcosjj2_dev = np.absolute( dcosjj2 - dcosjj2_validate) / dcosjj2_validate - for j in range(3): - if np.absolute(dcosjj2_validate[j]) < min_value: - dcosjj2_dev[j] = 0.0 + dcosjj2_dev[np.nonzero(dcosjj2_validate < min_value)] = 0.0 # Eq. (33) [Perrin1936]. dcosij2_validate[0, 1] = 1. / 3. - (1. / 6.) * (1. - (D[2] - D0) / (2. * np.sqrt(D0**2 - D1D1))) \ @@ -292,10 +281,7 @@ def check_rot_diffusion(self): dcosij2_validate[2, 1] = dcosij2_validate[1, 2] dcosij2_dev = np.absolute( dcosij2 - dcosij2_validate) / dcosij2_validate - for i in range(3): - for j in range(3): - if np.absolute(dcosij2_validate[i, j]) < min_value: - dcosij2_dev[i, j] = 0.0 + dcosij2_dev[np.nonzero(dcosij2_validate < min_value)] = 0.0 for j in range(3): self.assertLessEqual( diff --git a/testsuite/python/save_checkpoint.py b/testsuite/python/save_checkpoint.py index b088cd14740..b135cf2d56c 100644 --- a/testsuite/python/save_checkpoint.py +++ b/testsuite/python/save_checkpoint.py @@ -67,10 +67,6 @@ **config.get_checkpoint_params()) path_cpt_root = pathlib.Path(checkpoint.checkpoint_dir) -# cleanup old checkpoint files -for filepath in path_cpt_root.iterdir(): - filepath.unlink(missing_ok=True) - # Lees-Edwards boundary conditions if 'INT.NPT' not in modes and 'LB.GPU' not in modes and ( 'LB' not in modes or n_nodes in (1, 2, 3)): diff --git a/testsuite/python/sigint.py b/testsuite/python/sigint.py index a8d9b1bbb3b..2354e6fa7df 100644 --- a/testsuite/python/sigint.py +++ b/testsuite/python/sigint.py @@ -25,10 +25,9 @@ import os -EXPECTED_TRACEBACK_ENDING = """ in handle_sigint - signal.raise_signal(signal.Signals.SIGINT) -KeyboardInterrupt -""" +EXPECTED_TRACEBACK_ENDING = r""" in handle_sigint + signal\.raise_signal\(signal\.Signals\.SIGINT\)(?:\n +~+\^+)? +KeyboardInterrupt\s*$""" class SigintTest(ut.TestCase): @@ -51,8 +50,8 @@ def check_signal_handling(self, process, sig): self.assertEqual(traceback, "") elif sig == signal.Signals.SIGINT: self.assertIn(" self.integrator.run(", traceback) - self.assertTrue(traceback.endswith(EXPECTED_TRACEBACK_ENDING), - msg=f"Traceback failed string match:\n{traceback}") + with self.assertRaisesRegex(KeyboardInterrupt, EXPECTED_TRACEBACK_ENDING): + raise KeyboardInterrupt(traceback) def test_signal_handling(self): signals = [signal.Signals.SIGINT, signal.Signals.SIGTERM] diff --git a/testsuite/python/tests_common.py b/testsuite/python/tests_common.py index 5b3b4be339d..9b7f9b8722c 100644 --- a/testsuite/python/tests_common.py +++ b/testsuite/python/tests_common.py @@ -322,11 +322,12 @@ def lj_generic_force(espressomd, r, epsilon, sigma, cutoff, offset=0., e1=12, if r >= offset + cutoff: f = 0. else: + has_ljgen_softcore = espressomd.has_features("LJGEN_SOFTCORE") h = (r - offset)**2 + delta * (1. - lam) * sigma**2 f = (r - offset) * epsilon * lam * ( - b1 * e1 * np.power(sigma / np.sqrt(h), e1) - b2 * e2 * np.power(sigma / np.sqrt(h), e2)) / h - if (not espressomd.has_features("LJGEN_SOFTCORE")) and generic: - f *= np.sign(r - offset) + b1 * e1 * np.power(sigma / np.sqrt(h), e1) - + b2 * e2 * np.power(sigma / np.sqrt(h), e2)) / h + f *= np.sign(r - offset) if generic and not has_ljgen_softcore else 1 return f # Lennard-Jones