Skip to content

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

Closed

Description

@martinscripts

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

Activity

  1. arun3688 commented on Apr 30, 2024

    @arun3688
    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

  2. martinscripts commented on Apr 30, 2024

    @martinscripts
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions