From dfe1dbedf41cfc9983cb445be7dd2fbefcffcebc Mon Sep 17 00:00:00 2001 From: CompatHelper Julia Date: Tue, 27 Feb 2024 00:58:41 +0000 Subject: [PATCH 1/2] CompatHelper: bump compat for GeometricEquations to 0.16, (keep existing compat) --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 590c583..5004458 100644 --- a/Project.toml +++ b/Project.toml @@ -12,7 +12,7 @@ Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7" [compat] GeometricBase = "0.9" -GeometricEquations = "0.12, 0.13, 0.14, 0.15" +GeometricEquations = "0.12, 0.13, 0.14, 0.15, 0.16" RuntimeGeneratedFunctions = "0.5" Symbolics = "5" julia = "1.6" From 0f89fc6988781e513a8c3d4e97d7abbb6d5c337c Mon Sep 17 00:00:00 2001 From: Michael Kraus Date: Tue, 27 Feb 2024 17:40:43 +0100 Subject: [PATCH 2/2] Update for GeometricBase v0.10 and GeometricEquations v0.16. --- Project.toml | 4 ++-- src/EulerLagrange.jl | 2 +- src/hamiltonian.jl | 6 ++++++ src/lagrangian.jl | 9 ++++++++- src/lagrangian_degenerate.jl | 9 ++++++++- test/lagrangian_particle.jl | 2 +- 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/Project.toml b/Project.toml index 1bd1cdf..dd4d5ac 100644 --- a/Project.toml +++ b/Project.toml @@ -11,8 +11,8 @@ RuntimeGeneratedFunctions = "7e49a35a-f44a-4d26-94aa-eba1b4ca6b47" Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7" [compat] -GeometricBase = "0.9, 0.10" -GeometricEquations = "0.12, 0.13, 0.14, 0.15, 0.16" +GeometricBase = "0.10" +GeometricEquations = "0.16" RuntimeGeneratedFunctions = "0.5" Symbolics = "5" julia = "1.6" diff --git a/src/EulerLagrange.jl b/src/EulerLagrange.jl index 898c6c3..a586a51 100644 --- a/src/EulerLagrange.jl +++ b/src/EulerLagrange.jl @@ -1,6 +1,6 @@ module EulerLagrange - using GeometricBase: NullParameters, StateVariable + using GeometricBase: NullParameters, StateVariable, AlgebraicVariable using LinearAlgebra using RuntimeGeneratedFunctions using Symbolics diff --git a/src/hamiltonian.jl b/src/hamiltonian.jl index b6c7585..59bb390 100644 --- a/src/hamiltonian.jl +++ b/src/hamiltonian.jl @@ -110,3 +110,9 @@ function HODEProblem(lsys::HamiltonianSystem, tspan::Tuple, tstep::Real, q₀::S ics = (q = q₀, p = p₀) HODEProblem(lsys, tspan, tstep, ics; kwargs...) end + +function HODEProblem(lsys::HamiltonianSystem, tspan::Tuple, tstep::Real, q₀::AbstractArray, p₀::AbstractArray; kwargs...) + _q₀ = StateVariable(q₀) + _p₀ = StateVariable(p₀) + HODEProblem(lsys, tspan, tstep, _q₀, _p₀; kwargs...) +end diff --git a/src/lagrangian.jl b/src/lagrangian.jl index 2f59f0a..6726414 100644 --- a/src/lagrangian.jl +++ b/src/lagrangian.jl @@ -119,7 +119,14 @@ function LODEProblem(lsys::LagrangianSystem, tspan::Tuple, tstep::Real, ics::Nam LODEProblem(eqs.ϑ, eqs.f, eqs.g, eqs.ω, eqs.L, tspan, tstep, ics; v̄ = v̄, f̄ = f̄, kwargs...) end -function LODEProblem(lsys::LagrangianSystem, tspan::Tuple, tstep::Real, q₀::StateVariable, p₀::StateVariable, λ₀::StateVariable = zero(q₀); kwargs...) +function LODEProblem(lsys::LagrangianSystem, tspan::Tuple, tstep::Real, q₀::StateVariable, p₀::StateVariable, λ₀::AlgebraicVariable; kwargs...) ics = (q = q₀, p = p₀, λ = λ₀) LODEProblem(lsys, tspan, tstep, ics; kwargs...) end + +function LODEProblem(lsys::LagrangianSystem, tspan::Tuple, tstep::Real, q₀::AbstractArray, p₀::AbstractArray, λ₀::AbstractArray = zero(q₀); kwargs...) + _q₀ = StateVariable(q₀) + _p₀ = StateVariable(p₀) + _λ₀ = AlgebraicVariable(λ₀) + LODEProblem(lsys, tspan, tstep, _q₀, _p₀, _λ₀; kwargs...) +end diff --git a/src/lagrangian_degenerate.jl b/src/lagrangian_degenerate.jl index 9e44473..5c4aa49 100644 --- a/src/lagrangian_degenerate.jl +++ b/src/lagrangian_degenerate.jl @@ -114,7 +114,14 @@ function LODEProblem(lsys::DegenerateLagrangianSystem, tspan::Tuple, tstep::Real LODEProblem(eqs.ϑ, eqs.f, eqs.g, eqs.ω, eqs.L, tspan, tstep, ics; v̄ = v̄, f̄ = f̄, kwargs...) end -function LODEProblem(lsys::DegenerateLagrangianSystem, tspan::Tuple, tstep::Real, q₀::StateVariable, p₀::StateVariable, λ₀::StateVariable = zero(q₀); kwargs...) +function LODEProblem(lsys::DegenerateLagrangianSystem, tspan::Tuple, tstep::Real, q₀::StateVariable, p₀::StateVariable, λ₀::AlgebraicVariable; kwargs...) ics = (q = q₀, p = p₀, λ = λ₀) LODEProblem(lsys, tspan, tstep, ics; kwargs...) end + +function LODEProblem(lsys::DegenerateLagrangianSystem, tspan::Tuple, tstep::Real, q₀::AbstractArray, p₀::AbstractArray, λ₀::AbstractArray = zero(q₀); kwargs...) + _q₀ = StateVariable(q₀) + _p₀ = StateVariable(p₀) + _λ₀ = AlgebraicVariable(λ₀) + LODEProblem(lsys, tspan, tstep, _q₀, _p₀, _λ₀; kwargs...) +end diff --git a/test/lagrangian_particle.jl b/test/lagrangian_particle.jl index 67c17af..5b7263e 100644 --- a/test/lagrangian_particle.jl +++ b/test/lagrangian_particle.jl @@ -17,7 +17,7 @@ f₁, f₂ = zero(p₀), zero(p₀) ntime = 1000 tstep = 0.01 tspan = (0.0, ntime * tstep) -ics = (q = q₀, p = p₀, λ = zero(q₀)) +ics = (q = StateVariable(q₀), p = StateVariable(p₀), λ = AlgebraicVariable(zero(q₀))) # Test without parameters