Hannes
Sep 19 2007, 05:32 PM
Hello Thore,
I'm sorry, but when I saw your error-message talking about 18 equations and 21 unknowns, I had to laugh. The reason is that in my diploma thesis I'm currently struggling with the same problem: I'm also working on some basic thermodynamics and I'm using an exchangeable water model in my tanks, pumps, pipes and so on. And: I always have a difference of equations and unknowns that is THREE! Really always. I don't find the reason.
So I'm happy that there's someone else facing my problem. I'd be glad if we could discuss about it.
My WaterModel is something like this:
package SeaWater_2
"VERY simple model for seawater: incompressible, constants except u=u(s,t)"
extends PartialSeaWater;
//import
// PV_RO_components.Hydraulics.Water.Components.SpecificHeatCapacity.Fichtner.seawater_SI_SpecificHeatCapacity;
model extends Properties
//(
//t(start=25,stateSelect=StateSelect.prefer),
//p(start=2e5,stateSelect=StateSelect.prefer),
//X_s(start=0,stateSelect=StateSelect.prefer))
//initial equation
// der(p)=0;
// der(t)=0;
// der(X_s)=0;
equation
rho = 1020 "in kg/m^3 const";
/////////////////////////////////////////////////////////////////
u = 1e5 + cp*(t-0) "u=u0+cp*(t-t0)";
/////////////////////////////////////////////////////////////////
eta = 1e-3;
/////////////////////////////////////////////////////////////////
cp = 4180;
end Properties;
end SeaWater_2;
which inherits from
encapsulated partial package PartialSeaWater
"Basic (partial) features of seawater"
import SI = Modelica.SIunits;
import PV_RO_components.Quantities.Salinity;
import PV_RO_components.misc.myConstants.p_std;
record PropertiesRecord
"Collection of fundamental viables of this medium"
public
StaticPressure p "Static non-gauge pressure";
CelsiusTemperature t "Celsius temperature";
Density rho "Density";
SpecificInternalEnergy u "Specific internal energy";
SpecificEnthalpy h "Specific enthalpy";
MassFraction X_s "Mass fraction of salt";
////////////////////////////////////////////////////////////////////////////
// further variables, not necessarily basic ones
////////////////////////////////////////////////////////////////////////////
Salinity s "Salinity";
SpecificHeatCapacity cp "Specific heat capacity";
DynamicViscosity eta "Dynamic viscosity";
KinematicViscosity nu "Kinematic viscosity";
annotation (Icon(Rectangle(extent=[-80,80; 80,-80], style(color=3,
rgbcolor={0,0,255}))));
end PropertiesRecord;
replaceable partial model Properties
public
extends PropertiesRecord;
public
parameter MassFraction X_s_max(min=0.040,max=0.13,start=0.13)
"Maximal salinity before error";
equation
s = X_s/(1-X_s) "always valid";
assert(X_s>=0 and X_s<=X_s_max, "Invalid mass fraction of salt!");
h = u + p/rho "always valid";
eta = rho * nu "always valid";
annotation (Icon(Ellipse(extent=[-80,80; 80,-80], style(color=3,
rgbcolor={0,0,255}))));
end Properties;
type CelsiusTemperature = SI.CelsiusTemperature(min=0,max=60,nominal=25,start=25)
annotation (Icon(Line(points=[-80,-80; -80,-80; 80,-80; -80,40; 80,40;
0,80; -80,40; -80,-80; 80,40; 80,-80], style(color=3,
rgbcolor={0,0,255}))));
type DynamicViscosity = SI.DynamicViscosity(min=1e-5,max=6e-3,nominal=1e-3,start=1e-3)
annotation (Icon(Line(points=[-80,-80; -80,-80; 80,-80; -80,40; 80,40;
0,80; -80,40; -80,-80; 80,40; 80,-80], style(color=3,
rgbcolor={0,0,255}))));
type KinematicViscosity = SI.KinematicViscosity(min=1e-8,max=6e-6,nominal=1e-6,start=1e-6)
annotation (Icon(Line(points=[-80,-80; -80,-80; 80,-80; -80,40; 80,40;
0,80; -80,40; -80,-80; 80,40; 80,-80], style(color=3,
rgbcolor={0,0,255}))));
type StaticPressure = SI.StaticPressure(min=0.8*p_std,max=100e5,nominal=10e5,start=10e5)
annotation (Icon(Line(points=[-80,-80; -80,-80; 80,-80; -80,40; 80,40;
0,80; -80,40; -80,-80; 80,40; 80,-80], style(color=3,
rgbcolor={0,0,255}))));
type MassFraction = SI.MassFraction(min=0,max=1,nominal=0.035,start=0.035)
annotation (Icon(Line(points=[-80,-80; -80,-80; 80,-80; -80,40; 80,40;
0,80; -80,40; -80,-80; 80,40; 80,-80], style(color=3,
rgbcolor={0,0,255}))));
type Density = SI.Density(min=900,max=1200,nominal=1020,start=1020)
annotation (Icon(Line(points=[-80,-80; -80,-80; 80,-80; -80,40; 80,40;
0,80; -80,40; -80,-80; 80,40; 80,-80], style(color=3,
rgbcolor={0,0,255}))));
type SpecificInternalEnergy = SI.SpecificInternalEnergy(nominal=1e5,start=1e5)
annotation (Icon(Line(points=[-80,-80; -80,-80; 80,-80; -80,40; 80,40;
0,80; -80,40; -80,-80; 80,40; 80,-80], style(color=3,
rgbcolor={0,0,255}))));
type SpecificEnthalpy = SI.SpecificEnthalpy(nominal=1e5,start=1e5)
annotation (Icon(Line(points=[-80,-80; -80,-80; 80,-80; -80,40; 80,40;
0,80; -80,40; -80,-80; 80,40; 80,-80], style(color=3,
rgbcolor={0,0,255}))));
type SpecificHeatCapacity = SI.SpecificHeatCapacity(nominal=4180,start=4180)
annotation (Icon(Line(points=[-80,-80; -80,-80; 80,-80; -80,40; 80,40;
0,80; -80,40; -80,-80; 80,40; 80,-80], style(color=3,
rgbcolor={0,0,255}))));
type MassFlowRate = SI.MassFlowRate(nominal=10,start=0)
annotation (Icon(Line(points=[-80,-80; -80,-80; 80,-80; -80,40; 80,40;
0,80; -80,40; -80,-80; 80,40; 80,-80], style(color=3,
rgbcolor={0,0,255}))));
type EnthalpyFlowRate = SI.EnthalpyFlowRate(nominal=1e5,start=0)
annotation (Icon(Line(points=[-80,-80; -80,-80; 80,-80; -80,40; 80,40;
0,80; -80,40; -80,-80; 80,40; 80,-80], style(color=3,
rgbcolor={0,0,255}))));
end PartialSeaWater;
So the state of water is described by 10 variables while 7 equations are within the water model. Another 3 free state variables have to be computed from mass balance, energy balance and momentum balance or so.
model DummyComponent
annotation (Icon(Ellipse(extent=[-80,80; 80,-80], style(
color=3,
rgbcolor={0,0,255},
fillColor=6,
rgbfillColor={255,255,0}))));
import PV_RO_components.Hydraulics.Connectors.Port_SeaWater;
import waterLib = PV_RO_components.Hydraulics.Water;
import SI = Modelica.SIunits;
public
replaceable package Water = waterLib.PartialSeaWater;
Port_SeaWater port_a(redeclare package Water=Water)
annotation (extent=[-100,-8; -80,12]);
Port_SeaWater port_b(redeclare package Water=Water)
annotation (extent=[80,-10; 100,10]);
Water.Properties state;
SI.Mass m;
SI.Mass ms;
parameter SI.Volume vol(start=1);
SI.MassFlowRate dotM_flow;
SI.InternalEnergy U;
///////////////////////////////////////////////////////////////////
/**/
initial equation
///////////////////////////////////////////////////////////////////
state.t = 25;
der(state.t) = 0;
der(state.rho) = 0;
der(state.X_s) = 0;
///////////////////////////////////////////////////////////////////
/**/
equation
///////////////////////////////////////////////////////////////////
// pressure
state.p = (port_a.p + port_b.p)/2;
// total mass
m = vol * state.rho;
port_a.dotM_flow + port_b.dotM_flow = der(m);
// partial mass
ms = state.X_s * m;
port_a.dotM_flow_s + port_b.dotM_flow_s = der(ms);
// energy
U = state.u * m;
port_a.dotH_flow + port_b.dotH_flow = der(U);
// mass flow
port_a.dotM_flow = 10*(port_a.p - port_b.p) "Why especially this dotM?";
// partial mass flow
port_a.dotM_flow_s = port_a.dotM_flow * (if port_a.dotM_flow>=0 then port_a.X_s else state.X_s);
port_b.dotM_flow_s = port_b.dotM_flow * (if port_b.dotM_flow>=0 then port_b.X_s else state.X_s);
// enthalpy flow
port_a.dotH_flow = port_a.dotM_flow * (if port_a.dotM_flow>=0 then port_a.h else state.h);
port_b.dotH_flow = port_b.dotM_flow * (if port_b.dotM_flow>=0 then port_b.h else state.h);
end DummyComponent;
which uses
connector Port_SeaWater "Interface for a streaming salty seawater (binary fluid with water and salt)
OUT OF or INTO a hydraulic device"
import waterLib = PV_RO_components.Hydraulics.Water;
replaceable package Water = waterLib.PartialSeaWater;
///////////////////////////////////////////////////////////////////
Water.StaticPressure p "Static non-gauge pressure";
flow Water.MassFlowRate dotM_flow "Total mass flow rate";
Water.SpecificEnthalpy h "Mass-specific enthalpy";
flow Water.EnthalpyFlowRate dotH_flow "Enthalpy flow rate";
Water.MassFraction X_s "Ratio: Mass of salt per total mass";
flow Water.MassFlowRate dotM_flow_s "Mass flow rate of salt";
end Port_SeaWater;
Can you help me finding the last three equations?
Hannes