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

mod.linearize() returns wrong matrix on second call #212

Closed
martinscripts opened this issue Apr 29, 2024 · 2 comments
Closed

mod.linearize() returns wrong matrix on second call #212

martinscripts opened this issue Apr 29, 2024 · 2 comments

Comments

@martinscripts
Copy link

Description

If two models are loaded and linearized, only the first call of linearize() returns the correct result. All following calls will return the first call's result.

Steps to Reproduce

from OMPython import OMCSessionZMQ
omc = OMCSessionZMQ()
model_path=omc.sendExpression("getInstallationDirectoryPath()") + "/share/doc/omc/testmodels/"
from OMPython import ModelicaSystem

mod1 = ModelicaSystem(model_path + "BouncingBall.mo","BouncingBall")
mod1.linearize()
# returns [[[0, 1], [0, 0]], [], [], []]

mod2 = ModelicaSystem(model_path + "VanDerPol.mo","VanDerPol")
mod2.linearize()
# returns [[[0, 1], [0, 0]], [], [], []]

Expected Behavior

The result of the second linearization (mod2.linearize) should be [[[0, 1], [-0.730936067860485, -0.248180066111424]], [], [], []] but it only returns that after a kernel restart and when mod2 is executed first.

Version and OS

  • Python Version 3.10.11
  • OMPython Version 3.5.1
  • OpenModelica Version 1.22.2
  • OS: win10
@arun3688
Copy link
Collaborator

@martinscripts the issue is fixed with this commit 891528c, now i can get the correct results

>>> from OMPython import ModelicaSystem
>>> mod1 = ModelicaSystem("C:/OPENMODELICAGIT/OpenModelica/OMCompiler/Examples/BouncingBall.mo", "BouncingBall")
>>> mod2 = ModelicaSystem("C:/OPENMODELICAGIT/OpenModelica/OMCompiler/Examples/VanDerPol.mo", "VanDerPol")
>>> mod1.linearize()
[[[0, 1], [0, 0]], [], [], []]
>>> mod2.linearize()
[[[0, 1], [-0.730936067860485, -0.248180066111424]], [], [], []]
>>>

please update your pip package by python -m pip install -U https://github.com/OpenModelica/OMPython/archive/master.zip

@martinscripts
Copy link
Author

Thanks @arun3688.

I had to

pip uninstall OMPython

and then

pip install git+https://github.com/OpenModelica/OMPython.git/@master

and now it works.

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

2 participants