- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » OMPython
OMPython
OMPython
Hi,
I am freshly install OMPython. My OS is win7.
I have simple code such as below.
Code:
from OMPython import OMCSession
OMPython = OMCSession()
print OMPython.execute('loadModel(Modelica)')
print OMPython.execute ('loadFile(\"C:/loop/test.mo\")')
result = OMPython.execute('simulate(test)')
OMPython.execute("plot(meter.v)")
print result
I have 3 question.
1) I read print result file ..... 'resultFile': '"C:/loop/test.mat"'} but, there is no test.mat file in c:/loop folder.
2) How can get result file as csv file not mat?
3)If simulation stop time 100 then, how can i get specific time result on screen like meter.v (time =33) ?
Thanks
Oki
Re: OMPython
Hi,
1. the file is generated in the current directory, not in c:/loop.
use cd("c:/loop") before running simulate if you want the files there.
2. Use: simulate(Model, outputFormat="csv") to generate a comma separated values file.
3. Use val(meter.v, 33) to get the value of meter.v at time 33
See also:
https://build.openmodelica.org/Document … pting.html
and the user's guide.
Cheers,
Adrian Pop/
- adrpo
- 885 Posts
Re: OMPython
Yes, but you need to write it on a single line, for example:
j:=0; for i in 1:3 loop j:=j+i; end for; j
- sjoelund.se
- 1700 Posts
Re: OMPython
Thank you sjoelund,
So, i want to compare two different parameters inside loop.
I try something like this but it is not working,
for i in 1007:1016 loop i:=i+1; val(Meter1.v,i)-val(Meter2.v) ; end for;
Is there any documents explain more control about for, loop, if, while, wend e.t.c.
Oki
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » OMPython