@@ -101,51 +101,21 @@ def modify_pressure(self, inlet_stream_stage: FluidStream) -> FluidStream:
101101 return self .pressure_modifier .modify_pressure (inlet_stream_stage )
102102 return inlet_stream_stage
103103
104- def add_recirculation_rate (
105- self ,
106- inlet_stream_stage : FluidStream ,
107- asv_rate_fraction : float | None = 0.0 ,
108- asv_additional_mass_rate : float | None = 0.0 ,
109- ) -> FluidStream :
110- """Add recirculation rate to the inlet stream.
111-
112- Args:
113- inlet_stream_stage (FluidStream): Inlet fluid stream conditions.
114- asv_rate_fraction (float): Fraction of available capacity for pressure control. Defaults to 0.0.
115- asv_additional_mass_rate (float): Additional recirculated mass rate. Defaults to 0.0.
116-
117- Returns:
118- FluidStream: Updated inlet stream.
119- """
120- has_asv_rate_fraction = asv_rate_fraction is not None and asv_rate_fraction > 0
121- has_asv_additional_mass_rate = asv_additional_mass_rate is not None and asv_additional_mass_rate > 0
122- if has_asv_rate_fraction and has_asv_additional_mass_rate :
123- raise IllegalStateException ("asv_rate_fraction and asv_additional_mass_rate cannot both be > 0" )
124- if asv_rate_fraction is not None and not (0.0 <= asv_rate_fraction <= 1.0 ):
125- raise IllegalStateException ("asv_rate_fraction must be in [0.0, 1.0]" )
126-
127- actual_rate = inlet_stream_stage .volumetric_rate_m3_per_hour
128- max_rate = self .compressor .get_max_rate ()
129- min_rate = self .compressor .get_min_rate ()
130-
131- available_capacity = max (0.0 , max_rate - actual_rate )
132- additional_rate = max (
133- min_rate - actual_rate ,
134- asv_rate_fraction * available_capacity if asv_rate_fraction else 0.0 ,
135- asv_additional_mass_rate / inlet_stream_stage .density if asv_additional_mass_rate else 0.0 ,
104+ def add_rate (self , inlet_stream_stage : FluidStream ) -> FluidStream :
105+ return self .rate_modifier .add_rate (
106+ stream = inlet_stream_stage ,
136107 )
137108
138- self .rate_modifier .recirculation_mass_rate = additional_rate * inlet_stream_stage .density
139-
140- return self .rate_modifier .add_rate (inlet_stream_stage )
109+ def remove_rate (self , outlet_stream_stage : FluidStream ) -> FluidStream :
110+ return self .rate_modifier .remove_rate (
111+ stream = outlet_stream_stage ,
112+ )
141113
142114 def evaluate (
143115 self ,
144116 inlet_stream_stage : FluidStream ,
145117 rates_out_of_splitter : list [float ] | None = None ,
146118 streams_in_to_mixer : list [FluidStream ] | None = None ,
147- asv_rate_fraction : float | None = 0.0 ,
148- asv_additional_mass_rate : float | None = 0.0 ,
149119 ) -> CompressorTrainStageResultSingleTimeStep :
150120 """Evaluates a compressor train stage given the conditions and rate of the inlet stream, and the speed
151121 of the shaft driving the compressor if given.
@@ -155,10 +125,6 @@ def evaluate(
155125 the first one is the stage inlet stream, the others enter the stage at the Mixer.
156126 rates_out_of_splitter (list[float] | None, optional): Additional rates to the Splitter if defined.
157127 streams_in_to_mixer (list[FluidStream] | None, optional): Additional streams to the Mixer if defined.
158- asv_rate_fraction (float | None, optional): Fraction of the available capacity of the compressor to fill
159- using some kind of pressure control (on the interval [0,1]). Defaults to 0.0.
160- asv_additional_mass_rate (float | None, optional): Additional recirculated mass rate due to
161- pressure control. Defaults to 0.0.
162128
163129 Returns:
164130 CompressorTrainStageResultSingleTimeStep: The result of the evaluation for the compressor stage
@@ -201,10 +167,8 @@ def evaluate(
201167 inlet_stream_compressor = inlet_stream_after_liquid_remover
202168
203169 # Then additional rate is added by the RateModifier (if defined),
204- inlet_stream_compressor_including_asv = self .add_recirculation_rate (
170+ inlet_stream_compressor_including_asv = self .add_rate (
205171 inlet_stream_stage = inlet_stream_compressor ,
206- asv_rate_fraction = asv_rate_fraction ,
207- asv_additional_mass_rate = asv_additional_mass_rate ,
208172 )
209173
210174 # Compressor
@@ -332,9 +296,9 @@ def evaluate_given_speed_and_target_discharge_pressure(
332296 """
333297 # If no speed is defined for CompressorChart, use the minimum speed
334298
299+ self .rate_modifier .mass_rate_to_recirculate = 0
335300 result_no_recirculation = self .evaluate (
336301 inlet_stream_stage = inlet_stream_stage ,
337- asv_additional_mass_rate = 0 ,
338302 )
339303
340304 # result_no_recirculation.inlet_stream.density_kg_per_m3 will have correct pressure and temperature
@@ -347,9 +311,9 @@ def evaluate_given_speed_and_target_discharge_pressure(
347311 - EPSILON ,
348312 0 ,
349313 )
314+ self .rate_modifier .mass_rate_to_recirculate = max_recirculation
350315 result_max_recirculation = self .evaluate (
351316 inlet_stream_stage = inlet_stream_stage ,
352- asv_additional_mass_rate = max_recirculation ,
353317 )
354318 if result_no_recirculation .discharge_pressure < target_discharge_pressure :
355319 return result_no_recirculation
@@ -359,9 +323,9 @@ def evaluate_given_speed_and_target_discharge_pressure(
359323 def _calculate_compressor_stage (
360324 additional_mass_rate : float ,
361325 ) -> CompressorTrainStageResultSingleTimeStep :
326+ self .rate_modifier .mass_rate_to_recirculate = additional_mass_rate
362327 return self .evaluate (
363328 inlet_stream_stage = inlet_stream_stage ,
364- asv_additional_mass_rate = additional_mass_rate ,
365329 )
366330
367331 result_mass_rate = find_root (
0 commit comments