Skip to content

Simulation on linux doesn't wait to process #207

@InigoGastesi

Description

@InigoGastesi

Description

When using simulate function , this function uses subprocess.Popen to create a resultfile. In windwos it waits for the process to be finished to continue, but in linux it doesn't. So, if you call simulate and then getSolutions you will have an error.

Steps to Reproduce

omc = OMCSessionZMQ()
mod = ModelicaSystem(model_path_full, model_name)

mod.setSimulationOptions(["startTime=0.0",f'stopTime={s}',f'stepSize={step_size}',"tolerance=1e-06"])
#mod.setParameters(f"{variable}={v}")
mod.simulate(resultfile=f'{filename}.mat') #Para simular el modelo, empleo el método ".simulate()"

data = {}
data["time"] = mod.getSolutions(["time"],resultfile=f'{filename}.mat')[0] #error

Error:

Cell In[3], [line 9](vscode-notebook-cell:?execution_count=3&line=9)
      [6](vscode-notebook-cell:?execution_count=3&line=6) mod.simulate(resultfile=f'{filename}.mat') #Para simular el modelo, empleo el método ".simulate()"
      [8](vscode-notebook-cell:?execution_count=3&line=8) data = {}
----> [9](vscode-notebook-cell:?execution_count=3&line=9) data["time"] = mod.getSolutions(["time"],resultfile=f'{filename}.mat')[0]
     [10](vscode-notebook-cell:?execution_count=3&line=10) print(data)
     [11](vscode-notebook-cell:?execution_count=3&line=11) # Configure Plot

TypeError: 'NoneType' object is not subscriptable

Expected Behavior

Screenshots

Version and OS

  • Python Version: 3.9.18
  • OMPython Version: 3.5.1
  • OpenModelica Version: 1.22.3
  • OS: Ubuntu 22.04-64bit

Additional Context

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