Skip to content

Commit

Permalink
Merge pull request #154 from bluescarni/pr/heyoka_updates
Browse files Browse the repository at this point in the history
heyoka updates
  • Loading branch information
bluescarni authored Dec 16, 2023
2 parents 4c7ad8f + e6e94d6 commit 2b8eeb5
Show file tree
Hide file tree
Showing 26 changed files with 95 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gh_actions_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ jobs:
- name: Build
shell: pwsh
run: |
conda install -y python=3.10 git pybind11 numpy cmake 'llvmdev=14.*' tbb-devel tbb astroquery boost-cpp fmt spdlog sleef sympy cloudpickle zlib libzlib 'mppp=1.*' numba
conda install -y python=3.10 git pybind11 numpy cmake 'llvmdev=14.*' tbb-devel tbb astroquery libboost-devel fmt spdlog sleef sympy cloudpickle zlib libzlib 'mppp=1.*' numba
git clone --depth 1 https://github.com/bluescarni/heyoka.git heyoka_cpp
cd heyoka_cpp
mkdir build
Expand Down
21 changes: 21 additions & 0 deletions doc/breaking_changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@
Breaking changes
================

.. _bchanges_4_0_0:

4.0.0
-----

heyoka.py 4 includes several backwards-incompatible changes.

API/behaviour changes
~~~~~~~~~~~~~~~~~~~~~

``propagate_grid()``
^^^^^^^^^^^^^^^^^^^^

The ``propagate_grid()`` methods of the adaptive integrators now require the first element of the
time grid to be equal to the current integrator time. Previously, in case of a difference between the
integrator time and the first grid point, heyoka.py would propagate the state of the system up to the
first grid point with ``propagate_until()``.

If you want to recover the previous behaviour, you will have to invoke manually ``propagate_until(grid[0])``
before invoking ``propagate_grid()``.

.. _bchanges_1_0_0:

1.0.0
Expand Down
5 changes: 5 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ Changelog
Changes
~~~~~~~

- **BREAKING**: the ``propagate_grid()`` methods of the
adaptive integrators now require the first element of the
time grid to be equal to the current integrator time
(`#154 <https://github.com/bluescarni/heyoka.py/pull/154>`__).
This is a :ref:`breaking change <bchanges_4_0_0>`.
- The binary wheels are now built on top of ``manylinux2014``
(`#153 <https://github.com/bluescarni/heyoka.py/pull/153>`__).
- heyoka.py now requires C++20 when building from source
Expand Down
8 changes: 4 additions & 4 deletions doc/notebooks/Long term stability of Trappist-1.ipynb

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions doc/notebooks/Outer Solar System.ipynb

Large diffs are not rendered by default.

32 changes: 24 additions & 8 deletions doc/notebooks/The adaptive integrator.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
{
"data": {
"text/plain": [
"C++ datatype : double\n",
"Tolerance : 2.220446049250313e-16\n",
"High accuracy : false\n",
"Compact mode : false\n",
Expand Down Expand Up @@ -149,6 +150,7 @@
{
"data": {
"text/plain": [
"C++ datatype : double\n",
"Tolerance : 2.220446049250313e-16\n",
"High accuracy : false\n",
"Compact mode : false\n",
Expand Down Expand Up @@ -438,6 +440,7 @@
"Num. of steps: 97\n",
"Current time : 0.0\n",
"\n",
"C++ datatype : double\n",
"Tolerance : 2.220446049250313e-16\n",
"High accuracy : false\n",
"Compact mode : false\n",
Expand Down Expand Up @@ -592,10 +595,11 @@
"data": {
"text/plain": [
"(<taylor_outcome.time_limit: -4294967299>,\n",
" 0.20291845444801257,\n",
" 0.216140019757225,\n",
" 0.2021425243240425,\n",
" 0.21605277478009474,\n",
" 5,\n",
" array([[ 0.05003035, -0.024398 ],\n",
" array([[ 0.05 , 0.025 ],\n",
" [ 0.05003035, -0.024398 ],\n",
" [ 0.04519961, -0.07142727],\n",
" [ 0.03597685, -0.11152037],\n",
" [ 0.02325783, -0.14078016],\n",
Expand All @@ -619,7 +623,7 @@
"\n",
"# Propagate over a time grid from 0 to 1\n",
"# at regular intervals.\n",
"out = ta.propagate_grid(grid = [.1, .2, .3, .4, .5, .6, .7, .8, .9, 1.])\n",
"out = ta.propagate_grid(grid = [0., .1, .2, .3, .4, .5, .6, .7, .8, .9, 1.])\n",
"out"
]
},
Expand Down Expand Up @@ -656,8 +660,8 @@
}
],
"source": [
"# Print the state at t = 0.4 (index 3 in the time grid).\n",
"print(\"State at t = 0.4: {}\".format(out[4][3]))"
"# Print the state at t = 0.4 (index 4 in the time grid).\n",
"print(\"State at t = 0.4: {}\".format(out[4][4]))"
]
},
{
Expand All @@ -667,7 +671,17 @@
"source": [
"As you can see from the screen output above (where we printed the ``out`` variable), the use of ``propagate_grid()`` resulted in 5 integration timesteps being taken. Had we used ``propagate_until()``, we would have needed 10 integration timesteps to obtain the same result.\n",
"\n",
"There are no special requirements on the time values in the grid (apart from the fact that they must be finite and ordered monotonically).\n",
"There are a few requirements on the time values in the grid:\n",
"\n",
"- they must all be finite,\n",
"- they must be ordered monotonically,\n",
"- the first value in the grid must be equal to the current\n",
" time of the integrator.\n",
"\n",
"```{versionchanged} 4.0.0\n",
"\n",
"The requirement on the first value of the time grid.\n",
"```\n",
"\n",
"The ``propagate_grid()`` method\n",
"can be invoked with additional optional keyword arguments:\n",
Expand Down Expand Up @@ -713,6 +727,7 @@
" \n",
" return True\n",
"\n",
"ta.propagate_until(1.1)\n",
"ta.propagate_grid(grid = [1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.],\n",
" max_delta_t = .1, callback = cb);"
]
Expand Down Expand Up @@ -758,6 +773,7 @@
" def pre_hook(self, ta):\n",
" print(\"pre_hook() invoked!\")\n",
"\n",
"ta.propagate_until(1.1)\n",
"ta.propagate_grid(grid = [1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.],\n",
" max_delta_t = .1, callback = cb());"
]
Expand All @@ -779,7 +795,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
"version": "3.10.13"
}
},
"nbformat": 4,
Expand Down
10 changes: 10 additions & 0 deletions heyoka/_test_batch_integrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,12 @@ def test_propagate_grid(self):
dtype=fp_t,
)

ta.propagate_until(grid[0,:])
bres = ta.propagate_grid(grid)

for idx, cur_ta in enumerate(tas):
cur_ta.propagate_until(grid[0, idx]),

sres = [
tas[0].propagate_grid(grid[:, 0]),
tas[1].propagate_grid(grid[:, 1]),
Expand Down Expand Up @@ -740,12 +744,14 @@ def test_propagate_grid(self):
ta.set_time(fp_t(0.0))
ta.state[:] = [x_ic, v_ic]

ta.propagate_until(grid[0,:])
bres = ta.propagate_grid(grid, max_delta_t=[fp_t(1e-3)] * 4)
res = deepcopy(ta.propagate_res)

ta.set_time(fp_t(0.0))
ta.state[:] = [x_ic, v_ic]

ta.propagate_until(grid[0,:])
bres2 = ta.propagate_grid(grid, max_delta_t=fp_t(1e-3))

self.assertTrue(np.all(bres == bres2))
Expand All @@ -762,6 +768,7 @@ def cb(ta):
return True

ta.set_time(fp_t(0.0))
ta.propagate_until(grid[0,:])
ta.propagate_grid(grid, callback=cb)

self.assertTrue(ta.counter > 0)
Expand All @@ -777,6 +784,7 @@ def __call__(_, ta):
cb_inst.orig_id = id(cb_inst)

ta.set_time(fp_t(0.0))
ta.propagate_until(grid[0,:])
ta.propagate_grid(grid, callback=cb_inst)

# Test with a non-callable callback.
Expand All @@ -797,6 +805,7 @@ def __call__(self, ta):
with self.assertRaises(TypeError) as cm:
ta.set_time(fp_t(0.0))
ta.state[:] = [x_ic, v_ic]
ta.propagate_until(grid[0,:])
ta.propagate_grid(grid, callback=broken_cb())
self.assertTrue(
"The call operator of a step callback is expected to return a boolean, but a value of type"
Expand All @@ -813,6 +822,7 @@ def pre_hook(self, ta):

ta.set_time(fp_t(0.0))
ta.state[:] = [x_ic, v_ic]
ta.propagate_until(grid[0,:])
ta.propagate_grid(grid, callback=cb_hook())
self.assertTrue(ta.foo)
delattr(ta, "foo")
4 changes: 2 additions & 2 deletions heyoka/_test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def test_pendulum(self):
self.assertEqual(dyn[1][0], v)
self.assertEqual(dyn[1][1], -2.0 * sin(x))

dyn = model.pendulum(gconst=4.0, l=2.0)
dyn = model.pendulum(gconst=4.0, length=2.0)

self.assertEqual(dyn[0][0], x)
self.assertEqual(dyn[0][1], v)
Expand All @@ -241,7 +241,7 @@ def test_pendulum(self):
),
)

en = model.pendulum_energy(l=2.0, gconst=4.0)
en = model.pendulum_energy(length=2.0, gconst=4.0)

self.assertEqual(
en,
Expand Down
1 change: 1 addition & 0 deletions heyoka/cfunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <Python.h>

#include <heyoka/expression.hpp>
#include <heyoka/kw.hpp>
#include <heyoka/llvm_state.hpp>
#include <heyoka/variable.hpp>

Expand Down
1 change: 1 addition & 0 deletions heyoka/expose_batch_integrators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <pybind11/stl.h>

#include <heyoka/expression.hpp>
#include <heyoka/kw.hpp>
#include <heyoka/llvm_state.hpp>
#include <heyoka/step_callback.hpp>
#include <heyoka/taylor.hpp>
Expand Down
1 change: 1 addition & 0 deletions heyoka/expose_expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <pybind11/stl.h>

#include <heyoka/expression.hpp>
#include <heyoka/kw.hpp>
#include <heyoka/math.hpp>

#if defined(HEYOKA_HAVE_REAL128)
Expand Down
6 changes: 3 additions & 3 deletions heyoka/expose_models.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ auto pendulum_impl(const Op &op, const V &gconst, const V &l)
const auto gval = ex_from_variant(gconst);
const auto lval = ex_from_variant(l);

return op(hy::kw::gconst = gval, hy::kw::l = lval);
return op(hy::kw::gconst = gval, hy::kw::length = lval);
}

// Common logic to expose rotating rf helpers.
Expand Down Expand Up @@ -260,13 +260,13 @@ void expose_models(py::module_ &m)
m.def(
"_model_pendulum",
[](const vex_t &gconst, const vex_t &l) { return detail::pendulum_impl(hy::model::pendulum, gconst, l); },
"gconst"_a.noconvert() = 1., "l"_a.noconvert() = 1.);
"gconst"_a.noconvert() = 1., "length"_a.noconvert() = 1.);
m.def(
"_model_pendulum_energy",
[](const vex_t &gconst, const vex_t &l) {
return detail::pendulum_impl(hy::model::pendulum_energy, gconst, l);
},
"gconst"_a.noconvert() = 1., "l"_a.noconvert() = 1.);
"gconst"_a.noconvert() = 1., "length"_a.noconvert() = 1.);

// Fixed centres.
m.def(
Expand Down
1 change: 1 addition & 0 deletions heyoka/taylor_add_jet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <Python.h>

#include <heyoka/expression.hpp>
#include <heyoka/kw.hpp>
#include <heyoka/llvm_state.hpp>
#include <heyoka/taylor.hpp>

Expand Down
1 change: 1 addition & 0 deletions heyoka/taylor_expose_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#endif

#include <heyoka/callable.hpp>
#include <heyoka/kw.hpp>
#include <heyoka/s11n.hpp>
#include <heyoka/taylor.hpp>

Expand Down
1 change: 1 addition & 0 deletions heyoka/taylor_expose_integrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#endif

#include <heyoka/expression.hpp>
#include <heyoka/kw.hpp>
#include <heyoka/llvm_state.hpp>
#include <heyoka/step_callback.hpp>
#include <heyoka/taylor.hpp>
Expand Down
2 changes: 1 addition & 1 deletion tools/circleci_conda_heyoka_head_310.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge
export deps_dir=$HOME/local
export PATH="$HOME/miniforge/bin:$PATH"
bash miniforge.sh -b -p $HOME/miniforge
mamba create -y -q -p $deps_dir python=3.10 git pybind11 numpy mpmath cmake llvmdev tbb-devel tbb astroquery boost-cpp 'mppp>=0.27' sleef fmt spdlog myst-nb matplotlib sympy scipy pykep cloudpickle 'sphinx=6.*' 'sphinx-book-theme=1.*'
mamba create -y -q -p $deps_dir python=3.10 git pybind11 numpy mpmath cmake llvmdev tbb-devel tbb astroquery libboost-devel 'mppp>=0.27' sleef fmt spdlog myst-nb matplotlib sympy scipy pykep cloudpickle 'sphinx=6.*' 'sphinx-book-theme=1.*'
source activate $deps_dir

export HEYOKA_PY_PROJECT_DIR=`pwd`
Expand Down
2 changes: 1 addition & 1 deletion tools/circleci_conda_heyoka_head_312.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge
export deps_dir=$HOME/local
export PATH="$HOME/miniforge/bin:$PATH"
bash miniforge.sh -b -p $HOME/miniforge
mamba create -y -q -p $deps_dir python=3.12 git pybind11 numpy mpmath cmake llvmdev tbb-devel tbb boost-cpp 'mppp>=0.27' sleef fmt spdlog sympy cloudpickle
mamba create -y -q -p $deps_dir python=3.12 git pybind11 numpy mpmath cmake llvmdev tbb-devel tbb libboost-devel 'mppp>=0.27' sleef fmt spdlog sympy cloudpickle
source activate $deps_dir

# Checkout, build and install heyoka's HEAD.
Expand Down
2 changes: 1 addition & 1 deletion tools/circleci_conda_heyoka_head_39.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge
export deps_dir=$HOME/local
export PATH="$HOME/miniforge/bin:$PATH"
bash miniforge.sh -b -p $HOME/miniforge
mamba create -y -q -p $deps_dir python=3.9 c-compiler cxx-compiler git pybind11 numpy mpmath cmake llvmdev tbb-devel tbb astroquery boost-cpp 'mppp>=0.27' sleef fmt spdlog myst-nb matplotlib sympy scipy pykep cloudpickle 'sphinx=6.*' 'sphinx-book-theme=1.*'
mamba create -y -q -p $deps_dir python=3.9 c-compiler cxx-compiler git pybind11 numpy mpmath cmake llvmdev tbb-devel tbb astroquery libboost-devel 'mppp>=0.27' sleef fmt spdlog myst-nb matplotlib sympy scipy pykep cloudpickle 'sphinx=6.*' 'sphinx-book-theme=1.*'
source activate $deps_dir

export HEYOKA_PY_PROJECT_DIR=`pwd`
Expand Down
2 changes: 1 addition & 1 deletion tools/circleci_conda_heyoka_head_release_310.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge
export deps_dir=$HOME/local
export PATH="$HOME/miniforge/bin:$PATH"
bash miniforge.sh -b -p $HOME/miniforge
mamba create -y -q -p $deps_dir python=3.10 git pybind11 numpy mpmath cmake llvmdev tbb-devel tbb astroquery boost-cpp 'mppp>=0.27' sleef fmt spdlog myst-nb matplotlib sympy scipy pykep cloudpickle 'sphinx=6.*' 'sphinx-book-theme=1.*'
mamba create -y -q -p $deps_dir python=3.10 git pybind11 numpy mpmath cmake llvmdev tbb-devel tbb astroquery libboost-devel 'mppp>=0.27' sleef fmt spdlog myst-nb matplotlib sympy scipy pykep cloudpickle 'sphinx=6.*' 'sphinx-book-theme=1.*'
source activate $deps_dir

export HEYOKA_PY_PROJECT_DIR=`pwd`
Expand Down
2 changes: 1 addition & 1 deletion tools/circleci_ubuntu_arm64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge
export deps_dir=$HOME/local
export PATH="$HOME/miniforge/bin:$PATH"
bash miniforge.sh -b -p $HOME/miniforge
mamba create -y -q -p $deps_dir cxx-compiler c-compiler cmake llvmdev tbb-devel tbb astroquery boost-cpp 'mppp>=0.27' sleef fmt spdlog python=3.10 pybind11 numpy mpmath sympy scipy cloudpickle myst-nb matplotlib 'sphinx=6.*' 'sphinx-book-theme=1.*'
mamba create -y -q -p $deps_dir cxx-compiler c-compiler cmake llvmdev tbb-devel tbb astroquery libboost-devel 'mppp>=0.27' sleef fmt spdlog python=3.10 pybind11 numpy mpmath sympy scipy cloudpickle myst-nb matplotlib 'sphinx=6.*' 'sphinx-book-theme=1.*'
source activate $deps_dir

# Checkout, build and install heyoka's HEAD.
Expand Down
2 changes: 1 addition & 1 deletion tools/gha_conda_asan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export PATH="$HOME/miniconda/bin:$PATH"
bash miniconda.sh -b -p $HOME/miniconda
conda config --add channels conda-forge
conda config --set channel_priority strict
conda create -y -q -p $deps_dir python=3.10 git pybind11 numpy mpmath cmake llvmdev tbb-devel tbb boost-cpp 'mppp>=0.27' sleef fmt spdlog sympy cloudpickle c-compiler cxx-compiler
conda create -y -q -p $deps_dir python=3.10 git pybind11 numpy mpmath cmake llvmdev tbb-devel tbb libboost-devel 'mppp>=0.27' sleef fmt spdlog sympy cloudpickle c-compiler cxx-compiler
source activate $deps_dir

export CXXFLAGS="$CXXFLAGS -fsanitize=address"
Expand Down
2 changes: 1 addition & 1 deletion tools/gha_conda_static.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export PATH="$HOME/miniconda/bin:$PATH"
bash miniconda.sh -b -p $HOME/miniconda
conda config --add channels conda-forge
conda config --set channel_priority strict
conda create -y -q -p $deps_dir python=3.10 git pybind11 numpy mpmath cmake llvmdev tbb-devel tbb boost-cpp 'mppp>=0.27' sleef fmt spdlog sympy cloudpickle c-compiler cxx-compiler numba zlib
conda create -y -q -p $deps_dir python=3.10 git pybind11 numpy mpmath cmake llvmdev tbb-devel tbb libboost-devel 'mppp>=0.27' sleef fmt spdlog sympy cloudpickle c-compiler cxx-compiler numba zlib
source activate $deps_dir

# Checkout, build and install heyoka's HEAD.
Expand Down
2 changes: 1 addition & 1 deletion tools/gha_osx_heyoka_head.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge
export deps_dir=$HOME/local
export PATH="$HOME/miniconda/bin:$PATH"
bash miniconda.sh -b -p $HOME/miniconda
mamba create -y -p $deps_dir python=3.11 c-compiler cxx-compiler git pybind11 numpy cmake llvmdev tbb-devel tbb astroquery boost-cpp sleef fmt spdlog sympy cloudpickle 'mppp=1.*'
mamba create -y -p $deps_dir python=3.11 c-compiler cxx-compiler git pybind11 numpy cmake llvmdev tbb-devel tbb astroquery libboost-devel sleef fmt spdlog sympy cloudpickle 'mppp=1.*'
source activate $deps_dir

# Checkout, build and install heyoka's HEAD.
Expand Down
2 changes: 1 addition & 1 deletion tools/gha_osx_heyoka_head_static.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge
export deps_dir=$HOME/local
export PATH="$HOME/miniconda/bin:$PATH"
bash miniconda.sh -b -p $HOME/miniconda
mamba create -y -p $deps_dir python=3.11 c-compiler cxx-compiler git pybind11 numpy cmake llvmdev tbb-devel tbb astroquery boost-cpp sleef fmt spdlog sympy cloudpickle 'mppp=1.*' numba
mamba create -y -p $deps_dir python=3.11 c-compiler cxx-compiler git pybind11 numpy cmake llvmdev tbb-devel tbb astroquery libboost-devel sleef fmt spdlog sympy cloudpickle 'mppp=1.*' numba
source activate $deps_dir

# Checkout, build and install heyoka's HEAD.
Expand Down
2 changes: 1 addition & 1 deletion tools/gha_osx_heyoka_stable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export PATH="$HOME/miniconda/bin:$PATH"
bash miniconda.sh -b -p $HOME/miniconda
conda create -y -q -p $deps_dir
source activate $deps_dir
mamba install -y python=3.10 pybind11 numpy cmake heyoka boost-cpp
mamba install -y python=3.10 pybind11 numpy cmake heyoka libboost-devel

# Create the build dir and cd into it.
mkdir build
Expand Down
Loading

0 comments on commit 2b8eeb5

Please sign in to comment.