- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Equivalent for...
Equivalent for Modelica.Utilities.Streams.print() ???
Equivalent for Modelica.Utilities.Streams.print() ???
I need to print out some control values at specific events in the simulation. The book I read uses "Modelica.Utilities.Streams.print()" but as I have figured out Open Modelica does not support this function.
So is there any alternative for this in Open Modelica or not?
Re: Equivalent for Modelica.Utilities.Streams.print() ???
Bugs go here: https://trac.openmodelica.org/OpenModelica/newticket
I created a new one: https://trac.openmodelica.org/OpenModelica/ticket/1827
The work-around is using any function that prints and returns a value.
Code:
model M
function myPrint
input String str;
input String file := "";
output Boolean ok;
algorithm
Modelica.Utilities.Streams.print(str, file);
ok := true;
end myPrint;
Integer i;
protected
Boolean dummy;
equation
when sample(0,0.1) then
dummy = myPrint("printing at time: " + String(time) + "\n");
i = pre(i) + 1;
end when;
end M;
Which gives you output:
Code:
printing at time: 0
printing at time: 0.1
printing at time: 0.2
printing at time: 0.3
printing at time: 0.4
printing at time: 0.5
printing at time: 0.6
printing at time: 0.7
printing at time: 0.8
printing at time: 0.9
printing at time: 1
- sjoelund.se
- 1700 Posts
Re: Equivalent for Modelica.Utilities.Streams.print() ???
I've Simulated your Modelica Code and cannot find any text messages.
Do I have to open any special output window? And if so where do I open it? I haven't found any entries in the menu about any text output windows.
Or do I have to execute Open Modellica in the Windows Shell?
Re: Equivalent for Modelica.Utilities.Streams.print() ???
Yes, OMEdit sucks at displaying simulation output. Like "your model ended before the stop-time due to xyz". You can set the filename and read that if you prefer OMEdit over OMShell
- sjoelund.se
- 1700 Posts
Re: Equivalent for Modelica.Utilities.Streams.print() ???
Well, you could always send Adeel a message complaining you don't get the output from the executable... Or adding a bug to trac.openmodelica.org.
OMShell works the same way as you do in OpenModelica scripting from command-line
Code:
loadModel(Modelica)
getErrorString()
loadFile("path/to/myFile.mo")
getErrorString()
simulate(myModelName, stopTime=0.10)
getErrorString()
- sjoelund.se
- 1700 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Equivalent for...