Hello,
I encountered some problem in MTK which I could recreate in the following MWE:
using Pkg
pkg"activate --temp"
pkg"add ModelingToolkit"
using ModelingToolkit
using ModelingToolkit: t_nounits as t, D_nounits as Dt
@connector Connector begin
potential(t)
flow(t), [connect=Flow]
end
@mtkmodel Storage begin
@components begin
pin = Connector()
end
@variables begin
potential(t)
end
@equations begin
Dt(potential) ~ pin.flow
end
end
@named storage = Storage()
@named pin = Connector()
@parameters begin
inputflow
end
@variables begin
outputpotential(t)
end
eqs = [inputflow ~ pin.flow,
outputpotential ~ pin.potential,
connect(pin, storage.pin)]
@named sys = ODESystem(eqs, t; systems=[pin, storage])
structural_simplify(sys)
Which leads to an error of structural_simplify
because the system is overconstraint:
ERROR: ExtraEquationsSystemException: The system is unbalanced. There are 6 highest order derivative variables and 7 equations.
More equations than variables, here are the potential extra equation(s):
0 ~ pin₊flow(t)
It even points out an equation, but I don’t know where this equation is coming from in the first place. I think I have some deep misunderstand about how flow connectors work. I thought I would model the following system, which should cleanly reduce to just a single ODE:
What am I doing wrong here? Where does the 0 ~ pin₊flow(t)
constraint come from?