Skip to content
Snippets Groups Projects
Commit d8caeaca authored by PASCAL BOREL's avatar PASCAL BOREL
Browse files

Ensure compatibility of following component with MSL medium (mono

        substance notably):
                + atmosphere (source within fluidDynamics)
                + Opnening : compute X with 1 substance medium
parent 234dccf1
Branches master
No related tags found
No related merge requests found
......@@ -29,6 +29,7 @@ model Opening
Modelica.SIunits.IsentropicExponent gamma "Isentropic exponent";
Modelica.SIunits.MachNumber M "Mach number at the opening";
Medium.ThermodynamicState state, state_a, state_b;
Modelica.SIunits.MassFraction[Medium.nX] X_a,X_b;
// Imported modules
TAeZoSysPro.FluidDynamics.Interfaces.FlowPort_a port_a(redeclare package Medium = Medium) annotation (
......@@ -77,11 +78,15 @@ equation
m_flow_i[i] = Vel[i] * Cd * A / N * d[i];
end for ;
/*Ensure compatibility with mono substance medium*/
X_a=port_a.d/sum(port_a.d);
X_b=port_b.d/sum(port_b.d);
mX_flow_i = {m_flow_i[i] * TAeZoSysPro.FluidDynamics.Utilities.regStep(
x = Vel[i],
x_small = 1e-14,
y1 = state_a.X,
y2 = state_b.X ) for i in 1:N} ;
y1 = X_a,
y2 = X_b ) for i in 1:N} ;
m_flow = sum(m_flow_i) ;
......
......@@ -3,6 +3,8 @@ within TAeZoSysPro.FluidDynamics.Sources;
model Atmosphere
// Medium declaration
replaceable package Medium = TAeZoSysPro.Media.MyMedia ;
/*Get TAeZoSysPro reference moist air Media*/
package Medium_MoistAirTAezo=TAeZoSysPro.Media.Air.MoistAir;
// User defined parameters
parameter Boolean use_p_in = false "Get the pressure from the input connector" annotation(
......@@ -14,12 +16,14 @@ model Atmosphere
parameter Modelica.SIunits.Temperature T = 293.15 "Atmosphere temperature" ;
parameter Modelica.SIunits.Pressure p = 101325 "Atmosphere Pressure" ;
parameter Real RH = 0.6 "Atmosphere relative humidity" ;
parameter Real RH = 0.6 "Atmosphere relative humidity - Only accounted if medium == Moist air" ;
parameter Modelica.SIunits.MassFraction X[Medium.nX] = Medium.X_default "usefull except for Moist Air";
parameter Integer nPorts = 0 "Number of fluidport" annotation(Dialog(connectorSizing=true));
// Internal variables
Medium.ThermodynamicState state ;
// Imported module
Modelica.Fluid.Interfaces.FluidPort_a[nPorts] Fluidport(redeclare package Medium = Medium) annotation(
Placement(visible = true, transformation(origin = {-30, 26}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {0, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
......@@ -35,6 +39,15 @@ model Atmosphere
Placement(visible = true, transformation(origin = {-70, -30}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-95, -61}, extent = {{-15, -15}, {15, 15}}, rotation = 0)));
protected
/*Using TAeZoSysPro medium function ensure no fail with new OM frontend (function exist whatever medium used*/
parameter Medium_MoistAirTAezo.MassFraction X_moist[Medium_MoistAirTAezo.nX]= cat(1, {Medium_MoistAirTAezo.massFraction_pTphi(p = p, T = T, phi = RH)}, {1-Medium_MoistAirTAezo.massFraction_pTphi(p = p, T = T, phi = RH)});
/*depending on chosen medium, parameter X vector to be adjusted*/
parameter Modelica.SIunits.MassFraction X_final[Medium.nX] = if Medium.mediumName=="Moist air" then
X_moist
else
X;
Modelica.Blocks.Interfaces.RealInput T_internal
"Temperature at ports. Needed to connect to conditional connector";
Modelica.Blocks.Interfaces.RealInput p_internal
......@@ -59,31 +72,22 @@ equation
RH_internal = RH;
end if;
/* detection of the media between a gas with condensable species and a dry gas */
if Medium.mediumName == "Moist air" then
state = Medium.setState_pTX(p = p_internal,
T = T_internal,
X = {Medium.massFraction_pTphi(p = p_internal, T = T_internal, phi = RH_internal)}) ;
state = Medium.setState_pTX(p = p_internal,
T = T_internal,
X=X_final) ;
elseif Medium.mediumName == "Air" then
state = Medium.setState_pTX(p = p_internal,
T = T_internal) ;
else
assert(false, "Current Medium is not praticable", AssertionLevel.error);
end if ;
// Ports handover
// Flowport
Flowport.T = T_internal;
Flowport.d = p_internal / (Medium.gasConstant(state) * T_internal) * state.X ;
Flowport.d=Medium.density(state)*X_final;
// Heatport
Heatport.T = T_internal;
// Fluidport
for i in 1:nPorts loop
Fluidport[i].p = p_internal;
Fluidport[i].h_outflow = Medium.specificEnthalpy(state);
Fluidport[i].Xi_outflow = state.X[1:Medium.nXi];
Fluidport[i].Xi_outflow = X_final[1:Medium.nXi];
end for;
annotation(
Icon(coordinateSystem(initialScale = 0.1), graphics = {Ellipse(origin = {-8, 23}, extent = {{-52, 37}, {68, -83}}, endAngle = 360), Text(origin = {-65, 87}, extent = {{-35, 13}, {165, -7}}, textString = "P=%p"), Text(origin = {-37, 33}, extent = {{-63, 47}, {137, 27}}, textString = "T=%T"), Text(origin = {-17, -97}, extent = {{-83, 17}, {117, -3}}, textString = "RH=%RH")}),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment