All Projects → jacobwilliams → ddeabm

jacobwilliams / ddeabm

Licence: other
Modern Fortran implementation of the DDEABM Adams-Bashforth algorithm

Programming Languages

fortran
972 projects

Projects that are alternatives of or similar to ddeabm

dae-cpp
A simple but powerful C++ DAE (Differential Algebraic Equation) solver
Stars: ✭ 33 (+43.48%)
Mutual labels:  ode
DiffEqCallbacks.jl
A library of useful callbacks for hybrid scientific machine learning (SciML) with augmented differential equation solvers
Stars: ✭ 43 (+86.96%)
Mutual labels:  ode
numerical-veliz
Numerical Analysis code from the Oscar Veliz YouTube Channel
Stars: ✭ 83 (+260.87%)
Mutual labels:  root-finding
PKPDsim
Simulate PK-PD models defined as ODE systems
Stars: ✭ 24 (+4.35%)
Mutual labels:  ode
odex-js
Bulirsch-Stoer integration of systems of ordinary differential equations in JavaScript
Stars: ✭ 52 (+126.09%)
Mutual labels:  ode
pydens
PyDEns is a framework for solving Ordinary and Partial Differential Equations (ODEs & PDEs) using neural networks
Stars: ✭ 201 (+773.91%)
Mutual labels:  ode
DiffEqUncertainty.jl
Fast uncertainty quantification for scientific machine learning (SciML) and differential equations
Stars: ✭ 61 (+165.22%)
Mutual labels:  ode
DiffEqPhysics.jl
A library for building differential equations arising from physical problems for physics-informed and scientific machine learning (SciML)
Stars: ✭ 46 (+100%)
Mutual labels:  ode
parPE
Parameter estimation for dynamical models using high-performance computing, batch and mini-batch optimizers, and dynamic load balancing.
Stars: ✭ 16 (-30.43%)
Mutual labels:  ode
SBMLToolkit.jl
SBML differential equation and chemical reaction model (Gillespie simulations) for Julia's SciML ModelingToolkit
Stars: ✭ 25 (+8.7%)
Mutual labels:  ode
diffeqr
Solving differential equations in R using DifferentialEquations.jl and the SciML Scientific Machine Learning ecosystem
Stars: ✭ 118 (+413.04%)
Mutual labels:  ode
Sundials.jl
Julia interface to Sundials, including a nonlinear solver (KINSOL), ODE's (CVODE and ARKODE), and DAE's (IDA) in a SciML scientific machine learning enabled manner
Stars: ✭ 167 (+626.09%)
Mutual labels:  ode
cmna-pkg
Computational Methods for Numerical Analysis
Stars: ✭ 13 (-43.48%)
Mutual labels:  root-finding
heyoka.py
Python library for ODE integration via Taylor's method and LLVM
Stars: ✭ 45 (+95.65%)
Mutual labels:  ode
Fatou.jl
Fatou sets in Julia (Fractals, Newton basins, Mandelbrot)
Stars: ✭ 92 (+300%)
Mutual labels:  root-finding
Root-Finder
Root-Finder is a header-only univariate polynomial solver, which finds/counts all real roots of any polynomial within any interval.
Stars: ✭ 30 (+30.43%)
Mutual labels:  root-finding
DiffEqDevTools.jl
Benchmarking, testing, and development tools for differential equations and scientific machine learning (SciML)
Stars: ✭ 37 (+60.87%)
Mutual labels:  ode
heyoka
C++ library for ODE integration via Taylor's method and LLVM
Stars: ✭ 151 (+556.52%)
Mutual labels:  ode
DiffEqSensitivity.jl
A component of the DiffEq ecosystem for enabling sensitivity analysis for scientific machine learning (SciML). Optimize-then-discretize, discretize-then-optimize, and more for ODEs, SDEs, DDEs, DAEs, etc.
Stars: ✭ 186 (+708.7%)
Mutual labels:  ode
AMICI
Advanced Multilanguage Interface to CVODES and IDAS
Stars: ✭ 80 (+247.83%)
Mutual labels:  ode

ddeabm

Status

GitHub release Build Status codecov last-commit

Description

This is a modern object-oriented Fortran implementation of the DDEABM Adams-Bashforth-Moulton ODE solver. The original Fortran 77 code was obtained from the SLATEC library. It has been extensively refactored.

DDEABM uses the Adams-Bashforth-Moulton predictor-corrector formulas of orders 1 through 12 to integrate a system of first order ordinary differential equations of the form dx/dt = f(t,x). Also included is an event-location capability, where the equations can be integrated until a specified function g(t,x) = 0. Dense output is also supported.

This project is hosted on GitHub.

Examples

The ddeabm_module provides a thread-safe and object-oriented interface to the DDEABM method. Some example use cases are presented below:

Basic integration

This example shows how to integrate a conic orbit (6 state equations) around the Earth from an initial time t0 to a final time tf:

program ddeabm_example

use ddeabm_module, wp => ddeabm_rk

implicit none

real(wp),parameter :: mu = 398600.436233_wp !! Earth gravitational parameter (km^3/s^2)
integer,parameter  :: n = 6                 !! number of state variables

type(ddeabm_class) :: s
real(wp),dimension(n) :: x0,x
real(wp) :: t0,tf,t
integer :: idid

call s%initialize(n,maxnum=10000,df=twobody,rtol=[1.0e-12_wp],atol=[1.0e-12_wp])

!initial conditions:
x0 = [10000.0_wp,10000.0_wp,10000.0_wp,&   !initial state [r,v] (km,km/s)
        1.0_wp,2.0_wp,3.0_wp]
t0 = 0.0_wp       !initial time (sec)
tf = 1000.0_wp    !final time (sec)

write(*,'(A/,*(F15.6/))') 'Initial time: ',t0
write(*,'(A/,*(F15.6/))') 'Initial state:',x0
t = t0
x = x0
call s%integrate(t,x,tf,idid=idid)
write(*,'(A/,*(F15.6/))') 'Final time: ',t
write(*,'(A/,*(F15.6/))') 'Final state:',x

contains

    subroutine twobody(me,t,x,xdot)

        !! derivative routine for two-body orbit propagation

        implicit none

        class(ddeabm_class),intent(inout) :: me
        real(wp),intent(in)               :: t
        real(wp),dimension(:),intent(in)  :: x
        real(wp),dimension(:),intent(out) :: xdot

        real(wp),dimension(3) :: r,v,a_grav
        real(wp) :: rmag

        r = x(1:3)
        v = x(4:6)
        rmag = norm2(r)
        a_grav = -mu/rmag**3 * r ! acceleration due to gravity

        xdot(1:3) = v
        xdot(4:6) = a_grav

    end subroutine twobody

end program ddeabm_example

It produces the following output:

Initial time:
       0.000000

Initial state:
   10000.000000
   10000.000000
   10000.000000
       1.000000
       2.000000
       3.000000

Final time:
    1000.000000

Initial time:
   10667.963305
   11658.055962
   12648.148619
       0.377639
       1.350074
       2.322509

Reporting of intermediate points

The intermediate integration points can also be reported to a user-defined procedure. For the above example, the following subroutine could be defined:

subroutine twobody_report(me,t,x)

    !! report function - write time,state to console

    implicit none

    class(ddeabm_class),intent(inout)    :: me
    real(wp),intent(in)                  :: t
    real(wp),dimension(:),intent(in)     :: x

    write(*,'(*(F15.6,1X))') t,x

end subroutine twobody_report

Which can be added to the class on initialization:

call s%initialize(n,maxnum=10000,df=twobody,&
                  rtol=[1.0e-12_wp],atol=[1.0e-12_wp],&
                  report=twobody_report)

This function is then called at each time step if the equations are integrated using the integration_mode=2 option like so:

call s%integrate(t,x,tf,idid=idid,integration_mode=2)

Event location

A user-defined event function g(t,x) can also be defined in order to stop the integration at a specified event (i.e., when g(t,x)=0). In the above example, say it is desired that the integration stop when z = x(3) = 12,000 km. The event function for this would be:

subroutine twobody_event(me,t,x,g)

    !! event function for z = 12,000 km

    implicit none

    class(ddeabm_with_event_class),intent(inout) :: me
    real(wp),intent(in)                          :: t
    real(wp),dimension(:),intent(in)             :: x
    real(wp),intent(out)                         :: g

    g = 12000.0_wp - x(3)

end subroutine twobody_event

For event finding, the ddeabm_with_event_class type is used (which is an extension of the main ddeabm_class). For example:

type(ddeabm_with_event_class) :: s
...
call s%initialize_event(n,maxnum=10000,df=twobody,&
                        rtol=[1.0e-12_wp],atol=[1.0e-12_wp],&
                        g=twobody_event,root_tol=1.0e-12_wp)
...
call s%integrate_to_event(t,x,tf,idid=idid,gval=gval)

In this case, root_tol is the tolerance for the event location, and gval is the value of the event function at the final time (note that the integration will stop when g(t,x)=0 or at t=tf, whichever occurs first).

A vector event function is also supported (in which case, the integration stops if any of the roots are found). This is done using the ddeabm_with_event_class_vec type.

Fixed time step

All of the integration methods have an optional argument (tstep) to enable a fixed time step, which can be used for dense output, or to specify a fixed step used for event finding (since the default step may be too large). For example, for performing a root-finding integration with the event function evaluated every 100 seconds:

call s%integrate_to_event(t,x,tf,idid=idid,gval=gval,tstep=100.0_wp)

Building DDEABM

DDEABM and the test programs will build with any modern Fortran compiler. A Fortran Package Manager (FPM) manifest file (fmp.toml) is included, so that the library and tests cases can be compiled with FPM. For example:

fpm build --profile release
fpm test --profile release

To generate the documentation using ford, run:

ford ddeabm.md

To use ddeabm within your fpm project, add the following to your fpm.toml file:

[dependencies]
ddeabm = { git="https://github.com/jacobwilliams/ddeabm.git" }

A specific version can also be specified:

[dependencies]
ddeabm = { git="https://github.com/jacobwilliams/ddeabm.git", rev = "2.1.0" }

By default, the library is built with double precision (real64) real values. Explicitly specifying the real kind can be done using the following processor flags:

Preprocessor flag Kind Number of bytes
REAL32 real(kind=real32) 4
REAL64 real(kind=real64) 8
REAL128 real(kind=real128) 16

For example, to build a single precision version of the library, use:

fpm build --profile release --flag "-DREAL32"

Dependencies

Building the library requires the roots-fortran module. Building the tests requires the pyplot-fortran module. FPM will automatically download the correct versions of both (see fpm.toml).

Documentation

The latest API documentation can be found here. This was generated from the source code using FORD.

License

The DDEABM source code and related files and documentation are distributed under a permissive free software license (BSD-style). The original DDEABM Fortran 77 code is public domain.

Keywords

Adams-Bashforth-Moulton Method, DEPAC, Initial Value Problems, ODE, Ordinary Differential Equations, Predictor-Corrector, SLATEC, Modern Fortran

References

  1. L. F. Shampine, M. K. Gordon, "Solving ordinary differential equations with ODE, STEP, and INTRP", Report SLA-73-1060, Sandia Laboratories, 1973.
  2. L. F. Shampine, M. K. Gordon, "Computer solution of ordinary differential equations, the initial value problem", W. H. Freeman and Company, 1975.
  3. L. F. Shampine, H. A. Watts, "DEPAC - Design of a user oriented package of ode solvers", Report SAND79-2374, Sandia Laboratories, 1979.
  4. H. A. Watts, "A smoother interpolant for DE/STEP, INTRP and DEABM: II", Report SAND84-0293, Sandia Laboratories, 1984.
  5. R. P. Brent, "An algorithm with guaranteed convergence for finding a zero of a function", The Computer Journal, Vol 14, No. 4., 1971.
  6. R. P. Brent, "Algorithms for minimization without derivatives", Prentice-Hall, Inc., 1973.
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].