Giter Site home page Giter Site logo

abdulhamitozdemir / fractionaldiffeq.jl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from scifracx/fractionaldiffeq.jl

0.0 0.0 0.0 11.14 MB

Solve Fractional Differential Equations using high performance numerical methods

Home Page: https://scifracx.github.io/FractionalDiffEq.jl/dev/

License: MIT License

Julia 100.00%

fractionaldiffeq.jl's Introduction

FractionalDiffEq.jl

building codecov license license DOI

GitHub issues GitHub stars GitHub forks

FractionalDiffEq.jl provides FDE solvers to DifferentialEquations.jl ecosystem, including FODE(Fractional Ordianry Differential Equations), FDDE(Fractional Delay Differential Equations) and many more. There are many performant solvers available, capable of solving many kinds of fractional differential equations.

Installation

If you have already installed Julia, you can install FractionalDiffEq.jl in REPL using Julia package manager:

pkg> add FractionalDiffEq

Quick start

Fractional ordinary differential equations

Let's see if we have an initial value problem:

$$ D^{1.8}y(x)=1-y $$

$$ y(0)=0 $$

So we can use FractionalDiffEq.jl to solve the problem:

using FractionalDiffEq, Plots
fun(u, p, t) = 1-u
u0 = [0, 0]; tspan = (0, 20); h = 0.001;
prob = SingleTermFODEProblem(fun, 1.8, u0, tspan)
sol = solve(prob, h, PECE())
plot(sol)

And if you plot the result, you can see the result of the above IVP:

Example

A sophisticated example

Let's see if the initial value problem like:

$$ y'''(t)+\frac{1}{16}{^C_0D^{2.5}_t}y(t)+\frac{4}{5}y''(t)+\frac{3}{2}y'(t)+\frac{1}{25}{^C_0D^{0.5}_t}y(t)+\frac{6}{5}y(t)=\frac{172}{125}\cos(\frac{4t}{5}) $$

$$ y(0)=0,\ y'(0)=0,\ y''(0)=0 $$

using FractionalDiffEq, Plots
h=0.01; tspan = (0, 30)
rightfun(x, y) = 172/125*cos(4/5*x)
prob = MultiTermsFODEProblem([1, 1/16, 4/5, 3/2, 1/25, 6/5], [3, 2.5, 2, 1, 0.5, 0], rightfun, [0, 0, 0, 0, 0, 0], tspan)
sol = solve(prob, h, PIEX())
plot(sol, legend=:bottomright)

Or use the example file to plot the numerical approximation, we can see the FDE solver in FractionalDiffEq.jl is amazingly powerful:

Example

System of Fractional Differential Equations:

FractionalDiffEq.jl is a powerful tool to solve system of fractional differential equations, if you are familiar with DifferentialEquations.jl, it would be just like out of the box.

Let's see if we have a Chua chaos system:

$$ \begin{cases}D^{\alpha_1}x=10.725[y-1.7802x-[0.1927(|x+1|-|x-1|)]\\ D^{\alpha_2}y=x-y+z\\ D^{\alpha_3}z=-10.593y-0.268z\end{cases} $$

By using the NonLinearAlg algorithms to solve this problem:

using FractionalDiffEq, Plots
function chua!(du, x, p, t)
    a, b, c, m0, m1 = p
    du[1] = a*(x[2]-x[1]-(m1*x[1]+0.5*(m0-m1)*(abs(x[1]+1)-abs(x[1]-1))))
    du[2] = x[1]-x[2]+x[3]
    du[3] = -b*x[2]-c*x[3]
end
α = [0.93, 0.99, 0.92];
x0 = [0.2; -0.1; 0.1];
h = 0.01; tspan = (0, 100);
p = [10.725, 10.593, 0.268, -1.1726, -0.7872]
prob = FODESystem(chua!, α, x0, tspan, p)
sol = solve(prob, h, NonLinearAlg())
plot(sol, vars=(1, 2), title="Chua System", legend=:bottomright)

And plot the result:

Chua

Fractional Delay Differential Equations

There are also many powerful solvers for solving fractional delay differential equations.

$$ D^\alpha_ty(t)=3.5y(t)(1-\frac{y(t-0.74)}{19}) $$

$$ y(0)=19.00001 $$

With history function:

$$ y(t)=19,\ t<0 $$

using FractionalDiffEq, Plots
ϕ(x) = x == 0 ? (return 19.00001) : (return 19.0)
f(t, y, ϕ) = 3.5*y*(1-ϕ/19)
h = 0.05; α = 0.97; τ = 0.8; T = 56
fddeprob = FDDEProblem(f, ϕ, α, τ, T)
V, y = solve(fddeprob, h, DelayPECE())
plot(y, V, xlabel="y(t)", ylabel="y(t-τ)")

Delayed

Lyapunov exponents of fractional order system

FractionalDiffEq.jl is capable of generating lyapunov exponents of a fractional order system:

Rabinovich-Fabrikant system:

$$ \begin{cases} D^{\alpha_1} x=y(z-1+z^2)+\gamma x\\ D^{\alpha_2} y=x(3z+1-x^2)+\gamma y\\ D^{\alpha_3} z=-2z(\alpha+xy) \end{cases} $$

julia>LE, tspan = FOLyapunov(RF, 0.98, 0, 0.02, 300, [0.1; 0.1; 0.1], 0.005, 1000)

RF

Available Solvers

For more performant solvers, please refer to the FractionalDiffEq.jl Solvers page.

Road map

  • More performant algorithms
  • Better docs
  • More interesting ideas~

Contributing

If you are interested in Fractional Differential Equations and Julia, welcome to raise an issue or file a Pull Request!!

fractionaldiffeq.jl's People

Contributors

erikqqy avatar github-actions[bot] avatar jclugstor avatar

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.