Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Array use leads to excessive compilation times

Array use leads to excessive compilation times

I have developed an engine simulation model that includes an object component that allows for the modelling of a complete revolution of an engine cycle. The model works well and as an example, a  simulation of 1440 separate seconds within a day with a 501 element rotational arrays produces good results.

The problem with the model is that if I set the number of rotational elements to a value of 501 elements, the execution time increases as expected, but more significantly the compilation time becomes orders of magnitude longer. This is not an issue when a single simulation is run for an extended period as there is only one compilation process so the compilation time is just a single overhead at the beginning of the total simulation time. However, we would like to run multiple scenarios by varying parameters in the model and so each scenario requires a compilation step and makes the sensitivity study not possible

The included EngineState component has a parameter STEPS set to the number of steps of crank angle in the model. If no rotational analysis is required the number of steps can be set to 0 and as there is a FOR loop in the EngineState component, so STEPS = 0 effectively turns off the rotational analysis and the compilation time then becomes 3-4 seconds. A high number of rotational steps is required by the model , otherwise there are stability issues, so when STEPS = 501 the compilation time increases to about 12 MINUTES and the execution time is about 3 to 4 times longer which is expected and acceptable.

Here is the setting of the number of rotational steps in the included EngineState component:

Parent model

Code:


  // rotational
  Bases.EngineState engine_state(STEPS = N, PROP_UNA_STEPS = PROPORTION_UNA_OPEN_STEPS) "Engine state for the current time step";

And here is the EngineState model array definitions:

Bases.EngineState

Code:


  // angular variables
  Modelica.SIunits.Angle[STEPS] crank_angles "Crank angle steps in radians";
  Real[STEPS] strokes "Stroke steps";
  Modelica.SIunits.Area[STEPS] exhaust_valve_areas "Exhaust valve open area in m2";
  Modelica.SIunits.Area[STEPS] una_port_areas "Unaflow exhaust port open area in m2";
  Modelica.SIunits.Velocity[STEPS] exit_velocities "Exit velocities in m/s";
  Modelica.SIunits.Pressure[STEPS] pressures "Cylinder pressure in Pa";

I expected the increased execution times and these are acceptable, but I cannot work out why the compilation time increases so much and effectively stops us performing the sensitivity analysis, as I would not have expected 5 501 element arrays to cause any significant increase in compilation time. Changing the size of the number of the arrays directly influences the compilation time, roughly linearly

Is there a reason for the long compilation times?

Can I change the way I define the model to eliminate the problem?

Dr. Harley Mackenzie

There are 0 guests and 0 other users also viewing this topic
You are here: