From 93887e501780031e4007d6eaea1bc1ca23cec025 Mon Sep 17 00:00:00 2001 From: Dan Padilha Date: Fri, 13 Aug 2021 12:15:41 +0900 Subject: [PATCH 1/4] Bump versions on Symbolics, SymbolicUtils, ModelingToolkit. --- Project.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index c27d10d..7c08562 100644 --- a/Project.toml +++ b/Project.toml @@ -53,7 +53,7 @@ GeneralizedGenerated = "0.3.2" KernelDensity = "0.6.2" LineSearches = "7.1.1" Memoize = "0.4.4" -ModelingToolkit = "5.6.4" +ModelingToolkit = "6" NLsolve = "4.5.1" OrdinaryDiffEq = "5.49.1" PhysicalConstants = "0.2.1" @@ -67,7 +67,7 @@ SciMLBase = "1.8" SimpleTraits = "0.9.3" StaticArrays = "1" StatsPlots = "0.14.17" -SymbolicUtils = "0.8.4, 0.9, 0.10, 0.11" -Symbolics = "0.1.2" +SymbolicUtils = "0.13" +Symbolics = "3" Unitful = "1.5.0" julia = "1.6" From 37e5ab1a84e46a32fa6fa50c144220b8681238d4 Mon Sep 17 00:00:00 2001 From: Dan Padilha Date: Sun, 15 Aug 2021 22:24:29 +0900 Subject: [PATCH 2/4] Add ODESystem names for 3BP models. --- src/dynamics/dynamical_models.jl | 7 ++++--- src/dynamics/models/cr3bp.jl | 2 +- src/dynamics/models/er3bp.jl | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/dynamics/dynamical_models.jl b/src/dynamics/dynamical_models.jl index 50682fe..02c7ed8 100644 --- a/src/dynamics/dynamical_models.jl +++ b/src/dynamics/dynamical_models.jl @@ -35,7 +35,8 @@ end eqs, dvs = ode_order_lowering(eqs, independent_variable(_ode), ModelingToolkit.states(_ode)) eqs = [eqs[end - num_orig_eqs + 1:end]..., eqs[1:num_orig_eqs]...] dvs = [dvs[end - num_orig_eqs + 1:end]..., dvs[1:num_orig_eqs]...] - ODESystem(simplify.(eqs), independent_variable(_ode), dvs, parameters(_ode)) + + ODESystem(simplify.(eqs), independent_variable(_ode), dvs, parameters(_ode); name=nameof(_ode)) end @@ -80,5 +81,5 @@ state_length(s::State) = state_length(s.model) # INCLUDES # #----------# include("models/3bp.jl") -include("models/4bp.jl") -include("models/nbp.jl") \ No newline at end of file +# include("models/4bp.jl") +# include("models/nbp.jl") \ No newline at end of file diff --git a/src/dynamics/models/cr3bp.jl b/src/dynamics/models/cr3bp.jl index 50180b3..c1b279f 100644 --- a/src/dynamics/models/cr3bp.jl +++ b/src/dynamics/models/cr3bp.jl @@ -14,7 +14,7 @@ function ModelingToolkit.ODESystem(::Type{CR3BP_ODESystem}) eqs_er3bp = ODESystem(ER3BP_ODESystem) (μ, e) = parameters(eqs_er3bp) eqs = [eq.lhs ~ simplify(substitute(eq.rhs, e => 0)) for eq in equations(eqs_er3bp)] - return ODESystem(eqs, independent_variable(eqs_er3bp), states(eqs_er3bp), [μ]) + return ODESystem(eqs, independent_variable(eqs_er3bp), states(eqs_er3bp), [μ]; name=:CR3BP) end # Build the equations at pre-compile time diff --git a/src/dynamics/models/er3bp.jl b/src/dynamics/models/er3bp.jl index f41e60b..adb1d09 100644 --- a/src/dynamics/models/er3bp.jl +++ b/src/dynamics/models/er3bp.jl @@ -9,7 +9,7 @@ struct ER3BP_ODESystem{S,F} <: Abstract_AstrodynamicalODESystem ode_f :: F end -function ModelingToolkit.ODESystem(::Type{ER3BP_ODESystem}) +function ModelingToolkit.ODESystem(::Type{T}) where {T<:ER3BP_ODESystem} @parameters μ # Mass fraction @parameters e # Eccentricity @parameters f # True anomaly @@ -27,7 +27,8 @@ function ModelingToolkit.ODESystem(::Type{ER3BP_ODESystem}) ], f, [x, y, z], - [μ, e] + [μ, e]; + name=nameof(T) ) end From 63865b554d7518ba6831916bf494c3891e2e815d Mon Sep 17 00:00:00 2001 From: Dan Padilha Date: Sun, 15 Aug 2021 22:25:04 +0900 Subject: [PATCH 3/4] Add expand_derivatives to get around the issue in SciML/ModelingToolkit.jl#1197 --- src/dynamics/models/er3bp.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dynamics/models/er3bp.jl b/src/dynamics/models/er3bp.jl index adb1d09..51da789 100644 --- a/src/dynamics/models/er3bp.jl +++ b/src/dynamics/models/er3bp.jl @@ -20,11 +20,11 @@ function ModelingToolkit.ODESystem(::Type{T}) where {T<:ER3BP_ODESystem} # [DeiTos2017, Eqs. 14] # NOTE: need to expand the RHS derivatives before calling order-lowering ω = elliptical_potential(μ, (x, y, z), f, e) - return ODESystem([ + return ODESystem(expand_derivatives.([ D2(x) ~ +2D(y) + Dx(ω), D2(y) ~ -2D(x) + Dy(ω), D2(z) ~ + Dz(ω) - ], + ]), f, [x, y, z], [μ, e]; From 0b8f2754ec0c8ac1ac124cc057a09dfcec1efeb7 Mon Sep 17 00:00:00 2001 From: Dan Padilha Date: Mon, 16 Aug 2021 00:27:31 +0900 Subject: [PATCH 4/4] Re-add 4BP and NBP models. --- src/dynamics/dynamical_models.jl | 4 ++-- src/dynamics/models/bc4bp.jl | 2 +- src/dynamics/models/nbp.jl | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dynamics/dynamical_models.jl b/src/dynamics/dynamical_models.jl index 02c7ed8..d4c9d3d 100644 --- a/src/dynamics/dynamical_models.jl +++ b/src/dynamics/dynamical_models.jl @@ -81,5 +81,5 @@ state_length(s::State) = state_length(s.model) # INCLUDES # #----------# include("models/3bp.jl") -# include("models/4bp.jl") -# include("models/nbp.jl") \ No newline at end of file +include("models/4bp.jl") +include("models/nbp.jl") \ No newline at end of file diff --git a/src/dynamics/models/bc4bp.jl b/src/dynamics/models/bc4bp.jl index be74800..b1ef386 100644 --- a/src/dynamics/models/bc4bp.jl +++ b/src/dynamics/models/bc4bp.jl @@ -38,7 +38,7 @@ function ModelingToolkit.ODESystem(::Type{BC4BP_ODESystem}) eqs = @. D2(p) ~ [+2D(y) + x, -2D(x) + y, 0] + forces # Simplify and return the system - return ODESystem(simplify.(eqs), t, [x, y, z], [μ, μ2, a3, α0, a3, ω3]) + return ODESystem(simplify.(expand_derivatives.(eqs)), t, [x, y, z], [μ, μ2, a3, α0, a3, ω3]; name=:BC4BP) end # Build the equations at pre-compile time diff --git a/src/dynamics/models/nbp.jl b/src/dynamics/models/nbp.jl index b91d327..346e450 100644 --- a/src/dynamics/models/nbp.jl +++ b/src/dynamics/models/nbp.jl @@ -69,7 +69,7 @@ end eqs = @. D2(pos) ~ sum(accelerations) # Build the 2nd-order ODE props - return ODESystem(eqs, t, pos, []) + return ODESystem(expand_derivatives.(eqs), t, pos, []; name=:EphemerisNBP) end #---------------------#