Skip to content

Commit

Permalink
fix: a few things that were left out when the failure_status were ref…
Browse files Browse the repository at this point in the history
…actored
  • Loading branch information
olelod committed Apr 12, 2024
1 parent 5f74621 commit 145af5a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 40 deletions.
20 changes: 0 additions & 20 deletions src/libecalc/core/models/compressor/train/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from numpy.typing import NDArray

from libecalc import dto
from libecalc.common.decorators.feature_flags import Feature
from libecalc.common.logger import logger
from libecalc.common.units import Unit
from libecalc.core.models import (
Expand All @@ -18,9 +17,6 @@
from libecalc.core.models.compressor.train.fluid import FluidStream
from libecalc.core.models.compressor.utils import map_compressor_train_stage_to_domain
from libecalc.core.models.results import CompressorTrainResult
from libecalc.core.models.results.compressor import (
CompressorTrainCommonShaftFailureStatus,
)
from libecalc.domain.stream_conditions import StreamConditions
from libecalc.dto.models.compressor.train import CompressorTrain as CompressorTrainDTO
from libecalc.dto.models.compressor.train import (
Expand Down Expand Up @@ -168,10 +164,6 @@ def evaluate_rate_ps_pd(
compressor_charts=[stage.compressor_chart.data_transfer_object for stage in self.stages],
)

train_results = self.adjust_train_results_for_maximum_power(
train_results=train_results, power=power_mw_adjusted
)

return CompressorTrainResult(
energy_usage=list(power_mw_adjusted),
energy_usage_unit=Unit.MEGA_WATT,
Expand Down Expand Up @@ -209,18 +201,6 @@ def evaluate_streams(
discharge_pressure=np.asarray([outlet_stream.pressure.value]),
)

@Feature.experimental(
feature_description="Maximum power constraint is an experimental feature where the syntax may change at any time."
)
def adjust_train_results_for_maximum_power(
self, train_results: List[CompressorTrainResultSingleTimeStep], power: NDArray[np.float64]
) -> List[CompressorTrainResultSingleTimeStep]:
if self.data_transfer_object.maximum_power is not None:
for power_adjusted, train_result in zip(power, train_results):
if self.data_transfer_object.maximum_power < power_adjusted and train_result.failure_status is None:
train_result.failure_status = CompressorTrainCommonShaftFailureStatus.ABOVE_MAXIMUM_POWER
return train_results

@abstractmethod
def _evaluate_rate_ps_pd(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
get_single_speed_equivalent,
)
from libecalc.core.models.results.compressor import (
CompressorTrainCommonShaftFailureStatus,
StageTargetPressureStatus,
)
from libecalc.dto.types import FixedSpeedPressureControl
Expand Down Expand Up @@ -674,9 +673,6 @@ def _calculate_train_result_given_rate_ps_speed_asv_rate_fraction(
)

if not train_result_max_recirculation.discharge_pressure < outlet_pressure:
train_result_max_recirculation.failure_status = (
CompressorTrainCommonShaftFailureStatus.TARGET_DISCHARGE_PRESSURE_TOO_LOW
)
msg = (
f"Compressor train with inlet pressure {inlet_pressure} and speed {speed} is not able"
f"to reach the required discharge pressure {outlet_pressure} even with full recirculation. "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
)
from libecalc.core.models.compressor.train.utils.common import (
POWER_CALCULATION_TOLERANCE,
PRESSURE_CALCULATION_TOLERANCE,
RATE_CALCULATION_TOLERANCE,
)
from libecalc.core.models.compressor.train.utils.numeric_methods import (
Expand All @@ -34,7 +33,6 @@
)
from libecalc.core.models.results import CompressorTrainResult
from libecalc.core.models.results.compressor import (
CompressorTrainCommonShaftFailureStatus,
StageTargetPressureStatus,
)
from libecalc.domain.stream_conditions import StreamConditions
Expand Down Expand Up @@ -898,10 +896,6 @@ def evaluate_rate_ps_pint_pd(
power_mw > 0, power_mw + self.data_transfer_object.energy_usage_adjustment_constant, power_mw
)

for i, train_result in enumerate(train_results):
if input_failure_status[i] is not ModelInputFailureStatus.NO_FAILURE:
train_result.failure_status = input_failure_status[i]

return CompressorTrainResult(
energy_usage=list(power_mw_adjusted),
energy_usage_unit=Unit.MEGA_WATT,
Expand All @@ -912,7 +906,12 @@ def evaluate_rate_ps_pint_pd(
compressor_charts=[stage.compressor_chart.data_transfer_object for stage in self.stages],
),
rate_sm3_day=cast(list, rate.tolist()),
failure_status=[t.failure_status for t in train_results],
failure_status=[
input_failure_status[i]
if input_failure_status[i] is not ModelInputFailureStatus.NO_FAILURE
else t.failure_status
for i, t in enumerate(train_results)
],
)

def calculate_compressor_train_given_rate_ps_speed(
Expand Down Expand Up @@ -1108,12 +1107,7 @@ def _calculate_train_result_given_rate_ps_speed_asv_rate_fraction(
inlet_pressure_bara=inlet_pressure,
speed=speed,
)
if train_results.discharge_pressure * (1 + PRESSURE_CALCULATION_TOLERANCE) < outlet_pressure:
# Should probably never end up here. This is just in case we do.
train_results.failure_status = (
CompressorTrainCommonShaftFailureStatus.TARGET_DISCHARGE_PRESSURE_TOO_HIGH
)
elif self.pressure_control == FixedSpeedPressureControl.UPSTREAM_CHOKE:
if self.pressure_control == FixedSpeedPressureControl.UPSTREAM_CHOKE:
train_results = self.calculate_compressor_train_given_rate_pd_speed(
std_rates_std_m3_per_day_per_stream=std_rates_std_m3_per_day_per_stream,
outlet_pressure=outlet_pressure,
Expand Down Expand Up @@ -1145,9 +1139,6 @@ def _calculate_train_result_given_rate_ps_speed_asv_rate_fraction(
asv_rate_fraction=1.0,
)
if not train_result_max_recirculation.discharge_pressure < outlet_pressure:
train_result_max_recirculation.failure_status = (
CompressorTrainCommonShaftFailureStatus.TARGET_DISCHARGE_PRESSURE_TOO_LOW
)
msg = (
f"Compressor train with inlet pressure {inlet_pressure} and speed {speed} is not able"
f"to reach the required discharge pressure {outlet_pressure} even with full recirculation. "
Expand Down

0 comments on commit 145af5a

Please sign in to comment.