Opened 10 years ago

Last modified 7 years ago

#3294 new defect

Precalculate less functions — at Initial Version

Reported by: Rüdiger Franke Owned by: somebody
Priority: high Milestone: Future
Component: Frontend Version: trunk
Keywords: Cc:

Description

The example Modelica.Utilities.Examples.readRealParameterModel is all about reading model parameters at simulation time.

model readRealParameterModel "Demonstrate usage of Examples.readRealParameter/.expression"
  import SI = Modelica.SIunits;
  extends Modelica.Icons.Example;
  parameter String file = Modelica.Utilities.Files.loadResource("modelica://Modelica/Resources/Data/Utilities/Examples_readRealParameters.txt") "File on which data is present";
  parameter SI.Inertia J = readRealParameter(file, "J") "Inertia";
  parameter SI.Angle phi_rel0 = readRealParameter(file, "phi_rel0") "Relative angle";
  parameter SI.AngularVelocity w_rel0 = readRealParameter(file, "w_rel0") "Relative angular velocity";
end readRealParameterModel;

OpenModelica evaluates everything at translation time. This can hardly be counted as a passed test. It would be fine if the string parameter file was fixed, but the contents of the file must be read at simulation time.

As of today one can generally introduce some dummy inputs, whose values are not known at translation time, and pass them to a function like readReadParameter. Then the evaluation of the function is shifted to the simulation time -- and it works fine typically.

How can the translation of OpenModelica be changed to evaluate less functions, so that models like readRealParameterModel work as intented, without tricks?

Change History (0)

Note: See TracTickets for help on using tickets.