- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » numberOfIntervals in interactive mode
numberOfIntervals in interactive mode
numberOfIntervals in interactive mode
Hi all,
I need to know what exactly sets the numberOfIntervals parameter in buildModel() function, if I use the model in interactive mode.
I'm using also this kind of way (suggested by you) to evaluate a derivate
Code:
(delay(var, step) - var)) / step
so I need to know which is the relationship between that parameter and the simulation step.
I made some tries but I cant understand.
I'm also using a socket in an external C function to read some inputs. I get results with a strange time value.
I hope I well explainded, and you can help me.
Thanks in advance,
Francesco
Re: numberOfIntervals in interactive mode
Hi De Filippo,
When using DASSl solver, we could give a Tstop and Tout parameters to the solver. In this case, Tout = Tout + (Tstop / numberOfIntervals) with Tout=0 before starting the simulation. So the solver will interpolate to give you state values at each interval. Hope this can help you.
Best regards,
Hassen
Re: numberOfIntervals in interactive mode
I never used the interactive mode and I don't know how it works. I am just giving an explanation on how the DASSL solver used within OpenModelica works.
For the statement below :
buildModel(modelname, startTime=0, stopTime=1, numberOfIntervals=500, tolerance=1e-4, storeInTemp=false, method="dassl", outputFormat="plt")
The DASSL solver will take Tstop = 1, and Tout is equal to [1/500, 2/500, 3/500,...,500/500 = 1]. The initial time is equal to 0. The solver will interpolate and give you state values at these instants.
May be an OpenModelica developper could confirm this.
Best Regards,
Hassen
Re: numberOfIntervals in interactive mode
Yes, I think it works this way, but I need information about interactive mode.
In this case, according to guide, numberOfIntervals should be the numbers of step in a second.
My problem is I'd like to know how many time per second the sistem is solved, how often the extern function is called, and how often results are sent.
Are they all syncronous? (I mean for every step the extern function is called and results are given)
Thanks anyway,
Francesco
Re: numberOfIntervals in interactive mode
In the past, I used external socket functions to make communication between OpenModelica and an external tool. The best idea is to use the sample() function. In this way you are sure to obtain your data at a precise time corresponding to your sample. If you want to send data to OpenModelica, it will work too.
Could you give more information about your project?
Hope this help.
Regards,
Hassen
Re: numberOfIntervals in interactive mode
Yes, sample() is a good idea if you need to make sure when your function is called. Sadly, it's a bit slow in OpenModelica.
Without sample(), an external function can be called several thousand times even in a single time step (if inside an algebraic loop).
- sjoelund.se
- 1700 Posts
Re: numberOfIntervals in interactive mode
Dear Jawhar,
I was looking for a socket communication with external tool using Socket.
But whenever I tried to run the socket it runs the socket and turned off.
I was looking though this thread http://www.modelica-forum.com/forums/lo … p/t17.html
But got stuck. It would be really helpful to have your guidance.
My goal : create a socket from Open Modelica mode and receive message via that socket
A control program written in C++ will send some message to this socket.
Then message will be received by this socket and will work on some other models and then again send the message via that socket.
Re: numberOfIntervals in interactive mode
Jawhar wrote:
In the past, I used external socket functions to make communication between OpenModelica and an external tool. The best idea is to use the sample() function. In this way you are sure to obtain your data at a precise time corresponding to your sample. If you want to send data to OpenModelica, it will work too.
Could you give more information about your project?
Hope this help.
Regards,
Hassen
Dear Jawhar,
I was looking for a socket communication with external tool using Socket.
But whenever I tried to run the socket it runs the socket and turned off.
I was looking though this thread http://www.modelica-forum.com/forums/lo … p/t17.html
But got stuck. It would be really helpful to have your guidance.
My goal : create a socket from Open Modelica mode and receive message via that socket
A control program written in C++ will send some message to this socket.
Then message will be received by this socket and will work on some other models and then again send the message via that socket.
regards Akram
Re: numberOfIntervals in interactive mode
Hello Akram.
It seems that you make a lot of research to find my post in different Modelica forums.
Yes I developed already a small library to establish communication using sockets and to synchronize with 3rd party simulation tools and OpenModelica.
I can give you this link of my PHD thesis. it is in French, I am soory. You will find some code that you need to establish your server socket in OpenModelica .
Good luck.
Link
Re: numberOfIntervals in interactive mode
Dear Jawhar,
Thanks for the report of your Phd Thesis.
The problem I am facing now:
1. Whenever I run the model called Socket it runs and through the port option check in windows (netstat -an) when I check it I did not found that it had open the port 12345 in the address 127.0.0.1 . It just ran and gave the output which is nothing except port number.
What I am trying to do.
1. Create a socket server from OpenModelica and list to it from outside then do something and send Message to outside again.
Its like
a. create socket from OMC
b. send message from outside to OMC server
c. OMC receives the message
d. Do some computation
e. OMC send the message to outside again.
I have looked through your code and changed some of mine.
I have attached the code below.
It would be really helpful to have your guidance.
SocketModelica.zip
Re: numberOfIntervals in interactive mode
Hello Akram,
I'm also trying to get an interactive communication with the OMC compiler, from visual basic (VBA).
have you made any progress on this issue?
Could you send some results if available?
Best regards,
Geert
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » numberOfIntervals in interactive mode