Opened 6 years ago

Closed 6 years ago

#4981 closed defect (fixed)

Bad performance of IF97 Modelica.Medium model in NF

Reported by: Francesco Casella Owned by: Per Östlund
Priority: high Milestone: 2.0.0
Component: New Instantiation Version:
Keywords: Cc:

Description

The good news is that the SteamPipe_N_XX models of the ScalableTestSuite, which use the very complex IF97 water model from Modelica.Media are now handled by the NF and produce correct results. Also, the time taken by the NF to flatten the model is more than an order of magnitude less than the old FE.

The bad news is that the generated code is very slow, actually causing the timeout of all the cases in the testsuite.

Please consider this smaller version of the test cases

model Test
  extends ScalableTestSuite.Thermal.Advection.Models.SteamPipe(N = 1);
  annotation (experiment(
      StopTime=20,
      NumberOfIntervals=500,
      Tolerance=1e-004));
end Test;

When using the old FE, the simulation takes 0.06 s, while with the NF, it is around 8 s. The reason is an unwanted nonlinear loop involving the computation of steam properties, which is very time-consuming.

non-linear (torn), unknowns: 18, iteration variables: 1 der(h[1])
$cse2 := $DER$Modelica$PMedia$PWater$PIF97_Utilities$PwaterBaseProp_ph(p[1], h[1], 0, 0, $DER.p[1], $DER.h[1]);
(residual) $DER$Modelica$PMedia$PWater$PIF97_Utilities$Prho_props_ph(p[1], h[1], $cse1, 0.0, 0.0, $cse2) - $DER.rho[1] = 0
(torn) der(p[1]) := (M[1] * der(h[1]) + $DER.M[1] * h[1] - $DER.E[1]) / V

The output of -d=optdaedump is nearly identical, except for a small difference:

Old FE:
12/12 (16): $cse1 = Modelica.Media.Water.IF97_Utilities.waterBaseProp_ph(p[1], h[1], 0, 0)   [unknown |0|0|0|0|] 
13/28 (1): $DER.rho[1] = Modelica.Media.Water.IF97_Utilities.rho_ph_der(p[1], h[1], $cse1, der(p[1]), der(h[1]))   [unknown |0|0|0|0|] 

NF:
12/12 (16): $cse2 = $DER$Modelica$PMedia$PWater$PIF97_Utilities$PwaterBaseProp_ph(p[1], h[1], 0, 0, der(p[1]), der(h[1]))   [unknown |0|0|0|0|] 
13/28 (16): $cse1 = Modelica.Media.Water.IF97_Utilities.waterBaseProp_ph(p[1], h[1], 0, 0)   [unknown |0|0|0|0|] 
14/44 (1): $DER.rho[1] = $DER$Modelica$PMedia$PWater$PIF97_Utilities$Prho_props_ph(p[1], h[1], $cse1, 0.0, 0.0, $cse2)   [unknown |0|0|0|0|] 

The old FE correctly handles the Inline and derivative annotations of the Medium functions, eventually calling rho_ph_der. Apparently, the NF loses some of these annotations, forcing the back-end to take a much more expensive route (including implicit equations and numerical differentiation) to solve the equations.

Unfortunately, if I flatten the model with OMEdit, the annotations are never shown (should they?), so I can't tell which one is lost, but if you check among the functions reported above it shouldn't be hard to find that out and fix the problem.

Change History (1)

comment:1 by Per Östlund, 6 years ago

Resolution: fixed
Status: newclosed

Fixed in 5f366bae.

Note: See TracTickets for help on using tickets.