Skip to content
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

### Changed
- Sensors now contain a flow model to ease convergence [PR#383](https://github.com/Metroscope-dev/metroscope-modeling-library/pull/383)

### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,6 @@ Kth_0(start=5000.0),
NTU(start=1.6153173),
QCpMAX(start=10000000000.0),
QCpMIN(start=6346345.0),
Q_cold(start=1500.0),
Q_cold_0(start=1500.0),
Q_hot(start=386.7695),
Q_hot_0(start=387.0),
S(start=70.0),
S_0(start=100.0),
T_cold_in(start=392.286),
Expand All @@ -503,10 +499,6 @@ Kth_0(start=5000.0),
NTU(start=3.0310464),
QCpMAX(start=6274835.0),
QCpMIN(start=1828982.4),
Q_cold(start=1500.0),
Q_cold_0(start=1500.0),
Q_hot(start=386.7695),
Q_hot_0(start=387.0),
S(start=30.0),
S_0(start=100.0),
T_cold_in(start=353.16913),
Expand Down Expand Up @@ -1384,10 +1376,6 @@ Kth_0(start=5000.0),
NTU(start=0.26206133),
QCpMAX(start=10000000000.0),
QCpMIN(start=4426917.5),
Q_cold(start=1059.745),
Q_cold_0(start=1060.0),
Q_hot(start=55.557785),
Q_hot_0(start=55.0),
S(start=100.0),
S_0(start=100.0),
T_cold_in(start=312.17142),
Expand Down Expand Up @@ -1964,10 +1952,6 @@ P_offset(start=0.0),
P_tot(start=6980.0),
Psat(start=6980.0),
Psat_0(start=6980.0),
Q_cold(start=54232.63),
Q_cold_0(start=54000.0),
Q_hot(start=1059.745),
Q_hot_0(start=1000.0),
Qv_cold_in(start=54.332294),
R(start=8.314463),
S(start=100.0),
Expand Down Expand Up @@ -2847,10 +2831,6 @@ Kth_0(start=5000.0),
NTU(start=0.51276803),
QCpMAX(start=10000000000.0),
QCpMIN(start=3353037.2),
Q_cold(start=1059.745),
Q_cold_0(start=1059.0),
Q_hot(start=43.318386),
Q_hot_0(start=44.0),
S(start=100.0),
S_0(start=100.0),
T_cold_in(start=484.00034),
Expand All @@ -2867,10 +2847,6 @@ P_cold_in_0(start=1940000.0),
P_cold_out_0(start=1940000.0),
P_hot_in_0(start=4100000.0),
P_hot_out_0(start=4000000.0),
Q_cold(start=1059.745),
Q_cold_0(start=1059.0),
Q_hot(start=44.318386),
Q_hot_0(start=44.0),
Q_vent(start=1.0),
Q_vent_0(start=1.0),
S(start=100.0),
Expand Down
2 changes: 1 addition & 1 deletion MetroscopeModelingLibrary/FlueGases/Connectors/package.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ within MetroscopeModelingLibrary.FlueGases;
package Connectors
extends MetroscopeModelingLibrary.Utilities.Icons.PackageIcon;


annotation (Icon(graphics={
Rectangle(
extent={{20,30},{78,-28}},
Expand All @@ -19,5 +20,4 @@ package Connectors
lineThickness=1,
fillColor={255,255,255},
fillPattern=FillPattern.Solid)}));

end Connectors;
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ partial model IsoPHFlowModel "FlowModel with no pressure or enthalpy variations"
// Input Quantities
Units.SpecificEnthalpy h(start=h_0) "Enthalpy of the fluid into the component";
Units.Pressure P(start=P_0) "Pressure of the fluid into the component";
Units.Temperature T(start=T_0) "Temperature of the fluid into the component";

equation
// Input Quantities
P = P_in;
h = h_in;
T = T_in;

// Conservation equation
DP = 0;
Expand Down
6 changes: 4 additions & 2 deletions MetroscopeModelingLibrary/Partial/Sensors/BaseSensor.mo
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@ partial model BaseSensor
parameter Units.PositiveMassFlowRate Q_0=100;
parameter Units.Pressure P_0 = 1e5;
parameter Units.SpecificEnthalpy h_0 = 5e5;
Medium.ThermodynamicState state;

// Input Quantity
Units.PositiveMassFlowRate Q(start=Q_0, nominal=Q_0) "Component mass flow rate";
Units.MassFraction Xi[Medium.nXi] "Component mass fractions";
Units.Pressure P(start=P_0) "Pressure of the fluid into the component";
Units.SpecificEnthalpy h(start=h_0) "Enthalpy of the fluid into the component";
Medium.ThermodynamicState state;

// Failure modes
parameter Boolean faulty_flow_rate = false;
Units.MassFlowRate mass_flow_rate_bias(start=0); // mass_flow_rate_bias > 0 means that more mass flow enters the component
replaceable Connectors.FluidInlet C_in(Q(start=Q_0, nominal=Q_0), P(start=P_0, nominal=P_0), redeclare package Medium = Medium) annotation (Placement(transformation(extent={{-110,-10},{-90,10}})));
replaceable Connectors.FluidOutlet C_out(Q(start=-Q_0, nominal=Q_0), P(start=P_0, nominal=P_0), redeclare package Medium = Medium) annotation (Placement(transformation(extent={{90,-10},{110,10}})));
replaceable BaseClasses.IsoPHFlowModel flow_model annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
equation
if not faulty_flow_rate then
mass_flow_rate_bias = 0;
Expand All @@ -35,6 +36,7 @@ equation
state = Medium.setState_phX(P, h, Xi);

assert(Q > 0, "Wrong flow sign in inline sensor. Common causes : outlet connected as if it was inlet and vice versa, or Positive/NegativeMassflowrate misuse. Recall : inlet flow is positive, outlet is negatve", AssertionLevel.warning);
connect(C_in, C_out) annotation (Line(points={{-100,0},{100,0}}, color={95,95,95}));
connect(flow_model.C_in, C_in) annotation (Line(points={{-10,0},{-100,0}}, color={95,95,95}));
connect(flow_model.C_out, C_out) annotation (Line(points={{10,0},{100,0}}, color={0,0,0}));
annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio=false)));
end BaseSensor;
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ partial model TemperatureSensor
start=(T_0 +Constants.T0_degC_in_K) *Constants.degC_to_degF +Constants.T0_degC_in_degF,
nominal=(T_0 +Constants.T0_degC_in_K) *Constants.degC_to_degF +Constants.T0_degC_in_degF); // Temperature in degF
equation
T = Medium.temperature(state);
T =flow_model.T;
T_degC +Constants.T0_degC_in_K = T; // Conversion K to Celsius
T_degF = T_degC*Constants.degC_to_degF +Constants.T0_degC_in_degF; // Conversion Celsius to Farenheit
end TemperatureSensor;
2 changes: 1 addition & 1 deletion MetroscopeModelingLibrary/Power/Connectors/package.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ within MetroscopeModelingLibrary.Power;
package Connectors
extends MetroscopeModelingLibrary.Utilities.Icons.PackageIcon;


