diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 2759fa0b6..c989ce3a5 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -5,11 +5,14 @@ on: # twice when the pull request source branch is in the same repository. push: branches: - - "maint" - "master" + - "next" tags: - "v*" + pull_request: + types: [opened, labeled, reopened, synchronize] + # Trigger on request. workflow_dispatch: @@ -20,9 +23,10 @@ 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.event_name != 'pull_request' }} 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: @@ -45,6 +49,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" @@ -65,6 +70,7 @@ jobs: build_sdist: name: Build source distribution runs-on: ubuntu-latest + if: ${{ contains(github.event.pull_request.labels.*.name, 'build_wheels') || github.event_name != 'pull_request' }} steps: - uses: actions/checkout@v3.0.2 with: @@ -90,6 +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.event_name != 'pull_request' }} 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: 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..ebb0e55d3 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::abs(k); + auto nonnegative_k = std::max(float(0.0), k); #ifdef __clang__ // clang doesn't support the special math functions in @@ -94,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 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..485200472 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 = {https://www.scik.org/index.php/jmcs/article/viewFile/263/120} +} 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. * * */ 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