- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » when initial() then ...
when initial() then ...
when initial() then ...
I have this model:
Code:
model myModel
equation
when initial() then
Modelica.Utilities.Streams.print("hello");
end when;
end myModel;
If I simulate this with OpenModelica 1.9.0 Beta2 in OMShell I get this:
OMShell 1.1 Copyright Open Source Modelica Consortium (OSMC) 2002-2012
Distributed under OMSC-PL and GPL, see www.openmodelica.org
Connected to OpenModelica 1.9.0 Beta2 (r13495)
To get help on using OMShell and OpenModelica, type "help()" and press enter.
>> clear(); loadModel(Modelica,{"3.2.1"}); cd("C:/test"); loadFile("myModel.mo"); simulate(myModel)
true
true
"C:/test"
true
record SimulationResult
resultFile = "C:/test/myModel_res.mat",
simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'myModel', storeInTemp = false, noClean = false, options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = '', simflags = ''",
messages = "hellohello",
timeFrontend = 0.48506047147699,
timeBackend = 0.00381008109982807,
timeSimCode = 0.0024721147429428,
timeTemplates = 0.0157765793427199,
timeCompile = 1.36685796517343,
timeSimulation = 0.0236075452097846,
timeTotal = 1.89762297291522
end SimulationResult;
As you can see the string "hello" was printed twice.
And this is my problem. I used the when initial() section for initialization of 3D tables very similar to the combiTable models in the MSL. And this causes an error because I need to initialize each table once and only once.
I tested the same code in Dymola 2013 FD01 and a similar code in OpenModelica 1.8.1. Both do the when initial() section only once.
Is something wrong in OpenModelica 1.9.0 Beta2 ?
Re: when initial() then ...
As far as I know, you are not guaranteed any upper bound on how many times an initial equation is called in Modelica.
- sjoelund.se
- 1700 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » when initial() then ...