Opened 3 years ago

Last modified 3 years ago

#6349 new defect

Failed to insert class Test_VSC within HVDCcomponents.Examples

Reported by: jeduapf@… Owned by: arun3688
Priority: high Milestone:
Component: OMPython Version: 1.16.0
Keywords: Failed, Class, Within, Scope Cc:

Description

Hello,

I am having some trouble to open one simple class called "Test_VSC" because of a custom library and I am getting the following error:

2021-01-22 11:14:05,834 - OMPython - INFO - OMC Server is up and running at file:///C:/Users/J5046~1.ALV/AppData/Local/Temp/openmodelica.port.beb0bed9c01a4c248f8137b3d2e1b308 pid=12472
2021-01-22 11:14:06,147 - OMPython - INFO - OMC Server is up and running at file:///C:/Users/J5046~1.ALV/AppData/Local/Temp/openmodelica.port.5765d22327464c56b1d8d5829c7e24e9 pid=3676
loadFile Error: Error: Failed to insert class Test_VSC within HVDCcomponents.Examples;

 the available classes were:

Error: Failed to load package 'HVDCcomponents.Examples.Test_VSC' (default) using MODELICAPATH C:/OpenModelica/lib/omlibrary.
Error: Class 'HVDCcomponents.Examples.Test_VSC' not found in scope <TOP>.

The code is:

from OMPython import OMCSessionZMQ
from OMPython import ModelicaSystem


path = 'C:/OpenModelica/lib/omlibrary/HVDCcomponents/Examples'
within = 'HVDCcomponents.Examples'
name = 'Test_VSC'

file ='"'+ path + '/' + name + '.mo'+'"'
mod_file = path + '/' + name + '.mo'
load_file = "loadFile(" + file + ")"
within_name = "'" + within + '.' + name + "'"

# To create the modelica session and execute action 
omc = OMCSessionZMQ()

# To set variables, and change the model 
mod = ModelicaSystem(mod_file,within_name, ["C:/OpenModelica/lib/omlibrary/HVDCComponents/package.mo","C:/OpenModelica/lib/omlibrary/OpenIPSL/package.mo","Modelica"])
mod.buildModel()

# Loading the model file 
Load = omc.sendExpression(load_file)
if (not Load):
    raise NameError("Coudn't load file")

Before I've tried several ways to call the function "ModelicaSystem", being them:

mod = ModelicaSystem(mod_file,within_name)

mod = ModelicaSystem(file,within_name)

mod = ModelicaSystem(mod_file,name)

mod = ModelicaSystem(mod_file,within_name,["HVDCComponents","OpenIPSL","Modelica"])

mod = ModelicaSystem(file,within_name,["HVDCComponents","OpenIPSL","Modelica"])

mod = ModelicaSystem(mod_file,name,["HVDCComponents","OpenIPSL","Modelica"])

And all of them have errors, sometimes:

loadFile Error: Error: Failed to insert class Test_VSC within HVDCcomponents.Examples;
Error: Failed to load package HVDCcomponents (default) using MODELICAPATH C:/OpenModelica/lib/omlibrary.
Error: Class HVDCcomponents.Examples.Test_VSC not found in scope <TOP>.

The code in OpenModelica for Test_VSC is the following:

within HVDCcomponents.Examples;