annotation (Icon(graphics={
Rectangle(
extent={{20,30},{78,-28}},
Expand All @@ -19,5 +20,4 @@ package Connectors
lineThickness=1,
fillColor={255,255,255},
fillPattern=FillPattern.Solid)}));

end Connectors;
1 change: 1 addition & 0 deletions MetroscopeModelingLibrary/Sensors/FlueGases/FlowSensor.mo
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ model FlowSensor
extends Partial.Sensors.FlowSensor(
redeclare MetroscopeModelingLibrary.FlueGases.Connectors.Inlet C_in,
redeclare MetroscopeModelingLibrary.FlueGases.Connectors.Outlet C_out,
redeclare MetroscopeModelingLibrary.FlueGases.BaseClasses.IsoPHFlowModel flow_model,
redeclare package Medium = FlueGasesMedium) annotation (IconMap(primitivesVisible=false));
end FlowSensor;
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ model PressureSensor
extends Partial.Sensors.PressureSensor(
redeclare MetroscopeModelingLibrary.FlueGases.Connectors.Inlet C_in,
redeclare MetroscopeModelingLibrary.FlueGases.Connectors.Outlet C_out,
redeclare MetroscopeModelingLibrary.FlueGases.BaseClasses.IsoPHFlowModel flow_model,
redeclare package Medium = FlueGasesMedium) annotation (IconMap(primitivesVisible=false));
end PressureSensor;
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ model TemperatureSensor
extends Partial.Sensors.TemperatureSensor(
redeclare MetroscopeModelingLibrary.FlueGases.Connectors.Inlet C_in,
redeclare MetroscopeModelingLibrary.FlueGases.Connectors.Outlet C_out,
redeclare MetroscopeModelingLibrary.FlueGases.BaseClasses.IsoPHFlowModel flow_model,
redeclare package Medium = FlueGasesMedium) annotation (IconMap(primitivesVisible=false));
end TemperatureSensor;
1 change: 1 addition & 0 deletions MetroscopeModelingLibrary/Sensors/Fuel/FlowSensor.mo
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ model FlowSensor
extends Partial.Sensors.FlowSensor(
redeclare MetroscopeModelingLibrary.Fuel.Connectors.Inlet C_in,
redeclare MetroscopeModelingLibrary.Fuel.Connectors.Outlet C_out,
redeclare MetroscopeModelingLibrary.Fuel.BaseClasses.IsoPHFlowModel flow_model,
redeclare package Medium = FuelMedium) annotation (IconMap(primitivesVisible=false));
end FlowSensor;
1 change: 1 addition & 0 deletions MetroscopeModelingLibrary/Sensors/Fuel/PressureSensor.mo
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ model PressureSensor
extends Partial.Sensors.PressureSensor(
redeclare MetroscopeModelingLibrary.Fuel.Connectors.Inlet C_in,
redeclare MetroscopeModelingLibrary.Fuel.Connectors.Outlet C_out,
redeclare MetroscopeModelingLibrary.Fuel.BaseClasses.IsoPHFlowModel flow_model,
redeclare package Medium = FuelMedium) annotation (IconMap(primitivesVisible=false));
end PressureSensor;
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ model TemperatureSensor
extends Partial.Sensors.TemperatureSensor(
redeclare MetroscopeModelingLibrary.Fuel.Connectors.Inlet C_in,
redeclare MetroscopeModelingLibrary.Fuel.Connectors.Outlet C_out,
redeclare MetroscopeModelingLibrary.Fuel.BaseClasses.IsoPHFlowModel flow_model,
redeclare package Medium = FuelMedium) annotation (IconMap(primitivesVisible=false));
end TemperatureSensor;
1 change: 1 addition & 0 deletions MetroscopeModelingLibrary/Sensors/MoistAir/FlowSensor.mo
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ model FlowSensor
extends Partial.Sensors.FlowSensor(
redeclare MetroscopeModelingLibrary.MoistAir.Connectors.Inlet C_in,
redeclare MetroscopeModelingLibrary.MoistAir.Connectors.Outlet C_out,
redeclare MetroscopeModelingLibrary.MoistAir.BaseClasses.IsoPHFlowModel flow_model,
redeclare package Medium = MoistAirMedium) annotation (IconMap(primitivesVisible=false));
end FlowSensor;
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ model PressureSensor
extends Partial.Sensors.PressureSensor(
redeclare MetroscopeModelingLibrary.MoistAir.Connectors.Inlet C_in,
redeclare MetroscopeModelingLibrary.MoistAir.Connectors.Outlet C_out,
redeclare MetroscopeModelingLibrary.MoistAir.BaseClasses.IsoPHFlowModel flow_model,
redeclare package Medium = MoistAirMedium) annotation (IconMap(primitivesVisible=false));
end PressureSensor;
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ model TemperatureSensor
extends Partial.Sensors.TemperatureSensor(
redeclare MetroscopeModelingLibrary.MoistAir.Connectors.Inlet C_in,
redeclare MetroscopeModelingLibrary.MoistAir.Connectors.Outlet C_out,
redeclare MetroscopeModelingLibrary.MoistAir.BaseClasses.IsoPHFlowModel flow_model,
redeclare package Medium = MoistAirMedium) annotation (IconMap(primitivesVisible=false));
end TemperatureSensor;
1 change: 1 addition & 0 deletions MetroscopeModelingLibrary/Sensors/WaterSteam/FlowSensor.mo
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ model FlowSensor
extends Partial.Sensors.FlowSensor(
redeclare MetroscopeModelingLibrary.WaterSteam.Connectors.Inlet C_in,
redeclare MetroscopeModelingLibrary.WaterSteam.Connectors.Outlet C_out,
redeclare MetroscopeModelingLibrary.WaterSteam.BaseClasses.IsoPHFlowModel flow_model,
redeclare package Medium = WaterSteamMedium) annotation (IconMap(primitivesVisible=false));
end FlowSensor;
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ model PressureSensor
extends Partial.Sensors.PressureSensor(
redeclare MetroscopeModelingLibrary.WaterSteam.Connectors.Inlet C_in,
redeclare MetroscopeModelingLibrary.WaterSteam.Connectors.Outlet C_out,
redeclare MetroscopeModelingLibrary.WaterSteam.BaseClasses.IsoPHFlowModel flow_model,
redeclare package Medium = WaterSteamMedium) annotation (IconMap(primitivesVisible=false));
end PressureSensor;
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ model TemperatureSensor
extends Partial.Sensors.TemperatureSensor(
redeclare MetroscopeModelingLibrary.WaterSteam.Connectors.Inlet C_in,
redeclare MetroscopeModelingLibrary.WaterSteam.Connectors.Outlet C_out,
redeclare MetroscopeModelingLibrary.WaterSteam.BaseClasses.IsoPHFlowModel flow_model,
redeclare package Medium = WaterSteamMedium) annotation (IconMap(primitivesVisible=false));
end TemperatureSensor;
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ equation
source.P_out = source_P;
source.Q_out = source_Q;
source.h_out = source_h;
//T_sensor.T = 298.15; // does not initialize if set T_out instead of h_out

source.Xi_out = {0.768,0.232,0.0,0.0,0.0};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ equation
source.P_out = source_P;
source.Q_out = source_Q;
source.h_out = source_h;
//T_sensor.T = 298.15; // does not initialize if set T_out instead of h_out

source.Xi_out = {0.92,0.048,0.005,0.002,0.015,0.01};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ model DeltaPressureSensor

// Boundary conditions
input Utilities.Units.Pressure source_P(start=1e5) "Pa";
input Utilities.Units.SpecificEnthalpy source_h(start=1e3) "J/kg";
input Utilities.Units.SpecificEnthalpy source_h(start=2e4) "J/kg";
input Utilities.Units.NegativeMassFlowRate source_Q(start=-100) "kg/s";

MetroscopeModelingLibrary.Sensors.MoistAir.DeltaPressureSensor DP_sensor annotation (Placement(transformation(extent={{-10,10},{10,30}})));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ model FlowSensor

// Boundary conditions
input Utilities.Units.Pressure source_P(start=1e5) "Pa";
input Utilities.Units.SpecificEnthalpy source_h(start=1e3) "J/kg";
input Utilities.Units.SpecificEnthalpy source_h(start=2e4) "J/kg";
input Utilities.Units.PositiveMassFlowRate source_Q(start=100) "kg/s";

MetroscopeModelingLibrary.Sensors.MoistAir.FlowSensor source_Q_sensor annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ model PressureSensor

// Boundary conditions
input Utilities.Units.Pressure source_P(start=1e5) "Pa";
input Utilities.Units.SpecificEnthalpy source_h(start=1e3) "J/kg";
input Utilities.Units.SpecificEnthalpy source_h(start=2e4) "J/kg";
input Utilities.Units.NegativeMassFlowRate source_Q(start=-100) "kg/s";

MetroscopeModelingLibrary.Sensors.MoistAir.PressureSensor P_sensor annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ model TemperatureSensor

// Boundary conditions
input Utilities.Units.Pressure source_P(start=1e5) "Pa";
input Utilities.Units.SpecificEnthalpy source_h(start=1e3) "J/kg";
input Utilities.Units.SpecificEnthalpy source_h(start=2e4) "J/kg";
input Utilities.Units.NegativeMassFlowRate source_Q(start=-100) "kg/s";

MetroscopeModelingLibrary.Sensors.MoistAir.TemperatureSensor T_sensor annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
Expand All @@ -14,9 +14,9 @@ equation
source.P_out = source_P;
source.Q_out = source_Q;
source.relative_humidity = 0.1;
T_sensor.T = 298.15;
source.h_out = source_h;

assert(abs(T_sensor.T_degC - 25) < 1e-5, "T_sensor should detect 25 deg C");
assert(abs(T_sensor.T_degC - 16.91) < 1e-2, "T_sensor should detect 25 deg C");
assert(abs(source.P_out - sink.P_in) < 1e-5, "Pressure should be the same from source to sink");
assert(abs(source.h_out - sink.h_in) < 1e-5, "Enthalpy should be the same from source to sink");
assert(abs(source.Q_out + sink.Q_in) < 1e-5, "MassFlowRate should be the same from source to sink");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ model TemperatureSensor
equation
source.P_out = source_P;
source.Q_out = source_Q;
T_sensor.T = 298.15;
source.h_out = source_h;

assert(abs(T_sensor.T_degC - 25) < 1e-5, "T_sensor should detect 25 deg C");
assert(abs(T_sensor.T_degC - 99.6) < 1e-1, "T_sensor should detect 99.6 degC");
assert(abs(source.P_out - sink.P_in) < 1e-5, "Pressure should be the same from source to sink");
assert(abs(source.h_out - sink.h_in) < 1e-5, "Enthalpy should be the same from source to sink");
assert(abs(source.Q_out + sink.Q_in) < 1e-5, "MassFlowRate should be the same from source to sink");
Expand Down