Skip to content

Commit

Permalink
chore: more robust surge control margin calculation (#229)
Browse files Browse the repository at this point in the history
* chore: more robust surge control margin calculation
  • Loading branch information
frodehk authored Oct 6, 2023
1 parent 00ad854 commit 74b4e59
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@ MODELS:


For a variable speed compressor chart it is possible to add a surge control margin. This is currently done by giving a
fraction or percentage as input. This percentage/fraction is applied to the average of the minimum flow rate for all
speed curves in the compressor chart, to find how much the minimum flow should be increased. The increase in minimum
flow will be the same for all speed curves. The corresponding head and efficiency values for the new minimum flow rate
fraction or percentage as input. The control margin is used to calculate the increase in minimum flow, i.e. as a percentage
or fraction of the rate difference between minimum- and maximum flow, for the given speed. The increase in minimum
flow is calculated individually for each speed curve. The corresponding head and efficiency values for the new minimum flow rate
is found by interpolation along the speed curves. The same compressor chart can be used for multiple compressor stages,
but with different surge control margins. Hence, the surge control margin is defined when setting up the stages in a
[`Variable speed compressor train model`](/about/modelling/setup/models/compressor_modelling/compressor_models_types/variable_speed_compressor_train_model.md) or [`Variable speed compressor train model with multiple streams and pressures`](/about/modelling/setup/models/compressor_modelling/compressor_models_types/variable_speed_compressor_train_model_with_multiple_streams_and_pressures.md).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def _get_new_point(x: List[float], y: List[float], new_x_value) -> float:
"Any usage of this functionality is at your own risk."
)
new_curves = []
adjust_minimum_rate_by = np.average([np.min(curve.rate) for curve in self.curves]) * control_margin
for curve in self.curves:
adjust_minimum_rate_by = (np.max(curve.rate) - np.min(curve.rate)) * control_margin
new_minimum_rate = np.min(curve.rate) + adjust_minimum_rate_by
rate_head_efficiency_array = np.vstack((curve.rate, curve.head, curve.efficiency))
# remove points with rate less than the new minimum rate (i.e. chop off left part of chart curve)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,18 @@ def test_variable_speed_compressor_chart_control_margin():
control_margin = 0.1
compressor_chart_adjusted = compressor_chart.get_chart_adjusted_for_control_margin(control_margin=control_margin)

assert compressor_chart_adjusted.curves[0].rate_actual_m3_hour[0] == 1.25
assert compressor_chart_adjusted.curves[1].rate_actual_m3_hour[0] == 4.25
adjust_minimum_rate_by_speed1 = (
compressor_chart.curves[0].rate_actual_m3_hour[-1] - compressor_chart.curves[0].rate_actual_m3_hour[0]
) * control_margin
adjust_minimum_rate_by_speed2 = (
compressor_chart.curves[1].rate_actual_m3_hour[-1] - compressor_chart.curves[1].rate_actual_m3_hour[0]
) * control_margin

new_minimum_rate_speed1 = compressor_chart.curves[0].rate_actual_m3_hour[0] + adjust_minimum_rate_by_speed1
new_minimum_rate_speed2 = compressor_chart.curves[1].rate_actual_m3_hour[0] + adjust_minimum_rate_by_speed2

assert compressor_chart_adjusted.curves[0].rate_actual_m3_hour[0] == new_minimum_rate_speed1
assert compressor_chart_adjusted.curves[1].rate_actual_m3_hour[0] == new_minimum_rate_speed2


def test_compare_variable_speed_compressor_chart_head_and_efficiency_known_point_compared_to_interpolation(
Expand Down
Loading

0 comments on commit 74b4e59

Please sign in to comment.