- Index
- » Users
- » Mackenzie
- » Profile
Posts
Posts
This issue is related to the issue I raised in OpenModelica Programming "Array use leads to excessive compilation times" https://www.openmodelica.org/index.php/ … ic?id=1030 but is a different question.
Ideally I would like to change parameters in a model without requiring the compilation step to occur every time. I note that there is an OMOptim program but I have been able to get this work with the changes that we are trying to do with our sensitivity study, and from reading the documentation I believe it will recompile the model. The "Simulate" call in the omc API also seems to always recompile.
Is it possible to compile a model and supply an input file or some other technique to change the values of parameters in an OpenModlica model without recompiling the model for every parameter change?
Harley Mackenzie
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
- Index
- » Users
- » Mackenzie
- » Profile