1

I want to simulate a Model from Openmodelica with help from toolbox OMPython in Spyder.

Here is the script:

import numpy as np 
from numpy import linalg as la 
import matplotlib.pyplot as plt 
from OMPython import ModelicaSystem
from OMPython import OMCSessionZMQ


font = {'family': 'sans-serif',
        'color':  'darkblue',
        'weight': 'normal', 
        'size': 14}

h = 0.0001 # Simulationsschrittweite

STime = 0.1
omc = OMCSessionZMQ()

mod=ModelicaSystem("SystemZweiterOrdnungKausalTotal.mo","SystemZweiterOrdnungKausal")

mod.setSimulationOptions(["stopTime="+str(STime),"stepSize=" + str(h),"solver=euler"])

mod.simulate()

mod.getSolutions() 

But there is an error message in console:

 2020-11-28 20:23:48,407 - OMPython - INFO - OMC Server is up and running at file:///C:/Users/zhout/AppData/Local/Temp/openmodelica.port.e2c1a098db6645b48dd844f1925af6c8 pid=6492
2020-11-28 20:23:48,690 - OMPython - INFO - OMC Server is up and running at file:///C:/Users/zhout/AppData/Local/Temp/openmodelica.port.e6fe4b6d6426461586a0ea54038b6559 pid=5424
'utf-8' codec can't decode byte 0xd7 in position 103: invalid continuation byte
None
stopTime !is not a simulation-option variable
Traceback (most recent call last):

  File "C:\Users\zhout\OneDrive\desktop\Simulation und technische Diagnose\Aufgabe Phase 1-20201128\VorlageAuswertung——Muster.py", line 37, in <module>
    mod.simulate()

  File "C:\Users\zhout\anaconda3\lib\site-packages\OMPython\__init__.py", line 1108, in simulate
    raise Exception("Error: application file not generated yet")

Exception: Error: application file not generated yet

I didn't find any information in Internet about this Error. can someone help me? thanks a lot.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • I think you should start with the first error: `'utf-8' codec can't decode byte 0xd7 in position 103: invalid continuation byte` and only start investigating the second one after fixing the first one. – Priyanka Nov 29 '20 at 14:40
  • 1
    UTF-8 encoding issues can sometimes be ignored. However, they are often caused by treating iso-8859-1 as UTF-8; and 0xd7 is the multiplication sign × (in Modelica * is used instead); which could indicate more problems. – Hans Olsson Nov 30 '20 at 08:10
  • I have changed the modelica document into UTF-8 coding, But it's still not working. Shoild i change the coding in python script? – Zhou Tianjing Dec 01 '20 at 10:56
  • There are spaces in your path. We fixed a lot of issues with spaces in OpenModelica, but I would suggest to try a different path nonetheless. If that is the solution please open an iossue on github.com/OpenModelica/OpenModelica/ – AnHeuermann Dec 03 '20 at 12:33

0 Answers0