Giter Site home page Giter Site logo

ode-system-numerical-solver's Introduction

ODE System - Numerical Solver

Solve Ordinary differential equations systems using Runge-Kutta

Dependences

  • Codes made in Fortran 90
  • gfortran Compiler
  • Plot solution using Matlab/Octave

How to use

Running code

The code runs in Fortran 90, you will need a fortran compiler, such as gfortran. The problem conditions are changed in code, then you'll need to compile every change:

  gfortran ode_solver_main.f90 -o <your_exe_name>

Then, run:

  • On Windows
  your_exe_name.exe
  • On Linux
  ./your_exe_name.out

After this, the code will generate three .out files.

  • mash_info.out : Contain the points of domain discretization.
  • output_solution.out : Contain the solution for each point

Plotting solution

You will need Matlab or Octave to run the .m code. Once with Matlab/Octave opened, just run the code with execute button and watch the solution change in time.

Mathematical Model

We solve a Diferential Equation System using 4 order Runge-Kutta method

Varaibles in code

To set the interval that solution will be calculated

intr_x = 0.400

The number of points that the solution will be calculated

nodes_number = 1000

To set the system, follow the steps:

  • First, you'll need set the system size

Example:

!============================ System Size ============================!
system_size = 3
  • Set the initial system condition

Example:

!======================== Initial conditions ==========================!
old_sol(1) = 5.000
old_sol(2) = 1.000
old_sol(3) = -3.1415
  • Setting the functions

Example:

function f(x, u) result( f_res )
     real(8), intent(in)  :: x
     real(8), intent(in), dimension(:) :: u
     real(8), dimension( size(u) ) :: f_res

     !===== function =====!
     f_res(1) = 3*x - u(1)
     f_res(2) = u(2) + 3*u(1) - u(3)
     f_res(3) = log(x) - u(3) + (u(2))**2

 end function f

Solution Examples

Population Dynamics

Vertical Spring-Mass system

System with 2 springs coupled with 2 massive bodies

With Damping

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.