Skip to content

Commit

Permalink
fix: bug in get maximum standard rate for variable speed train with m…
Browse files Browse the repository at this point in the history
…aximum power (#694)
  • Loading branch information
olelod authored Nov 14, 2024
1 parent e2bef51 commit 42ce562
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def _calculate_train_result_given_speed_at_stone_wall(
# iterate between rate with minimum power, and the previously found rate to return, to find the
# maximum rate that gives power consumption below maximum power
return find_root(
lower_bound=result_with_minimum_rate.mass_rate_asv_corrected_kg_per_hour,
lower_bound=result_with_minimum_rate.stage_results[0].mass_rate_asv_corrected_kg_per_hour,
upper_bound=rate_to_return,
func=lambda x: self.evaluate_rate_ps_pd(
rate=np.asarray([self.fluid.mass_rate_to_standard_rate(x)]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,3 +385,40 @@ def test_adjustment_constant_and_factor_one_compressor(variable_speed_compressor
discharge_pressure=np.asarray([100.0]),
)
assert result_adjusted.power[0] == result.power[0] * 1.5 + adjustment_constant


def test_get_max_standard_rate_with_and_without_maximum_power(
variable_speed_compressor_train_one_compressor,
variable_speed_compressor_train_one_compressor_maximum_power,
):
max_standard_rate_without_maximum_power = variable_speed_compressor_train_one_compressor.get_max_standard_rate(
suction_pressures=np.asarray([30], dtype=float),
discharge_pressures=np.asarray([100], dtype=float),
)
max_standard_rate_with_maximum_power = (
variable_speed_compressor_train_one_compressor_maximum_power.get_max_standard_rate(
suction_pressures=np.asarray([30], dtype=float),
discharge_pressures=np.asarray([100], dtype=float),
)
)
power_at_max_standard_rate_without_maximum_power = (
variable_speed_compressor_train_one_compressor.evaluate_rate_ps_pd(
rate=np.asarray(max_standard_rate_without_maximum_power, dtype=float),
suction_pressure=np.asarray([30], dtype=float),
discharge_pressure=np.asarray([100], dtype=float),
).power
)
power_at_max_standard_rate_with_maximum_power = (
variable_speed_compressor_train_one_compressor_maximum_power.evaluate_rate_ps_pd(
rate=np.asarray(max_standard_rate_with_maximum_power, dtype=float),
suction_pressure=np.asarray([30], dtype=float),
discharge_pressure=np.asarray([100], dtype=float),
).power
)

assert max_standard_rate_without_maximum_power > max_standard_rate_with_maximum_power
assert power_at_max_standard_rate_without_maximum_power > power_at_max_standard_rate_with_maximum_power
assert (
power_at_max_standard_rate_with_maximum_power[0]
< variable_speed_compressor_train_one_compressor_maximum_power.maximum_power
)

0 comments on commit 42ce562

Please sign in to comment.