Skip to content

Commit

Permalink
test: update test
Browse files Browse the repository at this point in the history
ECALC-1361
  • Loading branch information
frodehk committed Sep 10, 2024
1 parent 8fd5ccb commit 10712b0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/libecalc/core/models/turbine.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,15 @@ def __init__(
def max_power(self) -> Optional[float]:
# Max power the compressor can ask for, based on max turbine load
# Note: the scaling is opposite to the turbine load adjustment
# Why a*x - b and not a*x + b?
return (
self._maximum_load * self.data_transfer_object.energy_usage_adjustment_factor
- self.data_transfer_object.energy_usage_adjustment_constant
)

def evaluate(self, load: NDArray[np.float64], fuel_lower_heating_value: float = 0) -> TurbineResult:
# Calibration of turbine load:
# Why not linear transformation? To ensure positive adjustment factor gives loss in turbine?
# If a*x + b: positive a will give gain in turbine (better power2load ratio)
# Linear adjustment a´*x + b´, but where a´=1/a and b´=b/a.
# This is probably to ensu
load_adjusted = np.where(
load > 0,
(load + self.data_transfer_object.energy_usage_adjustment_constant)
Expand Down
8 changes: 3 additions & 5 deletions src/tests/libecalc/core/models/test_turbine.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,12 @@ def test_turbine_with_power_adjustment_constant_and_factor(turbine: TurbineModel
# Result with adjustment:
result_adjusted = turbine.evaluate(load=np.asarray([load]))

power_to_energy_ratio = result.power[0] / result.energy_usage[0]
power_to_energy_ratio_adjusted = result_adjusted.power[0] / result_adjusted.energy_usage[0]

# Verify that adjustment is correct:
np.testing.assert_allclose(
(np.asarray(result.load) + energy_usage_adjustment_constant) / energy_usage_adjustment_factor,
result_adjusted.load,
)

# Verify that turbine uses more energy to deliver same amount of mechanical power
assert power_to_energy_ratio_adjusted < power_to_energy_ratio
# Verify that turbine efficiency is reduced with increased adjustment factor, i.e. higher load (and low constant):
# Efficiency is increasing with load (input data)
assert result_adjusted.efficiency < result.efficiency

0 comments on commit 10712b0

Please sign in to comment.