-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from JuliaTurkuDataScience/2nd-order-example
2nd order example
- Loading branch information
Showing
5 changed files
with
37 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using FdeSolver | ||
using Test | ||
using Statistics | ||
|
||
@testset "FdeSolver.jl" begin | ||
|
||
tSpan = [0, 10] # [intial time, final time] | ||
x0 = [1, 1] # intial value | ||
β = 2 # order of the derivative | ||
par = [16.0, 4.0] # [spring constant for a mass on a spring, inertial mass] | ||
h = 0.01 | ||
|
||
function F(t, n, β, x, par) | ||
|
||
K = par[1] | ||
m = par[2] | ||
|
||
- K ./ m .* x[n] | ||
|
||
end | ||
|
||
t, Yapp = FDEsolver(F, tSpan, x0, β, nothing, par, h = h) | ||
|
||
a = x0[1] .* map(cos, sqrt(par[1] / par[2]) .* t) .+ x0[2] ./ sqrt(par[1] / par[2]) .* map(sin, sqrt(par[1] / par[2]) .* t) | ||
|
||
@test @isdefined(t) | ||
@test @isdefined(Yapp) | ||
@test abs((mean(Yapp) - mean(a))) < 0.05 | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters