-
Notifications
You must be signed in to change notification settings - Fork 65
Description
Hello,
I am trying to open one file VSC_Test.mo that I developed using three
default Modelica libraries (Modelica 3.2.3,Complex 3.2.3,ModelicaServices
3.2.3) and 2 other libraries (OpenIPSL,HVDCcomponents). However when I try
to create the model mod using the function ModelicaSystem(), several
errors pop up. If I load the model only using the name of the file and its
path :
`
from OMPython import OMCSessionZMQ
from OMPython import ModelicaSystem
path = 'C:/Users/j.alves/Desktop/Stage/Python_CODES/Modele_HVDC_simplifie'
within = 'HVDCcomponents.Examples'
name = 'Test_VSC'
file ='"'+ path + '/' + name + '.mo'+'"'
mod_file = path + '/' + name + '.mo'
load_file = "loadFile(" + file + ")"
within_name = within + '.' + name
omc = OMCSessionZMQ()
mod = ModelicaSystem(mod_file)
mod.buildModel()
Load = omc.sendExpression(load_file)
if (not Load):
raise NameError("Coudn't load file")
2021-01-08 10:58:55,995 - OMPython - INFO - OMC Server is up and running
at
file:///C:/Users/J50461.ALV/AppData/Local/Temp/openmodelica.port.01c776f1a0d049748d371c59fde5c76e1.ALV/AppData/Local/Temp/openmodelica.port.c90c19bd229547c4abbc8c7f7570a383
pid=2436
2021-01-08 10:58:56,323 - OMPython - INFO - OMC Server is up and running
at
file:///C:/Users/J5046
pid=3316
Notification: Automatically loaded package Modelica 3.2.3 due to uses
annotation.
Notification: Automatically loaded package Complex 3.2.3 due to uses
annotation.
Notification: Automatically loaded package ModelicaServices 3.2.3 due to
uses annotation.
Notification: Skipped loading package OpenIPSL (1.5.0) using MODELICAPATH
C:/OpenModelica/lib/omlibrary (uses-annotation may be wrong).
Notification: Skipped loading package HVDCcomponents (1.0) using
MODELICAPATH C:/OpenModelica/lib/omlibrary (uses-annotation may be wrong).
TypeError Traceback (most recent call
last)
in
9
10 # To set variables, and change the model
---> 11 mod = ModelicaSystem(mod_file)
12 mod.buildModel()
13
c:\python38\lib\site-packages\OMPython_init_.py in init(self,
fileName, modelName, lmodel, useCorba, commandLineOptions)
718 if (self.fileName_): # execution from different path
719 os.chdir(self.currDir)
--> 720 self.__loadingModel()
721 else:
722 print("Error: File does not exist!!!")
c:\python38\lib\site-packages\OMPython_init_.py in __loadingModel(self)
758 if loadmodelError:
759 print(loadmodelError)
--> 760 self.buildModel()
761
762 def buildModel(self):
c:\python38\lib\site-packages\OMPython_init_.py in buildModel(self)
764 buildModelResult = self.requestApi("buildModel",
self.modelName)
765 buildModelError = self.requestApi("getErrorString")
--> 766 if ('' in buildModelResult):
767 print(buildModelError)
768 return
TypeError: argument of type 'NoneType' is not iterable
`
If instead of using only the name I put "within" in "mod =
ModelicaSystem(mod_file,within_name)" since there is a commented within in
the VSC_Test file, I get:
`
Notification: Automatically loaded package Modelica 3.2.3 due to uses
annotation.
Notification: Automatically loaded package Complex 3.2.3 due to uses
annotation.
Notification: Automatically loaded package ModelicaServices 3.2.3 due to
uses annotation.
Notification: Skipped loading package OpenIPSL (1.5.0) using MODELICAPATH
C:/OpenModelica/lib/omlibrary (uses-annotation may be wrong).
Notification: Skipped loading package HVDCcomponents (1.0) using
MODELICAPATH C:/OpenModelica/lib/omlibrary (uses-annotation may be wrong).
[C:/OpenModelica/lib/omlibrary/HVDCcomponents/Examples/Test_VSC.mo:3:1-81:13:writable]
Error: Expected the package to have within HVDCcomponents.Examples; but
got within ;.
Error: Failed to load package HVDCcomponents (default) using MODELICAPATH
C:/OpenModelica/lib/omlibrary.
Notification: Automatically loaded package OpenIPSL 1.5.0 due to uses
annotation.
Warning: Requested package Modelica of version 3.2.2, but this package was
already loaded with version 3.2.3. You might experience problems if these
versions are incompatible.
Warning: Requested package Complex of version 3.2.2, but this package was
already loaded with version 3.2.3. You might experience problems if these
versions are incompatible.
[C:/OpenModelica/lib/omlibrary/HVDCcomponents/Examples/Test_VSC.mo:3:1-81:13:writable]
Error: Expected the package to have within HVDCcomponents.Examples; but
got within ;.
Notification: Skipped loading package HVDCcomponents (1.0,default) using
MODELICAPATH C:/OpenModelica/lib/omlibrary (uses-annotation may be wrong).
Error: Class HVDCcomponents.Examples.Test_VSC not found in scope .
[C:/OpenModelica/lib/omlibrary/HVDCcomponents/Examples/Test_VSC.mo:3:1-81:13:writable]
Error: Expected the package to have within HVDCcomponents.Examples; but
got within ;.
Error: Failed to load package HVDCcomponents (default) using MODELICAPATH
C:/OpenModelica/lib/omlibrary.
[C:/OpenModelica/lib/omlibrary/HVDCcomponents/Examples/Test_VSC.mo:3:1-81:13:writable]
Error: Expected the package to have within HVDCcomponents.Examples; but
got within ;.
Notification: Skipped loading package HVDCcomponents (1.0,default) using
MODELICAPATH C:/OpenModelica/lib/omlibrary (uses-annotation may be wrong).
Warning: Requested package Modelica of version 3.2.2, but this package was
already loaded with version 3.2.3. You might experience problems if these
versions are incompatible.
Warning: Requested package Complex of version 3.2.2, but this package was
already loaded with version 3.2.3. You might experience problems if these
versions are incompatible.
Error: Class HVDCcomponents.Examples.Test_VSC not found in scope .
`
Also, the paths were those libraries are is the same as the path of all
default libraries in MODELICAPATH (added to environmental variables )
Basically I want to open the VSC_Test.mo file and run simulations to get
the results in real time with python to then change the inputs and run
more simulations and so on... I will update the inputs of the system based
on the outputs.
Moreover, using only the library Modelica I can run all the simulations I
want using the "mod", but with these other 2 libraries I always get one
kind of error. Please help me with this issue...
Metadata
Metadata
Assignees
Labels
Type
Projects
Status