22
33import numpy as np
44
5- from libecalc .common .fluid import FluidStreamCommon
65from libecalc .common .serializable_chart import SingleSpeedChartDTO , VariableSpeedChartDTO
76from libecalc .common .units import Unit
87from libecalc .domain .process .core .results .compressor import (
1211 TargetPressureStatus ,
1312)
1413from libecalc .domain .process .value_objects .chart .chart_area_flag import ChartAreaFlag
14+ from libecalc .domain .process .value_objects .fluid_stream import FluidStream
1515from libecalc .domain .process .value_objects .fluid_stream .fluid_composition import FluidComposition
1616
1717
@@ -28,17 +28,10 @@ class CompressorTrainStageResultSingleTimeStep:
2828
2929 def __init__ (
3030 self ,
31- inlet_stream : FluidStreamCommon | None ,
32- outlet_stream : FluidStreamCommon | None ,
33- # actual rate [Am3/hour] = mass rate [kg/hour] / density [kg/m3]
34- inlet_actual_rate_m3_per_hour : float ,
35- inlet_actual_rate_asv_corrected_m3_per_hour : float ,
36- standard_rate_sm3_per_day : float ,
37- standard_rate_asv_corrected_sm3_per_day : float ,
38- outlet_actual_rate_m3_per_hour : float ,
39- outlet_actual_rate_asv_corrected_m3_per_hour : float ,
40- mass_rate_kg_per_hour : float ,
41- mass_rate_asv_corrected_kg_per_hour : float ,
31+ inlet_stream : FluidStream | None ,
32+ outlet_stream : FluidStream | None ,
33+ inlet_stream_including_asv : FluidStream | None ,
34+ outlet_stream_including_asv : FluidStream | None ,
4235 polytropic_head_kJ_per_kg : float ,
4336 polytropic_efficiency : float ,
4437 polytropic_enthalpy_change_kJ_per_kg : float ,
@@ -53,14 +46,8 @@ def __init__(
5346 ):
5447 self .inlet_stream = inlet_stream
5548 self .outlet_stream = outlet_stream
56- self .inlet_actual_rate_m3_per_hour = inlet_actual_rate_m3_per_hour
57- self .inlet_actual_rate_asv_corrected_m3_per_hour = inlet_actual_rate_asv_corrected_m3_per_hour
58- self .standard_rate_sm3_per_day = standard_rate_sm3_per_day
59- self .standard_rate_asv_corrected_sm3_per_day = standard_rate_asv_corrected_sm3_per_day
60- self .outlet_actual_rate_m3_per_hour = outlet_actual_rate_m3_per_hour
61- self .outlet_actual_rate_asv_corrected_m3_per_hour = outlet_actual_rate_asv_corrected_m3_per_hour
62- self .mass_rate_kg_per_hour = mass_rate_kg_per_hour
63- self .mass_rate_asv_corrected_kg_per_hour = mass_rate_asv_corrected_kg_per_hour
49+ self .inlet_stream_including_asv = inlet_stream_including_asv
50+ self .outlet_stream_including_asv = outlet_stream_including_asv
6451 self .polytropic_head_kJ_per_kg = polytropic_head_kJ_per_kg
6552 self .polytropic_efficiency = polytropic_efficiency
6653 self .polytropic_enthalpy_change_kJ_per_kg = polytropic_enthalpy_change_kJ_per_kg
@@ -78,16 +65,8 @@ def create_empty(cls) -> CompressorTrainStageResultSingleTimeStep:
7865 return cls (
7966 inlet_stream = None ,
8067 outlet_stream = None ,
81- # actual rate [Am3/hour] = mass rate [kg/hour] / density [kg/m3]
82- inlet_actual_rate_m3_per_hour = 0.0 ,
83- inlet_actual_rate_asv_corrected_m3_per_hour = 0.0 ,
84- # standard rate [sm3/day]
85- standard_rate_sm3_per_day = 0.0 ,
86- standard_rate_asv_corrected_sm3_per_day = 0.0 ,
87- outlet_actual_rate_m3_per_hour = 0.0 ,
88- outlet_actual_rate_asv_corrected_m3_per_hour = 0.0 ,
89- mass_rate_kg_per_hour = 0.0 ,
90- mass_rate_asv_corrected_kg_per_hour = 0.0 ,
68+ inlet_stream_including_asv = None ,
69+ outlet_stream_including_asv = None ,
9170 polytropic_head_kJ_per_kg = 0.0 ,
9271 polytropic_efficiency = 1.0 ,
9372 polytropic_enthalpy_change_kJ_per_kg = 0.0 ,
@@ -101,6 +80,70 @@ def create_empty(cls) -> CompressorTrainStageResultSingleTimeStep:
10180 point_is_valid = True ,
10281 )
10382
83+ @property
84+ def inlet_actual_rate_m3_per_hour (self ) -> float :
85+ """Actual inlet rate in Am3/hour."""
86+ if self .inlet_stream is None :
87+ return 0.0
88+ else :
89+ return self .inlet_stream .volumetric_rate
90+
91+ @property
92+ def inlet_actual_rate_asv_corrected_m3_per_hour (self ) -> float :
93+ """Actual inlet rate in Am3/hour, corrected for ASV."""
94+ if self .inlet_stream_including_asv is None :
95+ return 0.0
96+ else :
97+ return self .inlet_stream_including_asv .volumetric_rate
98+
99+ @property
100+ def standard_rate_sm3_per_day (self ) -> float :
101+ """Standard inlet rate in Sm3/day."""
102+ if self .inlet_stream is None :
103+ return 0.0
104+ else :
105+ return self .inlet_stream .standard_rate
106+
107+ @property
108+ def standard_rate_asv_corrected_sm3_per_day (self ) -> float :
109+ """Standard inlet rate in Sm3/day, corrected for ASV."""
110+ if self .inlet_stream_including_asv is None :
111+ return 0.0
112+ else :
113+ return self .inlet_stream_including_asv .standard_rate
114+
115+ @property
116+ def outlet_actual_rate_m3_per_hour (self ) -> float :
117+ """Actual outlet rate in Am3/hour."""
118+ if self .outlet_stream is None :
119+ return 0.0
120+ else :
121+ return self .outlet_stream .volumetric_rate
122+
123+ @property
124+ def outlet_actual_rate_asv_corrected_m3_per_hour (self ) -> float :
125+ """Actual outlet rate in Am3/hour, corrected for ASV."""
126+ if self .outlet_stream_including_asv is None :
127+ return 0.0
128+ else :
129+ return self .outlet_stream_including_asv .volumetric_rate
130+
131+ @property
132+ def mass_rate_kg_per_hour (self ) -> float :
133+ """Mass rate in kg/hour"""
134+ if self .inlet_stream is None :
135+ return 0.0
136+ else :
137+ return self .inlet_stream .mass_rate
138+
139+ @property
140+ def mass_rate_asv_corrected_kg_per_hour (self ) -> float :
141+ """Mass rate in kg/hour, corrected for ASV."""
142+ if self .inlet_stream_including_asv is None :
143+ return 0.0
144+ else :
145+ return self .inlet_stream_including_asv .mass_rate
146+
104147 @property
105148 def is_valid (self ) -> bool :
106149 return self .within_capacity
@@ -143,8 +186,8 @@ class CompressorTrainResultSingleTimeStep:
143186
144187 def __init__ (
145188 self ,
146- inlet_stream : FluidStreamCommon | None ,
147- outlet_stream : FluidStreamCommon | None ,
189+ inlet_stream : FluidStream | None ,
190+ outlet_stream : FluidStream | None ,
148191 speed : float ,
149192 stage_results : list [CompressorTrainStageResultSingleTimeStep ],
150193 target_pressure_status : TargetPressureStatus ,
@@ -234,9 +277,9 @@ def from_result_list_to_dto(
234277 if result_list [t ].stage_results [i ].standard_rate_sm3_per_day is not None
235278 ]
236279 inlet_stream_condition_per_stage [i ].density_kg_per_m3 = [
237- result_list [t ].stage_results [i ].inlet_stream .density_kg_per_m3
280+ result_list [t ].stage_results [i ].inlet_stream .density
238281 if result_list [t ].stage_results [i ].inlet_stream is not None
239- and result_list [t ].stage_results [i ].inlet_stream .density_kg_per_m3 is not None
282+ and result_list [t ].stage_results [i ].inlet_stream .density is not None
240283 else np .nan
241284 for t in range (len (result_list ))
242285 ]
@@ -290,9 +333,9 @@ def from_result_list_to_dto(
290333 if result_list [t ].stage_results [i ].standard_rate_sm3_per_day is not None
291334 ]
292335 outlet_stream_condition_per_stage [i ].density_kg_per_m3 = [
293- result_list [t ].stage_results [i ].outlet_stream .density_kg_per_m3
336+ result_list [t ].stage_results [i ].outlet_stream .density
294337 if result_list [t ].stage_results [i ].outlet_stream is not None
295- and result_list [t ].stage_results [i ].outlet_stream .density_kg_per_m3 is not None
338+ and result_list [t ].stage_results [i ].outlet_stream .density is not None
296339 else np .nan
297340 for t in range (len (result_list ))
298341 ]
@@ -403,7 +446,7 @@ def from_result_list_to_dto(
403446 result_list
404447 ) # not relevant for train, only for stage
405448 inlet_stream_condition_for_train .density_kg_per_m3 = [
406- result_list [t ].inlet_stream .density_kg_per_m3 if result_list [t ].inlet_stream is not None else np .nan
449+ result_list [t ].inlet_stream .density if result_list [t ].inlet_stream is not None else np .nan
407450 for t in range (len (result_list ))
408451 ]
409452 inlet_stream_condition_for_train .kappa = [
@@ -441,7 +484,7 @@ def from_result_list_to_dto(
441484 result_list
442485 ) # not relevant for train, only for stage
443486 outlet_stream_condition_for_train .density_kg_per_m3 = [
444- result_list [t ].outlet_stream .density_kg_per_m3 if result_list [t ].outlet_stream is not None else np .nan
487+ result_list [t ].outlet_stream .density if result_list [t ].outlet_stream is not None else np .nan
445488 for t in range (len (result_list ))
446489 ]
447490 outlet_stream_condition_for_train .kappa = [
@@ -552,7 +595,7 @@ def inlet_actual_rate(self) -> float:
552595 @property
553596 def inlet_density (self ) -> float :
554597 if self .inlet_stream is not None :
555- return self .inlet_stream .density_kg_per_m3
598+ return self .inlet_stream .density
556599 else :
557600 return np .nan
558601
@@ -580,7 +623,7 @@ def inlet_temperature_kelvin(self) -> float:
580623 @property
581624 def inlet_fluid_composition (self ) -> FluidComposition :
582625 if self .inlet_stream is not None :
583- return self .inlet_stream .composition
626+ return self .inlet_stream .thermo_system . composition
584627 else :
585628 return FluidComposition ()
586629
@@ -591,7 +634,7 @@ def outlet_actual_rate(self) -> float:
591634 @property
592635 def outlet_density (self ) -> float :
593636 if self .outlet_stream is not None :
594- return self .outlet_stream .density_kg_per_m3
637+ return self .outlet_stream .density
595638 else :
596639 return np .nan
597640
@@ -619,7 +662,7 @@ def outlet_temperature_kelvin(self) -> float:
619662 @property
620663 def outlet_fluid_composition (self ) -> FluidComposition :
621664 if self .outlet_stream is not None :
622- return self .outlet_stream .composition
665+ return self .outlet_stream .thermo_system . composition
623666 else :
624667 return FluidComposition ()
625668
0 commit comments