From de8eeae3c52725033980ac873cefabcedd1b4070 Mon Sep 17 00:00:00 2001 From: Tommy Waltmann Date: Wed, 20 Jul 2022 13:14:21 -0400 Subject: [PATCH 01/10] try targeting newer macOS versions --- .github/workflows/build_wheels.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 70891192c..ee789229b 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -45,6 +45,7 @@ jobs: # Configure environment variables. CIBW_ENVIRONMENT_LINUX: "CMAKE_PREFIX_PATH=/project/tbb LD_LIBRARY_PATH=/project/tbb/lib/intel64/gcc4.8:$LD_LIBRARY_PATH" CIBW_ENVIRONMENT_MACOS: "CMAKE_PREFIX_PATH=/Users/runner/work/freud/freud/tbb LD_LIBRARY_PATH=/Users/runner/work/freud/freud/tbb/lib/intel64/gcc4.8:$LD_LIBRARY_PATH" + MACOSX_DEPLOYMENT_TARGET: "10.14" # Set up TBB. CIBW_BEFORE_BUILD_LINUX: "source .github/workflows/cibuildwheel-before-build.sh {package} linux" From ee14f3ebde6b5dd9093272b846d30d8f27ad16b8 Mon Sep 17 00:00:00 2001 From: Tommy Waltmann Date: Thu, 21 Jul 2022 10:23:45 -0400 Subject: [PATCH 02/10] run build_wheels when label is added --- .github/workflows/build_wheels.yml | 7 +++++++ .github/workflows/run_tests.yml | 1 + 2 files changed, 8 insertions(+) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index ee789229b..9ef5fcd0b 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -7,9 +7,13 @@ on: branches: - "maint" - "master" + - "next" tags: - "v*" + pull_request: + types: [opened, labeled, reopened, synchronize] + # Trigger on request. workflow_dispatch: @@ -20,6 +24,7 @@ jobs: build_wheels: name: Build wheel for ${{ matrix.os }}, Python ${{ matrix.pyver }} runs-on: ${{ matrix.os }} + if: ${{ contains(github.event.pull_request.labels.*.name, 'build_wheels') }} strategy: matrix: os: [ubuntu-20.04, macos-10.15] #, windows-2019] @@ -66,6 +71,7 @@ jobs: build_sdist: name: Build source distribution runs-on: ubuntu-latest + if: ${{ contains(github.event.pull_request.labels.*.name, 'build_wheels') }} steps: - uses: actions/checkout@v3.0.2 with: @@ -91,6 +97,7 @@ jobs: name: Publish [PyPI] needs: [build_wheels, build_sdist] runs-on: ubuntu-latest + if: ${{ contains(github.event.pull_request.labels.*.name, 'build_wheels') }} steps: - name: Download artifacts diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 20c8ec36c..feee7ef88 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -12,6 +12,7 @@ on: push: branches: - "master" + - "next" # trigger on request workflow_dispatch: From dd27cfad9da4e1a47683c3e723fba1102d0be966 Mon Sep 17 00:00:00 2001 From: Tommy Waltmann Date: Thu, 21 Jul 2022 10:38:51 -0400 Subject: [PATCH 03/10] upgrade macOS environment image --- .github/workflows/build_wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 9ef5fcd0b..8659ca2f4 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -27,7 +27,7 @@ jobs: if: ${{ contains(github.event.pull_request.labels.*.name, 'build_wheels') }} strategy: matrix: - os: [ubuntu-20.04, macos-10.15] #, windows-2019] + os: [ubuntu-20.04, macos-12] #, windows-2019] pyver: ["3.6", "3.7", "3.8", "3.9", "3.10"] steps: From 45e2e6148b6621b280b1e4f5c5cce02f55379967 Mon Sep 17 00:00:00 2001 From: Tommy Waltmann Date: Thu, 21 Jul 2022 11:05:36 -0400 Subject: [PATCH 04/10] add more complex booleans so jobs will run under correct conditions --- .github/workflows/build_wheels.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 8659ca2f4..492970071 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -5,7 +5,6 @@ on: # twice when the pull request source branch is in the same repository. push: branches: - - "maint" - "master" - "next" tags: @@ -24,7 +23,7 @@ jobs: build_wheels: name: Build wheel for ${{ matrix.os }}, Python ${{ matrix.pyver }} runs-on: ${{ matrix.os }} - if: ${{ contains(github.event.pull_request.labels.*.name, 'build_wheels') }} + if: ${{ contains(github.event.pull_request.labels.*.name, 'build_wheels') || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/next' }} strategy: matrix: os: [ubuntu-20.04, macos-12] #, windows-2019] @@ -71,7 +70,7 @@ jobs: build_sdist: name: Build source distribution runs-on: ubuntu-latest - if: ${{ contains(github.event.pull_request.labels.*.name, 'build_wheels') }} + if: ${{ contains(github.event.pull_request.labels.*.name, 'build_wheels') || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/next' }} steps: - uses: actions/checkout@v3.0.2 with: @@ -97,7 +96,7 @@ jobs: name: Publish [PyPI] needs: [build_wheels, build_sdist] runs-on: ubuntu-latest - if: ${{ contains(github.event.pull_request.labels.*.name, 'build_wheels') }} + if: ${{ contains(github.event.pull_request.labels.*.name, 'build_wheels') || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/next' }} steps: - name: Download artifacts From eb2ce6b06d97f3395fdc03cfd7eef43358f59ed5 Mon Sep 17 00:00:00 2001 From: Tommy Waltmann Date: Thu, 21 Jul 2022 12:46:52 -0400 Subject: [PATCH 05/10] miscellaneous fixes --- ChangeLog.md | 1 + cpp/diffraction/StaticStructureFactorDebye.cc | 2 +- extern/bessel-library.hpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index cdc91161b..43b1954e4 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -8,6 +8,7 @@ and this project adheres to ### Added * Support for 2D systems in `freud.diffraction.StaticStructureFactorDebye`. +* Compilation uses the C++17 standard. ### Fixed * `EnvironmentMotifMatch` correctly handles `NeighborList`s with more neighbors per particle than the motif. diff --git a/cpp/diffraction/StaticStructureFactorDebye.cc b/cpp/diffraction/StaticStructureFactorDebye.cc index 0290b5969..fdf341004 100644 --- a/cpp/diffraction/StaticStructureFactorDebye.cc +++ b/cpp/diffraction/StaticStructureFactorDebye.cc @@ -86,7 +86,7 @@ void StaticStructureFactorDebye::accumulate(const freud::locality::NeighborQuery // floating point precision errors can cause k to be // slightly negative, and make evaluating the cylindrical // bessel function impossible. - auto abs_k = std::abs(k); + auto abs_k = std::max(0, k); #ifdef __clang__ // clang doesn't support the special math functions in diff --git a/extern/bessel-library.hpp b/extern/bessel-library.hpp index 54e8efe42..22683c4a8 100644 --- a/extern/bessel-library.hpp +++ b/extern/bessel-library.hpp @@ -1,5 +1,5 @@ /* - * Taken from https://gtihub.com/jodesarro/bessel-library.git, distributed under + * Taken from https://github.com/jodesarro/bessel-library.git, distributed under * the MIT license. * * */ From 91ec7d3241058521762fe6941a601ea83a970422 Mon Sep 17 00:00:00 2001 From: Tommy Waltmann Date: Thu, 21 Jul 2022 12:47:07 -0400 Subject: [PATCH 06/10] make official citation --- doc/source/reference/credits.rst | 1 + doc/source/reference/freud.bib | 13 +++++++++++++ freud/diffraction.pyx | 17 ++++++++--------- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/doc/source/reference/credits.rst b/doc/source/reference/credits.rst index c4d203323..81fb08b14 100644 --- a/doc/source/reference/credits.rst +++ b/doc/source/reference/credits.rst @@ -331,6 +331,7 @@ Tommy Waltmann * Reformat static structure factor tests. * ``DiffractionPattern`` now raises an error when used with non-cubic boxes. * Implement ``StaticStructureFactorDebye`` for 2D systems. +* Add support for compilation with the C++17 standard. Maya Martirossyan diff --git a/doc/source/reference/freud.bib b/doc/source/reference/freud.bib index 7b6be51a9..cface03bf 100644 --- a/doc/source/reference/freud.bib +++ b/doc/source/reference/freud.bib @@ -258,3 +258,16 @@ @article{Teich2019 title = {Identity crisis in alchemical space drives the entropic colloidal glass transition}, url = {https://doi.org/10.1038/s41467-018-07977-2} } + +@article{Wieder2012, + author = {Thomas Wieder}, + issn = {1927-5307}, + issue = {4}, + journal = {Journal of Mathematical and Computational Sciences}, + year = {2012}, + volume = {2}, + pages = {1086-1090}, + publisher = {SCIK Publishing Corporation}, + title = {The Debye Scattering Formula in n Dimensions}, + url = {http://www.scik.org/index.php/jmcs/article/viewFile/263/120} +} diff --git a/freud/diffraction.pyx b/freud/diffraction.pyx index b65533220..671498785 100644 --- a/freud/diffraction.pyx +++ b/freud/diffraction.pyx @@ -98,15 +98,14 @@ cdef class StaticStructureFactorDebye(_StaticStructureFactor): .. note:: - For 2D systems freud uses the bessel function :math:`J_0` instead of the - :math:`\text{sinc}` function in the equation above. See this `link - `__ - for more information. For users wishing to calculate the structure - factor of quasi 2D systems (i.e. a 2D simulation is used to model a real - system such as particles on a 2D interface or similar) the 3D - formula should be used. In these cases users should use a 3D box with - its longest dimension being in the z-direction and particle positions of - the form :math:`(x, y, 0)`. + For 2D systems freud uses the Bessel function :math:`J_0` instead of the + :math:`\text{sinc}` function in the equation above. See + :cite:`Wieder2012` for more information. For users wishing to calculate + the structure factor of quasi 2D systems (i.e. a 2D simulation is used + to model a real system such as particles on a 2D interface or similar) + the 3D formula should be used. In these cases users should use a 3D box + with its longest dimension being in the z-direction and particle + positions of the form :math:`(x, y, 0)`. This implementation uses an evenly spaced number of :math:`k` points between `k_min`` and ``k_max``. If ``k_min`` is set to 0 (the default behavior), the From bd1950b4eae2f147ff03c4753ca0605208483f98 Mon Sep 17 00:00:00 2001 From: Tommy Waltmann Date: Thu, 21 Jul 2022 12:52:36 -0400 Subject: [PATCH 07/10] fix compile error --- cpp/diffraction/StaticStructureFactorDebye.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpp/diffraction/StaticStructureFactorDebye.cc b/cpp/diffraction/StaticStructureFactorDebye.cc index fdf341004..3abbe31dd 100644 --- a/cpp/diffraction/StaticStructureFactorDebye.cc +++ b/cpp/diffraction/StaticStructureFactorDebye.cc @@ -4,6 +4,7 @@ #ifdef __clang__ #include #endif +#include #include #include #include @@ -86,7 +87,7 @@ void StaticStructureFactorDebye::accumulate(const freud::locality::NeighborQuery // floating point precision errors can cause k to be // slightly negative, and make evaluating the cylindrical // bessel function impossible. - auto abs_k = std::max(0, k); + auto abs_k = std::max(float(0.0), k); #ifdef __clang__ // clang doesn't support the special math functions in From 93f2555f1dc26267020603fc38d2e0625cd7b8fb Mon Sep 17 00:00:00 2001 From: Tommy Waltmann Date: Thu, 21 Jul 2022 12:57:43 -0400 Subject: [PATCH 08/10] update boolean condition --- .github/workflows/build_wheels.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 492970071..b6ec63bee 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -23,7 +23,7 @@ jobs: build_wheels: name: Build wheel for ${{ matrix.os }}, Python ${{ matrix.pyver }} runs-on: ${{ matrix.os }} - if: ${{ contains(github.event.pull_request.labels.*.name, 'build_wheels') || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/next' }} + if: ${{ contains(github.event.pull_request.labels.*.name, 'build_wheels') || github.event_name != 'pull_request' }} strategy: matrix: os: [ubuntu-20.04, macos-12] #, windows-2019] @@ -70,7 +70,7 @@ jobs: build_sdist: name: Build source distribution runs-on: ubuntu-latest - if: ${{ contains(github.event.pull_request.labels.*.name, 'build_wheels') || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/next' }} + if: ${{ contains(github.event.pull_request.labels.*.name, 'build_wheels') || github.event_name != 'pull_request' }} steps: - uses: actions/checkout@v3.0.2 with: @@ -96,7 +96,7 @@ jobs: name: Publish [PyPI] needs: [build_wheels, build_sdist] runs-on: ubuntu-latest - if: ${{ contains(github.event.pull_request.labels.*.name, 'build_wheels') || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/next' }} + if: ${{ contains(github.event.pull_request.labels.*.name, 'build_wheels') || github.event_name != 'pull_request' }} steps: - name: Download artifacts From 3f751307fd8686682e14c5e4363db85d150c4498 Mon Sep 17 00:00:00 2001 From: tommy-waltmann <53307607+tommy-waltmann@users.noreply.github.com> Date: Mon, 8 Aug 2022 10:08:18 -0400 Subject: [PATCH 09/10] Update doc/source/reference/freud.bib Co-authored-by: Bradley Dice --- doc/source/reference/freud.bib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/reference/freud.bib b/doc/source/reference/freud.bib index cface03bf..485200472 100644 --- a/doc/source/reference/freud.bib +++ b/doc/source/reference/freud.bib @@ -269,5 +269,5 @@ @article{Wieder2012 pages = {1086-1090}, publisher = {SCIK Publishing Corporation}, title = {The Debye Scattering Formula in n Dimensions}, - url = {http://www.scik.org/index.php/jmcs/article/viewFile/263/120} + url = {https://www.scik.org/index.php/jmcs/article/viewFile/263/120} } From 0f5ae60c4899518874e54e441a03f1daf2efbf0c Mon Sep 17 00:00:00 2001 From: Tommy Waltmann Date: Mon, 8 Aug 2022 10:11:18 -0400 Subject: [PATCH 10/10] rename variable --- cpp/diffraction/StaticStructureFactorDebye.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cpp/diffraction/StaticStructureFactorDebye.cc b/cpp/diffraction/StaticStructureFactorDebye.cc index 3abbe31dd..ebb0e55d3 100644 --- a/cpp/diffraction/StaticStructureFactorDebye.cc +++ b/cpp/diffraction/StaticStructureFactorDebye.cc @@ -87,7 +87,7 @@ void StaticStructureFactorDebye::accumulate(const freud::locality::NeighborQuery // floating point precision errors can cause k to be // slightly negative, and make evaluating the cylindrical // bessel function impossible. - auto abs_k = std::max(float(0.0), k); + auto nonnegative_k = std::max(float(0.0), k); #ifdef __clang__ // clang doesn't support the special math functions in @@ -95,9 +95,9 @@ void StaticStructureFactorDebye::accumulate(const freud::locality::NeighborQuery // needed because the other library's implementation is // unique only for complex numbers, otherwise it just tries // to call std::cyl_bessel_j. - S_k += std::real(bessel::cyl_j0(std::complex(abs_k * distance))); + S_k += std::real(bessel::cyl_j0(std::complex(nonnegative_k * distance))); #else - S_k += std::cyl_bessel_j(0, abs_k * distance); + S_k += std::cyl_bessel_j(0, nonnegative_k * distance); #endif } else