This README provides a step-by-step guide to install Sundials from source and set up the scikits.odes Python package with Sundials support.
Ensure the following tools and libraries are installed on your system:
build-essentialcmakegitpython3andpipnumpyandscipy(Python packages)
-
Clone the Sundials Repository
git clone https://github.com/LLNL/sundials.git /home/ian/sundials/source
-
Create a Build Directory
mkdir -p /home/ian/sundials/build cd /home/ian/sundials/build -
Configure the Build with CMake
cmake -DCMAKE_INSTALL_PREFIX=/home/ian/sundials/install -DBUILD_SHARED_LIBS=ON -DEXAMPLES_ENABLE=OFF ../source
-
Build and Install Sundials
make -j$(nproc) make installThe compiled libraries and headers will be installed in
/home/ian/sundials/install.
-
Set Environment Variables Ensure the Sundials library paths are accessible:
export CFLAGS='-I/home/ian/sundials/install/include' export LDFLAGS='-L/home/ian/sundials/install/lib'
-
Install
scikits.odesUsepipto install the package:pip install scikits.odes
This will install
scikits.odeswith Sundials support.
Before building or running any examples, set up your environment with these variables:
# Add Sundials libraries to the system's library path
export LD_LIBRARY_PATH=/home/ian/sundials/install/lib:$LD_LIBRARY_PATH
# Set up compilation flags for building with Sundials
export CFLAGS="-I/home/ian/sundials/install/include"
export CXXFLAGS="-I/home/ian/sundials/install/include"
export LDFLAGS="-L/home/ian/sundials/install/lib"
# For pkg-config (if needed)
export PKG_CONFIG_PATH=/home/ian/sundials/install/lib/pkgconfig:$PKG_CONFIG_PATH
# For CMake to find Sundials
export CMAKE_PREFIX_PATH=/home/ian/sundials/install:$CMAKE_PREFIX_PATHAdd these environment variables to your ~/.bashrc or ~/.profile to make them permanent:
echo 'export LD_LIBRARY_PATH=/home/ian/sundials/install/lib:$LD_LIBRARY_PATH' >> ~/.bashrc
echo 'export CFLAGS="-I/home/ian/sundials/install/include"' >> ~/.bashrc
echo 'export CXXFLAGS="-I/home/ian/sundials/install/include"' >> ~/.bashrc
echo 'export LDFLAGS="-L/home/ian/sundials/install/lib"' >> ~/.bashrc
echo 'export PKG_CONFIG_PATH=/home/ian/sundials/install/lib/pkgconfig:$PKG_CONFIG_PATH' >> ~/.bashrc
echo 'export CMAKE_PREFIX_PATH=/home/ian/sundials/install:$CMAKE_PREFIX_PATH' >> ~/.bashrcRemember to source your ~/.bashrc after adding these lines:
source ~/.bashrcMake sure you have:
- A C++ compiler (g++ or clang++)
- CMake
- SUNDIALS libraries properly installed (follow the installation steps above)
-
Build simple_test.cpp
g++ -o simple_test simple_test.cpp \ -I/home/ian/sundials/install/include \ -L/home/ian/sundials/install/lib \ -lsundials_cvode -lsundials_nvecserial \ -lsundials_sunmatrixdense -lsundials_sunlinsoldense \ -lsundials_sunnonlinsol -
Build benchmark_ode_solver.cpp (if present)
g++ -o benchmark_ode_solver benchmark_ode_solver.cpp \ -I/home/ian/sundials/install/include \ -L/home/ian/sundials/install/lib \ -lsundials_cvode -lsundials_nvecserial \ -lsundials_sunmatrixdense -lsundials_sunlinsoldense \ -lsundials_sunnonlinsol
- Run simple_test
This will run ODE solver tests with:
./simple_test
- A simple system (dy/dt = -y)
- Robertson's stiff system
- Different step counts (100, 1000, 10000)
- Both analytical and finite difference Jacobians
The program will output:
- SUNDIALS version
- Solution values at regular intervals
- Detailed timing statistics for each run
- Average performance metrics across multiple runs
If you encounter library loading errors, ensure the SUNDIALS libraries are in your system's library path:
export LD_LIBRARY_PATH=/home/ian/sundials/install/lib:$LD_LIBRARY_PATHTo verify the installation, you can run a simple Python script using scikits.odes to solve an ODE. If you encounter any issues, ensure the environment variables are correctly set and the Sundials library is properly installed.
- The Sundials library is installed in
/home/ian/sundials/install. - Example programs and outputs are available in the
install/examplesdirectory. - If you need to rebuild Sundials, clean the
builddirectory and repeat the steps.
For further assistance, refer to the Sundials documentation or contact support.