-
Notifications
You must be signed in to change notification settings - Fork 29
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
Overhaul ContinuousDS #20
Comments
@ChrisRackauckas if you have any suggestions that will make the above easier / etc. please go ahead! |
Nah, that looks like how I'd do it. You do have to code a lot of paths in two ways to account for this. Overall, the out-of-place form is usually better for what you're doing I'd think (<100 ODEs). |
Alright, I wish somebody will want to work on this :) I think by viewing how I did it in #23 it can make things very clear! |
@ChrisRackauckas My plan here is to make a continuous dynamical system have a What do you think? |
Well, that's only true for in-place systems. If you're using out-of-place, the cache is essentially nothing. YMMV but that's something to think about. |
It's related to what I commented in the discrete DS issue #21 (comment) but I prefer to make DS types small and immutable structs; almost like a thin wrapper around For example, including integrator into the DS type is bad if you want to send the serialized DS struct over TCP (say) for doing parameter sweep of slightly different parameters and/or initial conditions using multiple machines. You'd just want to send DS definitions, not temporal variables. |
You can't change the system state if it is immutable, which means you have
to create a new one every time you want to change state and you can't
evolve in place either .
…On Feb 8, 2018 5:21 AM, "Takafumi Arakaki" ***@***.***> wrote:
It's related to what I commented in the discrete DS issue #21 (comment)
<#21 (comment)>
but I prefer to make DS types small and immutable structs; almost like a
thin wrapper around DiffEqBase.DiscreteProblem and DiffEqBase.ODEProblem
for packing up phase and tangent space dynamics (and other thing? like the
definition of the domain?).
For example, including integrator into the DS type is bad if you want to
send the serialized DS struct over TCP (say) for doing parameter sweep of
slightly different parameters and/or initial conditions using multiple
machines. You'd just want to send DS definitions, not temporal variables.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#20 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ASwgYbYknsEZULl9HTcNRn242_Wj7X_Eks5tSnYtgaJpZM4R4nVL>
.
|
@Datseris Please read #21 (comment) first |
Yeah
Makes 0 sense to have an "integrator" and "solved" or discrete systems.
Scientifically speaking , they are solved from the moment they are defined.
…On Feb 8, 2018 5:57 AM, "Takafumi Arakaki" ***@***.***> wrote:
@Datseris <https://github.com/datseris> Please read #21 (comment)
<#21 (comment)>
first
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#20 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ASwgYSuxyy6di4JfGu2jPZ5M1Q3d7NTrks5tSn6xgaJpZM4R4nVL>
.
|
Edit: "solver"
…On Feb 8, 2018 6:07 AM, "George Datseris" ***@***.***> wrote:
Yeah
Makes 0 sense to have an "integrator" and "solved" or discrete systems.
Scientifically speaking , they are solved from the moment they are defined.
On Feb 8, 2018 5:57 AM, "Takafumi Arakaki" ***@***.***>
wrote:
> @Datseris <https://github.com/datseris> Please read #21 (comment)
> <#21 (comment)>
> first
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#20 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ASwgYSuxyy6di4JfGu2jPZ5M1Q3d7NTrks5tSn6xgaJpZM4R4nVL>
> .
>
|
Another issue not mentioned in the plan: Currently, I think Also, what There is an additional nice side-effect because it works nice with periodic drive. User can use an integer multiple of periods for reinit!(tangent_system_integrator, u0)
solve!(tangent_system_integrator) to solve the system for a inter-orthonormalization-interval, then the cf. This is how I do van der Pol with periodic drive: Actually, the code above using |
Yeah, but we can also do this as an argument to the top level function though. And it will be less restricting this way imo. The plan is to always use (EDIT: with this approach you only |
Just a quick thought. Maybe we can merge ODEs and maps: struct DynamicalSystem{IIP, IAD, DEP<:DEProblem, JAC}
prob::DEP
jacobian::JAC
end This way, supporting random dynamical system (JuliaDynamics/ChaosTools.jl#32) would be transparent by accepting |
If you make this guarantee (which makes sense), you don't need import DiffEqBase: isinplace
isinplace(ds::ContinuousDynamicalSystem) = isinplace(ds.prob) |
Re: name, maybe just use DiffEqBase.init(ds) = init(ds, Val{:phase}) # default to phase
DiffEqBase.init(ds, ::Type{Val{:phase}}) # phase integrator
DiffEqBase.init(ds, ::Type{Val{:tangent}}) # phase-tangent integrator ...or @RainerEngelken Do you know what the standard term (or any other terms, for brainstorming) for the "derived" dynamical system? By that, I mean the ODE/map coupling the original system and the linearized system for tangent vector evolution. I use "tangent" too but I think it's better to reserve that for the ODE/map for evolving only for tangent vectors. For example, you might want to solve the phase space dynamics first and solve tangent dynamics several times given the solution of that trajectory (by using |
True, but it is still useful for dispatch purposes. From internal tests I found it useful, and it doesn't affect any high or low level API so I will still use it.
Wonderful idea. I only hope it will work out in the end. I will try it.
I am sorry, but I cannot agree with this. I heavily dislike using |
FYI, you can do DiffEqBase.init(ds, kind::Symbol) = init(ds, Val{kind}) to increase readability; i.e., users can do |
At the moment I am using:
I don't want add methods to e.g. What do you think about this syntax? It works and is readable for both kind of continuous or discrete systems. (By the way I have succeeded in merging both discrete and continuous into one |
I agree that it should not be ODEIntegrator, since it can be discrete DS or stochastic. There has to be a unified API to turn a DS type into a integrator. The direction of |
I am using integrator even for discrete, because in DiffEq, discrete problems are evolved using Alright, namings can be decided at the end, I don't really care about them atm. btw I will need your help when I am done with everything, to go over the PR. It is a massive upgrade and one pair of eyes alone (mine) can't be trusted. |
I know, but the libraries downstream to DynamicalSystemsBase does not have to see the name directly. Also, SDE/RODE/DDE/PDE can be used in the future. As you already noticed, avoid using ODEIntegrator helps. About this:
Checkout SciML/OrdinaryDiffEq.jl#253 |
How about using "type alias"?: using DiffEqBase
struct DynamicalSystem{DEP<:DEProblem, JAC}
prob::DEP
jacobian::JAC
DynamicalSystem(prob::DEP, jacobian::JAC = nothing) where {DEP, JAC} =
new{DEP, JAC}(prob, jacobian)
end
const IPContinuousDS = DynamicalSystem{DEP} where {
uType, tType, DEP <: ODEProblem{uType, tType, true}}
const NIPContinuousDS = DynamicalSystem{DEP} where {
uType, tType, DEP <: ODEProblem{uType, tType, false}}
ds_ip = DynamicalSystem(ODEProblem{true}((a...) -> nothing, [0.0], (0.0, 1.0)))
ds_nip = DynamicalSystem(ODEProblem{false}((a...) -> nothing, [0.0], (0.0, 1.0)))
ds_ip :: IPContinuousDS
ds_nip :: NIPContinuousDS
f(::IPContinuousDS) = true
f(::NIPContinuousDS) = false
@show f(ds_ip)
@show f(ds_nip) Since |
Let's continue this on #21 |
EDIT: THIS IS THE NEW AND CURRENT PLAN, IN PROGRESS BY ME IN A BRANCH.
Example at the end!
Rename
ContinuousDS
toContinuousDynamicalSystem
with aliasCDS
.CDS
will have 2 fields:prob::ODEProblem
andjacobian
(which is a function).Define two functions:
makeintegrator(CDS)
andmaketangentintegrator(CDS)
(names to be decided), that return integrators about the system or about the system+tangent space.Internally, all functions of
DynamicalSystemsBase.jl
andChaosTools.jl
(and any other packages of the ecosystem) will usestep!(integrator, Δt)
. An argument likedt
will be given to functions that actually care aboutdt
.Define a function
step!(integrator, Δt)
that steps until a span ofΔt
has passed.All high-level functions and internals for both
DynamicalSystemsBase.jl
andChaosTools.jl
will not care about thetspan
property ofODEProblem
.Be sure that current time and parameters is passed properly into the Jacobian function from ForwardDiff.
Define type aliases for
CDS
andDDS
, e.g.CDS{ODE, A,B,C} = DS{ODE, A, B, C} where {ODE<:ODEProblem, A, B, C}
. This will reduce integrator constructors by half!Provide high level constructors
CDS(eom, state, p [, jacobian])
andCDS(prob [, jacobian])
. The default tspan will be made (0.0, Inf)
.Parameterize
CDS
withIIP
(already part of the ODEProblem).All of the above are meant to work for 2 cases: both in-place (iip) and out-of-place versions. This is a lot of work but the performance benefits of
SVector
for small systems are worth it.Create an oop Lorenz63 model and implement tests, similar to the tests here: https://github.com/JuliaDynamics/DynamicalSystemsBase.jl/blob/master/test/discrete_types.jl
Create a
ParallelIntegrator
(this has already started in the source code) that evolves pairs of vectors of states.All high level functions that want to use a
CDS
, will first callmakeintegrator(CDS)
and immediatelly pass that to a lower-level function that uses the integrator andstep!
. This is very important for parallelization stuff.Here is the struct:
where
IIP
is "isinplace" andIAD
is "is auto differentiated".If the equations for the system are out of place, the Jacobian must be as well. The same for in-place. Supporting all 4 possible variants is a lot of work that I cannot do.
EDIT MORE: Try to combine DISCRETE + Continuous into DynamicalSystem, parameterized by the ODEProblem type. Meaning:
The text was updated successfully, but these errors were encountered: