SciML / DataDrivenDiffEq.jl

Data driven modeling and automated discovery of dynamical systems for the SciML Scientific Machine Learning organization
https://docs.sciml.ai/DataDrivenDiffEq/stable/
MIT License
402 stars 56 forks source link

Linear Time Continuous System Documentation Example Errors in ODESystem Creation #385

Closed abhijit-c closed 1 year ago

abhijit-c commented 1 year ago

Hello,

I've been trying to learn this library, and in the process I've been trying to run the following example in the documentation.

https://docs.juliahub.com/DataDrivenDiffEq/EZBji/0.8.6/examples/2_linear_continuous_system/

In particular, I've copy pasted the 'copy-pastable code' at the end into my enviornment. However, the line which reads:

@named sys = ODESystem(
    equations(sparse_system),
    get_iv(sparse_system),
    states(sparse_system),
    parameters(sparse_system)
    );

Errors out with the message ERROR: LoadError: ArgumentError: p₁ is not a parameter. I've included the full stack trace at the end of this comment as well as my package versions for my enviornment.

Has something changed in either the parameters function or the ODESystem function since this documentation has been written which breaks this piece of code? Alternatively, how would you suggest unpacking the data structures and solving the resulting ODE from a sparse identification problem. Thanks for any insight here.

(@v1.8) pkg> st DataDrivenDiffEq
Status `~/.julia/environments/v1.8/Project.toml`
  [2445eb08] DataDrivenDiffEq v0.8.6

(@v1.8) pkg> st ModelingToolkit
Status `~/.julia/environments/v1.8/Project.toml`
  [961ee093] ModelingToolkit v8.30.0

(@v1.8) pkg> st OrdinaryDiffEq
Status `~/.julia/environments/v1.8/Project.toml`
  [1dea7af3] OrdinaryDiffEq v6.29.3

julia> include("test.jl")
ERROR: LoadError: 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 ~/.julia/packages/ModelingToolkit/HUZd5/src/utils.jl:135
 [2] ODESystem(tag::UInt64, deqs::Vector{Equation}, iv::Sym{Real, Base.ImmutableDict{DataType, Any}}, dvs::Vector{Term{Real, Nothing}}, ps::Vector{Sym{Real, Base.ImmutableDict{DataType, Any}}}, tspan::Nothing, 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 ~/.julia/packages/ModelingToolkit/HUZd5/src/systems/diffeqs/odesystem.jl:138
 [3] ODESystem(deqs::Vector{Equation}, iv::Num, dvs::Vector{Term{Real, Nothing}}, ps::Vector{Sym{Real, Base.ImmutableDict{DataType, Any}}}; controls::Vector{Num}, observed::Vector{Equation}, systems::Vector{ODESystem}, tspan::Nothing, 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 ~/.julia/packages/ModelingToolkit/HUZd5/src/systems/diffeqs/odesystem.jl:200
 [4] top-level scope
   @ ~/.julia/packages/ModelingToolkit/HUZd5/src/systems/abstractsystem.jl:867
 [5] include(fname::String)
   @ Base.MainInclude ./client.jl:476
 [6] top-level scope
   @ REPL[1]:1
in expression starting at /home/trostaft/Documents/AcademicFiles/DataDrivenModeling/project4/abhi_code/test.jl:30
AlCap23 commented 1 year ago

Closed via #371