Skip to content

Commit

Permalink
#664 merge KLU branch
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinsulzer committed Oct 25, 2019
2 parents 0a7d5f7 + 7729dd6 commit 8e74cbc
Show file tree
Hide file tree
Showing 23 changed files with 2,353 additions and 22 deletions.
3 changes: 3 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Visual Studio format
BasedOnStyle: LLVM
BreakBeforeBraces: Allman
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,16 @@ pyvenv.cfg
# sundials
sundials
sundials4
SuiteSparse
SuiteSparse/.gitignore

# third party
third-party

# cmakefiles
CMakeFiles
Makefile
*.cmake
cmake_install.cmake
*.so
*.json


third-party/pybind11
Empty file added .gitmodules
Empty file.
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ addons:
- libopenblas-dev
- liblapack-dev
- graphviz
- libsuitesparse-dev

matrix:
include:
Expand All @@ -30,10 +31,12 @@ matrix:
- liblapack-dev
- graphviz
- python3.6-dev
- libsuitesparse-dev
env:
- PYBAMM_UNIT=true
- PYBAMM_EXAMPLES=true
- PYBAMM_SCIKITS_ODES=true
- PYBAMM_KLU=true
- python: "3.7"
addons:
apt:
Expand All @@ -46,10 +49,12 @@ matrix:
- liblapack-dev
- graphviz
- python3.7-dev
- libsuitesparse-dev
env:
- PYBAMM_UNIT=true
- PYBAMM_EXAMPLES=true
- PYBAMM_SCIKITS_ODES=true
- PYBAMM_KLU=true
if: type != cron
# Unit testing on Python3.7 on OS/X and Ubuntu
- os: osx
Expand All @@ -70,6 +75,7 @@ matrix:
- liblapack-dev
- graphviz
- python3.7-dev
- libsuitesparse-dev
env:
- PYBAMM_UNIT=true
- PYBAMM_SCIKITS_ODES=true
Expand All @@ -86,6 +92,7 @@ matrix:
- liblapack-dev
- graphviz
- python3.7-dev
- libsuitesparse-dev
env:
- PYBAMM_UNIT=true
if: type != cron
Expand All @@ -102,9 +109,11 @@ matrix:
- liblapack-dev
- graphviz
- python3.7-dev
- libsuitesparse-dev
env:
- PYBAMM_COVER=true
- PYBAMM_SCIKITS_ODES=true
- PYBAMM_KLU=true
if: type != cron
- python: "3.7"
addons:
Expand All @@ -118,6 +127,7 @@ matrix:
- liblapack-dev
- graphviz
- python3.7-dev
- libsuitesparse-dev
env:
- PYBAMM_DOCS=true
if: type != cron
Expand All @@ -133,6 +143,7 @@ matrix:
- liblapack-dev
- graphviz
- python3.7-dev
- libsuitesparse-dev
env:
- PYBAMM_STYLE=true
if: type != cron
Expand All @@ -149,10 +160,12 @@ matrix:
- liblapack-dev
- graphviz
- python3.7-dev
- libsuitesparse-dev
env:
- PYBAMM_UNIT=true
- PYBAMM_EXAMPLES=true
- PYBAMM_SCIKITS_ODES=true
- PYBAMM_KLU=true
if: type == cron

# Install graphviz for macs
Expand Down Expand Up @@ -190,6 +203,7 @@ install:
- if [[ $PYBAMM_STYLE == true || $PYBAMM_EXAMPLES ]]; then pip install -e .[dev]; fi;
- if [[ $PYBAMM_COVER == true ]]; then pip install coverage codecov; fi;
- if [[ $PYBAMM_SCIKITS_ODES == true ]]; then source scripts/install_scikits_odes.sh; fi;
- if [[ $PYBAMM_KLU == true ]]; then source scripts/install_sundials_4.1.0.sh; fi;

before_script:
- python --version
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Add interface to CasADi solver
- Add option to use CasADi's Algorithmic Differentiation framework to calculate Jacobians
- Added interface (via pybind11) to sundials with the KLU sparse linear solver ([#633] https://github.com/pybamm-team/PyBaMM/pull/657)
- Add method to evaluate parameters more easily ([#669](https://github.com/pybamm-team/PyBaMM/pull/669))
- Add `Jacobian` class to reuse known Jacobians of expressions ([#665](https://github.com/pybamm-team/PyBaMM/pull/670))
- Add `Interpolant` class to interpolate experimental data (e.g. OCP curves) ([#661](https://github.com/pybamm-team/PyBaMM/pull/661))
Expand Down Expand Up @@ -66,4 +67,5 @@ with the following optional physics:
- Scipy
- Scikits ODE
- Scikits DAE
- Sundials (with KLU sparse solver)
- Algebraic (root-finding)
28 changes: 28 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
cmake_minimum_required(VERSION 3.10)
project(klu)

set (CMAKE_CXX_STANDARD 11)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

add_subdirectory(third-party/pybind11)
pybind11_add_module(klu pybamm/solvers/c_solvers/klu.cpp)

# Sundials
set(SUNDIALS_INCLUDE "sundials4/include")
TARGET_INCLUDE_DIRECTORIES(klu PRIVATE ${SUNDIALS_INCLUDE})

find_library(SUNMATSPARSE sundials_sunmatrixsparse PATHS "sundials4/lib" NO_DEFAULT_PATH)
find_library(IDA sundials_ida PATHS "sundials4/lib" NO_DEFAULT_PATH)
find_library(NVECTOR sundials_nvecserial PATHS "sundials4/lib" NO_DEFAULT_PATH)
find_library(SUNKLU sundials_sunlinsolklu PATHS "sundials4/lib" NO_DEFAULT_PATH)
TARGET_LINK_LIBRARIES(klu PRIVATE ${SUNMATSPARSE} ${IDA} ${NVECTOR} ${SUNKLU})

# System libraries
find_library(RT rt)
TARGET_LINK_LIBRARIES(klu PRIVATE ${RT})

# link suitesparse
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR})
find_package(SuiteSparse OPTIONAL_COMPONENTS KLU AMD COLAMD BTF)
include_directories(${SuiteSparse_INCLUDE_DIRS})
target_link_libraries(klu PRIVATE ${SuiteSparse_LIBRARIES})
Loading

0 comments on commit 8e74cbc

Please sign in to comment.