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
I've found it hard to use if statements to control how equations involving arrays behave. This pattern is very common in modelica multibody models, but in MTK I frequently have to degrade parameters to be structural parameters to make it work. The following are two failed attempts
using ModelingToolkit
using ModelingToolkit: t_nounits as t, D_nounits as D
@mtkmodel ArrayIf begin
@parameters begin
stable = true
end
@variables begin
x(t)[1:2]
end
@equations begin
if stable
D(x) ~ -x
else
D(x) ~ x
end
end
end
@mtkbuild arrayif = ArrayIf()
julia> @mtkbuild arrayif = ArrayIf()
ERROR: TypeError: non-boolean (Num) used in boolean context
@mtkmodel ArrayIf begin
@parameters begin
stable = true
end
@variables begin
x(t)[1:2]
end
@equations begin
D(x) ~ ifelse(stable, -x, x)
end
end
@mtkbuild arrayif = ArrayIf()
ERROR: MethodError: no method matching ifelse(::SymbolicUtils.BasicSymbolic{…}, ::Symbolics.ArrayOp{…}, ::SymbolicUtils.BasicSymbolic{…})
I've found it hard to use if statements to control how equations involving arrays behave. This pattern is very common in modelica multibody models, but in MTK I frequently have to degrade parameters to be structural parameters to make it work. The following are two failed attempts