Opened 6 years ago

Last modified 5 years ago

#5499 new defect

setParameters of ModelicaSystem has no effect on simulation

Reported by: anonymous Owned by: Alachew Mengist
Priority: high Milestone: Future
Component: OMPython Version:
Keywords: Cc:

Description

Hi,
I'm trying to run the PowerWorld example from the PowerSystems library via OMPython.
No errors occur and the simulation itself works. The solutions are correct compared to the ones of OMEdit. However I run into problems when manipulating the parameters:

from OMPython import ModelicaSystem


mod = ModelicaSystem('/home/XXX/PowerSystems/package.mo', "PowerSystems.Examples.PowerWorld.PowerWorld",
                     ["Modelica"])
mod.setParameters(**{'windFarm.cut_out': 1.0})
mod.simulate()
print(mod.getParameters().get('windFarm.cut_out'))#prints out 1.0
frequ_sols = mod.getSolutions('frequency.y')
print(frequ_sols)#solutions are for windFarm.cut_out=0.0 :(

windFarm.cut_out has the default value 0.0. I set windFarm.cut_out to 1.0. No error occurs. I start the simulation.
The solutions (checked with the help of frequ_sols) are incorrect. The solutions are still the solutions of the default value.

I don't see any mistake on my side or hint in the doc that could help me.

Change History (2)

comment:1 by nytsch@…, 5 years ago

Hi,
I had a similar problem with the mod.setParameters() method:

from OMPython import ModelicaSystem

mod=ModelicaSystem("WallModels.mo","WallModels.WallWDVS",["Modelica","BuildingSystems"])
mod.setParameters(["wall.constructionData.thickness[1]=0.24),
                   "wall.constructionData.thickness[2]=0.1),
                   "wall.constructionData.thickness[3]=0.01",                    
                   "ambience.TAirRefSou=BuildingSystems.Buildings.Types.DataSource.Parameter",
                   "ambience.TAirRef_constant=263.15"])

The parametrization of Real values (code above) works fine, but the parametrization of a parameter with types fails (that means the default value BuildingSystems.Buildings.Types.DataSource.File is used instead of the wished value BuildingSystems.Buildings.Types.DataSource.Parameter):

mod.setParameters(["ambience.xAirSou=BuildingSystems.Buildings.Types.DataSource.Parameter",
                   "ambience.IrrDirHorSou=BuildingSystems.Buildings.Types.DataSource.Parameter",
                   "ambience.IrrDifHorSou=BuildingSystems.Buildings.Types.DataSource.Parameter",
                   "ambience.vWindRefSou=BuildingSystems.Buildings.Types.DataSource.Parameter"])

OpenModelica in principle is able to do this kind of parametrization, because this models works fine:

...    
BuildingSystems.Buildings.Ambience ambience(
      TAirRefSou=BuildingSystems.Buildings.Types.DataSource.Parameter,
      TAirRef_constant=263.15,
      xAirSou=BuildingSystems.Buildings.Types.DataSource.Parameter,
      IrrDirHorSou=BuildingSystems.Buildings.Types.DataSource.Parameter,
      IrrDifHorSou=BuildingSystems.Buildings.Types.DataSource.Parameter,
      vWindRefSou=BuildingSystems.Buildings.Types.DataSource.Parameter,	
      ...);

So I guess the Python interface of OpenModelica has an bug (The Ambience model class of the example can be find under https://github.com/UdK-VPT/BuildingSystems/blob/master/BuildingSystems/Buildings/Ambience.mo).

I did my tests with the official release 1.14.1 and with 1.15.0-dev.

Christoph

comment:2 by Christoph Nytsch-Geusen <nytsch@…>, 5 years ago

sorry, my first code example wasn't correct, the correct form is

from OMPython import ModelicaSystem

mod=ModelicaSystem("WallModels.mo","WallModels.WallWDVS",["Modelica","BuildingSystems"])
mod.setParameters(["wall.constructionData.thickness[1]=0.24",
                   "wall.constructionData.thickness[2]=0.1",
                   "wall.constructionData.thickness[3]=0.01",                    
                   "ambience.TAirRef_constant=263.15"])
Note: See TracTickets for help on using tickets.