Skip to content

BobDyn/BobSolve

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BobSolve

BobSolve is an open-source numerical methods library for solving nonlinear systems, ODEs, and DAEs, with an emphasis on clarity and educational value.

It provides clean, from-scratch implementations of core algorithms used in simulation, with a direct correspondence between theory and code.

BobSolve is part of the broader BobDyn ecosystem and serves as the numerical foundation for simulation workflows. It complements BobLib by providing transparent implementations of the numerical methods used to solve the underlying equations.


Overview

BobSolve focuses on:

  • Nonlinear system solvers (Newton-Raphson)
  • Time integration methods (explicit, implicit, adaptive)
  • Differential-Algebraic Equation (DAE) solvers
  • Modular problem definitions (ODE, DAE, nonlinear)
  • Clear separation between problems, solvers, and linear algebra

⚠️ Current Status: Core solvers are implemented and functional. The library is actively evolving toward improved robustness and expanded method coverage.


Intended Use

BobSolve is not intended to replace production-grade numerical libraries such as SciPy or Sundials.

Instead, it serves as a transparent, educational reference implementation of core numerical methods used in simulation.

The focus is on:

  • clarity of implementation
  • direct correspondence between theory and code
  • facilitating understanding of solver behavior

This makes BobSolve particularly useful for:

  • learning numerical methods
  • debugging and validating simulation workflows
  • exploring solver behavior in a controlled setting

For production applications, highly optimized and extensively tested libraries should be used.


Installation

Clone the repository:

git clone https://github.com/BobDyn/BobSolve.git
cd BobSolve

Install dependencies:

pip install -r requirements.txt

Getting Started

Example: Solve a nonlinear system

Below is a minimal example using Newton-Raphson.

We solve the system:

  • $x^2 + y^2 = 1$ (unit circle)
  • $x - y = 0$ (line $x = y$)

The solution is the intersection of the line and circle.

import numpy as np

from solver.nonlinear.newton_raphson import NewtonRaphsonSolver
from solver.problems.nonlinear import NonlinearProblem
from solver.residuals.autodiff import finite_difference_jacobian

def F(x):
    x1, x2 = x
    return np.array([
        x1**2 + x2**2 - 1.0,
        x1 - x2
    ])

x0 = np.array([0.5, 0.2])
jac = finite_difference_jacobian(F)

problem = NonlinearProblem(F=F, x0=x0, jac=jac)
solver = NewtonRaphsonSolver(problem=problem, tol=1e-8, max_iter=25)

solution, converged, iterations, residual_norm = solver.solve()

print("solution:", solution)
print("converged:", converged)
print("iterations:", iterations)
print("residual norm:", residual_norm)

Repository Structure

BobSolve/
├── solver/
│   ├── linear/             # Linear system solvers (e.g., LU decomposition)
│   ├── nonlinear/          # Nonlinear solvers (Newton-Raphson)
│   ├── time_integrators/   # ODE and DAE time integration methods
│   ├── problems/           # Problem definitions (ODE, DAE, nonlinear)
│   └── residuals/          # Residual evaluation and autodiff tools
├── requirements.txt
├── makefile
├── README.md
├── LICENSE

Core Components

🔢 Linear Solvers

  • Dense LU decomposition
  • Modular interface for extending linear solvers

🔁 Nonlinear Solvers

  • Newton-Raphson method

  • Designed for reuse across:

    • standalone nonlinear systems
    • implicit time integrators
    • DAE solvers

⏱ Time Integrators

Includes:

  • Explicit methods:

    • Euler Forward
    • Adams-Bashforth
    • Heun
  • Implicit methods:

    • Euler Backward
    • Theta Method
    • Radau IIA
  • Adaptive variants for error-controlled integration

  • DAE-compatible solvers


📐 Problem Definitions

  • NonlinearProblem
  • ODEProblem
  • DAEProblem

These provide a unified interface between mathematical formulation and solver implementation.


🧮 Residuals

  • Automatic differentiation tools
  • Residual evaluation for nonlinear systems

Modeling Philosophy

BobSolve follows a strict design philosophy:

  • Clarity over abstraction Algorithms are implemented to be readable and understandable

  • From-scratch implementations No reliance on black-box solver libraries

  • Separation of concerns

    • Problems define equations
    • Solvers define algorithms
    • Linear algebra is modular
  • Simulation-oriented design Built to support real-world physics simulations (e.g., vehicle dynamics)


Examples and Validation

BobSolve includes simple, self-contained examples demonstrating solver behavior and usage.

These examples are designed to:

  • illustrate how algorithms operate in practice
  • provide quick entry points for new users
  • validate solver implementations

More comprehensive demonstrations and documentation are available through the BobDocs project.


Example Use Cases

  • Solve nonlinear systems arising from implicit equations
  • Integrate stiff ODE systems
  • Solve index-1 DAEs
  • Prototype and analyze numerical methods
  • Support simulation workflows (BobDyn)

Roadmap

  • Improve solver robustness and convergence handling
  • Expand DAE solver capabilities
  • Add Jacobian-free methods
  • Improve adaptive step-size control
  • Integrate with BobSim workflows

License

This project is licensed under the GNU General Public License v3.0 (GPLv3).

See the LICENSE file for details.


Related Projects

  • BobLib – Modelica-based vehicle dynamics library
  • BobSim – Simulation orchestration and DOE workflows
  • BobDocs – Documentation and examples

Author

Developed as part of the BobDyn project.

About

An open-source numerical methods library for solving nonlinear systems, ODEs, and DAEs, with an emphasis on clarity and educational value

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors