diff --git a/src/ecalc/libraries/libecalc/common/libecalc/core/consumers/legacy_consumer/system/consumer_function.py b/src/ecalc/libraries/libecalc/common/libecalc/core/consumers/legacy_consumer/system/consumer_function.py index 207ad7eae..8829fe9ac 100644 --- a/src/ecalc/libraries/libecalc/common/libecalc/core/consumers/legacy_consumer/system/consumer_function.py +++ b/src/ecalc/libraries/libecalc/common/libecalc/core/consumers/legacy_consumer/system/consumer_function.py @@ -360,19 +360,17 @@ def evaluate_consumers( """ consumer_rates = operational_setting.rates - consumer_results = [] - for i, consumer in enumerate(self.consumers): - consumer_results.append( - CompressorResult( - name=consumer.name, - consumer_model_result=consumer.facility_model.evaluate_rate_ps_pd( - rate=consumer_rates[i], - suction_pressure=operational_setting.suction_pressures[i], - discharge_pressure=operational_setting.discharge_pressures[i], - ), - ) + return [ + CompressorResult( + name=consumer.name, + consumer_model_result=consumer.facility_model.evaluate_rate_ps_pd( + rate=consumer_rates[i], + suction_pressure=operational_setting.suction_pressures[i], + discharge_pressure=operational_setting.discharge_pressures[i], + ), ) - return consumer_results + for i, consumer in enumerate(self.consumers) + ] class PumpSystemConsumerFunction(ConsumerSystemConsumerFunction): diff --git a/src/ecalc/libraries/libecalc/common/libecalc/core/models/compressor/results.py b/src/ecalc/libraries/libecalc/common/libecalc/core/models/compressor/results.py index e22dc475f..9dafc3270 100644 --- a/src/ecalc/libraries/libecalc/common/libecalc/core/models/compressor/results.py +++ b/src/ecalc/libraries/libecalc/common/libecalc/core/models/compressor/results.py @@ -133,146 +133,139 @@ def from_result_list_to_dto( result_list: List[CompressorTrainResultSingleTimeStep], compressor_charts: Optional[List[Union[dto.SingleSpeedChart, dto.VariableSpeedChart]]], ) -> List[CompressorStageResult]: - stage_results = [] number_of_stages = max([len(t.stage_results) for t in result_list]) - for i in range(number_of_stages): - stage_results.append( - CompressorStageResult( - energy_usage=[result_list[t].stage_results[i].power_megawatt for t in range(len(result_list))], - energy_usage_unit=Unit.MEGA_WATT, - power=[result_list[t].stage_results[i].power_megawatt for t in range(len(result_list))], - power_unit=Unit.MEGA_WATT, - mass_rate_kg_per_hr=[ - result_list[t].stage_results[i].mass_rate_asv_corrected_kg_per_hour + return [ + CompressorStageResult( + energy_usage=[result_list[t].stage_results[i].power_megawatt for t in range(len(result_list))], + energy_usage_unit=Unit.MEGA_WATT, + power=[result_list[t].stage_results[i].power_megawatt for t in range(len(result_list))], + power_unit=Unit.MEGA_WATT, + mass_rate_kg_per_hr=[ + result_list[t].stage_results[i].mass_rate_asv_corrected_kg_per_hour for t in range(len(result_list)) + ], + mass_rate_before_asv_kg_per_hr=[ + result_list[t].stage_results[i].mass_rate_kg_per_hour for t in range(len(result_list)) + ], + inlet_stream_condition=CompressorStreamCondition( + pressure=[ + result_list[t].stage_results[i].inlet_stream.pressure_bara + if result_list[t].stage_results[i].inlet_stream is not None + else np.nan for t in range(len(result_list)) ], - mass_rate_before_asv_kg_per_hr=[ - result_list[t].stage_results[i].mass_rate_kg_per_hour for t in range(len(result_list)) + pressure_before_choking=[ + result_list[t].stage_results[i].inlet_pressure_before_choking for t in range(len(result_list)) ], - inlet_stream_condition=CompressorStreamCondition( - pressure=[ - result_list[t].stage_results[i].inlet_stream.pressure_bara - if result_list[t].stage_results[i].inlet_stream is not None - else np.nan - for t in range(len(result_list)) - ], - pressure_before_choking=[ - result_list[t].stage_results[i].inlet_pressure_before_choking - for t in range(len(result_list)) - ], - # Note: Here we reverse the lingo from "before ASV" to "ASV corrected" - actual_rate_m3_per_hr=[ - result_list[t].stage_results[i].inlet_actual_rate_asv_corrected_m3_per_hour - for t in range(len(result_list)) - ], - actual_rate_before_asv_m3_per_hr=[ - result_list[t].stage_results[i].inlet_actual_rate_m3_per_hour - for t in range(len(result_list)) - ], - density_kg_per_m3=[ - result_list[t].stage_results[i].inlet_stream.density_kg_per_m3 - if result_list[t].stage_results[i].inlet_stream is not None - else np.nan - for t in range(len(result_list)) - ], - kappa=[ - result_list[t].stage_results[i].inlet_stream.kappa - if result_list[t].stage_results[i].inlet_stream is not None - else np.nan - for t in range(len(result_list)) - ], - z=[ - result_list[t].stage_results[i].inlet_stream.z - if result_list[t].stage_results[i].inlet_stream is not None - else np.nan - for t in range(len(result_list)) - ], - temperature_kelvin=[ - result_list[t].stage_results[i].inlet_stream.temperature_kelvin - if result_list[t].stage_results[i].inlet_stream is not None - else np.nan - for t in range(len(result_list)) - ], - ), - outlet_stream_condition=CompressorStreamCondition( - pressure=[ - result_list[t].stage_results[i].outlet_stream.pressure_bara - if result_list[t].stage_results[i].outlet_stream is not None - else np.nan - for t in range(len(result_list)) - ], - pressure_before_choking=[ - result_list[t].stage_results[i].outlet_pressure_before_choking - for t in range(len(result_list)) - ], - actual_rate_m3_per_hr=[ - result_list[t].stage_results[i].outlet_actual_rate_m3_per_hour - for t in range(len(result_list)) - ], - actual_rate_before_asv_m3_per_hr=None, # Todo: Add me - density_kg_per_m3=[ - result_list[t].stage_results[i].outlet_stream.density_kg_per_m3 - if result_list[t].stage_results[i].outlet_stream is not None - else np.nan - for t in range(len(result_list)) - ], - kappa=[ - result_list[t].stage_results[i].outlet_stream.kappa - if result_list[t].stage_results[i].outlet_stream is not None - else np.nan - for t in range(len(result_list)) - ], - z=[ - result_list[t].stage_results[i].outlet_stream.z - if result_list[t].stage_results[i].outlet_stream is not None - else np.nan - for t in range(len(result_list)) - ], - temperature_kelvin=[ - result_list[t].stage_results[i].outlet_stream.temperature_kelvin - if result_list[t].stage_results[i].outlet_stream is not None - else np.nan - for t in range(len(result_list)) - ], - ), - polytropic_enthalpy_change_kJ_per_kg=[ - result_list[t].stage_results[i].polytropic_enthalpy_change_kJ_per_kg + # Note: Here we reverse the lingo from "before ASV" to "ASV corrected" + actual_rate_m3_per_hr=[ + result_list[t].stage_results[i].inlet_actual_rate_asv_corrected_m3_per_hour for t in range(len(result_list)) ], - polytropic_head_kJ_per_kg=[ - result_list[t].stage_results[i].polytropic_head_kJ_per_kg for t in range(len(result_list)) + actual_rate_before_asv_m3_per_hr=[ + result_list[t].stage_results[i].inlet_actual_rate_m3_per_hour for t in range(len(result_list)) ], - polytropic_efficiency=[ - result_list[t].stage_results[i].polytropic_efficiency for t in range(len(result_list)) + density_kg_per_m3=[ + result_list[t].stage_results[i].inlet_stream.density_kg_per_m3 + if result_list[t].stage_results[i].inlet_stream is not None + else np.nan + for t in range(len(result_list)) ], - polytropic_enthalpy_change_before_choke_kJ_per_kg=[ - result_list[t].stage_results[i].polytropic_enthalpy_change_before_choke_kJ_per_kg + kappa=[ + result_list[t].stage_results[i].inlet_stream.kappa + if result_list[t].stage_results[i].inlet_stream is not None + else np.nan for t in range(len(result_list)) ], - speed=[result.speed for result in result_list], - asv_recirculation_loss_mw=[ - result_list[t].stage_results[i].asv_recirculation_loss_mw for t in range(len(result_list)) + z=[ + result_list[t].stage_results[i].inlet_stream.z + if result_list[t].stage_results[i].inlet_stream is not None + else np.nan + for t in range(len(result_list)) ], - # Validity flags - is_valid=[result_list[t].stage_results[i].is_valid for t in range(len(result_list))], - chart_area_flags=[result_list[t].stage_results[i].chart_area_flag for t in range(len(result_list))], - rate_has_recirculation=[ - bool(result_list[t].stage_results[i].rate_has_recirculation) for t in range(len(result_list)) + temperature_kelvin=[ + result_list[t].stage_results[i].inlet_stream.temperature_kelvin + if result_list[t].stage_results[i].inlet_stream is not None + else np.nan + for t in range(len(result_list)) ], - rate_exceeds_maximum=[ - bool(result_list[t].stage_results[i].rate_exceeds_maximum) for t in range(len(result_list)) + ), + outlet_stream_condition=CompressorStreamCondition( + pressure=[ + result_list[t].stage_results[i].outlet_stream.pressure_bara + if result_list[t].stage_results[i].outlet_stream is not None + else np.nan + for t in range(len(result_list)) ], - pressure_is_choked=[ - bool(result_list[t].stage_results[i].pressure_is_choked) for t in range(len(result_list)) + pressure_before_choking=[ + result_list[t].stage_results[i].outlet_pressure_before_choking for t in range(len(result_list)) ], - head_exceeds_maximum=[ - bool(result_list[t].stage_results[i].head_exceeds_maximum) for t in range(len(result_list)) + actual_rate_m3_per_hr=[ + result_list[t].stage_results[i].outlet_actual_rate_m3_per_hour for t in range(len(result_list)) ], - fluid_composition={}, - chart=compressor_charts[i] if compressor_charts is not None else None, - ) + actual_rate_before_asv_m3_per_hr=None, # Todo: Add me + density_kg_per_m3=[ + result_list[t].stage_results[i].outlet_stream.density_kg_per_m3 + if result_list[t].stage_results[i].outlet_stream is not None + else np.nan + for t in range(len(result_list)) + ], + kappa=[ + result_list[t].stage_results[i].outlet_stream.kappa + if result_list[t].stage_results[i].outlet_stream is not None + else np.nan + for t in range(len(result_list)) + ], + z=[ + result_list[t].stage_results[i].outlet_stream.z + if result_list[t].stage_results[i].outlet_stream is not None + else np.nan + for t in range(len(result_list)) + ], + temperature_kelvin=[ + result_list[t].stage_results[i].outlet_stream.temperature_kelvin + if result_list[t].stage_results[i].outlet_stream is not None + else np.nan + for t in range(len(result_list)) + ], + ), + polytropic_enthalpy_change_kJ_per_kg=[ + result_list[t].stage_results[i].polytropic_enthalpy_change_kJ_per_kg + for t in range(len(result_list)) + ], + polytropic_head_kJ_per_kg=[ + result_list[t].stage_results[i].polytropic_head_kJ_per_kg for t in range(len(result_list)) + ], + polytropic_efficiency=[ + result_list[t].stage_results[i].polytropic_efficiency for t in range(len(result_list)) + ], + polytropic_enthalpy_change_before_choke_kJ_per_kg=[ + result_list[t].stage_results[i].polytropic_enthalpy_change_before_choke_kJ_per_kg + for t in range(len(result_list)) + ], + speed=[result.speed for result in result_list], + asv_recirculation_loss_mw=[ + result_list[t].stage_results[i].asv_recirculation_loss_mw for t in range(len(result_list)) + ], + # Validity flags + is_valid=[result_list[t].stage_results[i].is_valid for t in range(len(result_list))], + chart_area_flags=[result_list[t].stage_results[i].chart_area_flag for t in range(len(result_list))], + rate_has_recirculation=[ + bool(result_list[t].stage_results[i].rate_has_recirculation) for t in range(len(result_list)) + ], + rate_exceeds_maximum=[ + bool(result_list[t].stage_results[i].rate_exceeds_maximum) for t in range(len(result_list)) + ], + pressure_is_choked=[ + bool(result_list[t].stage_results[i].pressure_is_choked) for t in range(len(result_list)) + ], + head_exceeds_maximum=[ + bool(result_list[t].stage_results[i].head_exceeds_maximum) for t in range(len(result_list)) + ], + fluid_composition={}, + chart=compressor_charts[i] if compressor_charts is not None else None, ) - return stage_results + for i in range(number_of_stages) + ] class Config: extra = Extra.forbid diff --git a/src/ecalc/libraries/libecalc/common/libecalc/core/models/compressor/train/simplified_train.py b/src/ecalc/libraries/libecalc/common/libecalc/core/models/compressor/train/simplified_train.py index 2232ca329..f671a1fe6 100644 --- a/src/ecalc/libraries/libecalc/common/libecalc/core/models/compressor/train/simplified_train.py +++ b/src/ecalc/libraries/libecalc/common/libecalc/core/models/compressor/train/simplified_train.py @@ -112,7 +112,7 @@ def _evaluate_rate_ps_pd( :param rate: Rate values [Sm3/day] :param suction_pressure: suction pressure [bara] :param discharge_pressure: discharge pressure [bara] - :return: + :return: train result """ if isinstance(self, CompressorTrainSimplifiedUnknownStages): self.stages = self.get_stages( @@ -140,18 +140,13 @@ def _evaluate_rate_ps_pd( inlet_pressure = inlet_pressure * pressure_ratios_per_stage # Converting from individual stage results to a train results and adding max rate per time step. - train_result = [] - for time_step in range(len(compressor_stages_result_per_time_step[0])): - # Merging - train_result.append( - CompressorTrainResultSingleTimeStep( - speed=np.nan, - stage_results=[ - result[time_step].stage_results[0] for result in compressor_stages_result_per_time_step - ], - ) + return [ + CompressorTrainResultSingleTimeStep( + speed=np.nan, + stage_results=[result[time_step].stage_results[0] for result in compressor_stages_result_per_time_step], ) - return train_result + for time_step in range(len(compressor_stages_result_per_time_step[0])) + ] def calculate_compressor_stage_work_given_outlet_pressure( self, diff --git a/src/ecalc/libraries/libecalc/common/libecalc/core/models/compressor/train/variable_speed_compressor_train_common_shaft.py b/src/ecalc/libraries/libecalc/common/libecalc/core/models/compressor/train/variable_speed_compressor_train_common_shaft.py index 28812f515..ef5c1d34b 100644 --- a/src/ecalc/libraries/libecalc/common/libecalc/core/models/compressor/train/variable_speed_compressor_train_common_shaft.py +++ b/src/ecalc/libraries/libecalc/common/libecalc/core/models/compressor/train/variable_speed_compressor_train_common_shaft.py @@ -683,16 +683,15 @@ def get_single_speed_equivalent_train( A single speed compressor train at given shaft speed """ - single_speed_compressor_stages = [] - for stage in compressor_train.stages: - single_speed_compressor_stages.append( - CompressorTrainStage( - compressor_chart=get_single_speed_equivalent(compressor_chart=stage.compressor_chart, speed=speed), - inlet_temperature_kelvin=stage.inlet_temperature_kelvin, - remove_liquid_after_cooling=stage.remove_liquid_after_cooling, - pressure_drop_ahead_of_stage=stage.pressure_drop_ahead_of_stage, - ) + single_speed_compressor_stages = [ + CompressorTrainStage( + compressor_chart=get_single_speed_equivalent(compressor_chart=stage.compressor_chart, speed=speed), + inlet_temperature_kelvin=stage.inlet_temperature_kelvin, + remove_liquid_after_cooling=stage.remove_liquid_after_cooling, + pressure_drop_ahead_of_stage=stage.pressure_drop_ahead_of_stage, ) + for stage in compressor_train.stages + ] return SingleSpeedCompressorTrainCommonShaft( data_transfer_object=dto.SingleSpeedCompressorTrain( diff --git a/src/ecalc/libraries/libecalc/common/libecalc/core/models/compressor/train/variable_speed_compressor_train_common_shaft_multiple_streams_and_pressures.py b/src/ecalc/libraries/libecalc/common/libecalc/core/models/compressor/train/variable_speed_compressor_train_common_shaft_multiple_streams_and_pressures.py index d21c2ad6d..6d45f77ad 100644 --- a/src/ecalc/libraries/libecalc/common/libecalc/core/models/compressor/train/variable_speed_compressor_train_common_shaft_multiple_streams_and_pressures.py +++ b/src/ecalc/libraries/libecalc/common/libecalc/core/models/compressor/train/variable_speed_compressor_train_common_shaft_multiple_streams_and_pressures.py @@ -1035,18 +1035,15 @@ def _calculate_train_result_given_rate_ps_speed_asv_rate_fraction( "when there are multiple streams entering the subtrain in question" ) - single_speed_compressor_stages = [] - for stage in self.stages: - single_speed_compressor_stages.append( - CompressorTrainStage( - compressor_chart=get_single_speed_equivalent( - compressor_chart=stage.compressor_chart, speed=speed - ), - inlet_temperature_kelvin=stage.inlet_temperature_kelvin, - remove_liquid_after_cooling=stage.remove_liquid_after_cooling, - pressure_drop_ahead_of_stage=stage.pressure_drop_ahead_of_stage, - ) + single_speed_compressor_stages = [ + CompressorTrainStage( + compressor_chart=get_single_speed_equivalent(compressor_chart=stage.compressor_chart, speed=speed), + inlet_temperature_kelvin=stage.inlet_temperature_kelvin, + remove_liquid_after_cooling=stage.remove_liquid_after_cooling, + pressure_drop_ahead_of_stage=stage.pressure_drop_ahead_of_stage, ) + for stage in self.stages + ] single_speed_train = SingleSpeedCompressorTrainCommonShaft( data_transfer_object=dto.SingleSpeedCompressorTrain( @@ -1193,17 +1190,16 @@ def find_and_calculate_for_compressor_train_with_two_pressure_requirements( ) ) - max_standard_rate_per_stream = [] if self.data_transfer_object.calculate_max_rate: - for stream_index, _ in enumerate(compressor_train_first_part.streams): - max_standard_rate_per_stream.append( - compressor_train_first_part._get_max_rate_for_single_stream_single_timestep( - suction_pressure=inlet_pressure_first_part, - target_discharge_pressure=outlet_pressure_first_part, - rate_per_stream=std_rates_first_part, - stream_to_maximize=stream_index, - ) + max_standard_rate_per_stream = [ + compressor_train_first_part._get_max_rate_for_single_stream_single_timestep( + suction_pressure=inlet_pressure_first_part, + target_discharge_pressure=outlet_pressure_first_part, + rate_per_stream=std_rates_first_part, + stream_to_maximize=stream_index, ) + for stream_index, _ in enumerate(compressor_train_first_part.streams) + ] else: max_standard_rate_per_stream = [np.nan] * len(std_rates_first_part) diff --git a/src/ecalc/libraries/libecalc/common/libecalc/output/flow_diagram/EcalcModelMapper.py b/src/ecalc/libraries/libecalc/common/libecalc/output/flow_diagram/EcalcModelMapper.py index 009c7efe4..5ed0b5627 100644 --- a/src/ecalc/libraries/libecalc/common/libecalc/output/flow_diagram/EcalcModelMapper.py +++ b/src/ecalc/libraries/libecalc/common/libecalc/output/flow_diagram/EcalcModelMapper.py @@ -158,30 +158,28 @@ def _create_compressor_train_diagram( :param energy_usage_model: :return: list of flow diagrams. List of flow diagrams as we always add a default date in dtos. """ - flow_diagrams = [] time_intervals = _get_time_intervals(set(energy_usage_model.keys()), global_end_date) compressor_train_step = list(energy_usage_model.values())[0].model - for time_interval in time_intervals: - if hasattr(compressor_train_step, "stages"): - flow_diagrams.append( - FlowDiagram( - id=node_id, - title=title, - start_date=time_interval.start_date, - end_date=time_interval.end_date, - nodes=[ - Node( - id=f"{title} stage {index}", - title=f"{title} stage {index}", - type=NodeType.COMPRESSOR, - ) - for index, chart in enumerate(compressor_train_step.stages) - ], - edges=[], - flows=[], + return [ + FlowDiagram( + id=node_id, + title=title, + start_date=time_interval.start_date, + end_date=time_interval.end_date, + nodes=[ + Node( + id=f"{title} stage {index}", + title=f"{title} stage {index}", + type=NodeType.COMPRESSOR, ) - ) - return flow_diagrams + for index, chart in enumerate(compressor_train_step.stages) + ], + edges=[], + flows=[], + ) + for time_interval in time_intervals + if hasattr(compressor_train_step, "stages") + ] def _create_compressor_with_turbine_stages_diagram( @@ -366,16 +364,15 @@ def _create_installation_flow_diagram( if not isinstance(fuel_consumer, dto.GeneratorSet) ] - fuel_consumer_except_generator_set_nodes = [] - for fuel_consumer_dto in fuel_consumers_except_generator_sets: - if _consumer_is_active(fuel_consumer_dto, time_interval): - fuel_consumer_except_generator_set_nodes.append( - _create_consumer_node( - fuel_consumer_dto, - installation, - global_end_date, - ) - ) + fuel_consumer_except_generator_set_nodes = [ + _create_consumer_node( + fuel_consumer_dto, + installation, + global_end_date, + ) + for fuel_consumer_dto in fuel_consumers_except_generator_sets + if _consumer_is_active(fuel_consumer_dto, time_interval) + ] fuel_consumer_nodes = [ *generator_set_nodes, diff --git a/src/ecalc/libraries/libecalc/common/tests/core/conftest.py b/src/ecalc/libraries/libecalc/common/tests/core/conftest.py index 429ab11ef..61f049406 100644 --- a/src/ecalc/libraries/libecalc/common/tests/core/conftest.py +++ b/src/ecalc/libraries/libecalc/common/tests/core/conftest.py @@ -205,16 +205,15 @@ def variable_speed_compressor_chart_dto() -> dto.VariableSpeedChart: ], columns=["speed", "rate", "head", "efficiency"], ) - chart_curves = [] - for speed, data in df.groupby("speed"): - chart_curves.append( - dto.ChartCurve( - polytropic_head_joule_per_kg=data["head"].tolist(), - rate_actual_m3_hour=data["rate"].tolist(), - efficiency_fraction=data["efficiency"].tolist(), - speed_rpm=float(speed), # noqa - ) + chart_curves = [ + dto.ChartCurve( + polytropic_head_joule_per_kg=data["head"].tolist(), + rate_actual_m3_hour=data["rate"].tolist(), + efficiency_fraction=data["efficiency"].tolist(), + speed_rpm=float(speed), # noqa ) + for speed, data in df.groupby("speed") + ] return dto.VariableSpeedChart(curves=chart_curves) diff --git a/src/ecalc/libraries/libecalc/common/tests/core/models/compressor_modelling/test_compressor_chart.py b/src/ecalc/libraries/libecalc/common/tests/core/models/compressor_modelling/test_compressor_chart.py index bdaf60a43..d6c3d3be7 100644 --- a/src/ecalc/libraries/libecalc/common/tests/core/models/compressor_modelling/test_compressor_chart.py +++ b/src/ecalc/libraries/libecalc/common/tests/core/models/compressor_modelling/test_compressor_chart.py @@ -10,16 +10,16 @@ @pytest.fixture def variable_speed_compressor_chart(variable_speed_compressor_chart_dto) -> VariableSpeedCompressorChart: """Convert DTO to domain object.""" - curves = [] - for curve in variable_speed_compressor_chart_dto.curves: - curves.append( - dto.ChartCurve( - rate_actual_m3_hour=curve.rate_actual_m3_hour, - polytropic_head_joule_per_kg=curve.polytropic_head_joule_per_kg, - efficiency_fraction=curve.efficiency_fraction, - speed_rpm=curve.speed_rpm, - ) + curves = [ + dto.ChartCurve( + rate_actual_m3_hour=curve.rate_actual_m3_hour, + polytropic_head_joule_per_kg=curve.polytropic_head_joule_per_kg, + efficiency_fraction=curve.efficiency_fraction, + speed_rpm=curve.speed_rpm, ) + for curve in variable_speed_compressor_chart_dto.curves + ] + return VariableSpeedCompressorChart(dto.VariableSpeedChart(curves=curves)) @@ -57,16 +57,16 @@ def predefined_variable_speed_compressor_chart_2() -> VariableSpeedCompressorCha "efficiency": [0.700, 0.715, 0.738, 0.761, 0.772, 0.776, 0.773, 0.769, 0.752, 0.730, 0.721], }, } - chart_curves = [] - for speed, values in chart_data.items(): - chart_curves.append( - dto.ChartCurve( - rate_actual_m3_hour=values["rate"], - polytropic_head_joule_per_kg=values["head"], - efficiency_fraction=values["efficiency"], - speed_rpm=speed, - ) + chart_curves = [ + dto.ChartCurve( + rate_actual_m3_hour=values["rate"], + polytropic_head_joule_per_kg=values["head"], + efficiency_fraction=values["efficiency"], + speed_rpm=speed, ) + for speed, values in chart_data.items() + ] + return VariableSpeedCompressorChart(dto.VariableSpeedChart(curves=chart_curves)) diff --git a/src/ecalc/libraries/libecalc/common/tests/output/flow_diagram/test_ecalc_model_mapper.py b/src/ecalc/libraries/libecalc/common/tests/output/flow_diagram/test_ecalc_model_mapper.py index 017464a7a..7fca2624f 100644 --- a/src/ecalc/libraries/libecalc/common/tests/output/flow_diagram/test_ecalc_model_mapper.py +++ b/src/ecalc/libraries/libecalc/common/tests/output/flow_diagram/test_ecalc_model_mapper.py @@ -45,20 +45,18 @@ def test_correct_duplicate_filtering(self): The change in nodes happens 2019-01-01 when we use a mock instead of an empty list. """ - duplicate_flow_diagrams: List[FlowDiagram] = [] - - for year in range(2010, 2020): - duplicate_flow_diagrams.append( - FlowDiagram( - id="1", - title="dummy", - nodes=[] if year < 2019 else [Mock(Node)], - edges=[], - flows=[], - start_date=datetime(year, 1, 1), - end_date=datetime(year + 1, 1, 1), - ) + duplicate_flow_diagrams: List[FlowDiagram] = [ + FlowDiagram( + id="1", + title="dummy", + nodes=[] if year < 2019 else [Mock(Node)], + edges=[], + flows=[], + start_date=datetime(year, 1, 1), + end_date=datetime(year + 1, 1, 1), ) + for year in range(2010, 2020) + ] filtered_diagrams = _filter_duplicate_flow_diagrams(duplicate_flow_diagrams)