Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

modelica fluid library

modelica fluid library

any model thate i have give the same error:  component tank1 contains the definition of a partial class Medium. Please redeclare it to any package compatible with Modelica.Media.Interfaces.PartialMedium.

image link http://imgur.com/THKnBIo

Re: modelica fluid library

Unfortunately we don't yet support redeclares in the OMEdit dialogs  so you will have to write them it directly in the code.
I'm working on a solution which should be available soon. See:
https://trac.openmodelica.org/OpenModelica/ticket/2079

Re: modelica fluid library

THANK YOU , where is  language specification? is it norrmally openmodelica guide?

Re: modelica fluid library

What do you mean? If you're asking for the Modelica Language specification is here: https://www.modelica.org/documents/

Re: modelica fluid library

I don't understand  how to intervene in my case, reading your link I don't found an understandable solution

Re: modelica fluid library

You can read about redeclares in the Modelica Specification 3.x.

In your case you need to go into the Modelica source code for your model and for component tank1 just add:
redeclare Medium=Modelica.Media.Water.StandardWater to your components.

Code:


tank1(redeclare package Medium=Modelica.Media.Water.StandardWater);

You will need to add it for all the components that need it.

Re: modelica fluid library

adrpo wrote:


What do you mean? If you're asking for the Modelica Language specification is here: https://www.modelica.org/documents/

thank you

Re: modelica fluid library

a model that works good alone

model tanks
  import Modelica.Fluid;
  replaceable package Medium = Modelica.Media.Water.ConstantPropertyLiquidWater constrainedby Modelica.Media.Interfaces.PartialMedium "Medium in the component" annotation(choicesAllMatching = true);
  final Modelica.Fluid.Vessels.OpenTank tank1(redeclare package Medium = Medium, height = 80, crossArea = 20, nPorts = 1, level_start = 70, portsData = {Modelica.Fluid.Vessels.BaseClasses.VesselPortsData(diameter = 0.1)}) annotation(Placement(visible = true, transformation(origin = {-60, 60}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  final Modelica.Fluid.Vessels.OpenTank tank2(redeclare package Medium = Medium, height = 80, crossArea = 20, nPorts = 1, level_start = 0.0, portsData = {Modelica.Fluid.Vessels.BaseClasses.VesselPortsData(diameter = 0.1)}) annotation(Placement(visible = true, transformation(origin = {0, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Fluid.Pipes.StaticPipe pipe(redeclare package Medium = Medium, allowFlowReversal = true, length = 2, diameter = 0.5, height_ab = 0) annotation(Placement(visible = true, transformation(origin = {-35, 15}, extent = {{-5, -5}, {5, 5}}, rotation = 0)));
  inner Modelica.Fluid.System system annotation(Placement(visible = true, transformation(origin = {0, -20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
  connect(tank1.ports[1], pipe.port_a) annotation(Line(points = {{-60, 50}, {-40.1478, 50}, {-40.1478, 15.0246}, {-40.1478, 15.0246}}));
  connect(pipe.port_b, tank2.ports[1]) annotation(Line(points = {{-30, 15}, {-2.70936, 15}, {-2.70936, 9.85222}, {-2.70936, 9.85222}}));
  annotation(Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})), Diagram(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})));
end tanks;

Re: modelica fluid library

i understand now, in every component/class parentesi i put this: redeclare package Medium = Medium, and the entire model work good

There are 0 guests and 0 other users also viewing this topic