Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some ci/test issues, test sundials 7.x in CI #108

Merged
merged 5 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 9 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ jobs:
linux:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sundials_version: [2.7.0, 3.2.0]
sundials_version: [2.7.0, 3.2.0, 7.1.1]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9.x'
- name: Setup Python
Expand All @@ -26,18 +27,18 @@ jobs:
- name: Install superlu
run: |
cd /tmp
curl -fSsL https://portal.nersc.gov/project/sparse/superlu/superlu_mt_3.1.tar.gz | tar xz
cd SuperLU_MT_3.1
make CFLAGS="-O2 -fPIC -fopenmp" BLASLIB="-lblas" PLAT="_OPENMP" MPLIB="-fopenmp" lib -j1
sudo cp -v ./lib/libsuperlu_mt_OPENMP.a /usr/lib
sudo cp -v ./SRC/*.h /usr/include
curl -fSsL https://github.com/xiaoyeli/superlu_mt/archive/refs/tags/v4.0.1.tar.gz | tar xz
cd superlu_mt-4.0.1
cmake -Denable_examples=OFF -Denable_tests=OFF -DPLAT="_OPENMP" -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=lib -DSUPERLUMT_INSTALL_INCLUDEDIR=include .
make -j4
sudo make install
- name: Install sundials
run: |
git clone --depth 1 -b v${{ matrix.sundials_version }} https://github.com/LLNL/sundials /tmp/sundials
cd /tmp/sundials
if test "${{ matrix.sundials_version }}" = "2.7.0"; then echo "target_link_libraries(sundials_idas_shared lapack blas superlu_mt_OPENMP)" >> src/idas/CMakeLists.txt; echo "target_link_libraries(sundials_kinsol_shared lapack blas superlu_mt_OPENMP)" >> src/kinsol/CMakeLists.txt; fi
mkdir build && cd build
cmake -LAH -DSUPERLUMT_BLAS_LIBRARIES=blas -DSUPERLUMT_LIBRARIES=blas -DSUPERLUMT_INCLUDE_DIR=/usr/include -DSUPERLUMT_LIBRARY=/usr/lib/libsuperlu_mt_OPENMP.a -DSUPERLUMT_THREAD_TYPE=OpenMP -DCMAKE_INSTALL_PREFIX=/usr -DSUPERLUMT_ENABLE=ON -DLAPACK_ENABLE=ON -DEXAMPLES_ENABLE=OFF -DEXAMPLES_ENABLE_C=OFF -DBUILD_STATIC_LIBS=OFF ..
cmake -LAH -DSUPERLUMT_BLAS_LIBRARIES=blas -DSUPERLUMT_LIBRARIES=blas -DSUPERLUMT_INCLUDE_DIR=/usr/include -DSUPERLUMT_LIBRARY=/usr/lib/libsuperlu_mt_OPENMP.a -DSUPERLUMT_THREAD_TYPE=OpenMP -DCMAKE_INSTALL_PREFIX=/usr -DSUPERLUMT_ENABLE=ON -DLAPACK_ENABLE=ON -DEXAMPLES_ENABLE=OFF -DEXAMPLES_ENABLE_C=OFF -DBUILD_STATIC_LIBS=OFF -DSUNDIALS_INDEX_SIZE=32 ..
make -j4
sudo make install
- name: Build
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
--- CHANGELOG ---

--- Assimulo-3.5.x ---
* Added get_sundials_version function (import from assimulo.solvers.sundials).

--- Assimulo-3.5.2 ---
* Allow to build without distutils for Python>=3.12 support

Expand Down
5 changes: 5 additions & 0 deletions src/solvers/sundials.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ include "../lib/sundials_constants.pxi" #Sundials related constants
include "../lib/sundials_callbacks.pxi"
include "../lib/sundials_callbacks_ida_cvode.pxi"

_sundials_version = SUNDIALS_VERSION

cpdef get_sundials_version():
"""Return SUNDIALS version as tuple."""
return _sundials_version

cdef class IDA(Implicit_ODE):
"""
Expand Down
8 changes: 7 additions & 1 deletion tests/solvers/test_sundials.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import nose
from assimulo import testattr
from assimulo.solvers.sundials import CVode, IDA, CVodeError
from assimulo.solvers.sundials import CVode, IDA, CVodeError, get_sundials_version
from assimulo.problem import Explicit_Problem
from assimulo.problem import Implicit_Problem
from assimulo.exception import AssimuloException, TimeLimitExceeded, TerminateSimulation
Expand Down Expand Up @@ -1569,3 +1569,9 @@ def test_pbar(self):

nose.tools.assert_almost_equal(imp_sim.pbar[0], 1000.00000,4)
nose.tools.assert_almost_equal(imp_sim.pbar[1], 100.000000,4)

@testattr(stddist = True)
def test_get_sundials_version(self):
"""Test fetching the sundials version."""
version = get_sundials_version()
assert isinstance(version, tuple), "Expected version to be a tuple"
4 changes: 3 additions & 1 deletion tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from assimulo import testattr
from assimulo.exception import AssimuloException
from assimulo.examples import *
from assimulo.solvers.sundials import get_sundials_version

class Test_Examples:
@testattr(stddist = True)
Expand Down Expand Up @@ -195,7 +196,8 @@ def test_mech_system_pendulum3(self):
"""
This tests the class Mechanical_system together with ind3 and ida
"""
mech_system_pendulum.run_example('ind3',with_plots=False,with_test=True)
if get_sundials_version() < (4,):
mech_system_pendulum.run_example('ind3',with_plots=False,with_test=True)

@testattr(stddist = True)
def test_mech_system_pendulum_ggl2(self):
Expand Down