Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using "fixed-step" solver with ModelicaSystem library #87

Open
prat33kg opened this issue Apr 15, 2019 · 4 comments
Open

Using "fixed-step" solver with ModelicaSystem library #87

prat33kg opened this issue Apr 15, 2019 · 4 comments

Comments

@prat33kg
Copy link

Hello

I was wondering if there is any method to set fixed-step solver through ModelicaSystem library. I am trying to use this library along with Scipy.optimize to perform parameter fitting for my model. But everytime the model simulates with a different parameter value, it gives different number of outputs for a model. Is there any way to regularize this?

@arun3688
Copy link
Collaborator

arun3688 commented Apr 15, 2019

@PatronusCoder You can use getSimulationOptions() to see the options you can set and use
obj.setSimulationOptions(stepSize=0.004) to have fixed stepsize

For more information look into docs (https://www.openmodelica.org/doc/OpenModelicaUsersGuide/latest/ompython.html#enhanced-ompython-features)

@alchemyst
Copy link
Contributor

@PatronusCoder it might be better (more accurate or faster depending on the data) to use a variable step solver and then interpolated on the solution for the known points to calculate your error function.

@sjoelund
Copy link
Member

@arun3688 I would have expected that setting the stepSize will use the same solver as before, and not a fixed-step solver. Like @alchemyst says a variable step solver (dassl) is the default and by default OpenModelica interpolates the output points (and adds discrete event points on top).

To choose a fixed-step solver, you need to change the solver to Euler or Runge-Kutta...

There is also an API-function to re-interpolate a result-file (but there are still extra points for discrete events, I think): https://www.openmodelica.org/doc/OpenModelicaUsersGuide/latest/scripting_api.html#filtersimulationresults

@prat33kg
Copy link
Author

@arun3688 Setting the stepSize does not give the time steps only at the expected time instances. As @sjoelund said, OpenModelica interpolates the outputs and adds discrete event points on top. Some of these points are either on same time instances i.e. duplicates and some are between the time steps. Moreover, the number of output points are not consistent. They change with changing parameters. Although I made my Python script to remove the duplicates and all the in-between points, sometimes the final dataset is smaller than my measured dataset. So is it possible that the solver skips some time steps in between?

Also, I am focussing on using ModelicaSystem class because OMC commands are very slow and not very practical when you want to run these commands in a loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants