- Index
- » Programming
- » Modelica Language
- » Help with balanced fluid models
Help with balanced fluid models
Help with balanced fluid models
Hi there,
when working with OM, i often have to use the media models of the MSL in combination with the models of the fluid library. For a simple simulation, where i need to "pump" water from one tank to another, i tried to build a simple pump-like model. This is where i seem to make an error, that i often make, when it comes to using components of Modelica.Media and Modelica.Fluid - most of the time i get the message stating that the number of equations doesn't match the number of variables when trying to run the simulation (when i check the model itself, the number of variables and equations match).
If someone could tell me, where the the error in my code or within my method in general is, that would be really great. I tried finding literature on how to make balanced models or papers etc. on how to setup up those modelica models but unfortunately i can't find something like a checklist or a receipt. There seem to be some basic concepts i still don't understand.
Below is my code of the pump-model, the model i test it in and attached is the error message i get, when trying to simulate.
I know, this is not a problem of the software rather than my abilities to create models...i just can't get my head around this and you would help me a lot. Thank you very much!
model SimplePump
"Simple, pump-like model that induces a mass flow between ports a and b"
replaceable package Medium = Modelica.Media.Water.StandardWaterOnePhase;
parameter Real m_flow = 2;
Modelica.Fluid.Interfaces.FluidPort_a port_a(redeclare package Medium = Medium) annotation(
Placement(visible = true, transformation(origin = {-100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Fluid.Interfaces.FluidPort_b port_b(redeclare package Medium = Medium) annotation(
Placement(visible = true, transformation(origin = {100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
//pressures at ports
0 = port_a.p - port_b.p;
//mass balance
0 = port_a.m_flow + port_b.m_flow;
//Induced mass flow
m_flow = port_a.m_flow;
//energy balance
port_a.h_outflow = port_b.h_outflow;
annotation(
uses(Modelica(version = "3.2.3")),
Icon(graphics = {Ellipse(origin = {-0.26, 0.42}, lineThickness = 0.75, extent = {{39.63, 40.09}, {-39.63, -40.09}}, endAngle = 360), Line(origin = {-45, 0}, points = {{45, 0}, {-45, 0}, {-45, 0}}, thickness = 0.75), Line(origin = {39.79, 40.62}, points = {{-40, 0}, {40, 0}, {40, 0}}, thickness = 0.75), Line(origin = {-0.02, -38.8}, points = {{-27.9787, 8.79835}, {-39.9787, -9.20165}, {40.0213, -9.20165}, {26.0213, 8.79835}, {26.0213, 8.79835}}, thickness = 0.75), Rectangle(extent = {{-100, 100}, {100, -100}})}));
end SimplePump;
model TestCase
replaceable package Medium = Modelica.Media.Water.StandardWater;
SimplePump simplePump(redeclare package Medium = Medium, m_flow = 2) annotation(
Placement(visible = true, transformation(origin = {0, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
inner Modelica.Fluid.System system annotation(
Placement(visible = true, transformation(origin = {-90, 90}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Fluid.Sources.FixedBoundary Sink(nPorts = 1, redeclare package Medium = Medium) annotation(
Placement(visible = true, transformation(origin = {80, 0}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
Modelica.Fluid.Sources.FixedBoundary Source(nPorts = 1, redeclare package Medium = Medium) annotation(
Placement(visible = true, transformation(origin = {-80, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(simplePump.port_b, Sink.ports[1]) annotation(
Line(points = {{10, 0}, {70, 0}}, color = {0, 127, 255}));
connect(Source.ports[1], simplePump.port_a) annotation(
Line(points = {{-70, 0}, {-10, 0}}, color = {0, 127, 255}));
annotation(
uses(Modelica(version = "3.2.3")));
end TestCase;
ErrorMessageTestCase.txt
- Index
- » Programming
- » Modelica Language
- » Help with balanced fluid models