Skip to content

Commit

Permalink
refactor: remove dto from CompressorWithTurbine
Browse files Browse the repository at this point in the history
  • Loading branch information
jsolaas committed Nov 19, 2024
1 parent 19dca37 commit 35ffac2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/libecalc/core/models/compressor/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from libecalc.core.models.results import CompressorTrainResult
from libecalc.core.models.turbine import TurbineModel
from libecalc.domain.stream_conditions import StreamConditions
from libecalc.dto import CompressorWithTurbine


class CompressorModel(BaseModel):
Expand Down Expand Up @@ -72,11 +71,13 @@ def evaluate_streams(
class CompressorWithTurbineModel(CompressorModel):
def __init__(
self,
data_transfer_object: CompressorWithTurbine,
compressor_energy_function: CompressorModel,
energy_usage_adjustment_constant: float,
energy_usage_adjustment_factor: float,
turbine_model: TurbineModel,
):
self.data_transfer_object = data_transfer_object
self._energy_usage_adjustment_constant = energy_usage_adjustment_constant
self._energy_usage_adjustment_factor = energy_usage_adjustment_factor
self.compressor_model = compressor_energy_function
self.turbine_model = turbine_model

Expand Down Expand Up @@ -128,9 +129,8 @@ def evaluate_turbine_based_on_compressor_model_result(
# The compressor energy function evaluates to a power load in this case
load_adjusted = np.where(
np.asarray(compressor_energy_function_result.power) > 0,
np.asarray(compressor_energy_function_result.power)
* self.data_transfer_object.energy_usage_adjustment_factor
+ self.data_transfer_object.energy_usage_adjustment_constant,
np.asarray(compressor_energy_function_result.power) * self._energy_usage_adjustment_factor
+ self._energy_usage_adjustment_constant,
np.asarray(compressor_energy_function_result.power),
)
turbine_result = self.turbine_model.evaluate(load=load_adjusted)
Expand Down
3 changes: 2 additions & 1 deletion src/libecalc/core/models/compressor/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ def _create_compressor_with_turbine(
compressor_model_dto: CompressorWithTurbine,
) -> CompressorWithTurbineModel:
return CompressorWithTurbineModel(
data_transfer_object=compressor_model_dto,
energy_usage_adjustment_constant=compressor_model_dto.energy_usage_adjustment_constant,
energy_usage_adjustment_factor=compressor_model_dto.energy_usage_adjustment_factor,
compressor_energy_function=create_compressor_model(compressor_model_dto.compressor_train),
turbine_model=_create_turbine(compressor_model_dto.turbine),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def compressor_train_variable_speed_multiple_streams_and_pressures_with_turbine(
return CompressorWithTurbineModel(
turbine_model=turbine_factory(),
compressor_energy_function=variable_speed_compressor_train_two_compressors_one_stream,
data_transfer_object=compressor_train_variable_speed_multiple_streams_and_pressures_with_turbine_dto,
energy_usage_adjustment_constant=compressor_train_variable_speed_multiple_streams_and_pressures_with_turbine_dto.energy_usage_adjustment_constant,
energy_usage_adjustment_factor=compressor_train_variable_speed_multiple_streams_and_pressures_with_turbine_dto.energy_usage_adjustment_factor,
)


Expand All @@ -43,8 +44,8 @@ def test_variable_speed_multiple_streams_and_pressures_with_turbine(
)

expected_load = (
compressor_train_variable_speed_multiple_streams_and_pressures_with_turbine.data_transfer_object.energy_usage_adjustment_factor
compressor_train_variable_speed_multiple_streams_and_pressures_with_turbine._energy_usage_adjustment_factor
* sum([stage.power[0] for stage in result_with_turbine.stage_results])
+ compressor_train_variable_speed_multiple_streams_and_pressures_with_turbine.data_transfer_object.energy_usage_adjustment_constant
+ compressor_train_variable_speed_multiple_streams_and_pressures_with_turbine._energy_usage_adjustment_constant
)
assert result_with_turbine.turbine_result.load[0] == expected_load

0 comments on commit 35ffac2

Please sign in to comment.