Last active
May 15, 2019 03:56
-
-
Save asinghvi17/24ec1c836eff363cbb1b1c1999df3db0 to your computer and use it in GitHub Desktop.
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
## setup differential equation | |
using DifferentialEquations, | |
ParameterizedFunctions | |
lorenz = @ode_def Lorenz begin # define the system | |
dx = σ * (y - x) | |
dy = x * (ρ - z) - y | |
dz = x * y - β*z | |
end σ ρ β | |
u0 = [1.0,0.0,0.0] # initial conditions | |
tspan0 = (0.0,100.0) # initial timespan | |
p0 = [10.0,28.0,8/3] # initial parameters | |
prob = ODEProblem(lorenz, u0, tspan0, p0) # define the problem | |
using Makie | |
using AbstractPlotting: textslider | |
## setup sliders and plotting | |
"The order of magnitude to range between." | |
OME = 8 | |
sσ, oσ = textslider(exp10.(-OME:0.001:OME), "σ", start = p0[1]); | |
sρ, oρ = textslider(exp10.(-OME:0.001:OME), "ρ", start = p0[2]); | |
sβ, oβ = textslider(exp10.(-OME:0.001:OME), "β", start = p0[3]); | |
st, ot = textslider(exp10.(-OME:0.001:OME), "tₘₐₓ", start = tspan0[end]); | |
sr, or = textslider(100:10000, "resolution", start = 2000); | |
trange = lift(ot, or) do tmax, resolution | |
LinRange(0.0, tmax, resolution) | |
end | |
data = lift(oσ, oρ, oβ, trange) do σ, ρ, β, ts | |
Point3f0.( | |
solve( | |
remake( | |
prob; | |
p = [σ, ρ, β], | |
tspan = (ts[1], ts[end]) | |
) | |
)(ts).u | |
) # change to fit the dimensionality - maybe even return 2 arrays, or a set of `Point2`s... | |
end | |
three = lines(data) | |
vbox(hbox(sσ, sρ, sβ, st, sr), three) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment