Thankyou Chris.
Yeah… I do look into it. But the code given in the documentation isn’t working fine with me. The trouble is with trying to create a simulation model with the obtained result. These are the package specifications I use.
Julia 1.7.1
DataDrivenDiffEq v0.8.5
DifferentialEquations v7.5.0
Interpolations v0.14.6
ModelingToolkit v8.27.0
Plots v1.35.3
Below is the code and corresponding error message I received.
using DataDrivenDiffEq
using LinearAlgebra
using ModelingToolkit
using OrdinaryDiffEq
function slow_manifold(du, u, p, t)
du[1] = p[1] * u[1]
du[2] = p[2] * (u[2] - u[1]^2)
end
u0 = [3.0; -2.0]
tspan = (0.0, 5.0)
p = [-0.8; -0.7]
problem = ODEProblem(slow_manifold, u0, tspan, p)
solution = solve(problem, Tsit5(), saveat = 0.01);
prob = ContinuousDataDrivenProblem(solution)
@parameters t
@variables u[1:2](t)
Ψ = Basis([u; u[1]^2], u, independent_variable = t)
res = solve(prob, Ψ, DMDPINV(), digits = 1)
system = result(res)
sparse_res = solve(prob, Ψ, STLSQ(), digits = 1)
sparse_system = result(sparse_res)
parameter_map(res)
parameter_map(sparse_res)
@named sys = ODESystem(
equations(sparse_system),
get_iv(sparse_system),
states(sparse_system),
parameters(sparse_system)
);
ArgumentError: p₁ is not a parameter.
Stacktrace:
[1] check_parameters(ps::Vector{Sym{Real, Base.ImmutableDict{DataType, Any}}}, iv::Sym{Real, Base.ImmutableDict{DataType, Any}})
@ ModelingToolkit C:\Users\Jisna\.julia\packages\ModelingToolkit\2nkY8\src\utils.jl:135
[2] ODESystem(tag::UInt64, deqs::Vector{Equation}, iv::Sym{Real, Base.ImmutableDict{DataType, Any}}, dvs::Vector{Term{Real, Base.ImmutableDict{DataType, Any}}}, ps::Vector{Sym{Real, Base.ImmutableDict{DataType, Any}}}, var_to_name::Dict{Any, Any}, ctrls::Vector{Any}, observed::Vector{Equation}, tgrad::Base.RefValue{Vector{Num}}, jac::Base.RefValue{Any}, ctrl_jac::Base.RefValue{Any}, Wfact::Base.RefValue{Matrix{Num}}, Wfact_t::Base.RefValue{Matrix{Num}}, name::Symbol, systems::Vector{ODESystem}, defaults::Dict{Any, Any}, torn_matching::Nothing, connector_type::Nothing, preface::Nothing, cevents::Vector{ModelingToolkit.SymbolicContinuousCallback}, devents::Vector{ModelingToolkit.SymbolicDiscreteCallback}, metadata::Nothing, tearing_state::Nothing, substitutions::Nothing, complete::Bool; checks::Bool)
@ ModelingToolkit C:\Users\Jisna\.julia\packages\ModelingToolkit\2nkY8\src\systems\diffeqs\odesystem.jl:136
[3] ODESystem(deqs::Vector{Equation}, iv::Num, dvs::Vector{Num}, ps::Vector{Sym{Real, Base.ImmutableDict{DataType, Any}}}; controls::Vector{Num}, observed::Vector{Equation}, systems::Vector{ODESystem}, name::Symbol, default_u0::Dict{Any, Any}, default_p::Dict{Any, Any}, defaults::Dict{Any, Any}, connector_type::Nothing, preface::Nothing, continuous_events::Nothing, discrete_events::Nothing, checks::Bool, metadata::Nothing)
@ ModelingToolkit C:\Users\Jisna\.julia\packages\ModelingToolkit\2nkY8\src\systems\diffeqs\odesystem.jl:197
[4] top-level scope
@ C:\Users\Jisna\.julia\packages\ModelingToolkit\2nkY8\src\systems\abstractsystem.jl:866