- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » trouble with new media model
trouble with new media model
trouble with new media model
I created a simple model of two tanks connected by a single static pipe, (see code below). When I use the standard media package "Modelica.Media.Water.StandardOnePhase", the model compiles and simulates. When I try to use the custom media package "dieselfuel" I created below, the model fails to compile. Could someone point me in the right direction to get this to work?
model simple_media_test
replaceable package Medium = dieselfuel constrainedby Modelica.Media.Interfaces.PartialMedium;
//replaceable package Medium = Modelica.Media.Water.StandardWaterOnePhase constrainedby Modelica.Media.Interfaces.PartialMedium;
inner Modelica.Fluid.System system annotation(Placement(visible = true, transformation(origin = {68.1818,77.2727}, extent = {{-10,-10},{10,10}}, rotation = 0)));
Modelica.Fluid.Vessels.OpenTank tank(redeclare package Medium = Medium, height = 100, crossArea = 10, use_portsData = true, portsData = {Modelica.Fluid.Vessels.BaseClasses.VesselPortsData(diameter = 0.3)}, nPorts = 1) annotation(Placement(visible = true, transformation(origin = {-58.3333,65.9091}, extent = {{-10,-10},{10,10}}, rotation = 0)));
Modelica.Fluid.Pipes.StaticPipe pipe(redeclare package Medium = Medium, length = 150, diameter = 0.1) annotation(Placement(visible = true, transformation(origin = {-26.0101,23.9899}, extent = {{-10,-10},{10,10}}, rotation = 0)));
Modelica.Fluid.Vessels.OpenTank opentank1(redeclare package Medium = Medium, height = 100, crossArea = 10, use_portsData = true, level_start = 0, portsData = {Modelica.Fluid.Vessels.BaseClasses.VesselPortsData(diameter = 0.3)}, nPorts = 1) annotation(Placement(visible = true, transformation(origin = {12.4242,64.6969}, extent = {{-10,-10},{10,10}}, rotation = 0)));
package dieselfuel "Template for media models"
import Modelica.Media.*;
extends Modelica.Media.Interfaces.PartialMedium(final mediumName = "Diesel Fuel", final substanceNames = {mediumName}, final singleState = true, final reducedX = true, final fixedX = true, Temperature(min = 273, max = 373, start = 294));
constant SpecificHeatCapacity cp_const = 1900 "Constant specific heat capacity at constant pressure";
redeclare model extends BaseProperties(final standardOrderComponents = true) "Base properties of medium"
equation
d = 843;
h = cp_const * T;
u = h - p / d;
MM = 0.223;
R = 8.3144 / MM;
state.p = p;
state.T = T;
end BaseProperties;
redeclare replaceable record ThermodynamicState "A selection of variables that uniquely defines the thermodynamic state"
extends Modelica.Icons.Record;
AbsolutePressure p "Absolute pressure of medium";
Temperature T "Temperature of medium";
annotation(Documentation(info = "<html>
</html>"));
end ThermodynamicState;
redeclare function extends dynamicViscosity "Return dynamic viscosity"
algorithm
eta:=0.0035;
annotation(Documentation(info = "<html>
</html>"));
end dynamicViscosity;
annotation(Documentation(info = "<HTML>
<p>
This package is a <b>template</b> for <b>new medium</b> models. For a new
medium model just make a copy of this package, remove the
\"partial\" keyword from the package and provide
the information that is requested in the comments of the
Modelica source.
</p>
</HTML>"));
end dieselfuel;
equation
connect(pipe.port_b,opentank1.ports[1]) annotation(Line(points = {{-16.0101,23.9899},{12.6263,23.9899},{12.6263,54.6969},{12.4242,54.6969}}));
connect(tank.ports[1],pipe.port_a) annotation(Line(points = {{-58.3333,55.9091},{-57.5758,55.9091},{-57.5758,23.7374},{-36.0101,23.7374},{-36.0101,23.9899}}));
connect(tank.ports[1],pipe.port_a) annotation(Line(points = {{-58.3333,55.9091},{-57.5758,55.9091},{-57.5758,23.7374},{-35.8586,23.7374},{-35.8586,23.7374}}));
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 simple_media_test;
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » trouble with new media model