Skip to content
Draft

Bdf2 #128

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
b4738ed
add stub for FVC BDF2
bjodah Dec 7, 2020
e8e0cf1
small baby steps on getting bdf2 working
bjodah Dec 7, 2020
75ae187
tweaks
bjodah Dec 10, 2020
52ec471
colors
bjodah May 17, 2021
28098f4
rhs method on native
bjodah May 17, 2021
574f249
anyode
bjodah May 17, 2021
49a4730
fix rhs
bjodah May 18, 2021
41d71dc
branch master for anyode submodule
bjodah May 19, 2021
f622c45
only append in info in extend_by_integration when possible
bjodah May 20, 2021
b75fc92
expose jac
bjodah May 22, 2021
1911a24
title_info, relax req. on description attr
bjodah May 28, 2021
ee5d79b
make it easier to disable cse in native
bjodah May 30, 2021
ab3d501
bump version
bjodah May 31, 2021
4d69f32
skip notebook: _const_step_size.ipynb
bjodah Jun 1, 2021
3dc9b9d
bump CI image
bjodah Jun 1, 2021
6231257
avoid -e flag during quiet phase
bjodah Jun 1, 2021
892ae32
unsusre about max_invariant_violation formula for negative values?
bjodah Jun 11, 2021
8b18dc5
Lambdify_kw (cse)
bjodah Jun 12, 2021
9a91def
debug print of some cse exprs in native template
bjodah Jun 17, 2021
fe845b9
more specific debug
bjodah Jun 20, 2021
cb2892e
bump version number
bjodah Jun 23, 2021
8fbb669
compile kwargs etc.
bjodah Jun 23, 2021
35dcc86
bump CI image
bjodah Jul 13, 2021
41d3203
update CI config
bjodah Jul 14, 2021
a678dcb
point to newer sym branch
bjodah Jul 14, 2021
827d03d
latest pycompilation?
bjodah Jul 14, 2021
05c4837
deepcopy perhaps?
bjodah Jul 14, 2021
6a02789
Drop opt-in debug statement printing specific cse's in native rhs
bjodah Jul 14, 2021
73666d0
bump anyode
bjodah Jul 29, 2021
69ae520
bump anyode commit
bjodah Aug 3, 2021
96d31c6
stub for neumaier summation in generated code (currently CSEs will in…
bjodah Aug 7, 2021
4fbc2b7
compensated summation
bjodah Aug 7, 2021
0067845
typo
bjodah Aug 7, 2021
112d25e
other method for Neumaier compensation
bjodah Aug 16, 2021
d578444
in the middle of refactoring cse logic in native
bjodah Aug 20, 2021
604b42e
small steps
bjodah Aug 23, 2021
e799f83
continued refactoring
bjodah Aug 26, 2021
7acff63
add subset of symcse
bjodah Aug 30, 2021
5752213
mostly passing
bjodah Aug 30, 2021
895c91e
grab compensated_summation kwarg
bjodah Aug 30, 2021
0895b93
update symcse
bjodah Aug 31, 2021
dcc4ab8
Fix symcse issue
bjodah Aug 31, 2021
a5d9bd0
also test use_cse
bjodah Aug 31, 2021
bd314e6
test with cse on/off
bjodah Sep 1, 2021
e657c1d
fixes in native._base
bjodah Sep 1, 2021
8c4cd35
refactoring
bjodah Sep 2, 2021
253e604
comparison of all GroupwiseCSE configs
bjodah Sep 2, 2021
bd104a6
added summation_cxx
bjodah Sep 7, 2021
87d3edb
compensation: sxx
bjodah Sep 14, 2021
68e5e6c
forgot impl
bjodah Sep 14, 2021
16a9f6d
make groupwise_kw optional
bjodah Dec 6, 2021
f66dcc4
git:// -> https://
bjodah Jan 11, 2022
26c3fc6
scalar ode
bjodah Jan 31, 2022
66dc9e6
sort legend
bjodah Jan 31, 2022
3fbf822
fix last tests for use with GroupwiseCSE
bjodah Jun 8, 2022
ae1fb99
excceded lower_bound -> violated lower_bound
bjodah Jun 14, 2022
ca74a66
added notebook
bjodah Aug 19, 2022
db10d3f
added another notebook
bjodah Aug 20, 2022
b069bad
import Iterable from collections.abc
bjodah Oct 25, 2022
3bd63cb
updates
bjodah Oct 31, 2022
d2d2fe5
Update summation-cxx
bjodah Nov 14, 2022
d840622
update sxx
bjodah Nov 14, 2022
a7c6d23
fix test
bjodah Nov 15, 2022
1ec6b44
run tests for sdist install
bjodah Apr 24, 2024
79e6b08
select all for tests
bjodah Apr 24, 2024
e4e3f16
move flags for compilation
bjodah Apr 24, 2024
936ea69
pass yes-flag to pip-uninstall
bjodah Apr 24, 2024
119d7c5
move nogil
bjodah Apr 24, 2024
0691aed
bump commits
bjodah Apr 24, 2024
e5e6c02
fix cython syntax: except+
bjodah Jan 13, 2025
75674da
Merge branch 'make-sure-anyode-headers-are-distributed' of github.com…
bjodah Jan 14, 2025
dfb97f0
nogil except +
bjodah Jan 14, 2025
477a554
bjodahimg20dot -> triceratops-3:24
bjodah Jan 14, 2025
8e0458f
ci: update paths and env
bjodah Jan 15, 2025
22e6f90
Merge branch 'master' into make-sure-anyode-headers-are-distributed
bjodah Jan 15, 2025
29efeb6
exit on first failed test
bjodah Jan 15, 2025
462df0f
-std=c++11 -> -std=c++20
bjodah Jan 15, 2025
f84f774
Merge branch 'make-sure-anyode-headers-are-distributed' into bdf2
bjodah Jan 15, 2025
b70e529
.so -> EXT_SUFFIX in sysconfig
bjodah Jan 15, 2025
29b19ab
relax .names attribute on Result
bjodah Jan 17, 2025
8847771
error on nan or inf
bjodah Feb 7, 2025
ddd445b
template.cpp.mako
bjodah Feb 7, 2025
f96e25e
bupmy anyode
bjodah Apr 3, 2025
502fc70
bump anyode
bjodah Jul 25, 2025
e511952
bump CI config
bjodah May 5, 2026
60eb3c4
Fix typo
bjodah May 5, 2026
92e17e1
update branch
bjodah May 5, 2026
f84c647
Update boost
bjodah May 5, 2026
31f3538
Bump CI image
bjodah May 5, 2026
6ad6850
Bump AnyODE
bjodah May 5, 2026
67612bd
do without pkg_resources
bjodah May 8, 2026
cd67c0e
drop pkg_resources
bjodah May 10, 2026
fb097eb
Merge branch 'bdf2' of github.com:bjodah/pyodesys into bdf2
bjodah May 10, 2026
def6727
pyodeint for testing
bjodah May 10, 2026
2099f82
fix native src file paths, fix regression in requires impl.
bjodah May 10, 2026
534e066
Implemented and verified against the CI-style installed-package test …
bjodah May 10, 2026
eb15977
bump dep reqs
bjodah May 10, 2026
731ae95
bump pyodint req
bjodah May 10, 2026
f7cb6d6
ci: add -DNDEBUG to CXXFLAGS to disable Boost uBLAS type checks
bjodah May 10, 2026
3b37b2e
tests: use first_step=1e-14 for all reduced values in RecoverableErro…
bjodah May 10, 2026
4151b2f
handle flaky test
bjodah May 10, 2026
26053d1
handle imprecise lu factorization in boost's ublas
bjodah May 10, 2026
1c9dde4
typo
bjodah May 10, 2026
ef51190
handle imprecise lu factorization in boost's ublas (NDEBUG needed?)
bjodah May 10, 2026
efd830f
about to release v0.14.6
bjodah May 10, 2026
1ed4b8e
Merge branch 'master' into bdf2
ai-bot-bjodah May 10, 2026
02806a6
Bdf2 (#127)
bjodah May 11, 2026
92a9237
bump "release" version
bjodah May 11, 2026
ea04147
Merge branch 'bdf2' of github.com:bjodah/pyodesys into bdf2
bjodah May 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 22 additions & 17 deletions .ci/run_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,46 @@ if [ -e /etc/profile.d/boost.sh ]; then
export CPATH=$BOOST_ROOT/include
fi
source $(compgen -G "/opt-3/cpython-v3.*-apt-deb/bin/activate")
python -m pip install --cache-dir $CI_WORKSPACE/cache-ci/pip_cache --upgrade-strategy=eager --upgrade cython "git+https://github.com/bjodah/pycompilation@master#egg=pycompilation"
python3 -m pip install --cache-dir $CI_WORKSPACE/cache-ci/pip_cache --upgrade-strategy=eager --upgrade cython "git+https://github.com/bjodah/pycompilation@master#egg=pycompilation"
# REPO_TEMP_DIR="$(mktemp -d)"
# trap 'rm -rf -- "$REPO_TEMP_DIR"' EXIT
# cp -ra . "$REPO_TEMP_DIR/."
# cd "$REPO_TEMP_DIR"

mkdir -p $HOME/.config/pip/
echo -e "[global]\nno-cache-dir = false\ndownload-cache = $CI_WORKSPACE/cache-ci/pip_cache" >$HOME/.config/pip/pip.conf
python -m pip install mako cython
python -m pip install --no-build-isolation "git+https://github.com/bjodah/symcxx#egg=symcxx" "git+https://github.com/bjodah/pysym#egg=pysym" # unofficial backends, symengine is tested in the conda build

echo -e "[global]\nno-cache-dir = false\ndownload-cache = $CI_WORKSPACE/cache-ci/pip_cache" >$HOME/.config/pip/pip.conf # CI_WORKSPACE or pwd?
python3 -m pip install mako cython
python3 -m pip install --no-build-isolation "git+https://github.com/bjodah/symcxx#egg=symcxx" "git+https://github.com/bjodah/pysym#egg=pysym" # unofficial backends, symengine is tested in the conda build
python3 -m pip install "git+https://github.com/bjodah/sym@jun21#egg=sym"


# (cd ./tmp/pycvodes;
SUND_CFLAGS="-isystem $SUNDBASE/include $CFLAGS"
SUND_LDFLAGS="-Wl,--disable-new-dtags -Wl,-rpath,$SUNDBASE/lib -L$SUNDBASE/lib $LDFLAGS"
CFLAGS="$SUND_CFLAGS $CXXFLAGS" CXXFLAGS="$SUND_CFLAGS $CXXFLAGS" LDFLAGS=$SUND_LDFLAGS python -m pip install --no-build-isolation pycvodes
CPLUS_INCLUDE_PATH="$BOOST_ROOT/include" python -m pip install --no-build-isolation "git+https://github.com/bjodah/pyodeint#egg=pyodeint"
python -m pip install --no-build-isolation "git+https://github.com/bjodah/pygslodeiv2#egg=pygslodeiv2"
git clean -xfd # -e tmp/

CFLAGS="$SUND_CFLAGS $CXXFLAGS" CXXFLAGS="$SUND_CFLAGS $CXXFLAGS" LDFLAGS=$SUND_LDFLAGS python3 -m pip install --no-build-isolation "git+https://github.com/bjodah/pycvodes@may21#egg=pycvodes"
python3 -m pip install --no-build-isolation "git+https://github.com/bjodah/pyodeint@sep21#egg=pyodeint"
python3 -m pip install --no-build-isolation "git+https://github.com/bjodah/pygslodeiv2#egg=pygslodeiv2"

python setup.py sdist
PKG_VERSION=$(python setup.py --version)
python3 setup.py sdist
PKG_VERSION=$(python3 setup.py --version)
export PYODESYS_CVODE_FLAGS=$SUND_CFLAGS
export PYODESYS_CVODE_LDFLAGS=$SUND_LDFLAGS
(cd dist/; python -m pip install "$PKG_NAME-$PKG_VERSION.tar.gz[all]"; python -m pytest -v -x --pyargs $PKG_NAME)
python -m pip uninstall --yes $PKG_NAME
python -m pip install -e .[all]
python -m pytest -xv -k test_integrate_chained_robertson pyodesys/tests/test_robertson.py
(cd dist/; python3 -m pip install "$PKG_NAME-$PKG_VERSION.tar.gz[all]"; python3 -m pytest -v -x --pyargs $PKG_NAME)
python3 -m pip uninstall --yes $PKG_NAME
python3 -m pip install -e .[all]
python3 -m pytest -xv -k test_integrate_chained_robertson pyodesys/tests/test_robertson.py
export PYTHONHASHSEED=$(python3 -c "import random; print(random.randint(1,2**32-1))")
PYTHON="python -R" ./scripts/run_tests.sh --cov $PKG_NAME --cov-report html
PYTHON="python3 -R" ./scripts/run_tests.sh --cov $PKG_NAME --cov-report html

( export PYTHONPATH=$(pwd); ./scripts/render_notebooks.sh; cd $PKG_NAME/tests; jupyter nbconvert --log-level=INFO --to=html --ExecutePreprocessor.enabled=True --ExecutePreprocessor.timeout=600 *.ipynb )
./scripts/generate_docs.sh

# Test package without any 3rd party libraries that are in extras_require:
python -m pip install virtualenv
python -m virtualenv venv
python3 -m pip install virtualenv
python3 -m virtualenv venv
git archive -o dist/$PKG_NAME-head.zip HEAD # test pip installable zip (symlinks break)
set +u
(source ./venv/bin/activate; cd dist/; python -m pip install pytest $PKG_NAME-head.zip; python -m pytest --pyargs $PKG_NAME)
(source ./venv/bin/activate; cd dist/; python3 -m pip install pytest $PKG_NAME-head.zip; python3 -m pytest --pyargs $PKG_NAME)
4 changes: 2 additions & 2 deletions .woodpecker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ steps:
environment:
CC: gcc-14
CXX: g++-14
CXXFLAGS: -std=c++20
CXXFLAGS: -std=c++20 -DBOOST_UBLAS_TYPE_CHECK=0 -DNDEBUG
OMP_NUM_THREADS: 1
ANYODE_NUM_THREADS: 2
CPLUS_INCLUDE_PATH: /usr/include/suitesparse:/opt-4/boost-1.91.0-release/include
Expand All @@ -48,7 +48,7 @@ steps:
environment:
CC: gcc-14
CXX: g++-14
CXXFLAGS: -std=c++20
CXXFLAGS: -std=c++20 -DBOOST_UBLAS_TYPE_CHECK=0 -DNDEBUG
OMP_NUM_THREADS: 1
ANYODE_NUM_THREADS: 2
CPLUS_INCLUDE_PATH: /usr/include/suitesparse:/opt-4/boost-1.91.0-release/include
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v0.14.6
=======
- Bump dependencies

v0.14.5
=======
- Update setup.yp
Expand Down
156 changes: 101 additions & 55 deletions examples/_const_step_size.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from itertools import product, repeat\n",
Expand All @@ -15,21 +23,19 @@
"from pyodesys import ODESys\n",
"from pyodesys.integrators import (RK4_example_integrator, EulerForward_example_integrator,\n",
" EulerBackward_example_integrator, Trapezoidal_example_integrator,\n",
" Midpoint_example_integrator)\n",
" Midpoint_example_integrator, BDF2FVC_example_integrator)\n",
"from pyodesys.tests.bateman import bateman_full\n",
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"choice = RadioButtons(\n",
" options=['decay', 'sine'],\n",
" options=['sine', 'decay'],\n",
" description='Case:',\n",
" disabled=False\n",
")\n",
Expand All @@ -39,9 +45,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"if choice.value == 'decay':\n",
Expand Down Expand Up @@ -69,57 +73,80 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"def demo(integrator, slc=slice(None)):\n",
" xout1 = np.linspace(x0, xend, n0+1)[slc]\n",
" res1 = odesys.integrate(xout1, y0, p, first_step=xend/n0, integrator=integrator)\n",
"\n",
" fig, axes = plt.subplots(1, 2, figsize=(14, 4))\n",
" fig.suptitle(integrator.__name__)\n",
" res1.plot(ls=('-',), ax=axes[0])\n",
" axes[0].set_title(\"values\")\n",
"\n",
" xplt = np.linspace(xout1[0], xout1[-1])\n",
" yref1 = ref(res1.xout)\n",
" res1.plot(x=xplt, y=ref(xplt), ls=(':',), ax=axes[0])\n",
" res1.plot(y=res1.yout - yref1, ax=axes[1])\n",
" axes[1].set_title(\"errors\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"xout1 = np.linspace(x0, xend, n0 + 1)\n",
"res1 = odesys.integrate(xout1, y0, p, first_step=xend/n0, integrator=EulerForward_example_integrator)\n",
"yref1 = ref(res1.xout)\n",
"fig, axes = plt.subplots(1, 2, figsize=(14, 4))\n",
"res1.plot(ls=('-',), ax=axes[0])\n",
"xplt = np.linspace(x0, xend)\n",
"res1.plot(x=xplt, y=ref(xplt), ls=(':',), ax=axes[0])\n",
"res1.plot(y=res1.yout - yref1, ax=axes[1])"
"demo(EulerForward_example_integrator, slc=slice(0,13))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"demo(BDF2FVC_example_integrator, slc=slice(0,13))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def plot_order_of_convergence(Integrator, nruns=6):\n",
" res, nruns = [], 7\n",
" res = []\n",
" for i in range(nruns):\n",
" n = n0 * 2**i\n",
" x = np.linspace(0, 1, n)\n",
" res.append(odesys.integrate(x, y0, p, integrator=Integrator))\n",
"\n",
" vals = {}\n",
" vals, refs = {}, {}\n",
" for ix, iy in product(range(n0), range(len(y0))):\n",
" vals[ix, iy] = [res[i].yout[ix*(2**i), iy] for i in range(nruns)]\n",
" refs[ix, iy] = [ref(res[i].xout)[ix*(2**i), iy] for i in range(nruns)]\n",
"\n",
" logn = np.log(n0 * 2**np.arange(nruns))\n",
" lgn = np.log10([len(r.xout) for r in res])\n",
" fig, axes = plt.subplots(1, len(y0), figsize=(14, 4))\n",
" fig.suptitle(Integrator.__name__)\n",
" for iy, ax in enumerate(axes):\n",
" for ix in range(1, n0):\n",
" lnabserr = np.log(np.abs(np.array(vals[ix, iy]) - yref1[ix, iy]))\n",
" ax.plot(logn, lnabserr, '.-', c=(ix/n0, 0, 0))\n",
" popt = np.polyfit(logn, lnabserr, 1)\n",
" ax.plot(logn[[0,-1]], np.polyval(popt, logn[[0,-1]]), label='y=%.2f x %+.2f' % tuple(popt))\n",
" ax.legend()"
" lgabserr = np.log10(np.abs(np.array(vals[ix, iy]) - refs[ix, iy]))\n",
" ax.plot(lgn, lgabserr, '.-', c=(ix/n0, 0, 0))\n",
" popt = np.polyfit(lgn, lgabserr, 1)\n",
" ax.plot(lgn[[0,-1]], np.polyval(popt, lgn[[0,-1]]), label='err_y%d(n)=%.2f x %+.2f' % ((iy,)+tuple(popt)))\n",
" ax.legend()\n",
" ax.set_xlabel(r'$\\lg{n_\\mathrm{t}}$')\n",
" ax.set_ylabel(r'$\\lg{|e|}$')\n",
" ax.set_ylim([-13, 2])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"plot_order_of_convergence(EulerForward_example_integrator)"
Expand All @@ -128,10 +155,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"scrolled": true
},
"metadata": {},
"outputs": [],
"source": [
"plot_order_of_convergence(EulerBackward_example_integrator)"
Expand All @@ -140,9 +164,16 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"plot_order_of_convergence(BDF2FVC_example_integrator)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plot_order_of_convergence(Midpoint_example_integrator)"
Expand All @@ -151,9 +182,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"plot_order_of_convergence(Trapezoidal_example_integrator)"
Expand All @@ -162,16 +191,32 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"plot_order_of_convergence(RK4_example_integrator)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"@webio": {
"lastCommId": null,
"lastKernelId": null
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
Expand All @@ -187,16 +232,17 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
"version": "3.8.1+"
},
"name": "_const_step_size.ipynb",
"widgets": {
"state": {
"7d4a5a6f8d584513bb39fffa7cdc282a": {
"views": [
{
"cell_index": 1
}
]
"views": {
"cell_index": [
1
]
}
}
},
"version": "1.2.0"
Expand Down
Loading