-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using NeuralNetworkBlock results in an ODESystem with mass matrix #31
Comments
This seems to happen due to function registration. Consider the following: using ModelingToolkitStandardLibrary.Blocks
@named out_inside = RealOutputArray(nout=2)
@named out_outside = RealOutputArray(nout=2)
@named in_inside = RealInputArray(nin=2)
@named in_outside = RealInputArray(nin=2)
@variables x(t) = 0
f(x) = x .* x
f2(x) = x .* x
@register_array_symbolic f(x::AbstractVector) begin
size=(2,)
end
eqs = [
D(x) ~ x + in_outside.u[1],
out_outside.u[1] ~ x,
out_outside.u[2] ~ x+1,
out_inside.u ~ f2(in_inside.u),
connect(out_inside, in_outside),
connect(in_inside, out_outside)
]
@named sys = ODESystem(eqs, t)
ss = structural_simplify(sys) if you use
but if you use
|
But I don't see any Thanks |
Unfortunately, I am not sure we can avoid registration in |
Yes, function registration is crucial for this to work. |
When running the friction example, I noticed that after:
the resulting system has a mass matrix and the unknowns are:
I checked a little deeper and noticed that nn₊input₊u has irreducible set in its metadata.
I suggest not making this a default behavior since a system with a mass matrix restricts the set of solvers that can be used for the problem. One could create an option in the NeuralNetworkBlock to make the input irreducible.
The text was updated successfully, but these errors were encountered: