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

Newbie Help with Redeclaring Medium

Newbie Help with Redeclaring Medium

[2] 14:24:49 Translation Error
[BraytonCycle: 2:3-4:113]: component compressor1 contains the definition of a partial class Medium.
Please redeclare it to any package compatible with Modelica.Media.Interfaces.PartialMedium.

This is the error message that first pops up when trying to check my Brayton Cycle Example Model pulled from the Modelica Library. It is in relation with the first component in my model, the compressor. I understand that I need to call upon a new medium, standard air would suffice, but I just cannot figure out where to insert this line of code into my body of code describing my system. Below is a snippet of code where I'm supposed to redeclare the medium, I just cannot figure out where.

model BraytonCycle
  ThermoPower.Gas.Compressor compressor1(Ndesign = 150, Table = ThermoPower.Choices.TurboMachinery.TableTypes.matrix, Tdes_in = 300, allowFlowReversal = false, pout(start = 100))  annotation(
 
    Placement(visible = true, transformation(origin = {-71, 3}, extent = {{-13, -13}, {13, 13}}, rotation = 0)));

  ThermoPower.Gas.Turbine turbine1(Ndesign = 300, Tdes_in = 500, pout(start = 1))  annotation(
    Placement(visible = true, transformation(origin = {11, 3}, extent = {{-13, -13}, {13, 13}}, rotation = 0)));
  ThermoPower.Gas.SourcePressure sourcePressure1(T = 300, allowFlowReversal = false, p0 = 100000)  annotation(


Let me know what you guys think! I just cannot figure out why simulating a model pulled from the Modelica Library is giving me so much trouble. Thanks.

Re: Newbie Help with Redeclaring Medium

I believe the correct redeclare would be along the lines of ... " replaceable package MyMedium = Modelica.Media.Air.SimpleAir "

But like I said, I cannot figure out where to insert this declaration in order to solve the error mentioned above. 

Re: Newbie Help with Redeclaring Medium

Update: After redeclaring my medium within the compressor1 variable, I received a new error. Cannot tell if this is a step in the right direction or not. Below I have copied an update on the compressor1 code with the new error.

model BraytonCycle
  ThermoPower.Gas.Compressor compressor1(Ndesign = 150, Table = ThermoPower.Choices.TurboMachinery.TableTypes.matrix, Tdes_in = 300, allowFlowReversal = false, pout(start = 100), MyMedium = Modelica.Media.Air.SimpleAir)  annotation(
    Placement(visible = true, transformation(origin = {-71, 3}, extent = {{-13, -13}, {13, 13}}, rotation = 0)));

[1] 14:43:34 Translation Error
[BraytonCycle: 2:180-2:219]: Variable Modelica.Media.Air.SimpleAir not found in scope BraytonCycle.

I don't really understand why this medium cannot be found "within the scope of Brayton Cycle" because I'm calling it from the Modelica Library. If anyone can shed some light on this that would be really helpful for this beginner's learning experience. Thanks!

Re: Newbie Help with Redeclaring Medium

I guess something like this will work:

Code:


ThermoPower.Gas.Compressor compressor1(redeclare package Medium = Modelica.Media.Air.SimpleAir, Ndesign = 150, Table = ThermoPower.Choices.TurboMachinery.TableTypes.matrix, Tdes_in = 300, allowFlowReversal = false, pout(start = 100));

Re: Newbie Help with Redeclaring Medium

Hey Adrpo,

Thanks for the reply. Is there a specific order in which you must declare information?

However, I tried this and still received the error of " [1] 14:43:34 Translation Error
[BraytonCycle: 2:180-2:219]: Variable Modelica.Media.Air.SimpleAir not found in scope BraytonCycle. "

Re: Newbie Help with Redeclaring Medium

Show me the entire model again.

Re: Newbie Help with Redeclaring Medium

Here is the entire model of the Brayton Cycle pulled from Modelica's ThermoPower Library. My first error occurs in the first line pertaining to the compressor1 class.

Code:


model BraytonCycle
  ThermoPower.Gas.Compressor compressor1( MyMedium = Modelica.Media.Air.SimpleAir, Ndesign = 150, Table = ThermoPower.Choices.TurboMachinery.TableTypes.matrix, Tdes_in = 300, allowFlowReversal = false, pout(start = 100))  annotation(
    Placement(visible = true, transformation(origin = {-71, 3}, extent = {{-13, -13}, {13, 13}}, rotation = 0)));
  ThermoPower.Gas.Turbine turbine1(Ndesign = 300, Tdes_in = 500, pout(start = 1))  annotation(
    Placement(visible = true, transformation(origin = {11, 3}, extent = {{-13, -13}, {13, 13}}, rotation = 0)));
  ThermoPower.Gas.SourcePressure sourcePressure1(T = 300, allowFlowReversal = false, p0 = 100000)  annotation(
    Placement(visible = true, transformation(origin = {-103, 23}, extent = {{-9, -9}, {9, 9}}, rotation = 0)));
  ThermoPower.Gas.PressDrop pressDrop1 annotation(
    Placement(visible = true, transformation(origin = {-61, 33}, extent = {{-5, -5}, {5, 5}}, rotation = -90)));
  ThermoPower.Gas.CombustionChamber combustionChamber1(Cm = 1, S = 10, V = 10, allowFlowReversal = false, gamma = 1)  annotation(
    Placement(visible = true, transformation(origin = {-30, 50}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  ThermoPower.Gas.PressDrop pressDrop2 annotation(
    Placement(visible = true, transformation(origin = {1, 33}, extent = {{-5, -5}, {5, 5}}, rotation = -90)));
  Modelica.Mechanics.Rotational.Sensors.PowerSensor powerSensor1 annotation(
    Placement(visible = true, transformation(origin = {32, 0}, extent = {{-6, -6}, {6, 6}}, rotation = 0)));
  ThermoPower.Electrical.Generator generator1 annotation(
    Placement(visible = true, transformation(origin = {52, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Blocks.Continuous.FirstOrder PowerSensor annotation(
    Placement(visible = true, transformation(origin = {45, -45}, extent = {{-9, -9}, {9, 9}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealOutput GeneratedPower annotation(
    Placement(visible = true, transformation(origin = {82, -44}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {82, -44}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealInput FuelSource annotation(
    Placement(visible = true, transformation(origin = {-100, 52}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-100, 52}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Blocks.Continuous.FirstOrder GasFlowActuator(T = 4, initType = Modelica.Blocks.Types.Init.SteadyState, y_start = 500)  annotation(
    Placement(visible = true, transformation(origin = {-64, 86}, extent = {{-6, -6}, {6, 6}}, rotation = 0)));
  ThermoPower.Gas.SourceMassFlow sourceMassFlow1 annotation(
    Placement(visible = true, transformation(origin = {-46, 68}, extent = {{-6, -6}, {6, 6}}, rotation = 0)));
equation
  connect(pressDrop1.inlet, combustionChamber1.ina) annotation(
    Line(points = {{-61, 38}, {-61, 50}, {-40, 50}}, color = {159, 159, 223}));
  connect(sourceMassFlow1.flange, combustionChamber1.inf) annotation(
    Line(points = {{-40, 68}, {-30, 68}, {-30, 60}}, color = {159, 159, 223}));
  connect(combustionChamber1.out, pressDrop2.inlet) annotation(
    Line(points = {{-20, 50}, {1, 50}, {1, 38}}, color = {159, 159, 223}));
  connect(compressor1.outlet, pressDrop1.outlet) annotation(
    Line(points = {{-61, 13}, {-61, 28}}, color = {159, 159, 223}));
  connect(pressDrop2.outlet, turbine1.inlet) annotation(
    Line(points = {{1, 28}, {1, 13}}, color = {159, 159, 223}));
  connect(sourcePressure1.flange, compressor1.inlet) annotation(
    Line(points = {{-94, 23}, {-81, 23}, {-81, 13}}, color = {159, 159, 223}));
  connect(compressor1.shaft_b, turbine1.shaft_a) annotation(
    Line(points = {{-63, 3}, {3, 3}}));
  connect(turbine1.shaft_b, powerSensor1.flange_a) annotation(
    Line(points = {{19, 3}, {21, 3}, {21, 0}, {26, 0}}));
  connect(GasFlowActuator.y, sourceMassFlow1.in_w0) annotation(
    Line(points = {{-58, 86}, {-50, 86}, {-50, 72}, {-50, 72}}, color = {0, 0, 127}));
  connect(FuelSource, GasFlowActuator.u) annotation(
    Line(points = {{-100, 52}, {-80, 52}, {-80, 86}, {-71, 86}}, color = {0, 0, 127}));
  connect(PowerSensor.y, GeneratedPower) annotation(
    Line(points = {{54, -44}, {82, -44}}, color = {0, 0, 127}));
  connect(powerSensor1.power, PowerSensor.u) annotation(
    Line(points = {{28, -6}, {28, -45}, {34, -45}}, color = {0, 0, 127}));
  connect(powerSensor1.flange_b, generator1.shaft) annotation(
    Line(points = {{38, 0}, {44, 0}, {44, 0}, {44, 0}}));

annotation(
    uses(ThermoPower(version = "3.1"), Modelica(version = "3.2.2")));end BraytonCycle;

Re: Newbie Help with Redeclaring Medium

This modification is wrong:

Code:


MyMedium = Modelica.Media.Air.SimpleAir

It says that a variable MyMedium should be set to variable Modelica.Media.Air.SimpleAir.
Modelica.Media.Air.SimpleAir exists, but as a class, not a variable.
You cannot set replaceable classes or components like that.
Also note that MyMedium does not exist in Compressor. You should redeclare Medium.

If you want a redeclare of a class, then you need to use this syntax:

Code:


redeclare package Medium = Modelica.Media.Air.SimpleAir

Re: Newbie Help with Redeclaring Medium

Hey Ardpo,

I still cannot manage to figure out to declare the medium class. I think the location of my inserted code is the root of the issue. I tried taking a step back on a much more simpler model, the pump pulled from the library but still cannot manage to simulate the model due to the very common error of: : [4] 09:25:35 Translation Error
[pump: 2:5-3:112]: component pump1 contains the definition of a partial class Medium.
Please redeclare it to any package compatible with Modelica.Media.Interfaces.PartialMedium.

Here is the most logical insert of class declaration I've tried but with no success.

Code:


model pump
  Modelica.Fluid.Machines.Pump pump1 annotation(
    Placement(visible = true, transformation(origin = {-22, -2}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation

annotation(
    uses(Modelica(version = "3.2.2")));end pump;

I've always declared the media at the beginning of the model, look below.

Code:


model pump
  replaceable package Medium = Modelica.Media.Water.StandardWater
  Modelica.Fluid.Machines.Pump pump1 annotation(
    Placement(visible = true, transformation(origin = {-22, -2}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation

annotation(
    uses(Modelica(version = "3.2.2")));end pump;

Let me know what you think, thanks.

There are 0 guests and 0 other users also viewing this topic
You are here: