Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Additional units for sensor #212

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ThermofluidStream/Sensors/DifferenceSensorSelect.mo
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ model DifferenceSensorSelect "Sensor for selectable quantatiy difference"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.rho_kgpm3 then "d in kg/m3"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.v_m3pkg then "v in m3/kg"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.h_Jpkg then "h in J/kg"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.h_kJpkg then "h in kJ/kg"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.s_JpkgK then "s in J/(kg.K)"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.s_kJpkgK then "s in kJ/(kg.K)"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.a_mps then "Velocity of sound in m/s"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.cv_JpkgK then "cv in J/(kg.K)"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.cp_JpkgK then "cp in J/(kg.K)"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.kappa_1 then "kappa"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.MM_kgpmol then "M in kg/mol"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.MM_kgpkmol then "M in kg/kmol"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.r_Pa then "r in Pa"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.r_bar then "r in bar"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.p_total_Pa then "(p+r) in Pa"
Expand Down
5 changes: 5 additions & 0 deletions ThermofluidStream/Sensors/Internal/Types.mo
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ package Types "Types used in the Sensor Package"
rho_kgpm3 "Density (kg/m3)",
v_m3pkg "Specific volume (m3/kg)",
h_Jpkg "Specific enthalpy (J/kg)",
h_kJpkg "Specific enthalpy (kJ/kg)",
s_JpkgK "Specific entropy (J/(kg.K))",
s_kJpkgK "Specific entropy (kJ/(kg.K))",
cp_JpkgK "Specific isobaric heatcapacity (J/(kg.K))",
cv_JpkgK "Specific isochoric heatcapacity (J/(kg.K))",
kappa_1 "Isentropic Exponent (1))",
a_mps "Velocity of sound (m/s)",
MM_kgpmol "Molar Mass (kg/mol)",
MM_kgpkmol "Molar Mass (kg/kmol)",
r_Pa "Inertial pressure (Pa)",
r_bar "Inertial pressure (bar)",
p_total_Pa "Steadystate pressure + inertial pressure (Pa)",
Expand All @@ -45,6 +48,8 @@ package Types "Types used in the Sensor Package"
V_flow_m3ps "Volume flow rate (m3/s)",
V_flow_lpMin "Volume flow rate (l/min)",
H_flow_Jps "Enthalpy flow rate (W)",
H_flow_kJps "Enthalpy flow rate (kW)",
H_flow_MJps "Enthalpy flow rate (MW)",
S_flow_JpKs "Entropy flow rate (W/K)",
Cp_flow_JpKs "Heat capacity flow rate (W/K)");
type TwoPhaseQuantities = enumeration(
Expand Down
4 changes: 4 additions & 0 deletions ThermofluidStream/Sensors/Internal/getFlowQuantity.mo
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ algorithm
value := m_flow * Medium.specificHeatCapacityCp(state);
elseif quantity == Types.MassFlowQuantities.H_flow_Jps then
value := m_flow * Medium.specificEnthalpy(state);
elseif quantity == Types.MassFlowQuantities.H_flow_kJps then
value := 1e-3*m_flow * Medium.specificEnthalpy(state);
elseif quantity == Types.MassFlowQuantities.H_flow_MJps then
value := 1e-6*m_flow * Medium.specificEnthalpy(state);
elseif quantity == Types.MassFlowQuantities.m_flow_kgps then
value := m_flow;
elseif quantity == Types.MassFlowQuantities.m_flow_gps then
Expand Down
6 changes: 5 additions & 1 deletion ThermofluidStream/Sensors/Internal/getFlowUnit.mo
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ algorithm
if quantity == Types.MassFlowQuantities.Cp_flow_JpKs then
unit :="J/(K.s)";
elseif quantity == Types.MassFlowQuantities.H_flow_Jps then
unit :="J/s";
unit :="W";
elseif quantity == Types.MassFlowQuantities.H_flow_kJps then
unit :="kW";
elseif quantity == Types.MassFlowQuantities.H_flow_MJps then
unit :="MW";
elseif quantity == Types.MassFlowQuantities.m_flow_kgps then
unit :="kg/s";
elseif quantity == Types.MassFlowQuantities.V_flow_m3ps then
Expand Down
6 changes: 6 additions & 0 deletions ThermofluidStream/Sensors/Internal/getQuantity.mo
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ algorithm
value :=Modelica.Units.Conversions.to_bar(Medium.pressure(state) + r);
elseif quantity == Types.Quantities.h_Jpkg then
value := Medium.specificEnthalpy(state);
elseif quantity == Types.Quantities.h_kJpkg then
value := 1e-3*Medium.specificEnthalpy(state);
elseif quantity == Types.Quantities.s_JpkgK then
value := Medium.specificEntropy(state);
elseif quantity == Types.Quantities.s_kJpkgK then
value := 1e-3*Medium.specificEntropy(state);
elseif quantity == Types.Quantities.rho_kgpm3 then
value := Medium.density(state);
elseif quantity == Types.Quantities.v_m3pkg then
Expand All @@ -50,6 +54,8 @@ algorithm
value := Medium.isentropicExponent(state);
elseif quantity == Types.Quantities.MM_kgpmol then
value := Medium.molarMass(state);
elseif quantity == Types.Quantities.MM_kgpkmol then
value := 1e3*Medium.molarMass(state);
else
value :=0;
end if;
Expand Down
10 changes: 8 additions & 2 deletions ThermofluidStream/Sensors/Internal/getUnit.mo
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,28 @@ algorithm
unit :="bar";
elseif quantity == Types.Quantities.h_Jpkg then
unit :="J/kg";
elseif quantity == Types.Quantities.h_kJpkg then
unit :="kJ/kg";
elseif quantity == Types.Quantities.s_JpkgK then
unit :="J/(kg.K)";
elseif quantity == Types.Quantities.s_kJpkgK then
unit :="kJ/(kg.K)";
elseif quantity == Types.Quantities.rho_kgpm3 then
unit :="kg/m3";
elseif quantity == Types.Quantities.v_m3pkg then
unit :="m3/kg";
elseif quantity == Types.Quantities.a_mps then
unit := "(m/s)";
unit := "m/s";
elseif quantity == Types.Quantities.cv_JpkgK then
unit :="J/(kg.K)";
elseif quantity == Types.Quantities.cp_JpkgK then
unit :="J/(kg.K)";
elseif quantity == Types.Quantities.kappa_1 then
unit :="1";
elseif quantity == Types.Quantities.MM_kgpmol then
unit := "(kg/mol)";
unit := "kg/mol";
elseif quantity == Types.Quantities.MM_kgpkmol then
unit := "kg/kmol";
else
unit :="";
end if;
Expand Down
2 changes: 2 additions & 0 deletions ThermofluidStream/Sensors/SingleFlowSensor.mo
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ model SingleFlowSensor "Flow rate sensor"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.MassFlowQuantities.V_flow_m3ps then "V_flow in m3/s"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.MassFlowQuantities.V_flow_lpMin then "V_flow in l/min"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.MassFlowQuantities.H_flow_Jps then "H_flow in W"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.MassFlowQuantities.H_flow_kJps then "H_flow in kW"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.MassFlowQuantities.H_flow_MJps then "H_flow in MW"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.MassFlowQuantities.S_flow_JpKs then "S_flow in W/K"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.MassFlowQuantities.Cp_flow_JpKs then "Cp_flow in W/K"
else "error";
Expand Down
5 changes: 4 additions & 1 deletion ThermofluidStream/Sensors/SingleSensorSelect.mo
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ model SingleSensorSelect "Selectable sensor"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.rho_kgpm3 then "d in kg/m3"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.v_m3pkg then "v in m3/kg"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.h_Jpkg then "h in J/kg"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.h_kJpkg then "h in kJ/kg"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.s_JpkgK then "s in J/(kg.K)"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.a_mps then "Velocity of sound in m/s"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.s_kJpkgK then "s in kJ/(kg.K)"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.a_mps then "Speed of sound in m/s"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.cv_JpkgK then "cv in J/(kg.K)"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.cp_JpkgK then "cp in J/(kg.K)"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.kappa_1 then "kappa"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.MM_kgpmol then "M in kg/mol"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.MM_kgpkmol then "M in kg/kmol"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.r_Pa then "r in Pa"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.r_bar then "r in bar"
elseif quantity == ThermofluidStream.Sensors.Internal.Types.Quantities.p_total_Pa then "(p+r) in Pa"
Expand Down
82 changes: 68 additions & 14 deletions ThermofluidStream/Sensors/Tests/TestSensors.mo
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ model TestSensors "Test model for all sensors."
Boundaries.Sink sink(redeclare package Medium = Medium2)
annotation (Placement(transformation(extent={{80,-24},{100,-4}})));
Boundaries.Sink sink1(redeclare package Medium = Medium1, p0_par=100000)
annotation (Placement(transformation(extent={{96,44},{116,64}})));
annotation (Placement(transformation(extent={{98,44},{118,64}})));
Processes.FlowResistance flowResistance(
redeclare package Medium = Medium1,
m_flowStateSelect=StateSelect.prefer,
Expand Down Expand Up @@ -82,12 +82,12 @@ model TestSensors "Test model for all sensors."
redeclare package Medium = Medium1,
digits=2,
quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.h_Jpkg)
annotation (Placement(transformation(extent={{-74,36},{-54,56}})));
annotation (Placement(transformation(extent={{-74,144},{-54,164}})));
SingleSensorSelect singleSensorSelect9(
redeclare package Medium = Medium2,
outputValue=true,
quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.s_JpkgK)
annotation (Placement(transformation(extent={{-84,16},{-104,36}})));
annotation (Placement(transformation(extent={{-84,-4},{-104,16}})));
SingleSensorSelect singleSensorSelect10(redeclare package Medium = Medium2,
outputValue=true,
quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.rho_kgpm3,
Expand Down Expand Up @@ -200,8 +200,10 @@ model TestSensors "Test model for all sensors."
annotation (Placement(transformation(extent={{68,44},{88,64}})));
SingleFlowSensor singleFlowSensor5(
redeclare package Medium = Medium1,
digits=1,
outputValue=true,
quantity=ThermofluidStream.Sensors.Internal.Types.MassFlowQuantities.H_flow_Jps) annotation (Placement(transformation(extent={{68,64},{88,84}})));
quantity=ThermofluidStream.Sensors.Internal.Types.MassFlowQuantities.H_flow_kJps)
annotation (Placement(transformation(extent={{68,64},{88,84}})));
TwoPhaseSensorSelect twoPhaseSensorSelect(redeclare package Medium = Medium2, quantity=ThermofluidStream.Sensors.Internal.Types.TwoPhaseQuantities.x_kgpkg)
annotation (Placement(transformation(extent={{-74,-58},{-54,-38}})));
TwoPhaseSensorSelect twoPhaseSensorSelect1(redeclare package Medium = Medium2, quantity=ThermofluidStream.Sensors.Internal.Types.TwoPhaseQuantities.p_sat_Pa)
Expand Down Expand Up @@ -306,6 +308,32 @@ model TestSensors "Test model for all sensors."
outputValue=true,
filter_output=true,
row=3) annotation (Placement(transformation(extent={{4,-142},{24,-122}})));
SingleSensorSelect singleSensorSelect15(
redeclare package Medium = Medium1,
digits=2,
quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.h_kJpkg)
annotation (Placement(transformation(extent={{-74,156},{-54,176}})));
SingleSensorSelect singleSensorSelect16(
redeclare package Medium = Medium2,
outputValue=true,
quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.s_kJpkgK)
annotation (Placement(transformation(extent={{-84,8},{-104,28}})));
SingleSensorSelect singleSensorSelect17(
redeclare package Medium = Medium1,
digits=2,
quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.MM_kgpmol)
annotation (Placement(transformation(extent={{-74,168},{-54,188}})));
SingleSensorSelect singleSensorSelect18(
redeclare package Medium = Medium1,
digits=2,
quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.MM_kgpkmol)
annotation (Placement(transformation(extent={{-74,180},{-54,200}})));
SingleFlowSensor singleFlowSensor6(
redeclare package Medium = Medium1,
outputValue=true,
quantity=ThermofluidStream.Sensors.Internal.Types.MassFlowQuantities.H_flow_MJps)
annotation (Placement(transformation(extent={{94,64},
{114,84}})));
equation
connect(flowResistance.inlet, source.outlet) annotation (Line(
points={{-10,74},{-80,74}},
Expand All @@ -316,7 +344,7 @@ equation
color={28,108,200},
thickness=0.5));
connect(singleSensorSelect9.inlet, source1.outlet) annotation (Line(
points={{-84,26},{-78,26},{-78,-14},{-80,-14}},
points={{-84,6},{-78,6},{-78,-14},{-80,-14}},
color={28,108,200},
thickness=0.5));
connect(singleSensorSelect13.inlet, source1.outlet) annotation (Line(
Expand All @@ -336,7 +364,7 @@ equation
color={28,108,200},
thickness=0.5));
connect(singleSensorSelect8.inlet, source.outlet) annotation (Line(
points={{-74,46},{-78,46},{-78,74},{-80,74}},
points={{-74,154},{-78,154},{-78,74},{-80,74}},
color={28,108,200},
thickness=0.5));
connect(singleSensorSelect7.inlet, source.outlet) annotation (Line(
Expand Down Expand Up @@ -443,18 +471,10 @@ equation
points={{64,54},{68,54}},
color={28,108,200},
thickness=0.5));
connect(sink1.inlet, singleFlowSensor4.outlet) annotation (Line(
points={{96,54},{88,54}},
color={28,108,200},
thickness=0.5));
connect(singleFlowSensor1.outlet, singleFlowSensor5.inlet) annotation (Line(
points={{64,74},{68,74}},
color={28,108,200},
thickness=0.5));
connect(singleFlowSensor5.outlet, singleFlowSensor2.inlet) annotation (Line(
points={{88,74},{94,74},{94,70},{14,70},{14,54},{20,54}},
color={28,108,200},
thickness=0.5));
connect(twoPhaseSensorSelect.inlet, flowResistance1.inlet) annotation (Line(
points={{-74,-48},{-78,-48},{-78,-14},{-40,-14}},
color={28,108,200},
Expand Down Expand Up @@ -569,6 +589,40 @@ equation
points={{-84,38},{-78,38},{-78,-14},{-80,-14}},
color={28,108,200},
thickness=0.5));
connect(singleSensorSelect15.inlet, source.outlet)
annotation (Line(
points={{-74,166},{-78,166},{-78,74},{-80,74}},
color={28,108,200},
thickness=0.5));
connect(singleSensorSelect16.inlet, source1.outlet)
annotation (Line(
points={{-84,18},{-78,18},{-78,-14},{-80,-14}},
color={28,108,200},
thickness=0.5));
connect(singleSensorSelect17.inlet, source.outlet)
annotation (Line(
points={{-74,178},{-78,178},{-78,74},{-80,74}},
color={28,108,200},
thickness=0.5));
connect(singleSensorSelect18.inlet, source.outlet)
annotation (Line(
points={{-74,190},{-78,190},{-78,74},{-80,74}},
color={28,108,200},
thickness=0.5));
connect(singleFlowSensor4.outlet, sink1.inlet)
annotation (Line(
points={{88,54},{98,54}},
color={28,108,200},
thickness=0.5));
connect(singleFlowSensor5.outlet, singleFlowSensor6.inlet)
annotation (Line(
points={{88,74},{94,74}},
color={28,108,200},
thickness=0.5));
connect(singleFlowSensor6.outlet, singleFlowSensor2.inlet) annotation (Line(
points={{114,74},{122,74},{122,70},{16,70},{16,54},{20,54}},
color={28,108,200},
thickness=0.5));
annotation (experiment(StopTime=1, Tolerance=1e-6, Interval=0.001),
Documentation(info="<html>
<p>This model should test all sensors with all selecable quantities.</p>
Expand Down
Loading