- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » OpenModelica OMPython example model...
OpenModelica OMPython example model throws load file error
OpenModelica OMPython example model throws load file error
code:
import numpy as np
from matplotlib import pyplot as plt
import pyfmi
from OMPython import OMCSessionZMQ
from OMPython import ModelicaSystem
omc = OMCSessionZMQ()
model_path = '/usr/lib/omlibrary/Modelica 3.2.3/Electrical/'
omc.sendExpression('loadModel(model_path + Machines.mo)')
mod = ModelicaSystem(model_path + 'Machines.mo','Modelica.Electrical.Machines.Examples.AsynchronousInductionMachines.AIMC_Inverter')
error:
loadFile Error: Error: Failed to insert class Machines within Modelica.Electrical;
the available classes were:
Re: OpenModelica OMPython example model throws load file error
You always load the full Modelica library via loadModel(Modelica), you cannot load parts of it.
Seems the ModelicaSystem interface needs a file as the first argument, that is weird, it should not be need in some cases.
You can just do like this:
Code:
model_path = omc.sendExpression("getInstallationDirectoryPath()") + "/share/doc/omc/testmodels/"
mod = ModelicaSystem(model_path + "HelloWorld.mo","Modelica.Electrical.Machines.Examples.AsynchronousInductionMachines.AIMC_Inverter",["Modelica"]);
Basically load HelloWorld.mo but don't use it and also request Modelica library to be loaded (3rd argument).
- adrpo
- 885 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » OpenModelica OMPython example model...