Skip to content

Commit

Permalink
Merge pull request #187 from aragilar/support-sundials-v7
Browse files Browse the repository at this point in the history
Support sundials v7
  • Loading branch information
aragilar authored Dec 5, 2024
2 parents 06cc892 + 92bc6e5 commit 82efaee
Show file tree
Hide file tree
Showing 22 changed files with 567 additions and 621 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/test-namespace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,57 +11,57 @@ jobs:
matrix:
include:
#- python-version: "3.7"
# sundials-version: "6.5.0"
# sundials-version: "7.1.1"
# tox-env: py37
# sundials-precision: double
# sundials-index-size: 64
- python-version: "3.8"
sundials-version: "6.5.0"
sundials-version: "7.1.1"
tox-env: py38
sundials-precision: double
sundials-index-size: 64
- python-version: "3.9"
sundials-version: "6.5.0"
sundials-version: "7.1.1"
tox-env: py39
sundials-precision: double
sundials-index-size: 64
- python-version: "3.10"
sundials-version: "6.5.0"
sundials-version: "7.1.1"
tox-env: py310
sundials-precision: double
sundials-index-size: 64
- python-version: "3.11"
sundials-version: "6.5.0"
sundials-version: "7.1.1"
tox-env: py311
sundials-precision: double
sundials-index-size: 64
- python-version: "3.12"
sundials-version: "6.5.0"
sundials-version: "7.1.1"
tox-env: py312
sundials-precision: double
sundials-index-size: 64
- python-version: "3.11"
sundials-version: "6.5.0"
sundials-version: "7.1.1"
tox-env: check-manifest
sundials-precision: double
sundials-index-size: 64
#- python-version: "3.11"
# sundials-version: "6.5.0"
# sundials-version: "7.1.1"
# tox-env: checkreadme
# sundials-precision: double
# sundials-index-size: 64
- python-version: "3.11"
sundials-version: "6.5.0"
sundials-version: "7.1.1"
tox-env: py311
sundials-precision: double
sundials-index-size: 32
#- python-version: "3.11"
# sundials-version: "6.5.0"
# sundials-version: "7.1.1"
# tox-env: py311
# sundials-precision: single
# sundials-index-size: 64
- python-version: "3.11"
sundials-version: "6.5.0"
sundials-version: "7.1.1"
tox-env: py311
sundials-precision: extended
sundials-index-size: 64
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/test-overall.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,62 +11,62 @@ jobs:
matrix:
include:
#- python-version: "3.7"
# sundials-version: "6.5.0"
# sundials-version: "7.1.1"
# tox-env: py37-test
# sundials-precision: double
# sundials-index-size: 64
- python-version: "3.8"
sundials-version: "6.5.0"
sundials-version: "7.1.1"
tox-env: py38-test
sundials-precision: double
sundials-index-size: 64
- python-version: "3.9"
sundials-version: "6.5.0"
sundials-version: "7.1.1"
tox-env: py39-test
sundials-precision: double
sundials-index-size: 64
- python-version: "3.10"
sundials-version: "6.5.0"
sundials-version: "7.1.1"
tox-env: py310-test
sundials-precision: double
sundials-index-size: 64
- python-version: "3.11"
sundials-version: "6.5.0"
sundials-version: "7.1.1"
tox-env: py311-test
sundials-precision: double
sundials-index-size: 64
- python-version: "3.12"
sundials-version: "6.5.0"
sundials-version: "7.1.1"
tox-env: py312-test
sundials-precision: double
sundials-index-size: 64
- python-version: "3.11"
sundials-version: "6.5.0"
sundials-version: "7.1.1"
tox-env: apidocs
sundials-precision: double
sundials-index-size: 64
- python-version: "3.11"
sundials-version: "6.5.0"
sundials-version: "7.1.1"
tox-env: docs
sundials-precision: double
sundials-index-size: 64
- python-version: "3.11"
sundials-version: "6.5.0"
sundials-version: "7.1.1"
tox-env: py311-test
sundials-precision: double
sundials-index-size: 32
#- python-version: "3.11"
# sundials-version: "6.5.0"
# sundials-version: "7.1.1"
# tox-env: py311-test
# sundials-precision: single
# sundials-index-size: 64
- python-version: "3.11"
sundials-version: "6.5.0"
sundials-version: "7.1.1"
tox-env: py311-test
sundials-precision: extended
sundials-index-size: 64
#- python-version: "3.12"
# sundials-version: "6.5.0"
# sundials-version: "7.1.1"
# tox-env: py312-notebooks
# sundials-precision: double
# sundials-index-size: 64
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/test-sundials.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,57 +11,57 @@ jobs:
matrix:
include:
#- python-version: "3.7"
# sundials-version: "6.5.0"
# sundials-version: "7.1.1"
# tox-env: py37
# sundials-precision: double
# sundials-index-size: 64
- python-version: "3.8"
sundials-version: "6.5.0"
sundials-version: "7.1.1"
tox-env: py38
sundials-precision: double
sundials-index-size: 64
- python-version: "3.9"
sundials-version: "6.5.0"
sundials-version: "7.1.1"
tox-env: py39
sundials-precision: double
sundials-index-size: 64
- python-version: "3.10"
sundials-version: "6.5.0"
sundials-version: "7.1.1"
tox-env: py310
sundials-precision: double
sundials-index-size: 64
- python-version: "3.11"
sundials-version: "6.5.0"
sundials-version: "7.1.1"
tox-env: py311
sundials-precision: double
sundials-index-size: 64
- python-version: "3.12"
sundials-version: "6.5.0"
sundials-version: "7.1.1"
tox-env: py312
sundials-precision: double
sundials-index-size: 64
- python-version: "3.11"
sundials-version: "6.5.0"
sundials-version: "7.1.1"
tox-env: check-manifest
sundials-precision: double
sundials-index-size: 64
#- python-version: "3.11"
# sundials-version: "6.5.0"
# sundials-version: "7.1.1"
# tox-env: checkreadme
# sundials-precision: double
# sundials-index-size: 64
- python-version: "3.11"
sundials-version: "6.5.0"
sundials-version: "7.1.1"
tox-env: py311
sundials-precision: double
sundials-index-size: 32
#- python-version: "3.11"
# sundials-version: "6.5.0"
# sundials-version: "7.1.1"
# tox-env: py311
# sundials-precision: single
# sundials-index-size: 64
- python-version: "3.11"
sundials-version: "6.5.0"
sundials-version: "7.1.1"
tox-env: py311
sundials-precision: extended
sundials-index-size: 64
Expand Down
41 changes: 35 additions & 6 deletions packages/scikits-odes-sundials/setup_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,21 @@ def get_sundials_config_pxi(include_dirs, dist):
else:
has_lapack = False

