Skip to content

Commit f8d0496

Browse files
Flowmodel in sensor (#383)
* add flow model in base sensor * adapt sensors to flow model * update unit tests * make sure Metroscopia run correctly * update changelog * PEP comments
1 parent 500dff4 commit f8d0496

File tree

26 files changed

+30
-39
lines changed

26 files changed

+30
-39
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

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

1415
### Fixed
1516

MetroscopeModelingLibrary/Examples/Nuclear/MetroscopiaNPP/MetroscopiaNPP_internal_ramp_direct_withStartValues.mo

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,6 @@ Kth_0(start=5000.0),
479479
NTU(start=1.6153173),
480480
QCpMAX(start=10000000000.0),
481481
QCpMIN(start=6346345.0),
482-
Q_cold(start=1500.0),
483-
Q_cold_0(start=1500.0),
484-
Q_hot(start=386.7695),
485-
Q_hot_0(start=387.0),
486482
S(start=70.0),
487483
S_0(start=100.0),
488484
T_cold_in(start=392.286),
@@ -503,10 +499,6 @@ Kth_0(start=5000.0),
503499
NTU(start=3.0310464),
504500
QCpMAX(start=6274835.0),
505501
QCpMIN(start=1828982.4),
506-
Q_cold(start=1500.0),
507-
Q_cold_0(start=1500.0),
508-
Q_hot(start=386.7695),
509-
Q_hot_0(start=387.0),
510502
S(start=30.0),
511503
S_0(start=100.0),
512504
T_cold_in(start=353.16913),
@@ -1384,10 +1376,6 @@ Kth_0(start=5000.0),
13841376
NTU(start=0.26206133),
13851377
QCpMAX(start=10000000000.0),
13861378
QCpMIN(start=4426917.5),
1387-
Q_cold(start=1059.745),
1388-
Q_cold_0(start=1060.0),
1389-
Q_hot(start=55.557785),
1390-
Q_hot_0(start=55.0),
13911379
S(start=100.0),
13921380
S_0(start=100.0),
13931381
T_cold_in(start=312.17142),
@@ -1964,10 +1952,6 @@ P_offset(start=0.0),
19641952
P_tot(start=6980.0),
19651953
Psat(start=6980.0),
19661954
Psat_0(start=6980.0),
1967-
Q_cold(start=54232.63),
1968-
Q_cold_0(start=54000.0),
1969-
Q_hot(start=1059.745),
1970-
Q_hot_0(start=1000.0),
19711955
Qv_cold_in(start=54.332294),
19721956
R(start=8.314463),
19731957
S(start=100.0),
@@ -2847,10 +2831,6 @@ Kth_0(start=5000.0),
28472831
NTU(start=0.51276803),
28482832
QCpMAX(start=10000000000.0),
28492833
QCpMIN(start=3353037.2),
2850-
Q_cold(start=1059.745),
2851-
Q_cold_0(start=1059.0),
2852-
Q_hot(start=43.318386),
2853-
Q_hot_0(start=44.0),
28542834
S(start=100.0),
28552835
S_0(start=100.0),
28562836
T_cold_in(start=484.00034),
@@ -2867,10 +2847,6 @@ P_cold_in_0(start=1940000.0),
28672847
P_cold_out_0(start=1940000.0),
28682848
P_hot_in_0(start=4100000.0),
28692849
P_hot_out_0(start=4000000.0),
2870-
Q_cold(start=1059.745),
2871-
Q_cold_0(start=1059.0),
2872-
Q_hot(start=44.318386),
2873-
Q_hot_0(start=44.0),
28742850
Q_vent(start=1.0),
28752851
Q_vent_0(start=1.0),
28762852
S(start=100.0),

MetroscopeModelingLibrary/FlueGases/Connectors/package.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ within MetroscopeModelingLibrary.FlueGases;
22
package Connectors
33
extends MetroscopeModelingLibrary.Utilities.Icons.PackageIcon;
44

5+
56
annotation (Icon(graphics={
67
Rectangle(
78
extent={{20,30},{78,-28}},
@@ -19,5 +20,4 @@ package Connectors
1920
lineThickness=1,
2021
fillColor={255,255,255},
2122
fillPattern=FillPattern.Solid)}));
22-
2323
end Connectors;

MetroscopeModelingLibrary/Partial/BaseClasses/IsoPHFlowModel.mo

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ partial model IsoPHFlowModel "FlowModel with no pressure or enthalpy variations"
1111
// Input Quantities
1212
Units.SpecificEnthalpy h(start=h_0) "Enthalpy of the fluid into the component";
1313
Units.Pressure P(start=P_0) "Pressure of the fluid into the component";
14+
Units.Temperature T(start=T_0) "Temperature of the fluid into the component";
1415

1516
equation
1617
// Input Quantities
1718
P = P_in;
1819
h = h_in;
20+
T = T_in;
1921

2022
// Conservation equation
2123
DP = 0;

MetroscopeModelingLibrary/Partial/Sensors/BaseSensor.mo

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,20 @@ partial model BaseSensor
99
parameter Units.PositiveMassFlowRate Q_0=100;
1010
parameter Units.Pressure P_0 = 1e5;
1111
parameter Units.SpecificEnthalpy h_0 = 5e5;
12-
Medium.ThermodynamicState state;
1312

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

2020
// Failure modes
2121
parameter Boolean faulty_flow_rate = false;
2222
Units.MassFlowRate mass_flow_rate_bias(start=0); // mass_flow_rate_bias > 0 means that more mass flow enters the component
2323
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}})));
2424
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}})));
25+
replaceable BaseClasses.IsoPHFlowModel flow_model annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
2526
equation
2627
if not faulty_flow_rate then
2728
mass_flow_rate_bias = 0;
@@ -35,6 +36,7 @@ equation
3536
state = Medium.setState_phX(P, h, Xi);
3637

3738
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);
38-
connect(C_in, C_out) annotation (Line(points={{-100,0},{100,0}}, color={95,95,95}));
39+
connect(flow_model.C_in, C_in) annotation (Line(points={{-10,0},{-100,0}}, color={95,95,95}));
40+
connect(flow_model.C_out, C_out) annotation (Line(points={{10,0},{100,0}}, color={0,0,0}));
3941
annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio=false)));
4042
end BaseSensor;

MetroscopeModelingLibrary/Partial/Sensors/TemperatureSensor.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ partial model TemperatureSensor
1616
start=(T_0 +Constants.T0_degC_in_K) *Constants.degC_to_degF +Constants.T0_degC_in_degF,
1717
nominal=(T_0 +Constants.T0_degC_in_K) *Constants.degC_to_degF +Constants.T0_degC_in_degF); // Temperature in degF
1818
equation
19-
T = Medium.temperature(state);
19+
T =flow_model.T;
2020
T_degC +Constants.T0_degC_in_K = T; // Conversion K to Celsius
2121
T_degF = T_degC*Constants.degC_to_degF +Constants.T0_degC_in_degF; // Conversion Celsius to Farenheit
2222
end TemperatureSensor;

MetroscopeModelingLibrary/Power/Connectors/package.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ within MetroscopeModelingLibrary.Power;
22
package Connectors
33
extends MetroscopeModelingLibrary.Utilities.Icons.PackageIcon;
44

5+
56
annotation (Icon(graphics={
67
Rectangle(
78
extent={{20,30},{78,-28}},
@@ -19,5 +20,4 @@ package Connectors
1920
lineThickness=1,
2021
fillColor={255,255,255},
2122
fillPattern=FillPattern.Solid)}));
22-
2323
end Connectors;

MetroscopeModelingLibrary/Sensors/FlueGases/FlowSensor.mo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ model FlowSensor
77
extends Partial.Sensors.FlowSensor(
88
redeclare MetroscopeModelingLibrary.FlueGases.Connectors.Inlet C_in,
99
redeclare MetroscopeModelingLibrary.FlueGases.Connectors.Outlet C_out,
10+
redeclare MetroscopeModelingLibrary.FlueGases.BaseClasses.IsoPHFlowModel flow_model,
1011
redeclare package Medium = FlueGasesMedium) annotation (IconMap(primitivesVisible=false));
1112
end FlowSensor;

MetroscopeModelingLibrary/Sensors/FlueGases/PressureSensor.mo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ model PressureSensor
77
extends Partial.Sensors.PressureSensor(
88
redeclare MetroscopeModelingLibrary.FlueGases.Connectors.Inlet C_in,
99
redeclare MetroscopeModelingLibrary.FlueGases.Connectors.Outlet C_out,
10+
redeclare MetroscopeModelingLibrary.FlueGases.BaseClasses.IsoPHFlowModel flow_model,
1011
redeclare package Medium = FlueGasesMedium) annotation (IconMap(primitivesVisible=false));
1112
end PressureSensor;

MetroscopeModelingLibrary/Sensors/FlueGases/TemperatureSensor.mo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ model TemperatureSensor
77
extends Partial.Sensors.TemperatureSensor(
88
redeclare MetroscopeModelingLibrary.FlueGases.Connectors.Inlet C_in,
99
redeclare MetroscopeModelingLibrary.FlueGases.Connectors.Outlet C_out,
10+
redeclare MetroscopeModelingLibrary.FlueGases.BaseClasses.IsoPHFlowModel flow_model,
1011
redeclare package Medium = FlueGasesMedium) annotation (IconMap(primitivesVisible=false));
1112
end TemperatureSensor;

0 commit comments

Comments
 (0)