All Projects → ivan-pi → stiff3

ivan-pi / stiff3

Licence: Apache-2.0 License
Adaptive solver for stiff systems of ODEs using semi-implicit Runge-Kutta method of third order

Programming Languages

fortran
972 projects

Projects that are alternatives of or similar to stiff3

dae-cpp
A simple but powerful C++ DAE (Differential Algebraic Equation) solver
Stars: ✭ 33 (+153.85%)
Mutual labels:  solver, ode
odex-js
Bulirsch-Stoer integration of systems of ordinary differential equations in JavaScript
Stars: ✭ 52 (+300%)
Mutual labels:  solver, ode
Fluid Simulation
Self advection, external force and pressure solve to a velocity field represented by a MaC grid.
Stars: ✭ 107 (+723.08%)
Mutual labels:  solver, equation
rust-lp-modeler
Lp modeler written in Rust
Stars: ✭ 75 (+476.92%)
Mutual labels:  solver
rcbc
COIN-OR branch and cut (CBC) bindings for R
Stars: ✭ 16 (+23.08%)
Mutual labels:  solver
JSMinesweeper
Minesweeper player, solver and analyser in javascript
Stars: ✭ 25 (+92.31%)
Mutual labels:  solver
split-ease
The JavaScript Easing function with a beginning, middle and end
Stars: ✭ 55 (+323.08%)
Mutual labels:  equation
differential-array
a simple differential array using XMOS 6+1 board
Stars: ✭ 21 (+61.54%)
Mutual labels:  differential
FirstOrderSolvers.jl
Large scale convex optimization solvers in julia
Stars: ✭ 20 (+53.85%)
Mutual labels:  solver
irrlamb
irrlamb is a 3D game that probably involves a lot of physics and frustrating gameplay.
Stars: ✭ 28 (+115.38%)
Mutual labels:  ode
SciMLBenchmarks.jl
Benchmarks for scientific machine learning (SciML) software and differential equation solvers
Stars: ✭ 195 (+1400%)
Mutual labels:  ode
rom-operator-inference-Python3
Operator Inference for data-driven, non-intrusive model reduction of dynamical systems.
Stars: ✭ 31 (+138.46%)
Mutual labels:  ode
Alpha
A lazy-grounding Answer-Set Programming system
Stars: ✭ 44 (+238.46%)
Mutual labels:  solver
cplex-example
Solving a TSP with the CPLEX C++ API.
Stars: ✭ 40 (+207.69%)
Mutual labels:  solver
tex-equation-to-svg
Convert a TeX or LaTeX string to an SVG.
Stars: ✭ 34 (+161.54%)
Mutual labels:  equation
ddeabm
Modern Fortran implementation of the DDEABM Adams-Bashforth algorithm
Stars: ✭ 23 (+76.92%)
Mutual labels:  ode
Equation and Codebox
Microsoft Word VSTO Add-In,可以插入带编号的公式和代码
Stars: ✭ 27 (+107.69%)
Mutual labels:  equation
FOODIE
Fortran Object-Oriented Differential-equations Integration Environment, FOODIE
Stars: ✭ 109 (+738.46%)
Mutual labels:  ode
DiffEqGPU.jl
GPU-acceleration routines for DifferentialEquations.jl and the broader SciML scientific machine learning ecosystem
Stars: ✭ 131 (+907.69%)
Mutual labels:  ode
ddrl
Deep Developmental Reinforcement Learning
Stars: ✭ 27 (+107.69%)
Mutual labels:  ode

stiff3

stiff3 is a Fortran subprogram for solving stiff autonomous systems of ordinary differential equations (ODE's) using a semi-implicit Runge-Kutta method with three steps (SIRK3). The stiff3 source code was originally published in the work:

Villadsen, J., & Michelsen, M. L. (1978). Solution of differential equation models by polynomial approximation. Prentice-Hall, Inc.

This repository provides a refactored version with a simplified procedural interface.

Installation

To use this project you need to have

To use stiff3 include it as a dependency in your fpm package manifest

[dependencies]
stiff3.git = "https://github.com/ivan-pi/stiff3"

To build the library (as the main project) invoke fpm in the project root with

fpm build

Two examples called robertson and vanpol are provided. They can be run with the the command

fpm run --example <name>

Usage

Basic use of the solver is demonstrated using the Van der Pol oscillator:

program vanpol

  use stiff3_solver, only: wp => stiff3_wp, stiff3
  implicit none

  integer, parameter :: n = 2, nout = 1
  real(wp), parameter :: mu = 10.0_wp
  real(wp) :: y(n), w(n), x0, x1, h0, eps

! initial value
  y = [1.0_wp, 1.0_wp]
! initial step size
  h0 = 0.001_wp
! tolerance
  eps = 1.0e-4_wp
  w = 1
! time interval
  x0 = 0.0_wp
  x1 = 100.0_wp
! output initial condition
  call out(x0,y,0,0.0_wp)
! integrate system of ODEs
  call stiff3(n,fun,jac,out,nout,x0,x1,h0,eps,w,y)

contains

  subroutine fun(n,y,f)
    integer, intent(in) :: n
    real(wp), intent(in) :: y(n)
    real(wp), intent(inout) :: f(n)
    f(1) = y(2)
    f(2) = mu*(1.0_wp - y(1)**2)*y(2) - y(1)
  end subroutine

  subroutine jac(n,y,df)
    integer, intent(in) :: n
    real(wp), intent(in) :: y(n)
    real(wp), intent(inout) :: df(n,n)
    df(1,1) = 0.0_wp
    df(1,2) = 1.0_wp
    df(2,1) = mu*y(2)*(-2*y(1)) - 1.0_wp
    df(2,2) = mu*(1.0_wp - y(1)**2)
  end subroutine

  subroutine out(t,y,ih,qa)
    real(wp), intent(in) :: t
    real(wp), intent(in) :: y(:)
    integer, intent(in) :: ih
    real(wp), intent(in) :: qa
    write(*,'(3(E18.12,2X),I4,2X,G0)') t, y(1), y(2), ih, qa
  end subroutine

end program

Method

The semi-implicit Runge-Kutta method used by stiff3 was first published in

Caillaud, J. B., & Padmanabhan, L. (1971). An improved semi-implicit Runge-Kutta method for stiff systems. The Chemical Engineering Journal, 2(4), 227-232. https://doi.org/10.1016/0300-9467(71)85001-3

The adaptive stepsize selection strategy is described in Villadsen & Michelsen (1978), Section 8.2.3, pages 314 - 317.

The error tolerance values eps (scalar) and w (vector) are used to keep the local error estimate of component i smaller than (1 + abs(y(i)))*eps/w(i).

Contributing

We look forward to all types of contributions. If you would like to propose additional features or submit a bug report please open a new issue.

For students interested in CSE, here are some contribution ideas:

  • Support for banded or sparse Jacobian matrices
  • Use BLAS kernels for vector operations
  • Continuous (dense) output of variables
  • Extend stiff3 to non-autonomous systems of ODE's
  • Advanced stepsize control settings
  • Write a tutorial on how to use stiff3
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].