fix: automatically remove false structural and symbolic incidences#34
fix: automatically remove false structural and symbolic incidences#34AayushSabharwal merged 4 commits intomainfrom
Conversation
|
A clarifying description: The initial problem is that (ignoring I tried to fix this by enabling the flag by default. There’s no place where that function is called that doesn’t want to remove false incidences. I also made it symbolically remove false incidences. However, this leads to two issues: We were previously “guarded” from these bugs by the flag being disabled, and resultant warnings being spammed. So, |
…ally The differentiated equation could symbolically contain a variable but be singular in it. This would then be removed by `find_eq_solvables!` but be mishandled in tearing.
c44abce to
40f6aa3
Compare
Close SciML/ModelingToolkit.jl#4282
Some equations in the system can contain false incidence information for some variables, such as in the test where
xis symbolically present in the equation but is easily eliminated. This causes some"internal error"warnings, as well as bad simplification. If the equation is differentiated, the problem worsens. Now,find_eq_solvables!hasmay_be_zero = trueby default. It will always remove false incidence information, and update the symbolic equations accordingly too. Inadvertently, this fixes the below issueClose SciML/ModelingToolkit.jl#3897
since we need to use the new
strictflag inlinear_expansion(viaLinearExpander). Even more incidentally, I think part of the reason this flag wasn't on by default is becauselinear_expansionwould falsely claim that elements of arrays aren't present in an expression that contains an indexed registered array function involving the array. See the test case in https://github.com/JuliaSymbolics/Symbolics.jl/blob/master/test/linear_solver.jl#L168, which this PR depends on. Now that that is fixed, we won't falsely assume that a variable isn't present and thus won't incorrectly remove the incidence. As a result, MTK won't spam warnings in such cases. This shouldn't (and doesn't, for the cases I tried) affect simplification. Since the warnings were ignored anyway, this is a strict improvement. As a result, we canClose SciML/ModelingToolkit.jl#3003