{"id":25854772,"url":"https://github.com/jchristopherson/diffeq","last_synced_at":"2026-02-03T11:34:20.830Z","repository":{"id":166615163,"uuid":"630649470","full_name":"jchristopherson/diffeq","owner":"jchristopherson","description":"A modern Fortran library providing an object-oriented approach to solving ordinary differential equations.","archived":false,"fork":false,"pushed_at":"2025-12-12T15:14:26.000Z","size":3160,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-14T06:36:03.530Z","etag":null,"topics":["differential-equations","runge-kutta-methods"],"latest_commit_sha":null,"homepage":"","language":"Fortran","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jchristopherson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-04-20T20:57:35.000Z","updated_at":"2025-12-12T15:13:32.000Z","dependencies_parsed_at":"2024-04-18T20:42:50.873Z","dependency_job_id":"7a730dbd-8b26-4afe-b0c3-213cbaa69b30","html_url":"https://github.com/jchristopherson/diffeq","commit_stats":null,"previous_names":["jchristopherson/diffeq"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/jchristopherson/diffeq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchristopherson%2Fdiffeq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchristopherson%2Fdiffeq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchristopherson%2Fdiffeq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchristopherson%2Fdiffeq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jchristopherson","download_url":"https://codeload.github.com/jchristopherson/diffeq/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchristopherson%2Fdiffeq/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29044396,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T10:09:22.136Z","status":"ssl_error","status_checked_at":"2026-02-03T10:09:16.814Z","response_time":96,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["differential-equations","runge-kutta-methods"],"created_at":"2025-03-01T16:18:05.962Z","updated_at":"2026-02-03T11:34:20.811Z","avatar_url":"https://github.com/jchristopherson.png","language":"Fortran","funding_links":[],"categories":[],"sub_categories":[],"readme":"# diffeq\nA modern Fortran library providing an object-oriented approach to solving and exploring ordinary differential equations.\n\n## Build Status\n[![CMake](https://github.com/jchristopherson/diffeq/actions/workflows/cmake.yml/badge.svg)](https://github.com/jchristopherson/diffeq/actions/workflows/cmake.yml)\n[![Actions Status](https://github.com/jchristopherson/diffeq/workflows/fpm/badge.svg)](https://github.com/jchristopherson/diffeq/actions)\n\n## Documentation\nThe documentation can be found [here](https://jchristopherson.github.io/diffeq/).\n\n## Available Integrators\n- Runge-Kutta, 5th Order (Dormand-Prince)\n- Runge-Kutta, 3rd Order (Bogacki-Shampine)\n- Runge-Kutta, 8th Order (Hairer, Nörsett, \u0026 Wanner)\n- Rosenbrock, 4th Order\n- Adams (VODE)\n- Backward Differentiation Formula (VODE)\n\n## Building DIFFEQ\n[CMake](https://cmake.org/)This library can be built using CMake.  For instructions see [Running CMake](https://cmake.org/runningcmake/).\n\n[FPM](https://github.com/fortran-lang/fpm) can also be used to build this library using the provided fpm.toml.\n```txt\nfpm build\n```\nThe DIFFEQ library can be used within your FPM project by adding the following to your fpm.toml file.\n```toml\n[dependencies]\ndiffeq = { git = \"https://github.com/jchristopherson/diffeq\" }\n```\n\n## Examples\nThe following example illustrates solving the Van der Pol equation using a 4th-order Rosenbrock solver, but other solvers can be used in an identical manner.  The example also utilizes the [FPLOT](https://github.com/jchristopherson/fplot) library to plot the solution.\n```fortran\nprogram example\n    use iso_fortran_env\n    use diffeq\n    use diffeq_models\n    use fplot_core\n    implicit none\n\n    ! Local Variables\n    type(rosenbrock) :: integrator\n    type(ode_container) :: mdl\n    real(real64), allocatable :: sol(:,:)\n\n    ! Plot Variables\n    type(plot_2d) :: plt\n    type(plot_data_2d) :: pd1, pd2\n    class(plot_axis), pointer :: xAxis, yAxis, y2Axis\n    class(legend), pointer :: lgnd\n\n    ! Define the model\n    mdl%fcn =\u003e vanderpol\n\n    ! Compute the solution\n    call integrator%solve(mdl, [0.0d0, 5.0d1], [2.0d0, 0.0d0])\n    sol = integrator%get_solution()\n\n    ! Plot the results\n    call plt%initialize()\n    xAxis =\u003e plt%get_x_axis()\n    yAxis =\u003e plt%get_y_axis()\n    y2Axis =\u003e plt%get_y2_axis()\n    lgnd =\u003e plt%get_legend()\n    call xAxis%set_title(\"x\")\n    call yAxis%set_title(\"y(x)\")\n    call y2Axis%set_title(\"y'(x)\")\n    call plt%set_use_y2_axis(.true.)\n    call lgnd%set_is_visible(.true.)\n    \n    call pd1%define_data(sol(:,1), sol(:,2))\n    call pd1%set_name(\"y(x)\")\n    call plt%push(pd1)\n\n    call pd2%define_data(sol(:,1), sol(:,3))\n    call pd2%set_draw_against_y2(.true.)\n    call pd2%set_name(\"y'(x)\")\n    call plt%push(pd2)\n\n    call plt%draw()\nend program\n```\nThe routine containing the ODE is located in a different module for this example.  This routine is as follows.\n```fortran\npure subroutine vanderpol(x, y, dydx, args)\n    ! Arguments\n    real(real64), intent(in) :: x, y(:)\n    real(real64), intent(out) :: dydx(:)\n    class(*), intent(inout), optional :: args\n\n    ! Model Constants\n    real(real64), parameter :: mu = 5.0d0\n\n    ! An alternative approach to defining model parameters in the routine is\n    ! to use the optional \"args\" variable.  For example, if mu were to be\n    ! passed from the calling routine the args parameter could be used as \n    ! follows:\n    !\n    ! select type (args)\n    ! type is (real(real64))\n    !   mu = args\n    ! end select\n    !\n    ! Of course, the call to the solve routine would have to pass this\n    ! argument in a manner similar to the following.\n    !\n    ! mu = 5.0d0\n    ! call integrator%solve(...., args = mu)\n\n    ! Equations\n    dydx(1) = y(2)\n    dydx(2) = mu * (1.0d0 - y(1)**2) * y(2) - y(1)\nend subroutine\n```\n![](images/rosenbrock_example.png?raw=true)\n\n\n\nHere's another example comparing the behavior of several integrators for the same Van der Pol problem illustrated in the previous example.  In this example it can be seen that all of the integrators can be utilized in an identical manner.  Additionally, this example illustrates the use of a PI-type controller for step-size control.  Such a controller can be beneficial in the event stability issues are encountered during solution; however, this benefit usually comes with a drawback of decreased efficiency.  For this reason, the default behavior for any of the solvers is to not utilize any PI control; however, it is available if needed.\n```fortran\nprogram example\n    use iso_fortran_env\n    use diffeq\n    use diffeq_models\n    implicit none\n\n    ! Initial Conditions \u0026 Time Constraints\n    real(real64), parameter :: t(2) = [0.0d0, 5.0d1]\n    real(real64), parameter :: ic(2) = [2.0d0, 0.0d0]\n\n    ! Local Variables\n    type(runge_kutta_23) :: integrator_1\n    type(runge_kutta_45) :: integrator_2\n    type(runge_kutta_853) :: integrator_3\n    type(rosenbrock) :: integrator_4\n    type(bdf) :: integrator_5\n    type(adams) :: integrator_6\n    type(ode_container) :: mdl\n    real(real64), allocatable, dimension(:,:) :: s1, s2, s3, s4, s4a, s5, s6\n\n    ! Define the model\n    mdl%fcn =\u003e vanderpol\n\n    ! Integrate the model with each integrator\n    call integrator_1%solve(mdl, t, ic)\n    call integrator_2%solve(mdl, t, ic)\n    call integrator_3%solve(mdl, t, ic)\n    call integrator_4%solve(mdl, t, ic)\n    call integrator_5%solve(mdl, t, ic)\n    call integrator_6%solve(mdl, t, ic)\n\n    ! Retrieve the solution from each integrator\n    s1 = integrator_1%get_solution()\n    s2 = integrator_2%get_solution()\n    s3 = integrator_3%get_solution()\n    s4 = integrator_4%get_solution()\n    s5 = integrator_5%get_solution()\n    s6 = integrator_6%get_solution()\n\n    ! Print out the size of each solution\n    print \"(AI0A)\", \"RUNGE_KUTTA_23: \", size(s1, 1), \" Solution Points\"\n    print \"(AI0A)\", \"RUNGE_KUTTA_45: \", size(s2, 1), \" Solution Points\"\n    print \"(AI0A)\", \"RUNGE_KUTTA_853: \", size(s3, 1), \" Solution Points\"\n    print \"(AI0A)\", \"ROSENBROCK: \", size(s4, 1), \" Solution Points\"\n\n    ! Now, implement a PI controller and check its effect.  This might\n    ! increase the number of steps (loss of efficiency), but if there were\n    ! any stability issues, stability will likely improve.  Stability is likely\n    ! not relevant on this problem, but it's here for illustration purposes.\n    call integrator_4%set_step_size_control_parameter(0.1d0)\n    call integrator_4%solve(mdl, t, ic)\n    s4a = integrator_4%get_solution()\n    print \"(AI0A)\", \"ROSENBROCK w/ PI Controller: \", size(s4a, 1), \" Solution Points\"\n\n    ! VODE Integrators\n    print \"(AI0A)\", \"BDF: \", size(s5, 1), \" Solution Points\"\n    print \"(AI0A)\", \"ADAMS: \", size(s6, 1), \" Solution Points\"\nend program\n```\n```txt\nRUNGE_KUTTA_23: 2465 Solution Points\nRUNGE_KUTTA_45: 583 Solution Points\nRUNGE_KUTTA_853: 925 Solution Points\nROSENBROCK: 1191 Solution Points\nROSENBROCK w/ PI Controller: 1191 Solution Points\nBDF: 1527 Solution Points\nADAMS: 1865 Solution Points\n```\n\n## External Libraries\nHere is a list of external code libraries utilized by this library.  The CMake build script will include these dependencies automatically; however, it is highly recommended that an optimized BLAS and LAPACK already reside on your system for best performance (used by LINALG for linear algebra calculations).\n- [FERROR](https://github.com/jchristopherson/ferror)\n- [LINALG](https://github.com/jchristopherson/linalg)\n\n## References\n1. Butcher, J. C. (2003). Numerical methods for ordinary differential equations. J. Wiley.\n2. Shampine, L. F., \u0026 Reichelt, M. W., (1997). The MATLAB ODE suite. SIAM Journal on Scientific Computing. 18. 10.1137/S1064827594276424. \n3. J.R. Dormand, P.J. Prince (1980). A family of embedded Runge-Kutta formulae, Journal of Computational and Applied Mathematics, Volume 6, Issue 1, Pages 19-26, ISSN 0377-0427, https://doi.org/10.1016/0771-050X(80)90013-3.\n4. P. Bogacki, L.F. Shampine (1989). A 3(2) pair of Runge - Kutta formulas, Applied Mathematics Letters, Volume 2, Issue 4, Pages 321-325, ISSN 0893-9659, https://doi.org/10.1016/0893-9659(89)90079-7.\n5. Dormand, J. R. (1996). Numerical methods for differential equations a computational approach. CRC Press. \n6. Kennedy, C. A., Carpenter, M. H. (2016, March). Diagonally Implicit Runge-Kutta Methods for Ordinary Differential Equations. A Review. https://ntrs.nasa.gov/api/citations/20160005923/downloads/20160005923.pdf \n7. Stal, J. (2015). Implementation of Singly Diagonally Implicit Runge-Kutta Methods with Constant Step Sizes. https://core.ac.uk/download/pdf/289938621.pdf \n8. Nayfeh, A. H., \u0026 Balachandran, B. (1995). Applied Nonlinear Dynamics: Analytical, Computational, and Experimental Methods. J. Wiley.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjchristopherson%2Fdiffeq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjchristopherson%2Fdiffeq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjchristopherson%2Fdiffeq/lists"}