Open casella opened 1 month ago
Here is a MWE:
model Test
extends ScalableTestSuite.Thermal.HeatExchanger.ScaledExperiments.CounterCurrentHeatExchangerEquations_N_10(N = 2);
annotation(
__OpenModelica_simulationFlags(lv = "LOG_STDOUT,LOG_ASSERT,LOG_JAC,LOG_STATS", s = "dassl", variableFilter = ".*"));
end Test;
The system has three states: TAtilde[1]
, TBtilde[1]
, TW[1]
. The correct ODE jacobian at the end of the simulation computed by the OB-generated code is:
-10.2467 0 1.90476
0 -11.4752 4.7619
1 2.5 -14.0943
while the Jacobian computed by the NB-generated code is
-34.8256 0 0
0 -34.8256 0
0 0 -34.8256
which is obviously plain wrong.
If I try to turn on --generateSymbolicJacobian with the NB, the simulation gives the following error:
Process crashed Simulation process failed. Exited with code 0xffffffffc0000005.
Failed to parse Test_info.json
Expected 45 equations, but only found 32 equations.
Process crashed
@phannebohm, @kabdelhak can you please investigate? Thanks!
This is probably another low-hanging fruit. Checking what goes wrong in this very simple examples with three states should be easy. Maybe that's an easy fix, and it's going to solve other problems.
The ScalableTestSuite_OB test report shows the results of running the tests with the old backend. Cocurrent and Countercurrent heat exchanger models are tested with size up to 1280 volumes. Code generation is O(N) so it grows up to about 16 seconds for the largest two cases, but the simulation time remains under two seconds. For example, the simulation of ScalableTestSuite.Thermal.HeatExchanger.ScaledExperiments.CounterCurrentHeatExchangerEquations_N_1280 has these solver statistics:
Now, if you check the ScalableTestSuite_NB test report, obtained with the NB, the same models show 10X lower code generation times, but much large simulation times. For example, the simulaiton statitstics of ScalableTestSuite.Thermal.HeatExchanger.ScaledExperiments.CounterCurrentHeatExchangerEquations_N_1280 now is:
Clearly, the Jacobian used by IDA is grossly wrong, which causes a lot of convergence test failures and forces the solver to take very short steps in order to achieve convergence when solving the BDF formula.