if check_macro_true(
config_cmd,
"SUNDIALS_MPI_ENABLED", headers=[SUNDIALS_CONFIG_H],
include_dirs=include_dirs,
):
SUNDIALS_MPI_ENABLED = True
else:
SUNDIALS_MPI_ENABLED = False


cfg = dict(
float_type = SUNDIALS_FLOAT_TYPE,
index_size = SUNDIALS_INDEX_SIZE,
has_lapack = has_lapack,
with_mpi = SUNDIALS_MPI_ENABLED,
)

return write_pxi(join(BASE_PATH, "sundials_config.pxi"), dict(
Expand Down Expand Up @@ -207,15 +218,15 @@ def _get_cython_ext(self):
CVODE_LIBRARY_DIRS.append(str(d))
for d in cvode_pkgconf.get('include_dirs', []):
CVODE_INCLUDE_DIRS.append(str(d))
for lib in cvode_pkgconf.get('include_dirs', []):
for lib in cvode_pkgconf.get('libraries', []):
CVODE_LIBRARIES.append(str(lib))

ida_pkgconf = pkgconfig.parse(PKGCONFIG_IDA)
for d in ida_pkgconf.get('library_dirs', []):
IDA_LIBRARY_DIRS.append(str(d))
for d in ida_pkgconf.get('include_dirs', []):
IDA_INCLUDE_DIRS.append(str(d))
for lib in ida_pkgconf.get('include_dirs', []):
for lib in ida_pkgconf.get('libraries', []):
IDA_LIBRARIES.append(str(lib))


Expand All @@ -224,15 +235,15 @@ def _get_cython_ext(self):
CVODES_LIBRARY_DIRS.append(str(d))
for d in cvodes_pkgconf.get('include_dirs', []):
CVODES_INCLUDE_DIRS.append(str(d))
for lib in cvodes_pkgconf.get('include_dirs', []):
for lib in cvodes_pkgconf.get('libraries', []):
CVODES_LIBRARIES.append(str(lib))

idas_pkgconf = pkgconfig.parse(PKGCONFIG_IDAS)
for d in idas_pkgconf.get('library_dirs', []):
IDAS_LIBRARY_DIRS.append(str(d))
for d in idas_pkgconf.get('include_dirs', []):
IDAS_INCLUDE_DIRS.append(str(d))
for lib in idas_pkgconf.get('include_dirs', []):
for lib in idas_pkgconf.get('libraries', []):
IDAS_LIBRARIES.append(str(lib))
except (EnvironmentError, PackageNotFoundError) as e:
pass
Expand All @@ -242,9 +253,27 @@ def _get_cython_ext(self):
sundials_pxi, cfg = get_sundials_config_pxi(SUNDIALS_INCLUDE_DIRS,
self.distribution)

has_lapack = cfg['has_lapack']

if not SUNDIALS_LIBRARIES:
has_lapack = cfg['has_lapack']
with_mpi = cfg["with_mpi"]
if with_mpi:
# use pkgconfig to find mpi
try:
import pkgconfig
from pkgconfig.pkgconfig import PackageNotFoundError
try:
mpi_pkgconf = pkgconfig.parse("mpi")
for d in mpi_pkgconf.get('library_dirs', []):
SUNDIALS_LIBRARY_DIRS.append(str(d))
for d in mpi_pkgconf.get('include_dirs', []):
SUNDIALS_INCLUDE_DIRS.append(str(d))
for lib in mpi_pkgconf.get('libraries', []):
SUNDIALS_LIBRARIES.append(str(lib))
except (EnvironmentError, PackageNotFoundError) as e:
pass
except ImportError:
info("pkgconfig module not found, using preset paths")

# This is where to put N_vector codes (currently only serial is
# supported)
SUNDIALS_LIBRARIES.append('sundials_nvecserial')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .c_sundials cimport *
from libc.stdio cimport FILE


cdef extern from "cvode/cvode.h":
# lmm
enum: CV_ADAMS # 1
Expand Down Expand Up @@ -123,6 +124,7 @@ cdef extern from "cvode/cvode.h":
char *CVodeGetReturnFlagName(long int flag)
void CVodeFree(void **cvode_mem)


cdef extern from "cvode/cvode_ls.h":
#CVDLS return values
enum: CVLS_SUCCESS # 0
Expand Down Expand Up @@ -186,15 +188,6 @@ cdef extern from "cvode/cvode_ls.h":
int CVodeGetLastLinFlag(void *cvode_mem, long int *flag)
char *CVodeGetLinReturnFlagName(long int flag)

cdef extern from "cvode/cvode_direct.h":
ctypedef CVLsJacFn CVodeJacFn

int CVodeSetJacFn(void *cvode_mem, CVodeJacFn jac)
int CVodeGetWorkSpace(void *cvode_mem, long int *lenrwLS, long int *leniwLS)
int CVodeGetNumJacEvals(void *cvode_mem, long int *njevals)
int CVodeGetNumRhsEvals(void *cvode_mem, long int *nfevalsLS)
int CVodeGetLastFlag(void *cvode_mem, long int *flag)
char *CVodeGetReturnFlagName(long int flag)

cdef extern from "cvode/cvode_bandpre.h":
int CVBandPrecInit(void *cvode_mem, sunindextype N, sunindextype mu,
Expand All @@ -203,6 +196,7 @@ cdef extern from "cvode/cvode_bandpre.h":
long int *leniwLS)
int CVBandPrecGetNumRhsEvals(void *cvode_mem, long int *nfevalsBP)


cdef extern from "cvode/cvode_diag.h":
# CVDIAG return values
enum: CVDIAG_SUCCESS # 0
Expand All @@ -221,6 +215,7 @@ cdef extern from "cvode/cvode_diag.h":
int CVDiagGetLastFlag(void *cvode_mem, long int *flag)
char *CVDiagGetReturnFlagName(long int flag)


cdef extern from "cvode/cvode_bbdpre.h":
ctypedef int (*CVLocalFn)(sunindextype Nlocal, sunrealtype t, N_Vector y,
N_Vector g, void *user_data)
Expand All @@ -236,27 +231,3 @@ cdef extern from "cvode/cvode_bbdpre.h":
int CVBBDPrecGetWorkSpace(void *cvode_mem, long int *lenrwBBDP,
long int *leniwBBDP)
int CVBBDPrecGetNumGfnEvals(void *cvode_mem, long int *ngevalsBBDP)

cdef extern from "cvode/cvode_spils.h":

ctypedef CVLsPrecSetupFn CVodePrecSetupFn
ctypedef CVLsPrecSolveFn CVodePrecSolveFn
ctypedef CVLsJacTimesSetupFn CVodeJacTimesSetupFn
ctypedef CVLsJacTimesVecFn CVodeJacTimesVecFn

int CVodeSetEpsLin(void *cvode_mem, sunrealtype eplifac)
int CVodeSetPreconditioner(void *cvode_mem, CVodePrecSetupFn pset,
CVodePrecSolveFn psolve)
int CVodeSetJacTimes(void *cvode_mem, CVodeJacTimesSetupFn jtsetup,
CVodeJacTimesVecFn jtimes)

int CVodeGetWorkSpace(void *cvode_mem, long int *lenrwLS, long int *leniwLS)
int CVodeGetNumPrecEvals(void *cvode_mem, long int *npevals)
int CVodeGetNumPrecSolves(void *cvode_mem, long int *npsolves)
int CVodeGetNumLinIters(void *cvode_mem, long int *nliters)
int CVodeGetNumConvFails(void *cvode_mem, long int *nlcfails)
int CVodeGetNumJTSetupEvals(void *cvode_mem, long int *njtsetups)
int CVodeGetNumJtimesEvals(void *cvode_mem, long int *njvevals)
int CVodeGetNumRhsEvals(void *cvode_mem, long int *nfevalsLS)
int CVodeGetLastFlag(void *cvode_mem, long int *flag)
char *CVodeGetReturnFlagName(long int flag)
Loading

0 comments on commit 82efaee

Please sign in to comment.