Skip to content

ianpepper/sundials_testing

Repository files navigation

Sundials Installation Guide

This README provides a step-by-step guide to install Sundials from source and set up the scikits.odes Python package with Sundials support.

Prerequisites

Ensure the following tools and libraries are installed on your system:

  • build-essential
  • cmake
  • git
  • python3 and pip
  • numpy and scipy (Python packages)

Steps to Install Sundials

  1. Clone the Sundials Repository

    git clone https://github.com/LLNL/sundials.git /home/ian/sundials/source
  2. Create a Build Directory

    mkdir -p /home/ian/sundials/build
    cd /home/ian/sundials/build
  3. Configure the Build with CMake

    cmake -DCMAKE_INSTALL_PREFIX=/home/ian/sundials/install -DBUILD_SHARED_LIBS=ON -DEXAMPLES_ENABLE=OFF ../source
  4. Build and Install Sundials

    make -j$(nproc)
    make install

    The compiled libraries and headers will be installed in /home/ian/sundials/install.

Steps to Install scikits.odes

  1. 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'
  2. Install scikits.odes Use pip to install the package:

    pip install scikits.odes

    This will install scikits.odes with Sundials support.

Environment Setup

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_PATH

Add 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' >> ~/.bashrc

Remember to source your ~/.bashrc after adding these lines:

source ~/.bashrc

Building and Running C++ Examples

Prerequisites for C++ Examples

Make sure you have:

  • A C++ compiler (g++ or clang++)
  • CMake
  • SUNDIALS libraries properly installed (follow the installation steps above)

Compiling the C++ Files

  1. 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
  2. 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

Running the Examples

  1. Run simple_test
    ./simple_test
    This will run ODE solver tests with:
    • 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

Troubleshooting

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_PATH

Verification

To 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.

Notes

  • The Sundials library is installed in /home/ian/sundials/install.
  • Example programs and outputs are available in the install/examples directory.
  • If you need to rebuild Sundials, clean the build directory and repeat the steps.

For further assistance, refer to the Sundials documentation or contact support.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors