-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RateSystem #117
base: main
Are you sure you want to change the base?
RateSystem #117
Changes from 2 commits
e58aeab
c7d44b1
c71f1b4
525c6a1
4e8366c
727740f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# | | | | | ||
# t_i autonomous t_ni non-autonomous t_nf autonomous t_f | ||
# | | | | | ||
|
||
using DynamicalSystems | ||
using Plots | ||
|
||
# we write | ||
|
||
function RateSyst(tni,tnf,f,λ,p_λ,initvals) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my opinion, these are quite many positional arguments, which makes it less user-friendly. What do you think of reorganising this in the following structure: RateSystem(ds::ContinuousTimeDynamicalSystem, rate_protocol::function) where rate_protocol(u, p_lambda, t; t_start=0.0, t_end=Inf, kwargs...) i.e. it would contain all the input arguments needed to define the rate forcing function. Behind the scenes, this would then create and return a new There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The naming here is just a suggestion, but generally I think we should give more descriptive names than just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This sounds great, thanks Reyk! However, rate_protocol should not depend on u, in my opinion. |
||
func(u,p,t) = combined_system(u,t,tni,tnf,f,λ,p_λ); | ||
return ContinuousDynamicalSystem(func, initvals, Float64[], t0=tni) | ||
oameye marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end | ||
|
||
function combined_system(u,t,tni,tnf,f,λ,p_λ) | ||
lambda = t < tni ? λ(u,p_λ,tni) : tni <= t <= tnf ? λ(u,p_λ,t) : λ(u,p_λ,tnf) | ||
return f(u,lambda,t) | ||
oameye marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end; | ||
|
||
|
||
oameye marked this conversation as resolved.
Show resolved
Hide resolved
|
||
############### | ||
# user writes | ||
|
||
function f(u::SVector{1, Float64},p::SVector{1, Float64},t::Float64) | ||
oameye marked this conversation as resolved.
Show resolved
Hide resolved
|
||
x = u[1] | ||
λ = p[1] | ||
dx = (x+λ)^2 - 1 | ||
oameye marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return SVector{1}(dx) | ||
end; | ||
|
||
function λ(p::Vector{Float64},t::Float64) | ||
r,λ_max = p | ||
lambda = (λ_max/2)*(tanh(λ_max*r*t/2) +1) | ||
oameye marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return SVector{1}(lambda) | ||
end; | ||
|
||
tni=-10.; tnf=10.; p_λ = [1.0,3.0]; initvals = [-4.]; | ||
sys = RateSyst(tni,tnf,f,λ,p_λ,initvals) | ||
|
||
traj=trajectory(sys,40.,t0=-20.) | ||
oameye marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
trajic=[traj[1][i][1] for i in 1:length(traj[1])] | ||
plot(collect(traj[2]),trajic) | ||
oameye marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
oameye marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# further ideas | ||
# function futureSyst(RateSyst) | ||
# Canard Trajectories | ||
|
||
# \dot(x) = f(x(t),λ(t)) | ||
|
||
|
||
|
||
oameye marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be sufficient to use
DynamicalSystemsBase
.