model Test_VSC

  OpenIPSL.Electrical.Buses.Bus bus1(S_b = 1000, V_b = 230, displayPF = true, fn = 50) annotation(
    Placement(visible = true, transformation(origin = {116, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  OpenIPSL.Electrical.Buses.InfiniteBus infiniteBus1(S_b = 1000, V_b = 230, fn = 50) annotation(
    Placement(visible = true, transformation(origin = {108, -34}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  HVDCcomponents.PQ_sensor pQ_sensor1(S_b = 1000) annotation(
    Placement(visible = true, transformation(origin = {84.4, 2}, extent = {{-6, -5}, {6, 5}}, rotation = 0)));
  Modelica.Electrical.Analog.Basic.Ground ground1 annotation(
    Placement(visible = true, transformation(origin = {-55, -27}, extent = {{-7, -7}, {7, 7}}, rotation = 0)));
  HVDCcomponents.PQ_sensor pQ_sensor2(S_b = 1000) annotation(
    Placement(visible = true, transformation(origin = {-231.6, 0}, extent = {{6, -5}, {-6, 5}}, rotation = 0)));
  OpenIPSL.Electrical.Buses.Bus bus2(S_b = 1000, V_b = 230, displayPF = true, fn = 50) annotation(
    Placement(visible = true, transformation(origin = {-264, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  OpenIPSL.Electrical.Buses.InfiniteBus infiniteBus2(S_b = 1000, V_b = 230, fn = 50) annotation(
    Placement(visible = true, transformation(origin = {-272, -36}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
  Modelica.Blocks.Sources.Step step5(height = 10, startTime = 10) annotation(
    Placement(visible = true, transformation(origin = {-172, 50}, extent = {{4, -4}, {-4, 4}}, rotation = 0)));
  Modelica.Blocks.Sources.Step step4(height = 0, offset = 0, startTime = 2) annotation(
    Placement(visible = true, transformation(origin = {42, 34}, extent = {{4, -4}, {-4, 4}}, rotation = 0)));
  Modelica.Blocks.Sources.Step step1(height = 0, startTime = 0) annotation(
    Placement(visible = true, transformation(origin = {30, 66}, extent = {{4, -4}, {-4, 4}}, rotation = 0)));
  HVDCcomponents.VSC_station_final vSC_station_final(MVAb = 1000, P_ref = 0, Q_ref = 0, S_b = 1000, Vb = 230, Vdcb = 640, Vgd = 230)  annotation(
    Placement(visible = true, transformation(origin = {-194, 2}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
  HVDCcomponents.DC_cable_PI_section dC_cable_PI_section(Vinit = 640E3, length = 100)  annotation(
    Placement(visible = true, transformation(origin = {-90, 2}, extent = {{-15, -5}, {15, 5}}, rotation = 0)));
  Modelica.Blocks.Sources.Step step(height = 10, offset = 0, startTime = 5) annotation(
    Placement(visible = true, transformation(origin = {-152, 26}, extent = {{4, -4}, {-4, 4}}, rotation = 0)));
  HVDCcomponents.VSC_station_final vSC_station_final1(MVAb = 1000, P_ref = 0, Q_ref = 0, S_b = 1000, Vb = 230, Vdc_Control_Type = "PI+filter", Vdcb = 640, Vgd = 230) annotation(
    Placement(visible = true, transformation(origin = {0, 8}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.Analog.Sensors.CurrentSensor Sensor annotation(
    Placement(visible = true, transformation(origin = {-52, 42}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
  connect(pQ_sensor1.n, bus1.p) annotation(
    Line(points = {{90, 2}, {116.4, 2}}, color = {0, 0, 255}));
  connect(bus1.p, infiniteBus1.p) annotation(
    Line(points = {{116, 2}, {132, 2}, {132, -34}, {125, -34}, {125, -34}, {123.5, -34}, {123.5, -34}, {118, -34}}, color = {0, 0, 255}));
  connect(bus2.p, infiniteBus2.p) annotation(
    Line(points = {{-264, 0}, {-290, 0}, {-290, -36}, {-282, -36}, {-282, -36}}, color = {0, 0, 255}));
  connect(pQ_sensor2.n, bus2.p) annotation(
    Line(points = {{-238, 0}, {-264, 0}, {-264, 0}, {-264, 0}}, color = {0, 0, 255}));
  connect(pQ_sensor2.p, vSC_station_final.p) annotation(
    Line(points = {{-226, 0}, {-216, 0}, {-216, 2}, {-205, 2}}, color = {0, 0, 255}));
  connect(dC_cable_PI_section.pin_p, vSC_station_final.pin_p) annotation(
    Line(points = {{-105, 5}, {-144, 5}, {-144, 7}, {-183, 7}}, color = {0, 0, 255}));
  connect(vSC_station_final.pin_n, dC_cable_PI_section.pin_n) annotation(
    Line(points = {{-183, -3}, {-104, -3}, {-104, -1}, {-105, -1}}, color = {0, 0, 255}));
  connect(ground1.p, dC_cable_PI_section.pin_n1) annotation(
    Line(points = {{-54, -20}, {-54, -1}, {-75, -1}}, color = {0, 0, 255}));
  connect(vSC_station_final1.p, pQ_sensor1.p) annotation(
    Line(points = {{12, 8}, {70, 8}, {70, 2}, {78, 2}, {78, 2}}, color = {0, 0, 255}));
  connect(vSC_station_final1.pin_n, dC_cable_PI_section.pin_n1) annotation(
    Line(points = {{-10, 2}, {-54, 2}, {-54, 0}, {-75, 0}, {-75, -1}}, color = {0, 0, 255}));
  connect(step5.y, vSC_station_final.Qref) annotation(
    Line(points = {{-176, 50}, {-198, 50}, {-198, 14}, {-198, 14}}, color = {0, 0, 127}));
  connect(step.y, vSC_station_final.Pref) annotation(
    Line(points = {{-156, 26}, {-190, 26}, {-190, 14}, {-190, 14}}, color = {0, 0, 127}));
  connect(vSC_station_final1.Pref, step1.y) annotation(
    Line(points = {{-4, 20}, {-8, 20}, {-8, 66}, {26, 66}}, color = {0, 0, 127}));
  connect(step4.y, vSC_station_final1.Qref) annotation(
    Line(points = {{38, 34}, {4, 34}, {4, 20}, {4, 20}}, color = {0, 0, 127}));
  connect(Sensor.p, dC_cable_PI_section.pin_p1) annotation(
    Line(points = {{-62, 42}, {-74, 42}, {-74, 6}, {-74, 6}}, color = {0, 0, 255}));
  connect(Sensor.n, vSC_station_final1.pin_p) annotation(
    Line(points = {{-42, 42}, {-22, 42}, {-22, 12}, {-10, 12}, {-10, 14}}, color = {0, 0, 255}));
  annotation(
    Diagram(graphics = {Line(origin = {0, 8}, points = {{0, 0}})}, coordinateSystem(extent = {{-300, -100}, {150, 100}}, initialScale = 0.1)),
    Icon(coordinateSystem(extent = {{-300, -100}, {150, 100}})),
    __OpenModelica_commandLineOptions = "", experiment(
      StopTime=20,
      Interval=0.002,
      Tolerance=1e-006,
      __OpenModelica_Algorithm="dassl"));



end Test_VSC;

Attachments (5)

HVDCcomponents.zip (44.9 KB) - added by jeduapf 3 years ago.
HVDCComponents library with the Test_VSC example
OpenIPSL.zip (554.7 KB) - added by jeduapf 3 years ago.
OpenIPSL
Jose.zip (599.6 KB) - added by jeduapf 3 years ago.
everything I am using now
Untitled.ipynb (12.8 KB) - added by jeduapf 3 years ago.
python script
jose_corrected.ipynb (162.6 KB) - added by arun3688 3 years ago.

Download all attachments as: .zip

Change History (40)

comment:1 follow-up: Changed 3 years ago by casella

  • Milestone changed from NeedsInput to 1.17.0

comment:2 Changed 3 years ago by ceraolo

Just to know, is HVDCcomponents a library, o part of a library? I would be interested to have a look.

comment:3 in reply to: ↑ 1 Changed 3 years ago by jeduapf

Replying to casella:

Well, there is a package (and package order) with all the classes in HVDCComponents and inside it there is another folder with the Examples, where the file Test_VSC.

What would you like to see actually ?

And there is no other folder before HVDCCompnents...

comment:4 follow-up: Changed 3 years ago by arun3688

@jeduapf, I understand now that you are trying to run a model HVDCcomponents.Examples.Test_VSC which is a part of the HVDCComponents package, and it is dependent on OpenIPSL library, so your commands should be something like this

from OMPython import ModelicaSystem
mod=ModelicaSystem("C:/OpenModelica/lib/omlibrary/HVDCComponents/package.mo","HVDCcomponents.Examples.Test_VSC", ["C:/OpenModelica/lib/omlibrary/OpenIPSL/package.mo","Modelica"])

I hope this works, if it does not work can you share the library so that it will be easier to test and find the problem.

comment:5 in reply to: ↑ 4 Changed 3 years ago by jeduapf

Replying to arun3688:

@jeduapf, I understand now that you are trying to run a model HVDCcomponents.Examples.Test_VSC which is a part of the HVDCComponents package, and it is dependent on OpenIPSL library, so your commands should be something like this

from OMPython import ModelicaSystem
mod=ModelicaSystem("C:/OpenModelica/lib/omlibrary/HVDCComponents/package.mo","HVDCcomponents.Examples.Test_VSC", ["C:/OpenModelica/lib/omlibrary/OpenIPSL/package.mo","Modelica"])

I hope this works, if it does not work can you share the library so that it will be easier to test and find the problem.

Thank you Arun for you efforts to solve this, but still... Always the same problem.

About the library, I am waiting the answer of the company to know if I can share or if there is anything confidential.

In case I can share, how could I do it ? Can I send heavy files here ?

comment:6 follow-up: Changed 3 years ago by arun3688

@jeduapf you can attach the package as a zip file, And also can you able to simulate your example in OMEdit ?

comment:7 in reply to: ↑ 6 Changed 3 years ago by jeduapf

Replying to arun3688:

@jeduapf you can attach the package as a zip file, And also can you able to simulate your example in OMEdit ?

Yes I can simulate with no errors the model in OMEdit...

comment:8 follow-up: Changed 3 years ago by arun3688

@jeduaf, Then you are doing something wrong in loading the constructor either with the path or the model in OMPython, I hope your model "Test_VSC" is named as "Test_VSC.mo" so in that case it should be the following arguments

from OMPython import ModelicaSystem
mod=ModelicaSystem("C:/OpenModelica/lib/omlibrary/HVDCcomponents/Examples/Test_VSC.mo","Test_VSC",["HVDCcomponents","OpenIPSL","Modelica"])

comment:9 follow-up: Changed 3 years ago by adrpo

Don't load a file from the library and the library at the same time, I don't think that will work. The error seems to point to that as you cannot insert a class into something that was already loaded (via the first argument, the file).

We should change OMPython so that the first argument (the one with the file) can be empty "" when you don't need any file as you just load and use stuff from the library. You can try this, load HelloWorld.mo and just ignore it, the HVDCcomponents will be loaded also and you can directly use the model from it via the path: HVDCcomponents.Examples.Test_VSC:

from OMPython import ModelicaSystem
mod=ModelicaSystem("C:/OpenModelica/share/doc/omc/testmodels/HelloWorld.mo","HVDCcomponents.Examples.Test_VSC",["HVDCcomponents","OpenIPSL","Modelica"])

comment:10 in reply to: ↑ 8 Changed 3 years ago by jeduapf

Replying to arun3688:
Yes I think I'm doing something wrong when calling the function or, more likely, the HVDCComponents library is not well written... I am still waiting the answer of my company to share it. Thank you a lot for your help and time !

comment:11 in reply to: ↑ 9 Changed 3 years ago by jeduapf

Replying to adrpo:

Don't load a file from the library and the library at the same time, I don't think that will work. The error seems to point to that as you cannot insert a class into something that was already loaded (via the first argument, the file).

Hello adrpo,

I tried as you said not calling the class and the class inside the library at the same time, but I am getting the same errors as before and some more haha... Here:

from OMPython import ModelicaSystem

mod=ModelicaSystem("C:/OpenModelica/share/doc/omc/testmodels/HelloWorld.mo","HVDCComponents.Examples.Test_VSC",["HVDCComponents","OpenIPS","Modelica"])
Error: Failed to load package HVDCComponents (default) using MODELICAPATH C:/OpenModelica/lib/omlibrary.

Error: Failed to load package OpenIPS (default) using MODELICAPATH C:/OpenModelica/lib/omlibrary.

Error: Failed to load package HVDCComponents (default) using MODELICAPATH C:/OpenModelica/lib/omlibrary.
Error: Class HVDCComponents.Examples.Test_VSC not found in scope <TOP>.

Seems like OMPython can't find the libraries in the PATH environmental variable even though I put the library there and set the PATH to there...

comment:12 follow-up: Changed 3 years ago by adrpo

If is working to load HVDCComponents in OMEdit it should work in OMPython too.
How do you load HVDCComponents and OpenIPS in OMEdit?

comment:13 in reply to: ↑ 12 Changed 3 years ago by jeduapf

Replying to adrpo:

If is working to load HVDCComponents in OMEdit it should work in OMPython too.
How do you load HVDCComponents and OpenIPS in OMEdit?

I just drag the package dile into OMEdit and open the file Test_VSC...

comment:14 follow-up: Changed 3 years ago by arun3688

@jeduapf, add the full path of HVDCComponents and OpenIPS package and try it ?

mod=ModelicaSystem("C:/OpenModelica/share/doc/omc/testmodels/HelloWorld.mo","HVDCComponents.Examples.Test_VSC",["C:/OpenModelica/lib/omlibrary/HVDCComponents/package.mo","C:/OpenModelica/lib/omlibrary/OpenIPS/package.mo","Modelica"])

adjust your path according to your location

comment:15 in reply to: ↑ 14 Changed 3 years ago by jeduapf@…

Replying to arun3688:

@jeduapf, add the full path of HVDCComponents and OpenIPS package and try it ?

mod=ModelicaSystem("C:/OpenModelica/share/doc/omc/testmodels/HelloWorld.mo","HVDCComponents.Examples.Test_VSC",["C:/OpenModelica/lib/omlibrary/HVDCComponents/package.mo","C:/OpenModelica/lib/omlibrary/OpenIPS/package.mo","Modelica"])

adjust your path according to your location

I've tried all kinds of different compositions...

Anyway, they allowed me to share the library but I prefer to send it to your e-mail if possible.
So here is my e-mail: jeduapf (a) hotmail.com, please contact me so that I can send you the library with the example.

Changed 3 years ago by jeduapf

HVDCComponents library with the Test_VSC example

comment:16 Changed 3 years ago by jeduapf

Hello,

Since the library will be an Open Source shortly I attached a simple version of it with the Test_VSC example.

Please tell me what I am doing wrong with OMPython and Modelica language.

Thank you in advance for all the help.

comment:17 Changed 3 years ago by arun3688

@jeduapf, Can you also attach the OpenIPSL library, it is needed in your example.

comment:18 Changed 3 years ago by adrpo

Arun, get it from here: https://github.com/OpenIPSL/OpenIPSL

comment:19 follow-up: Changed 3 years ago by arun3688

@adrpo thanks adrian, I already took the library and ran it but it reported some packages missing, but it seems that the example uses OpenIPSL version 1.5.0, I downloaded it from repository and everything works now.

@jeduaf, I ran your example in OMPython and it works without any problem, I loaded the example in the following way, here are my list of commands. I hope this should solve your problem.

(base) c:\pythontest>python
Python 3.8.5 (default, Sep  3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from OMPython import ModelicaSystem
>>> mod = ModelicaSystem("C:/HVDCcomponents/package.mo","HVDCcomponents.Examples.Test_VSC",["C:/OpenIPSL-1.5.0/OpenIPSL/package.mo"])

[C://HVDCcomponents/package.order:0:0-0:0:readonly] Warning: The package.order file does not list all .mo files and directories (containing package.mo) present in its directory.
Missing names are:
        DynamicLine_RLC
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: You can install the requested package using one of the commands:
  installPackage(OpenIPSL, "1.5.0", exactMatch=false)
  installPackage(OpenIPSL, "1.5.0", exactMatch=true).
Notification: Skipped loading package OpenIPSL (1.5.0,default) using MODELICAPATH C:/;C:/OPENMODELICAGIT/OpenModelica/build/lib/omlibrary;C:/Users/arupa54/AppData/Roaming/.openmodelica/libraries/ (uses-annotation may be wrong).
Notification: Skipped loading package Dynawo (0.1,default) using MODELICAPATH C:/;C:/OPENMODELICAGIT/OpenModelica/build/lib/omlibrary;C:/Users/arupa54/AppData/Roaming/.openmodelica/libraries/ (uses-annotation may be wrong).

Notification: OpenIPSL requested package Modelica of version 3.2.2. Modelica 3.2.3 is used instead which states that it is fully compatible without conversion script needed.
Notification: OpenIPSL requested package Complex of version 3.2.2. Complex 3.2.3 is used instead which states that it is fully compatible without conversion script needed.

>>> mod.sendExpression("getClassNames()")
('OpenIPSL', 'ModelicaServices', 'Complex', 'Modelica', 'HVDCcomponents')
>>> mod.simulate()
LOG_SUCCESS       | info    | The initialization finished successfully without homotopy method.
LOG_SUCCESS       | info    | The simulation finished successfully.
>>>


Changed 3 years ago by jeduapf

OpenIPSL

comment:20 Changed 3 years ago by arun3688

@jeduapf, Thanks for the attachment, but i have already tested your example and it is working, see my above comments

comment:21 in reply to: ↑ 19 Changed 3 years ago by jeduapf

Replying to arun3688:

@adrpo thanks adrian, I already took the library and ran it but it reported some packages missing, but it seems that the example uses OpenIPSL version 1.5.0, I downloaded it from repository and everything works now.

@jeduaf, I ran your example in OMPython and it works without any problem, I loaded the example in the following way, here are my list of commands. I hope this should solve your problem.

It looks interesting, can you please try to change one variable and show it like the variable "pQ_sensor1.P12"

Also I tried exactly as you showed, but I get this:

from OMPython import ModelicaSystem
mod = ModelicaSystem("C:/Users/j.alves/Desktop/HVDCcomponents/package.mo","HVDCcomponents.Examples.Test_VSC",["C:/Users/j.alves/Desktop/OpenIPSL/package.mo"])

----
2021-02-08 11:51:50,253 - OMPython - INFO - OMC Server is up and running at file:///C:/Users/J5046~1.ALV/AppData/Local/Temp/openmodelica.port.8635bd5851fe476c892e6f272075be6e pid=16192
[C:/Users/j.alves/Desktop//HVDCcomponents/package.order:0:0-0:0:readonly] Warning: The package.order file does not list all .mo files and directories (containing package.mo) present in its directory.
Missing names are:
        DynamicLine_RLC
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:/Users/j.alves/Desktop/;C:/OpenModelica/lib/omlibrary (uses-annotation may be wrong).
Notification: Skipped loading package Dynawo (0.1) using MODELICAPATH C:/Users/j.alves/Desktop/;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.

Expected end of text, found '-'  (at char 6929), (line:58, col:192)


----
mod.sendExpression("getClassNames()")

----
('OpenIPSL', 'ModelicaServices', 'Complex', 'Modelica', 'HVDCcomponents')

----
OutputFile = 'output'
tim = 1
t0 = "0"
tf = "20"
step = "0.00002"
tol = "1e-06"
method = "dassl"
simOptions = [
                "startTime" + "=" + t0,
                "stopTime" + "=" + tf,
                "stepSize" + "=" + step,
                "tolerance" + "=" + tol,
                "solver" + "=" + method
             ]

mod.setSimulationOptions(simOptions)
# Simulate the model 
mod.simulate(resultfile= OutputFile + ".mat") 


var = mod.getSolutions()
print(var)
----

()

What is happening? Is it because I am using a different OpenIPSL version?

comment:22 follow-ups: Changed 3 years ago by arun3688

@jeduaf I don't know where should i change the variable, but i tested the OpenIPSL version you sent , it also worked for me, based on the above messages you showed, it seems the model is not simulated yet , did you see some messages in your terminal something like this

>>> mod.simulate(resultfile="a"+".mat")
LOG_SUCCESS       | info    | The initialization finished successfully without homotopy method.
LOG_SUCCESS       | info    | The simulation finished successfully.

comment:23 in reply to: ↑ 22 Changed 3 years ago by jeduapf

Replying to arun3688:

@jeduaf I don't know where should i change the variable, but i tested the OpenIPSL version you sent , it also worked for me, based on the above messages you showed, it seems the model is not simulated yet , did you see some messages in your terminal something like this

>>> mod.simulate(resultfile="a"+".mat")
LOG_SUCCESS       | info    | The initialization finished successfully without homotopy method.
LOG_SUCCESS       | info    | The simulation finished successfully.

Yes I get just like you in the terminal, but when I try to open the results there is nothing inside... And when I try to open manually it says that the file is too large to be opened by notepad (it really is too large: 2,5Gbs)

[I 13:20:39.345 NotebookApp] Saving file at /Desktop/Stage/Python_CODES/Modele_HVDC_simplifie/Untitled.ipynb
LOG_SUCCESS       | info    | The initialization finished successfully without homotopy method.
LOG_SUCCESS       | info    | The simulation finished successfully.

comment:24 in reply to: ↑ 22 Changed 3 years ago by jeduapf

Replying to arun3688:

@jeduaf I don't know where should i change the variable, but i tested the OpenIPSL version you sent , it also worked for me, based on the above messages you showed, it seems the model is not simulated yet , did you see some messages in your terminal something like this

By change the variable I mean

mod.setParameters(['vSC_station_final.Vdc_Control_Type = P_mode','vSC_station_final1.Vdc_Control_Type = P_mode'])

Because normally if simulate and verify the variable 'pQ_sensor1.P12' before and after the change they should be different. I just want to assure that changing a variable from python really changes the system in modelica by this

comment:25 follow-up: Changed 3 years ago by arun3688

@jeduapf, You cannot open a mat file in notepad, But you can use some other plot libraries in python and see your results or you can use OMEdit (file-> open Result files), The result file will be in current directory working directory. I set the parameter and get the correct results

>>> mod.getParameters("SysData.fn")
['50.0']
>>> mod.setParameters("SysData.fn=100")
>>> mod.getParameters("SysData.fn")
['100']
>>> mod.simulate()
LOG_SUCCESS       | info    | The initialization finished successfully without homotopy method.
LOG_SUCCESS       | info    | The simulation finished successfully.
>>> mod.getSolutions("SysData.fn")
array([[100., 100., 100., ..., 100., 100., 100.]])
>>>

comment:26 in reply to: ↑ 25 Changed 3 years ago by jeduapf

Replying to arun3688:

@jeduapf, You cannot open a mat file in notepad, But you can use some other plot libraries in python and see your results or you can use OMEdit (file-> open Result files), The result file will be in current directory working directory. I set the parameter and get the correct results

>>> mod.getParameters("SysData.fn")
['50.0']
>>> mod.setParameters("SysData.fn=100")
>>> mod.getParameters("SysData.fn")
['100']
>>> mod.simulate()
LOG_SUCCESS       | info    | The initialization finished successfully without homotopy method.
LOG_SUCCESS       | info    | The simulation finished successfully.
>>> mod.getSolutions("SysData.fn")
array([[100., 100., 100., ..., 100., 100., 100.]])
>>>

I am really confused right now. The function getSolutions() will open directly the results of the result file, no?

Moreover, I tried with SysData.fn and I got

mod.getParameters("SysData.fn")

----
['NotExist']


Why I have no results for the variables in the system, such as 'pQ_sensor1.P12' ?

comment:27 Changed 3 years ago by jeduapf

What I want to do is controlling some key variables in "getParameters,setParameters" change the results of the system after simulation. For example:

'pQ_sensor1.P12' is a result variables which looks like a energy curve that will change when the power comes to the system in the cable.

After changing a Parameter variable (vSC_station_final.Vdc_Control_Type) I should expect a different curve of the variable 'pQ_sensor1.P12'.

comment:28 follow-up: Changed 3 years ago by arun3688

I guess you and me are running different versions of your model,I hope you send only the minimal version of your model, if you simply run mod.getParameters() will show you list of available parameters in the model and i can see the variable SysData.fn and i changed it and get the results.

Changed 3 years ago by jeduapf

everything I am using now

comment:29 Changed 3 years ago by arun3688

@jeduapf, Can you also send your python script, so that i can simply run your script

comment:30 in reply to: ↑ 28 Changed 3 years ago by jeduapf

Replying to arun3688:

I guess you and me are running different versions of your model,I hope you send only the minimal version of your model, if you simply run mod.getParameters() will show you list of available parameters in the model and i can see the variable SysData.fn and i changed it and get the results.

I resend everything I am using right now, but even if there is this variable, the most important one is 'pQ_sensor1.P12', so I must have its values...

Please could you try with the new documents I sent?


Changed 3 years ago by jeduapf

python script

Changed 3 years ago by arun3688

comment:31 follow-ups: Changed 3 years ago by arun3688

@jeduapf, I have corrected your jupyter notebook, i see that after running "ModelicaSystem()" constructor will do the building process, you should not use mod.buildModel(), you must use that only when you did some changes to your model and rebuild it. see the above corrected jupyter notebook commands, correct your path to the package in the constructor

comment:32 in reply to: ↑ 31 Changed 3 years ago by jeduapf

Replying to arun3688:

@jeduapf, I have corrected your jupyter notebook, i see that after running "ModelicaSystem()" constructor will do the building process, you should not use mod.buildModel(), you must use that only when you did some changes to your model and rebuild it. see the above corrected jupyter notebook commands, correct your path to the package in the constructor


Thank you ! It worked.

So after applying one change to the parameters of the model (Ex.: "vSC_station_final1.Vdc_Control_Type = PI+filter" to "vSC_station_final1.Vdc_Control_Type = PI+filter = P_mode" using setParameters(); I just need to run mod.simulate() and the results will change in consequence? I don't need to rebuild before simulation, correct?) , I must not use buildModel() in this case? Can you give an example where I must use mod.simulate() and when I must not please?

comment:33 in reply to: ↑ 31 Changed 3 years ago by jeduapf

Replying to arun3688:

@jeduapf, I have corrected your jupyter notebook, i see that after running "ModelicaSystem()" constructor will do the building process, you should not use mod.buildModel(), you must use that only when you did some changes to your model and rebuild it. see the above corrected jupyter notebook commands, correct your path to the package in the constructor

Maybe tolorrow I will still need some help, but finally I can keep working on it now, thank you very much!

comment:34 Changed 3 years ago by casella

  • Milestone changed from 1.17.0 to 1.18.0

Retargeted to 1.18.0 because of 1.17.0 timed release.

comment:35 Changed 3 years ago by casella

  • Milestone 1.18.0 deleted

Ticket retargeted after milestone closed

Note: See TracTickets for help on using tickets.