An acausal modeling framework for automatically parallelized scientific machine learning (SciML) in Julia. A computer algebra system for integrated symbolics for physics-informed machine learning and automated transformations of differential equations
It works if we skip the initialization problem. But the initialization does something funny. In particular, if you use prob = ODEProblem(simpsys, [D(u[i](t)) => 1.0 for i in 2:6], (0, 2pi)), then you get for the isys:
@parameters t
@variables (u(..))[1:6]
D = Differential(t)
eqs = [0.9(u(t))[6] + D(D((u(t))[2])) ~ 0,
- 0.9(u(t))[4] + D(D((u(t))[3])) ~ 0,
- 0.9(u(t))[5] + D(D((u(t))[4])) ~ 0,
0.9(u(t))[6] + D(D((u(t))[5])) ~ 0,
- 0.9(u(t))[5] + D(D((u(t))[6])) ~ 0,
(u(t))[1] ~ (u(t))[6]]
defaults = Dict(vcat([u(t)[i] => 0.0 for i in 1:6], [D(u(t)[i]) => 1.0 for i in 1:6]))
ps = Pair[]
sys = ODESystem(eqs, t, [u(t)[i] for i in 1:6], ps, defaults=defaults, name = :sys)
simpsys = structural_simplify(sys)
prob = ODEProblem(simpsys, [D(u(t)[i]) => 1.0 for i in 1:6], (0, 2pi))
then you get:
julia> prob = ODEProblem(simpsys, [D(u(t)[i]) => 1.0 for i in 1:6], (0, 2pi))
ERROR: Initialization expression Differential(t)((u(t))[1]) is currently not supported. If its a higher order derivative expression, then only the dummy derivative expressions are supported.
Stacktrace:
[1] error(s::String)
@ Base .\error.jl:35
[2] generate_initializesystem(sys::ODESystem; u0map::Vector{…}, name::Symbol, guesses::Dict{…}, check_defguess::Bool, default_dd_value::Float64, kwargs::@Kwargs{})
@ ModelingToolkit c:\Users\accou\.julia\dev\ModelingToolkit\src\systems\nonlinear\initializesystem.jl:54
[3] generate_initializesystem
@ c:\Users\accou\.julia\dev\ModelingToolkit\src\systems\nonlinear\initializesystem.jl:6 [inlined]
[4] ModelingToolkit.InitializationProblem{…}(sys::ODESystem, t::Int64, u0map::Vector{…}, parammap::SciMLBase.NullParameters; guesses::Dict{…}, check_length::Bool, warn_initialize_determined::Bool, kwargs::@Kwargs{})
@ ModelingToolkit c:\Users\accou\.julia\dev\ModelingToolkit\src\systems\diffeqs\abstractodesystem.jl:1576
[5] InitializationProblem
@ c:\Users\accou\.julia\dev\ModelingToolkit\src\systems\diffeqs\abstractodesystem.jl:1560 [inlined]
[6] #_#762
@ C:\Users\accou\.julia\dev\ModelingToolkit\src\systems\diffeqs\abstractodesystem.jl:1538 [inlined]
[7] #InitializationProblem#760
@ C:\Users\accou\.julia\dev\ModelingToolkit\src\systems\diffeqs\abstractodesystem.jl:1526 [inlined]
[8] process_DEProblem(constructor::Type, sys::ODESystem, u0map::Vector{…}, parammap::SciMLBase.NullParameters; implicit_dae::Bool, du0map::Nothing, version::Nothing, tgrad::Bool, jac::Bool, checkbounds::Bool, sparse::Bool, simplify::Bool, linenumbers::Bool, parallel::Symbolics.SerialForm, eval_expression::Bool, use_union::Bool, tofloat::Bool, symbolic_u0::Bool, u0_constructor::typeof(identity), guesses::Dict{…}, t::Int64, warn_initialize_determined::Bool, build_initializeprob::Bool, kwargs::@Kwargs{…})
@ ModelingToolkit c:\Users\accou\.julia\dev\ModelingToolkit\src\systems\diffeqs\abstractodesystem.jl:889
[9] process_DEProblem
@ c:\Users\accou\.julia\dev\ModelingToolkit\src\systems\diffeqs\abstractodesystem.jl:845 [inlined]
[10] (ODEProblem{…})(sys::ODESystem, u0map::Vector{…}, tspan::Tuple{…}, parammap::SciMLBase.NullParameters; callback::Nothing, check_length::Bool, warn_initialize_determined::Bool, kwargs::@Kwargs{})
@ ModelingToolkit C:\Users\accou\.julia\dev\ModelingToolkit\src\systems\diffeqs\abstractodesystem.jl:1048
[11] ODEProblem
@ ModelingToolkit C:\Users\accou\.julia\dev\ModelingToolkit\src\systems\diffeqs\abstractodesystem.jl:1038 [inlined]
[12] (ODEProblem{true, SciMLBase.AutoSpecialize})(sys::ODESystem, u0map::Vector{Pair{…}}, tspan::Tuple{Int64, Float64})
@ ModelingToolkit C:\Users\accou\.julia\dev\ModelingToolkit\src\systems\diffeqs\abstractodesystem.jl:1038
[13] (ODEProblem{true})(::ODESystem, ::Vector{Pair{Num, Float64}}, ::Vararg{Any}; kwargs::@Kwargs{})
@ ModelingToolkit C:\Users\accou\.julia\dev\ModelingToolkit\src\systems\diffeqs\abstractodesystem.jl:1025
[14] (ODEProblem{true})(::ODESystem, ::Vector{Pair{Num, Float64}}, ::Vararg{Any})
@ ModelingToolkit C:\Users\accou\.julia\dev\ModelingToolkit\src\systems\diffeqs\abstractodesystem.jl:1024
[15] ODEProblem(::ODESystem, ::Vector{Pair{Num, Float64}}, ::Vararg{Any}; kwargs::@Kwargs{})
@ ModelingToolkit C:\Users\accou\.julia\dev\ModelingToolkit\src\systems\diffeqs\abstractodesystem.jl:1014
[16] ODEProblem(::ODESystem, ::Vector{Pair{Num, Float64}}, ::Vararg{Any})
@ ModelingToolkit C:\Users\accou\.julia\dev\ModelingToolkit\src\systems\diffeqs\abstractodesystem.jl:1013
[17] top-level scope
@ REPL[30]:1
Some type information was truncated. Use `show(err)` to see complete types.
The reason that you get this is because u(t)[1] is eliminated from the expression, and so D(u(t)[1]) is not in the diffmap to know how to make it correspond to a differentiation equation.
Take this case which comes from a periodic BC discretization of a PDE:
It works if we skip the initialization problem. But the initialization does something funny. In particular, if you use
prob = ODEProblem(simpsys, [D(u[i](t)) => 1.0 for i in 2:6], (0, 2pi))
, then you get for the isys:This structural simplification bug is https://github.com/SciML/ModelingToolkit.jl/issues/2515. But ignoring that, if we do what we'd want to do, i.e.
then you get:
The reason that you get this is because
u(t)[1]
is eliminated from the expression, and soD(u(t)[1])
is not in thediffmap
to know how to make it correspond to a differentiation equation.