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
No related branches found
No related tags found
No related merge requests found
...@@ -29,6 +29,7 @@ model Opening ...@@ -29,6 +29,7 @@ model Opening
Modelica.SIunits.IsentropicExponent gamma "Isentropic exponent"; Modelica.SIunits.IsentropicExponent gamma "Isentropic exponent";
Modelica.SIunits.MachNumber M "Mach number at the opening"; Modelica.SIunits.MachNumber M "Mach number at the opening";
Medium.ThermodynamicState state, state_a, state_b; Medium.ThermodynamicState state, state_a, state_b;
Modelica.SIunits.MassFraction[Medium.nX] X_a,X_b;
// Imported modules // Imported modules
TAeZoSysPro.FluidDynamics.Interfaces.FlowPort_a port_a(redeclare package Medium = Medium) annotation ( TAeZoSysPro.FluidDynamics.Interfaces.FlowPort_a port_a(redeclare package Medium = Medium) annotation (
...@@ -77,11 +78,15 @@ equation ...@@ -77,11 +78,15 @@ equation
m_flow_i[i] = Vel[i] * Cd * A / N * d[i]; m_flow_i[i] = Vel[i] * Cd * A / N * d[i];
end for ; 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( mX_flow_i = {m_flow_i[i] * TAeZoSysPro.FluidDynamics.Utilities.regStep(
x = Vel[i], x = Vel[i],
x_small = 1e-14, x_small = 1e-14,
y1 = state_a.X, y1 = X_a,
y2 = state_b.X ) for i in 1:N} ; y2 = X_b ) for i in 1:N} ;
m_flow = sum(m_flow_i) ; m_flow = sum(m_flow_i) ;
......
...@@ -3,6 +3,8 @@ within TAeZoSysPro.FluidDynamics.Sources; ...@@ -3,6 +3,8 @@ within TAeZoSysPro.FluidDynamics.Sources;
model Atmosphere model Atmosphere
// Medium declaration // Medium declaration
replaceable package Medium = TAeZoSysPro.Media.MyMedia ; replaceable package Medium = TAeZoSysPro.Media.MyMedia ;
/*Get TAeZoSysPro reference moist air Media*/
package Medium_MoistAirTAezo=TAeZoSysPro.Media.Air.MoistAir;
// User defined parameters // User defined parameters
parameter Boolean use_p_in = false "Get the pressure from the input connector" annotation( parameter Boolean use_p_in = false "Get the pressure from the input connector" annotation(
...@@ -14,12 +16,14 @@ model Atmosphere ...@@ -14,12 +16,14 @@ model Atmosphere
parameter Modelica.SIunits.Temperature T = 293.15 "Atmosphere temperature" ; parameter Modelica.SIunits.Temperature T = 293.15 "Atmosphere temperature" ;
parameter Modelica.SIunits.Pressure p = 101325 "Atmosphere Pressure" ; 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)); parameter Integer nPorts = 0 "Number of fluidport" annotation(Dialog(connectorSizing=true));
// Internal variables // Internal variables
Medium.ThermodynamicState state ; Medium.ThermodynamicState state ;
// Imported module // Imported module
Modelica.Fluid.Interfaces.FluidPort_a[nPorts] Fluidport(redeclare package Medium = Medium) annotation( 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))); 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 ...@@ -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))); 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 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 Modelica.Blocks.Interfaces.RealInput T_internal
"Temperature at ports. Needed to connect to conditional connector"; "Temperature at ports. Needed to connect to conditional connector";
Modelica.Blocks.Interfaces.RealInput p_internal Modelica.Blocks.Interfaces.RealInput p_internal
...@@ -59,31 +72,22 @@ equation ...@@ -59,31 +72,22 @@ equation
RH_internal = RH; RH_internal = RH;
end if; end if;
/* detection of the media between a gas with condensable species and a dry gas */ state = Medium.setState_pTX(p = p_internal,
if Medium.mediumName == "Moist air" then T = T_internal,
state = Medium.setState_pTX(p = p_internal, X=X_final) ;
T = T_internal,
X = {Medium.massFraction_pTphi(p = p_internal, T = T_internal, phi = RH_internal)}) ;
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 // Ports handover
// Flowport // Flowport
Flowport.T = T_internal; Flowport.T = T_internal;
Flowport.d = p_internal / (Medium.gasConstant(state) * T_internal) * state.X ; Flowport.d=Medium.density(state)*X_final;
// Heatport // Heatport
Heatport.T = T_internal; Heatport.T = T_internal;
// Fluidport // Fluidport
for i in 1:nPorts loop for i in 1:nPorts loop
Fluidport[i].p = p_internal; Fluidport[i].p = p_internal;
Fluidport[i].h_outflow = Medium.specificEnthalpy(state); 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; end for;
annotation( 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")}), 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