From 641fd6437003ebd7a2ab5ddb211ea5de4f70f15e Mon Sep 17 00:00:00 2001 From: Orjan Ameye Date: Tue, 29 Oct 2024 10:50:41 +0000 Subject: [PATCH] feat: add `ODEProblem(::DIfferentialEquation) (#302) --- ext/ModelingToolkitExt.jl | 1 + test/ModelingToolkitExt.jl | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ext/ModelingToolkitExt.jl b/ext/ModelingToolkitExt.jl index de0cd3c7..ccfbabaa 100644 --- a/ext/ModelingToolkitExt.jl +++ b/ext/ModelingToolkitExt.jl @@ -61,6 +61,7 @@ function ModelingToolkit.ODESystem(eom::HarmonicEquation) end function ModelingToolkit.ODESystem(diff_eq::DifferentialEquation) + diff_eq = deepcopy(diff_eq) if !is_rearranged_standard(diff_eq) rearrange_standard!(diff_eq) end diff --git a/test/ModelingToolkitExt.jl b/test/ModelingToolkitExt.jl index 778253f1..690bc7b3 100644 --- a/test/ModelingToolkitExt.jl +++ b/test/ModelingToolkitExt.jl @@ -1,11 +1,9 @@ using HarmonicBalance using ModelingToolkit - -ModelingToolkitExt = Base.get_extension(HarmonicBalance, :ModelingToolkitExt) - using Test @testset "Utilities" begin + ModelingToolkitExt = Base.get_extension(HarmonicBalance, :ModelingToolkitExt) @variables α check = ModelingToolkitExt.declare_parameter(α) @test ModelingToolkit.PARAMETER ∈ values(check.val.metadata) @@ -25,6 +23,9 @@ end for p in string.([α, ω, ω0, F, γ]) @test p ∈ string.(parameters(sys)) end + + # can run a second time without error; diff_eq unmutated + ODESystem(diff_eq) end @testset "ODEProblem" begin @variables α ω ω0 F γ t x(t)