From 2c9bbd6272eb3c91ac8ad2f9c0e822de2e379a43 Mon Sep 17 00:00:00 2001 From: Frode Helgetun Krogh <70878501+frodehk@users.noreply.github.com> Date: Thu, 12 Dec 2024 14:37:42 +0100 Subject: [PATCH] move energy components and dto to infrastructure (#726) * chore: move energy components and dto to domain/infrastructure --- src/libecalc/application/energy_calculator.py | 145 +----------- src/libecalc/core/consumers/factory.py | 51 ----- .../domain/infrastructure/__init__.py | 8 + .../infrastructure}/components.py | 213 +++++++++++++++++- .../energy_components}/__init__.py | 0 .../energy_components}/base/__init__.py | 0 .../energy_components}/base/component.py | 0 .../energy_components}/compressor/__init__.py | 0 .../compressor/component.py | 2 +- .../energy_components}/consumer_system.py | 2 +- .../generator_set}/__init__.py | 0 .../generator_set}/generator_set.py | 0 .../legacy_consumer/__init__.py | 0 .../legacy_consumer/component.py | 24 +- .../consumer_function/__init__.py | 0 .../compressor_consumer_function.py | 20 +- .../consumer_function/consumer_function.py | 2 +- .../consumer_tabular_energy_function.py | 14 +- .../direct_expression_consumer_function.py | 6 +- .../pump_consumer_function.py | 6 +- .../consumer_function/results.py | 6 +- .../consumer_function/types.py | 0 .../consumer_function/utils.py | 0 .../consumer_function_mapper/__init__.py | 2 +- .../compressor_consumer_function.py | 4 +- .../compressor_system_consumer_function.py | 8 +- .../direct_consumer_function.py | 2 +- .../pump_consumer_function.py | 4 +- .../pump_system_consumer_function.py | 8 +- .../consumer_function_mapper/tabulated.py | 6 +- .../legacy_consumer/result_mapper.py | 8 +- .../legacy_consumer/system/__init__.py | 0 .../system/consumer_function.py | 16 +- .../system/operational_setting.py | 0 .../legacy_consumer/system/results.py | 12 +- .../legacy_consumer/system/types.py | 0 .../legacy_consumer/system/utils.py | 4 +- .../energy_components}/pump/__init__.py | 0 .../energy_components}/pump/component.py | 2 +- src/libecalc/dto/__init__.py | 8 - src/libecalc/fixtures/case_types.py | 2 +- .../cases/consumer_with_time_slots_models.py | 12 +- .../presentation/exporter/infrastructure.py | 2 +- .../presentation/json_result/mapper.py | 3 +- .../yaml/mappers/component_mapper.py | 9 +- .../components/system/yaml_consumer_system.py | 2 +- .../yaml_types/components/train/yaml_train.py | 2 +- .../yaml_types/components/yaml_compressor.py | 2 +- .../yaml/yaml_types/components/yaml_pump.py | 2 +- tests/libecalc/core/consumers/conftest.py | 17 +- .../test_consumer_function.py | 4 +- ...est_direct_expression_consumer_function.py | 4 +- .../core/consumers/system/conftest.py | 8 +- .../consumers/system/test_consumer_system.py | 8 +- .../system/test_operational_setting.py | 2 +- .../consumers/system/test_system_results.py | 2 +- .../consumers/system/test_system_utils.py | 6 +- .../core/consumers/test_consumer_utils.py | 6 +- .../libecalc/core/consumers/test_crossover.py | 2 +- tests/libecalc/core/consumers/test_genset.py | 2 +- .../core/consumers/test_legacy_consumer.py | 6 +- .../models/test_energy_function_results.py | 2 +- tests/libecalc/core/models/test_fuel_model.py | 2 +- .../libecalc/dto/test_electricity_consumer.py | 5 +- tests/libecalc/dto/test_fuel_consumer.py | 11 +- tests/libecalc/dto/test_generator_set.py | 15 +- .../input/mappers/test_model_mapper.py | 3 +- ...est_all_consumer_with_time_slots_models.py | 4 +- .../libecalc/output/flow_diagram/conftest.py | 19 +- .../flow_diagram/test_ecalc_model_mapper.py | 6 +- .../json_result/test_aggregators.py | 17 +- 71 files changed, 408 insertions(+), 362 deletions(-) delete mode 100644 src/libecalc/core/consumers/factory.py create mode 100644 src/libecalc/domain/infrastructure/__init__.py rename src/libecalc/{dto => domain/infrastructure}/components.py (77%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/__init__.py (100%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/base/__init__.py (100%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/base/component.py (100%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/compressor/__init__.py (100%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/compressor/component.py (97%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/consumer_system.py (99%) rename src/libecalc/{core/consumers/legacy_consumer => domain/infrastructure/energy_components/generator_set}/__init__.py (100%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components/generator_set}/generator_set.py (100%) create mode 100644 src/libecalc/domain/infrastructure/energy_components/legacy_consumer/__init__.py rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/legacy_consumer/component.py (97%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/legacy_consumer/consumer_function/__init__.py (100%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/legacy_consumer/consumer_function/compressor_consumer_function.py (97%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/legacy_consumer/consumer_function/consumer_function.py (96%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/legacy_consumer/consumer_function/consumer_tabular_energy_function.py (95%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/legacy_consumer/consumer_function/direct_expression_consumer_function.py (95%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/legacy_consumer/consumer_function/pump_consumer_function.py (95%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/legacy_consumer/consumer_function/results.py (97%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/legacy_consumer/consumer_function/types.py (100%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/legacy_consumer/consumer_function/utils.py (100%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/legacy_consumer/consumer_function_mapper/__init__.py (94%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/legacy_consumer/consumer_function_mapper/compressor_consumer_function.py (87%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/legacy_consumer/consumer_function_mapper/compressor_system_consumer_function.py (92%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/legacy_consumer/consumer_function_mapper/direct_consumer_function.py (79%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/legacy_consumer/consumer_function_mapper/pump_consumer_function.py (86%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/legacy_consumer/consumer_function_mapper/pump_system_consumer_function.py (88%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/legacy_consumer/consumer_function_mapper/tabulated.py (94%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/legacy_consumer/result_mapper.py (97%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/legacy_consumer/system/__init__.py (100%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/legacy_consumer/system/consumer_function.py (96%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/legacy_consumer/system/operational_setting.py (100%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/legacy_consumer/system/results.py (94%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/legacy_consumer/system/types.py (100%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/legacy_consumer/system/utils.py (96%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/pump/__init__.py (100%) rename src/libecalc/{core/consumers => domain/infrastructure/energy_components}/pump/component.py (98%) diff --git a/src/libecalc/application/energy_calculator.py b/src/libecalc/application/energy_calculator.py index 0302db4296..e11e9c00b1 100644 --- a/src/libecalc/application/energy_calculator.py +++ b/src/libecalc/application/energy_calculator.py @@ -1,37 +1,16 @@ import operator -from collections import defaultdict from functools import reduce from typing import Optional -import libecalc.dto.components from libecalc.application.energy.component_energy_context import ComponentEnergyContext from libecalc.application.energy.emitter import Emitter from libecalc.application.energy.energy_model import EnergyModel from libecalc.common.math.numbers import Numbers -from libecalc.common.priorities import PriorityID -from libecalc.common.priority_optimizer import PriorityOptimizer -from libecalc.common.temporal_model import TemporalModel -from libecalc.common.time_utils import Period from libecalc.common.units import Unit -from libecalc.common.utils.rates import TimeSeriesFloat, TimeSeriesInt, TimeSeriesStreamDayRate, TimeSeriesString +from libecalc.common.utils.rates import TimeSeriesFloat, TimeSeriesStreamDayRate from libecalc.common.variables import ExpressionEvaluator -from libecalc.core.consumers.consumer_system import ConsumerSystem -from libecalc.core.consumers.factory import create_consumer -from libecalc.core.consumers.generator_set import Genset -from libecalc.core.consumers.legacy_consumer.component import Consumer -from libecalc.core.consumers.legacy_consumer.consumer_function_mapper import EnergyModelMapper -from libecalc.core.models.generator import GeneratorModelSampled -from libecalc.core.result import ComponentResult, EcalcModelResult +from libecalc.core.result import EcalcModelResult from libecalc.core.result.emission import EmissionResult -from libecalc.dto.components import ( - ElectricityConsumer as ElectricityConsumerDTO, -) -from libecalc.dto.components import ( - FuelConsumer as FuelConsumerDTO, -) -from libecalc.dto.components import ( - GeneratorSet as GeneratorSetDTO, -) class Context(ComponentEnergyContext): @@ -89,126 +68,14 @@ def evaluate_energy_usage(self) -> dict[str, EcalcModelResult]: energy_components = self._energy_model.get_energy_components() for energy_component in energy_components: - if isinstance(energy_component, ElectricityConsumerDTO | FuelConsumerDTO): - consumer = Consumer( - id=energy_component.id, - name=energy_component.name, - component_type=energy_component.component_type, - regularity=TemporalModel(energy_component.regularity), - consumes=energy_component.consumes, - energy_usage_model=TemporalModel( - { - period: EnergyModelMapper.from_dto_to_domain(model) - for period, model in energy_component.energy_usage_model.items() - } - ), - ) - self._consumer_results[energy_component.id] = consumer.evaluate( - expression_evaluator=self._expression_evaluator - ) - elif isinstance(energy_component, GeneratorSetDTO): - fuel_consumer = Genset( - id=energy_component.id, - name=energy_component.name, - temporal_generator_set_model=TemporalModel( - { - period: GeneratorModelSampled( - fuel_values=model.fuel_values, - power_values=model.power_values, - energy_usage_adjustment_constant=model.energy_usage_adjustment_constant, - energy_usage_adjustment_factor=model.energy_usage_adjustment_factor, - ) - for period, model in energy_component.generator_set_model.items() - } - ), - ) - + if hasattr(energy_component, "evaluate_energy_usage"): context = self._get_context(energy_component.id) - - self._consumer_results[energy_component.id] = EcalcModelResult( - component_result=fuel_consumer.evaluate( - expression_evaluator=self._expression_evaluator, - power_requirement=context.get_power_requirement(), - ), - models=[], - sub_components=[], - ) - elif isinstance(energy_component, libecalc.dto.components.ConsumerSystem): - evaluated_stream_conditions = energy_component.evaluate_stream_conditions( - expression_evaluator=self._expression_evaluator, - ) - optimizer = PriorityOptimizer() - - results_per_period: dict[str, dict[Period, ComponentResult]] = defaultdict(dict) - priorities_used = [] - for period in self._expression_evaluator.get_periods(): - consumers_for_period = [ - create_consumer( - consumer=consumer, - period=period, - ) - for consumer in energy_component.consumers - ] - - consumer_system = ConsumerSystem( - id=energy_component.id, - consumers=consumers_for_period, - component_conditions=energy_component.component_conditions, - ) - - def evaluator(priority: PriorityID): - stream_conditions_for_priority = evaluated_stream_conditions[priority] - stream_conditions_for_timestep = { - component_id: [ - stream_condition.for_period(period) for stream_condition in stream_conditions - ] - for component_id, stream_conditions in stream_conditions_for_priority.items() - } - return consumer_system.evaluate_consumers(stream_conditions_for_timestep) - - optimizer_result = optimizer.optimize( - priorities=list(evaluated_stream_conditions.keys()), - evaluator=evaluator, + self._consumer_results.update( + energy_component.evaluate_energy_usage( + context=context, expression_evaluator=self._expression_evaluator ) - priorities_used.append(optimizer_result.priority_used) - for consumer_result in optimizer_result.priority_results: - results_per_period[consumer_result.id][period] = consumer_result - - priorities_used = TimeSeriesString( - periods=self._expression_evaluator.get_periods(), - values=priorities_used, - unit=Unit.NONE, - ) - # merge consumer results - consumer_ids = [consumer.id for consumer in energy_component.consumers] - merged_consumer_results = [] - for consumer_id in consumer_ids: - first_result, *rest_results = list(results_per_period[consumer_id].values()) - merged_consumer_results.append(first_result.merge(*rest_results)) - - # Convert to legacy compatible operational_settings_used - priorities_to_int_map = { - priority_name: index + 1 for index, priority_name in enumerate(evaluated_stream_conditions.keys()) - } - operational_settings_used = TimeSeriesInt( - periods=priorities_used.periods, - values=[priorities_to_int_map[priority_name] for priority_name in priorities_used.values], - unit=priorities_used.unit, ) - system_result = ConsumerSystem.get_system_result( - id=energy_component.id, - consumer_results=merged_consumer_results, - operational_settings_used=operational_settings_used, - ) - self._consumer_results[energy_component.id] = system_result - for consumer_result in merged_consumer_results: - self._consumer_results[consumer_result.id] = EcalcModelResult( - component_result=consumer_result, - sub_components=[], - models=[], - ) - self._consumer_results = Numbers.format_results_to_precision(self._consumer_results, precision=6) return self._consumer_results diff --git a/src/libecalc/core/consumers/factory.py b/src/libecalc/core/consumers/factory.py deleted file mode 100644 index 036ae9ccb8..0000000000 --- a/src/libecalc/core/consumers/factory.py +++ /dev/null @@ -1,51 +0,0 @@ -from typing import Union, overload - -from libecalc.common.component_type import ComponentType -from libecalc.common.time_utils import Period -from libecalc.core.consumers.compressor import Compressor -from libecalc.core.consumers.pump import Pump -from libecalc.core.models.compressor import create_compressor_model -from libecalc.core.models.pump import create_pump_model -from libecalc.dto.components import CompressorComponent, PumpComponent - - -@overload -def create_consumer(consumer: CompressorComponent, period: Period) -> Compressor: ... - - -@overload -def create_consumer(consumer: PumpComponent, period: Period) -> Pump: # type: ignore[misc] - ... - - -def create_consumer( - consumer: Union[CompressorComponent, PumpComponent], - period: Period, -) -> Union[Compressor, Pump]: - periods = consumer.energy_usage_model.keys() - energy_usage_models = list(consumer.energy_usage_model.values()) - - model_for_period = None - for _period, energy_usage_model in zip(periods, energy_usage_models): - if period in _period: - model_for_period = energy_usage_model - - if model_for_period is None: - raise ValueError(f"Could not find model for consumer {consumer.name} at timestep {period}") - - if consumer.component_type == ComponentType.COMPRESSOR: - return Compressor( - id=consumer.id, - compressor_model=create_compressor_model( - compressor_model_dto=model_for_period, - ), - ) - elif consumer.component_type == ComponentType.PUMP: - return Pump( - id=consumer.id, - pump_model=create_pump_model( - pump_model_dto=model_for_period, - ), - ) - else: - raise TypeError(f"Unknown consumer. Received consumer with type '{consumer.component_type}'") diff --git a/src/libecalc/domain/infrastructure/__init__.py b/src/libecalc/domain/infrastructure/__init__.py new file mode 100644 index 0000000000..89c600c4a8 --- /dev/null +++ b/src/libecalc/domain/infrastructure/__init__.py @@ -0,0 +1,8 @@ +from libecalc.domain.infrastructure.components import ( + Asset, + BaseConsumer, + ElectricityConsumer, + FuelConsumer, + GeneratorSet, + Installation, +) diff --git a/src/libecalc/dto/components.py b/src/libecalc/domain/infrastructure/components.py similarity index 77% rename from src/libecalc/dto/components.py rename to src/libecalc/domain/infrastructure/components.py index 91b5c69cde..13dd458987 100644 --- a/src/libecalc/dto/components.py +++ b/src/libecalc/domain/infrastructure/components.py @@ -1,7 +1,7 @@ from abc import ABC, abstractmethod from collections import defaultdict from datetime import datetime -from typing import Annotated, Any, Literal, Optional, TypeVar, Union +from typing import Annotated, Any, Literal, Optional, TypeVar, Union, overload import numpy as np from pydantic import ConfigDict, Field, field_validator, model_validator @@ -16,17 +16,35 @@ from libecalc.common.energy_usage_type import EnergyUsageType from libecalc.common.logger import logger from libecalc.common.priorities import Priorities +from libecalc.common.priority_optimizer import PriorityOptimizer from libecalc.common.stream_conditions import TimeSeriesStreamConditions from libecalc.common.string.string_utils import generate_id +from libecalc.common.temporal_model import TemporalModel from libecalc.common.time_utils import Period, Periods from libecalc.common.units import Unit from libecalc.common.utils.rates import ( RateType, TimeSeriesFloat, + TimeSeriesInt, TimeSeriesStreamDayRate, + TimeSeriesString, ) from libecalc.common.variables import ExpressionEvaluator +from libecalc.core.models.compressor import create_compressor_model +from libecalc.core.models.generator import GeneratorModelSampled +from libecalc.core.models.pump import create_pump_model +from libecalc.core.result import ComponentResult, EcalcModelResult from libecalc.core.result.emission import EmissionResult +from libecalc.domain.infrastructure.energy_components.compressor import Compressor +from libecalc.domain.infrastructure.energy_components.consumer_system import ( + ConsumerSystem as ConsumerSystemEnergyComponent, +) +from libecalc.domain.infrastructure.energy_components.generator_set.generator_set import Genset +from libecalc.domain.infrastructure.energy_components.legacy_consumer.component import ( + Consumer as ConsumerEnergyComponent, +) +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function_mapper import EnergyModelMapper +from libecalc.domain.infrastructure.energy_components.pump import Pump from libecalc.dto.base import ( EcalcBaseModel, ) @@ -170,6 +188,27 @@ def get_component_process_type(self) -> ComponentType: def get_name(self) -> str: return self.name + def evaluate_energy_usage( + self, expression_evaluator: ExpressionEvaluator, context: ComponentEnergyContext + ) -> dict[str, EcalcModelResult]: + consumer_results: dict[str, EcalcModelResult] = {} + consumer = ConsumerEnergyComponent( + id=self.id, + name=self.name, + component_type=self.component_type, + regularity=TemporalModel(self.regularity), + consumes=self.consumes, + energy_usage_model=TemporalModel( + { + period: EnergyModelMapper.from_dto_to_domain(model) + for period, model in self.energy_usage_model.items() + } + ), + ) + consumer_results[self.id] = consumer.evaluate(expression_evaluator=expression_evaluator) + + return consumer_results + @field_validator("energy_usage_model", mode="before") @classmethod def check_energy_usage_model(cls, energy_usage_model): @@ -214,6 +253,27 @@ def get_component_process_type(self) -> ComponentType: def get_name(self) -> str: return self.name + def evaluate_energy_usage( + self, expression_evaluator: ExpressionEvaluator, context: ComponentEnergyContext + ) -> dict[str, EcalcModelResult]: + consumer_results: dict[str, EcalcModelResult] = {} + consumer = ConsumerEnergyComponent( + id=self.id, + name=self.name, + component_type=self.component_type, + regularity=TemporalModel(self.regularity), + consumes=self.consumes, + energy_usage_model=TemporalModel( + { + period: EnergyModelMapper.from_dto_to_domain(model) + for period, model in self.energy_usage_model.items() + } + ), + ) + consumer_results[self.id] = consumer.evaluate(expression_evaluator=expression_evaluator) + + return consumer_results + def evaluate_emissions( self, energy_context: ComponentEnergyContext, @@ -396,6 +456,85 @@ def get_component_process_type(self) -> ComponentType: def get_name(self) -> str: return self.name + def evaluate_energy_usage( + self, expression_evaluator: ExpressionEvaluator, context: ComponentEnergyContext + ) -> dict[str, EcalcModelResult]: + consumer_results = {} + evaluated_stream_conditions = self.evaluate_stream_conditions( + expression_evaluator=expression_evaluator, + ) + optimizer = PriorityOptimizer() + + results_per_period: dict[str, dict[Period, ComponentResult]] = defaultdict(dict) + priorities_used = [] + for period in expression_evaluator.get_periods(): + consumers_for_period = [ + create_consumer( + consumer=consumer, + period=period, + ) + for consumer in self.consumers + ] + + consumer_system = ConsumerSystemEnergyComponent( + id=self.id, + consumers=consumers_for_period, + component_conditions=self.component_conditions, + ) + + def evaluator(priority: PriorityID): + stream_conditions_for_priority = evaluated_stream_conditions[priority] + stream_conditions_for_timestep = { + component_id: [stream_condition.for_period(period) for stream_condition in stream_conditions] + for component_id, stream_conditions in stream_conditions_for_priority.items() + } + return consumer_system.evaluate_consumers(stream_conditions_for_timestep) + + optimizer_result = optimizer.optimize( + priorities=list(evaluated_stream_conditions.keys()), + evaluator=evaluator, + ) + priorities_used.append(optimizer_result.priority_used) + for consumer_result in optimizer_result.priority_results: + results_per_period[consumer_result.id][period] = consumer_result + + priorities_used = TimeSeriesString( + periods=expression_evaluator.get_periods(), + values=priorities_used, + unit=Unit.NONE, + ) + # merge consumer results + consumer_ids = [consumer.id for consumer in self.consumers] + merged_consumer_results = [] + for consumer_id in consumer_ids: + first_result, *rest_results = list(results_per_period[consumer_id].values()) + merged_consumer_results.append(first_result.merge(*rest_results)) + + # Convert to legacy compatible operational_settings_used + priorities_to_int_map = { + priority_name: index + 1 for index, priority_name in enumerate(evaluated_stream_conditions.keys()) + } + operational_settings_used = TimeSeriesInt( + periods=priorities_used.periods, + values=[priorities_to_int_map[priority_name] for priority_name in priorities_used.values], + unit=priorities_used.unit, + ) + + system_result = ConsumerSystemEnergyComponent.get_system_result( + id=self.id, + consumer_results=merged_consumer_results, + operational_settings_used=operational_settings_used, + ) + consumer_results[self.id] = system_result + for consumer_result in merged_consumer_results: + consumer_results[consumer_result.id] = EcalcModelResult( + component_result=consumer_result, + sub_components=[], + models=[], + ) + + return consumer_results + def evaluate_emissions( self, energy_context: ComponentEnergyContext, @@ -508,6 +647,37 @@ def get_component_process_type(self) -> ComponentType: def get_name(self) -> str: return self.name + def evaluate_energy_usage( + self, expression_evaluator: ExpressionEvaluator, context: ComponentEnergyContext + ) -> dict[str, EcalcModelResult]: + consumer_results: dict[str, EcalcModelResult] = {} + fuel_consumer = Genset( + id=self.id, + name=self.name, + temporal_generator_set_model=TemporalModel( + { + period: GeneratorModelSampled( + fuel_values=model.fuel_values, + power_values=model.power_values, + energy_usage_adjustment_constant=model.energy_usage_adjustment_constant, + energy_usage_adjustment_factor=model.energy_usage_adjustment_factor, + ) + for period, model in self.generator_set_model.items() + } + ), + ) + + consumer_results[self.id] = EcalcModelResult( + component_result=fuel_consumer.evaluate( + expression_evaluator=expression_evaluator, + power_requirement=context.get_power_requirement(), + ), + models=[], + sub_components=[], + ) + + return consumer_results + def evaluate_emissions( self, energy_context: ComponentEnergyContext, @@ -799,3 +969,44 @@ def evaluate_emissions( ) return dict(sorted(emissions.items())) + + +@overload +def create_consumer(consumer: CompressorComponent, period: Period) -> Compressor: ... + + +@overload +def create_consumer(consumer: PumpComponent, period: Period) -> Pump: ... + + +def create_consumer( + consumer: Union[CompressorComponent, PumpComponent], + period: Period, +) -> Union[Compressor, Pump]: + periods = consumer.energy_usage_model.keys() + energy_usage_models = list(consumer.energy_usage_model.values()) + + model_for_period = None + for _period, energy_usage_model in zip(periods, energy_usage_models): + if period in _period: + model_for_period = energy_usage_model + + if model_for_period is None: + raise ValueError(f"Could not find model for consumer {consumer.name} at timestep {period}") + + if consumer.component_type == ComponentType.COMPRESSOR: + return Compressor( + id=consumer.id, + compressor_model=create_compressor_model( + compressor_model_dto=model_for_period, + ), + ) + elif consumer.component_type == ComponentType.PUMP: + return Pump( + id=consumer.id, + pump_model=create_pump_model( + pump_model_dto=model_for_period, + ), + ) + else: + raise TypeError(f"Unknown consumer. Received consumer with type '{consumer.component_type}'") diff --git a/src/libecalc/core/consumers/__init__.py b/src/libecalc/domain/infrastructure/energy_components/__init__.py similarity index 100% rename from src/libecalc/core/consumers/__init__.py rename to src/libecalc/domain/infrastructure/energy_components/__init__.py diff --git a/src/libecalc/core/consumers/base/__init__.py b/src/libecalc/domain/infrastructure/energy_components/base/__init__.py similarity index 100% rename from src/libecalc/core/consumers/base/__init__.py rename to src/libecalc/domain/infrastructure/energy_components/base/__init__.py diff --git a/src/libecalc/core/consumers/base/component.py b/src/libecalc/domain/infrastructure/energy_components/base/component.py similarity index 100% rename from src/libecalc/core/consumers/base/component.py rename to src/libecalc/domain/infrastructure/energy_components/base/component.py diff --git a/src/libecalc/core/consumers/compressor/__init__.py b/src/libecalc/domain/infrastructure/energy_components/compressor/__init__.py similarity index 100% rename from src/libecalc/core/consumers/compressor/__init__.py rename to src/libecalc/domain/infrastructure/energy_components/compressor/__init__.py diff --git a/src/libecalc/core/consumers/compressor/component.py b/src/libecalc/domain/infrastructure/energy_components/compressor/component.py similarity index 97% rename from src/libecalc/core/consumers/compressor/component.py rename to src/libecalc/domain/infrastructure/energy_components/compressor/component.py index 09f654d7dd..b5f47678bd 100644 --- a/src/libecalc/core/consumers/compressor/component.py +++ b/src/libecalc/domain/infrastructure/energy_components/compressor/component.py @@ -9,10 +9,10 @@ TimeSeriesBoolean, TimeSeriesStreamDayRate, ) -from libecalc.core.consumers.base import BaseConsumerWithoutOperationalSettings from libecalc.core.models.compressor import CompressorModel from libecalc.core.result import EcalcModelResult from libecalc.core.result import results as core_results +from libecalc.domain.infrastructure.energy_components.base import BaseConsumerWithoutOperationalSettings from libecalc.domain.stream_conditions import Pressure, StreamConditions diff --git a/src/libecalc/core/consumers/consumer_system.py b/src/libecalc/domain/infrastructure/energy_components/consumer_system.py similarity index 99% rename from src/libecalc/core/consumers/consumer_system.py rename to src/libecalc/domain/infrastructure/energy_components/consumer_system.py index 8cc5ed5f64..ea45c6d211 100644 --- a/src/libecalc/core/consumers/consumer_system.py +++ b/src/libecalc/domain/infrastructure/energy_components/consumer_system.py @@ -10,8 +10,8 @@ from libecalc.common.utils.rates import ( TimeSeriesInt, ) -from libecalc.core.consumers.base import BaseConsumerWithoutOperationalSettings from libecalc.core.result import ComponentResult, ConsumerSystemResult, EcalcModelResult +from libecalc.domain.infrastructure.energy_components.base import BaseConsumerWithoutOperationalSettings from libecalc.domain.stream_conditions import Rate, StreamConditions Consumer = TypeVar("Consumer", bound=BaseConsumerWithoutOperationalSettings) diff --git a/src/libecalc/core/consumers/legacy_consumer/__init__.py b/src/libecalc/domain/infrastructure/energy_components/generator_set/__init__.py similarity index 100% rename from src/libecalc/core/consumers/legacy_consumer/__init__.py rename to src/libecalc/domain/infrastructure/energy_components/generator_set/__init__.py diff --git a/src/libecalc/core/consumers/generator_set.py b/src/libecalc/domain/infrastructure/energy_components/generator_set/generator_set.py similarity index 100% rename from src/libecalc/core/consumers/generator_set.py rename to src/libecalc/domain/infrastructure/energy_components/generator_set/generator_set.py diff --git a/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/__init__.py b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/libecalc/core/consumers/legacy_consumer/component.py b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/component.py similarity index 97% rename from src/libecalc/core/consumers/legacy_consumer/component.py rename to src/libecalc/domain/infrastructure/energy_components/legacy_consumer/component.py index 0f3cc63f72..593176cdda 100644 --- a/src/libecalc/core/consumers/legacy_consumer/component.py +++ b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/component.py @@ -18,27 +18,27 @@ TimeSeriesStreamDayRate, ) from libecalc.common.variables import ExpressionEvaluator -from libecalc.core.consumers.base import BaseConsumer -from libecalc.core.consumers.legacy_consumer.consumer_function import ( +from libecalc.core.models.results import CompressorTrainResult +from libecalc.core.result import ConsumerSystemResult, EcalcModelResult +from libecalc.core.result.results import ( + CompressorResult, + ConsumerModelResult, + GenericComponentResult, + PumpResult, +) +from libecalc.domain.infrastructure.energy_components.base import BaseConsumer +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function import ( ConsumerFunction, ConsumerFunctionResult, ) -from libecalc.core.consumers.legacy_consumer.result_mapper import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.result_mapper import ( get_consumer_system_models, get_operational_settings_results_from_consumer_result, get_single_consumer_models, ) -from libecalc.core.consumers.legacy_consumer.system import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system import ( ConsumerSystemConsumerFunctionResult, ) -from libecalc.core.models.results import CompressorTrainResult -from libecalc.core.result import ConsumerSystemResult, EcalcModelResult -from libecalc.core.result.results import ( - CompressorResult, - ConsumerModelResult, - GenericComponentResult, - PumpResult, -) from libecalc.expression import Expression diff --git a/src/libecalc/core/consumers/legacy_consumer/consumer_function/__init__.py b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function/__init__.py similarity index 100% rename from src/libecalc/core/consumers/legacy_consumer/consumer_function/__init__.py rename to src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function/__init__.py diff --git a/src/libecalc/core/consumers/legacy_consumer/consumer_function/compressor_consumer_function.py b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function/compressor_consumer_function.py similarity index 97% rename from src/libecalc/core/consumers/legacy_consumer/consumer_function/compressor_consumer_function.py rename to src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function/compressor_consumer_function.py index 6302183d02..200ab56522 100644 --- a/src/libecalc/core/consumers/legacy_consumer/consumer_function/compressor_consumer_function.py +++ b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function/compressor_consumer_function.py @@ -4,16 +4,6 @@ from libecalc.common.utils.rates import Rates from libecalc.common.variables import ExpressionEvaluator -from libecalc.core.consumers.legacy_consumer.consumer_function import ( - ConsumerFunction, - ConsumerFunctionResult, -) -from libecalc.core.consumers.legacy_consumer.consumer_function.utils import ( - apply_condition, - apply_power_loss_factor, - get_condition_from_expression, - get_power_loss_factor_from_expression, -) from libecalc.core.models.compressor.base import ( CompressorModel, CompressorWithTurbineModel, @@ -22,6 +12,16 @@ VariableSpeedCompressorTrainCommonShaftMultipleStreamsAndPressures, ) from libecalc.core.models.results import CompressorTrainResult +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function import ( + ConsumerFunction, + ConsumerFunctionResult, +) +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function.utils import ( + apply_condition, + apply_power_loss_factor, + get_condition_from_expression, + get_power_loss_factor_from_expression, +) from libecalc.expression import Expression diff --git a/src/libecalc/core/consumers/legacy_consumer/consumer_function/consumer_function.py b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function/consumer_function.py similarity index 96% rename from src/libecalc/core/consumers/legacy_consumer/consumer_function/consumer_function.py rename to src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function/consumer_function.py index 7738868848..8cabed1791 100644 --- a/src/libecalc/core/consumers/legacy_consumer/consumer_function/consumer_function.py +++ b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function/consumer_function.py @@ -3,7 +3,7 @@ from abc import ABC, abstractmethod from libecalc.common.variables import ExpressionEvaluator -from libecalc.core.consumers.legacy_consumer.consumer_function.results import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function.results import ( ConsumerFunctionResult, ) from libecalc.expression import Expression diff --git a/src/libecalc/core/consumers/legacy_consumer/consumer_function/consumer_tabular_energy_function.py b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function/consumer_tabular_energy_function.py similarity index 95% rename from src/libecalc/core/consumers/legacy_consumer/consumer_function/consumer_tabular_energy_function.py rename to src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function/consumer_tabular_energy_function.py index 5105238d75..4c61791c4e 100644 --- a/src/libecalc/core/consumers/legacy_consumer/consumer_function/consumer_tabular_energy_function.py +++ b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function/consumer_tabular_energy_function.py @@ -3,21 +3,21 @@ from libecalc.common.list.list_utils import array_to_list from libecalc.common.utils.rates import Rates from libecalc.common.variables import ExpressionEvaluator -from libecalc.core.consumers.legacy_consumer.consumer_function import ( +from libecalc.core.models.tabulated import ( + ConsumerTabularEnergyFunction, + Variable, + VariableExpression, +) +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function import ( ConsumerFunction, ConsumerFunctionResult, ) -from libecalc.core.consumers.legacy_consumer.consumer_function.utils import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function.utils import ( apply_condition, apply_power_loss_factor, get_condition_from_expression, get_power_loss_factor_from_expression, ) -from libecalc.core.models.tabulated import ( - ConsumerTabularEnergyFunction, - Variable, - VariableExpression, -) from libecalc.expression import Expression diff --git a/src/libecalc/core/consumers/legacy_consumer/consumer_function/direct_expression_consumer_function.py b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function/direct_expression_consumer_function.py similarity index 95% rename from src/libecalc/core/consumers/legacy_consumer/consumer_function/direct_expression_consumer_function.py rename to src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function/direct_expression_consumer_function.py index 68b6ad1124..fc92455744 100644 --- a/src/libecalc/core/consumers/legacy_consumer/consumer_function/direct_expression_consumer_function.py +++ b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function/direct_expression_consumer_function.py @@ -7,17 +7,17 @@ from libecalc.common.units import Unit from libecalc.common.utils.rates import Rates, RateType from libecalc.common.variables import ExpressionEvaluator -from libecalc.core.consumers.legacy_consumer.consumer_function import ( +from libecalc.core.models.results import EnergyFunctionGenericResult +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function import ( ConsumerFunction, ConsumerFunctionResult, ) -from libecalc.core.consumers.legacy_consumer.consumer_function.utils import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function.utils import ( apply_condition, apply_power_loss_factor, get_condition_from_expression, get_power_loss_factor_from_expression, ) -from libecalc.core.models.results import EnergyFunctionGenericResult from libecalc.expression import Expression diff --git a/src/libecalc/core/consumers/legacy_consumer/consumer_function/pump_consumer_function.py b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function/pump_consumer_function.py similarity index 95% rename from src/libecalc/core/consumers/legacy_consumer/consumer_function/pump_consumer_function.py rename to src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function/pump_consumer_function.py index 2ecaca69e0..190bb8d217 100644 --- a/src/libecalc/core/consumers/legacy_consumer/consumer_function/pump_consumer_function.py +++ b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function/pump_consumer_function.py @@ -4,17 +4,17 @@ from libecalc.common.utils.rates import Rates from libecalc.common.variables import ExpressionEvaluator -from libecalc.core.consumers.legacy_consumer.consumer_function import ( +from libecalc.core.models.pump import PumpModel +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function import ( ConsumerFunction, ConsumerFunctionResult, ) -from libecalc.core.consumers.legacy_consumer.consumer_function.utils import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function.utils import ( apply_condition, apply_power_loss_factor, get_condition_from_expression, get_power_loss_factor_from_expression, ) -from libecalc.core.models.pump import PumpModel from libecalc.expression import Expression diff --git a/src/libecalc/core/consumers/legacy_consumer/consumer_function/results.py b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function/results.py similarity index 97% rename from src/libecalc/core/consumers/legacy_consumer/consumer_function/results.py rename to src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function/results.py index 5a950367b3..17370cc8ee 100644 --- a/src/libecalc/core/consumers/legacy_consumer/consumer_function/results.py +++ b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function/results.py @@ -9,11 +9,11 @@ from libecalc.common.logger import logger from libecalc.common.time_utils import Periods -from libecalc.core.consumers.legacy_consumer.consumer_function.types import ( - ConsumerFunctionType, -) from libecalc.core.models.results.base import EnergyFunctionResult from libecalc.core.utils.array_type import PydanticNDArray +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function.types import ( + ConsumerFunctionType, +) class ConsumerFunctionResultBase(BaseModel): diff --git a/src/libecalc/core/consumers/legacy_consumer/consumer_function/types.py b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function/types.py similarity index 100% rename from src/libecalc/core/consumers/legacy_consumer/consumer_function/types.py rename to src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function/types.py diff --git a/src/libecalc/core/consumers/legacy_consumer/consumer_function/utils.py b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function/utils.py similarity index 100% rename from src/libecalc/core/consumers/legacy_consumer/consumer_function/utils.py rename to src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function/utils.py diff --git a/src/libecalc/core/consumers/legacy_consumer/consumer_function_mapper/__init__.py b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function_mapper/__init__.py similarity index 94% rename from src/libecalc/core/consumers/legacy_consumer/consumer_function_mapper/__init__.py rename to src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function_mapper/__init__.py index 60ebf8b66c..f09bc3e943 100644 --- a/src/libecalc/core/consumers/legacy_consumer/consumer_function_mapper/__init__.py +++ b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function_mapper/__init__.py @@ -3,7 +3,7 @@ from libecalc.common.consumer_type import ConsumerType from libecalc.common.logger import logger -from libecalc.core.consumers.legacy_consumer.consumer_function import ConsumerFunction +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function import ConsumerFunction from libecalc.dto import ( CompressorConsumerFunction, CompressorSystemConsumerFunction, diff --git a/src/libecalc/core/consumers/legacy_consumer/consumer_function_mapper/compressor_consumer_function.py b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function_mapper/compressor_consumer_function.py similarity index 87% rename from src/libecalc/core/consumers/legacy_consumer/consumer_function_mapper/compressor_consumer_function.py rename to src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function_mapper/compressor_consumer_function.py index d6cf114c91..b51a0e179a 100644 --- a/src/libecalc/core/consumers/legacy_consumer/consumer_function_mapper/compressor_consumer_function.py +++ b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function_mapper/compressor_consumer_function.py @@ -1,7 +1,7 @@ -from libecalc.core.consumers.legacy_consumer.consumer_function.compressor_consumer_function import ( +from libecalc.core.models.compressor import create_compressor_model +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function.compressor_consumer_function import ( CompressorConsumerFunction, ) -from libecalc.core.models.compressor import create_compressor_model from libecalc.dto import CompressorConsumerFunction as CompressorConsumerFunctionDTO diff --git a/src/libecalc/core/consumers/legacy_consumer/consumer_function_mapper/compressor_system_consumer_function.py b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function_mapper/compressor_system_consumer_function.py similarity index 92% rename from src/libecalc/core/consumers/legacy_consumer/consumer_function_mapper/compressor_system_consumer_function.py rename to src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function_mapper/compressor_system_consumer_function.py index eb5221ba65..925addd7cd 100644 --- a/src/libecalc/core/consumers/legacy_consumer/consumer_function_mapper/compressor_system_consumer_function.py +++ b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function_mapper/compressor_system_consumer_function.py @@ -1,14 +1,14 @@ from typing import Optional -from libecalc.core.consumers.legacy_consumer.system.consumer_function import ( +from libecalc.core.models.compressor import create_compressor_model +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system.consumer_function import ( CompressorSystemConsumerFunction, ConsumerSystemConsumerFunction, ) -from libecalc.core.consumers.legacy_consumer.system.operational_setting import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system.operational_setting import ( CompressorSystemOperationalSettingExpressions, ) -from libecalc.core.consumers.legacy_consumer.system.types import ConsumerSystemComponent -from libecalc.core.models.compressor import create_compressor_model +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system.types import ConsumerSystemComponent from libecalc.dto import CompressorSystemConsumerFunction as CompressorSystemConsumerFunctionDTO from libecalc.dto import CompressorSystemOperationalSetting, SystemOperationalSetting from libecalc.expression import Expression diff --git a/src/libecalc/core/consumers/legacy_consumer/consumer_function_mapper/direct_consumer_function.py b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function_mapper/direct_consumer_function.py similarity index 79% rename from src/libecalc/core/consumers/legacy_consumer/consumer_function_mapper/direct_consumer_function.py rename to src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function_mapper/direct_consumer_function.py index 15842fcfdb..fe23af3ea6 100644 --- a/src/libecalc/core/consumers/legacy_consumer/consumer_function_mapper/direct_consumer_function.py +++ b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function_mapper/direct_consumer_function.py @@ -1,4 +1,4 @@ -from libecalc.core.consumers.legacy_consumer.consumer_function.direct_expression_consumer_function import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function.direct_expression_consumer_function import ( DirectExpressionConsumerFunction, ) from libecalc.dto import DirectConsumerFunction diff --git a/src/libecalc/core/consumers/legacy_consumer/consumer_function_mapper/pump_consumer_function.py b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function_mapper/pump_consumer_function.py similarity index 86% rename from src/libecalc/core/consumers/legacy_consumer/consumer_function_mapper/pump_consumer_function.py rename to src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function_mapper/pump_consumer_function.py index 63d1f146c3..ab78be664f 100644 --- a/src/libecalc/core/consumers/legacy_consumer/consumer_function_mapper/pump_consumer_function.py +++ b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function_mapper/pump_consumer_function.py @@ -1,7 +1,7 @@ -from libecalc.core.consumers.legacy_consumer.consumer_function.pump_consumer_function import ( +from libecalc.core.models.pump import create_pump_model +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function.pump_consumer_function import ( PumpConsumerFunction, ) -from libecalc.core.models.pump import create_pump_model from libecalc.dto import PumpConsumerFunction as PumpConsumerFunctionDTO diff --git a/src/libecalc/core/consumers/legacy_consumer/consumer_function_mapper/pump_system_consumer_function.py b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function_mapper/pump_system_consumer_function.py similarity index 88% rename from src/libecalc/core/consumers/legacy_consumer/consumer_function_mapper/pump_system_consumer_function.py rename to src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function_mapper/pump_system_consumer_function.py index ea2b372747..a7e8fd16bc 100644 --- a/src/libecalc/core/consumers/legacy_consumer/consumer_function_mapper/pump_system_consumer_function.py +++ b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function_mapper/pump_system_consumer_function.py @@ -1,14 +1,14 @@ from typing import Optional -from libecalc.core.consumers.legacy_consumer.system.consumer_function import ( +from libecalc.core.models.pump import create_pump_model +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system.consumer_function import ( ConsumerSystemConsumerFunction, PumpSystemConsumerFunction, ) -from libecalc.core.consumers.legacy_consumer.system.operational_setting import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system.operational_setting import ( PumpSystemOperationalSettingExpressions, ) -from libecalc.core.consumers.legacy_consumer.system.types import ConsumerSystemComponent -from libecalc.core.models.pump import create_pump_model +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system.types import ConsumerSystemComponent from libecalc.dto import PumpSystemConsumerFunction as PumpSystemConsumerFunctionDTO from libecalc.dto import PumpSystemOperationalSetting from libecalc.expression import Expression diff --git a/src/libecalc/core/consumers/legacy_consumer/consumer_function_mapper/tabulated.py b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function_mapper/tabulated.py similarity index 94% rename from src/libecalc/core/consumers/legacy_consumer/consumer_function_mapper/tabulated.py rename to src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function_mapper/tabulated.py index a039b91b18..6a86b18ea4 100644 --- a/src/libecalc/core/consumers/legacy_consumer/consumer_function_mapper/tabulated.py +++ b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/consumer_function_mapper/tabulated.py @@ -1,14 +1,14 @@ import numpy from libecalc.common.energy_usage_type import EnergyUsageType -from libecalc.core.consumers.legacy_consumer.consumer_function.consumer_tabular_energy_function import ( - TabulatedConsumerFunction, -) from libecalc.core.models.tabulated import ( ConsumerTabularEnergyFunction, Variable, VariableExpression, ) +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function.consumer_tabular_energy_function import ( + TabulatedConsumerFunction, +) from libecalc.dto import TabulatedConsumerFunction as TabulatedConsumerFunctionDTO diff --git a/src/libecalc/core/consumers/legacy_consumer/result_mapper.py b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/result_mapper.py similarity index 97% rename from src/libecalc/core/consumers/legacy_consumer/result_mapper.py rename to src/libecalc/domain/infrastructure/energy_components/legacy_consumer/result_mapper.py index 4ff776471c..68ca911aef 100644 --- a/src/libecalc/core/consumers/legacy_consumer/result_mapper.py +++ b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/result_mapper.py @@ -6,14 +6,14 @@ from libecalc.common.units import Unit from libecalc.common.utils.rates import TimeSeriesBoolean, TimeSeriesStreamDayRate from libecalc.core import result as core_results -from libecalc.core.consumers.legacy_consumer.consumer_function import ( +from libecalc.core.models.results import CompressorTrainResult, PumpModelResult +from libecalc.core.models.results.base import EnergyFunctionResult +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function import ( ConsumerFunctionResult, ) -from libecalc.core.consumers.legacy_consumer.system.results import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system.results import ( ConsumerSystemConsumerFunctionResult, ) -from libecalc.core.models.results import CompressorTrainResult, PumpModelResult -from libecalc.core.models.results.base import EnergyFunctionResult def get_single_consumer_models( diff --git a/src/libecalc/core/consumers/legacy_consumer/system/__init__.py b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/system/__init__.py similarity index 100% rename from src/libecalc/core/consumers/legacy_consumer/system/__init__.py rename to src/libecalc/domain/infrastructure/energy_components/legacy_consumer/system/__init__.py diff --git a/src/libecalc/core/consumers/legacy_consumer/system/consumer_function.py b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/system/consumer_function.py similarity index 96% rename from src/libecalc/core/consumers/legacy_consumer/system/consumer_function.py rename to src/libecalc/domain/infrastructure/energy_components/legacy_consumer/system/consumer_function.py index 5963bab35d..6e33d70076 100644 --- a/src/libecalc/core/consumers/legacy_consumer/system/consumer_function.py +++ b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/system/consumer_function.py @@ -9,33 +9,33 @@ from libecalc.common.list.list_utils import array_to_list from libecalc.common.logger import logger from libecalc.common.variables import ExpressionEvaluator -from libecalc.core.consumers.legacy_consumer.consumer_function import ConsumerFunction -from libecalc.core.consumers.legacy_consumer.consumer_function.utils import ( +from libecalc.core.models.compressor.base import CompressorModel +from libecalc.core.models.pump import PumpModel +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function import ConsumerFunction +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function.utils import ( apply_condition, apply_power_loss_factor, get_condition_from_expression, get_power_loss_factor_from_expression, ) -from libecalc.core.consumers.legacy_consumer.system.operational_setting import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system.operational_setting import ( CompressorSystemOperationalSetting, ConsumerSystemOperationalSetting, ConsumerSystemOperationalSettingExpressions, PumpSystemOperationalSetting, ) -from libecalc.core.consumers.legacy_consumer.system.results import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system.results import ( CompressorResult, ConsumerSystemComponentResult, ConsumerSystemConsumerFunctionResult, ConsumerSystemOperationalSettingResult, PumpResult, ) -from libecalc.core.consumers.legacy_consumer.system.types import ConsumerSystemComponent -from libecalc.core.consumers.legacy_consumer.system.utils import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system.types import ConsumerSystemComponent +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system.utils import ( assemble_operational_setting_from_model_result_list, get_operational_settings_number_used_from_model_results, ) -from libecalc.core.models.compressor.base import CompressorModel -from libecalc.core.models.pump import PumpModel from libecalc.expression import Expression diff --git a/src/libecalc/core/consumers/legacy_consumer/system/operational_setting.py b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/system/operational_setting.py similarity index 100% rename from src/libecalc/core/consumers/legacy_consumer/system/operational_setting.py rename to src/libecalc/domain/infrastructure/energy_components/legacy_consumer/system/operational_setting.py diff --git a/src/libecalc/core/consumers/legacy_consumer/system/results.py b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/system/results.py similarity index 94% rename from src/libecalc/core/consumers/legacy_consumer/system/results.py rename to src/libecalc/domain/infrastructure/energy_components/legacy_consumer/system/results.py index 985dc063f6..4417085bb3 100644 --- a/src/libecalc/core/consumers/legacy_consumer/system/results.py +++ b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/system/results.py @@ -9,18 +9,18 @@ from libecalc.common.logger import logger from libecalc.common.time_utils import Periods -from libecalc.core.consumers.legacy_consumer.consumer_function.results import ( +from libecalc.core.models.results import CompressorTrainResult, PumpModelResult +from libecalc.core.result.results import ConsumerModelResult +from libecalc.core.utils.array_type import PydanticNDArray +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function.results import ( ConsumerFunctionResultBase, ) -from libecalc.core.consumers.legacy_consumer.consumer_function.types import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function.types import ( ConsumerFunctionType, ) -from libecalc.core.consumers.legacy_consumer.system.operational_setting import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system.operational_setting import ( ConsumerSystemOperationalSetting, ) -from libecalc.core.models.results import CompressorTrainResult, PumpModelResult -from libecalc.core.result.results import ConsumerModelResult -from libecalc.core.utils.array_type import PydanticNDArray class ConsumerSystemComponentResult(BaseModel): diff --git a/src/libecalc/core/consumers/legacy_consumer/system/types.py b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/system/types.py similarity index 100% rename from src/libecalc/core/consumers/legacy_consumer/system/types.py rename to src/libecalc/domain/infrastructure/energy_components/legacy_consumer/system/types.py diff --git a/src/libecalc/core/consumers/legacy_consumer/system/utils.py b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/system/utils.py similarity index 96% rename from src/libecalc/core/consumers/legacy_consumer/system/utils.py rename to src/libecalc/domain/infrastructure/energy_components/legacy_consumer/system/utils.py index 3e34d99c0d..0628d997ac 100644 --- a/src/libecalc/core/consumers/legacy_consumer/system/utils.py +++ b/src/libecalc/domain/infrastructure/energy_components/legacy_consumer/system/utils.py @@ -3,10 +3,10 @@ from libecalc.common.list.list_utils import array_to_list from libecalc.common.logger import logger -from libecalc.core.consumers.legacy_consumer.system.operational_setting import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system.operational_setting import ( ConsumerSystemOperationalSetting, ) -from libecalc.core.consumers.legacy_consumer.system.results import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system.results import ( ConsumerSystemOperationalSettingResult, ) diff --git a/src/libecalc/core/consumers/pump/__init__.py b/src/libecalc/domain/infrastructure/energy_components/pump/__init__.py similarity index 100% rename from src/libecalc/core/consumers/pump/__init__.py rename to src/libecalc/domain/infrastructure/energy_components/pump/__init__.py diff --git a/src/libecalc/core/consumers/pump/component.py b/src/libecalc/domain/infrastructure/energy_components/pump/component.py similarity index 98% rename from src/libecalc/core/consumers/pump/component.py rename to src/libecalc/domain/infrastructure/energy_components/pump/component.py index 2c1b5f702d..1965e551cc 100644 --- a/src/libecalc/core/consumers/pump/component.py +++ b/src/libecalc/domain/infrastructure/energy_components/pump/component.py @@ -10,10 +10,10 @@ TimeSeriesFloat, TimeSeriesStreamDayRate, ) -from libecalc.core.consumers.base import BaseConsumerWithoutOperationalSettings from libecalc.core.models.pump import PumpModel from libecalc.core.result import EcalcModelResult from libecalc.core.result import results as core_results +from libecalc.domain.infrastructure.energy_components.base import BaseConsumerWithoutOperationalSettings from libecalc.domain.stream_conditions import Pressure, StreamConditions diff --git a/src/libecalc/dto/__init__.py b/src/libecalc/dto/__init__.py index c35778cce7..d845d38131 100644 --- a/src/libecalc/dto/__init__.py +++ b/src/libecalc/dto/__init__.py @@ -1,11 +1,3 @@ -from libecalc.dto.components import ( - Asset, - BaseConsumer, - ElectricityConsumer, - FuelConsumer, - GeneratorSet, - Installation, -) from libecalc.dto.emission import Emission from libecalc.dto.fuel_type import FuelType from libecalc.dto.models import ( diff --git a/src/libecalc/fixtures/case_types.py b/src/libecalc/fixtures/case_types.py index f72075f48b..8d7641eb8e 100644 --- a/src/libecalc/fixtures/case_types.py +++ b/src/libecalc/fixtures/case_types.py @@ -6,7 +6,7 @@ from ecalc_cli.infrastructure.file_resource_service import FileResourceService from libecalc.common.time_utils import Frequency from libecalc.common.variables import VariablesMap -from libecalc.dto import Asset +from libecalc.domain.infrastructure import Asset from libecalc.presentation.yaml.file_configuration_service import FileConfigurationService from libecalc.presentation.yaml.model import YamlModel from libecalc.presentation.yaml.yaml_entities import MemoryResource diff --git a/src/libecalc/fixtures/cases/consumer_with_time_slots_models.py b/src/libecalc/fixtures/cases/consumer_with_time_slots_models.py index d972959d4d..a0ac28b77f 100644 --- a/src/libecalc/fixtures/cases/consumer_with_time_slots_models.py +++ b/src/libecalc/fixtures/cases/consumer_with_time_slots_models.py @@ -9,19 +9,21 @@ from libecalc.common.serializable_chart import SingleSpeedChartDTO from libecalc.common.time_utils import Period from libecalc.common.variables import VariablesMap -from libecalc.dto import ( +from libecalc.domain.infrastructure import ( Asset, + ElectricityConsumer, + FuelConsumer, + GeneratorSet, + Installation, +) +from libecalc.dto import ( CompressorConsumerFunction, CompressorStage, CompressorSystemCompressor, CompressorSystemConsumerFunction, CompressorSystemOperationalSetting, DirectConsumerFunction, - ElectricityConsumer, - FuelConsumer, - GeneratorSet, GeneratorSetSampled, - Installation, SingleSpeedCompressorTrain, TabulatedConsumerFunction, TabulatedData, diff --git a/src/libecalc/presentation/exporter/infrastructure.py b/src/libecalc/presentation/exporter/infrastructure.py index bd03c48bea..486be485d4 100644 --- a/src/libecalc/presentation/exporter/infrastructure.py +++ b/src/libecalc/presentation/exporter/infrastructure.py @@ -11,7 +11,7 @@ from libecalc.common.units import Unit from libecalc.common.utils.rates import TimeSeries, TimeSeriesFloat, TimeSeriesRate, TimeSeriesStreamDayRate from libecalc.core.result import GeneratorSetResult -from libecalc.dto import FuelConsumer, GeneratorSet +from libecalc.domain.infrastructure.components import FuelConsumer, GeneratorSet from libecalc.dto.utils.validators import convert_expression from libecalc.presentation.exporter.domain.exportable import ( Attribute, diff --git a/src/libecalc/presentation/json_result/mapper.py b/src/libecalc/presentation/json_result/mapper.py index 06f8ea0099..b897ef6935 100644 --- a/src/libecalc/presentation/json_result/mapper.py +++ b/src/libecalc/presentation/json_result/mapper.py @@ -26,6 +26,7 @@ ) from libecalc.common.variables import ExpressionEvaluator from libecalc.core.result.emission import EmissionResult +from libecalc.domain.infrastructure import components from libecalc.dto import CompressorSystemConsumerFunction from libecalc.expression import Expression from libecalc.presentation.json_result.aggregators import ( @@ -365,7 +366,7 @@ def get_asset_result(graph_result: GraphResult) -> libecalc.presentation.json_re asset_id = graph_result.graph.root asset = graph_result.graph.get_node(asset_id) - if not isinstance(asset, libecalc.dto.Asset): + if not isinstance(asset, components.Asset): raise ProgrammingError("Need an asset graph to get asset result") installation_results = _evaluate_installations( diff --git a/src/libecalc/presentation/yaml/mappers/component_mapper.py b/src/libecalc/presentation/yaml/mappers/component_mapper.py index 57fe12426e..579bec6aa3 100644 --- a/src/libecalc/presentation/yaml/mappers/component_mapper.py +++ b/src/libecalc/presentation/yaml/mappers/component_mapper.py @@ -8,8 +8,15 @@ from libecalc.common.energy_model_type import EnergyModelType from libecalc.common.logger import logger from libecalc.common.time_utils import Period, define_time_model_for_period +from libecalc.domain.infrastructure.components import ( + Asset, + Consumer, + ElectricityConsumer, + FuelConsumer, + GeneratorSet, + Installation, +) from libecalc.dto import ConsumerFunction, FuelType -from libecalc.dto.components import Asset, Consumer, ElectricityConsumer, FuelConsumer, GeneratorSet, Installation from libecalc.dto.utils.validators import convert_expression from libecalc.expression import Expression from libecalc.presentation.yaml.domain.reference_service import InvalidReferenceException, ReferenceService diff --git a/src/libecalc/presentation/yaml/yaml_types/components/system/yaml_consumer_system.py b/src/libecalc/presentation/yaml/yaml_types/components/system/yaml_consumer_system.py index a4b318ec1b..00ee2c21ad 100644 --- a/src/libecalc/presentation/yaml/yaml_types/components/system/yaml_consumer_system.py +++ b/src/libecalc/presentation/yaml/yaml_types/components/system/yaml_consumer_system.py @@ -6,8 +6,8 @@ from libecalc.common.component_type import ComponentType from libecalc.common.consumption_type import ConsumptionType from libecalc.common.time_utils import Period, define_time_model_for_period +from libecalc.domain.infrastructure.components import ConsumerSystem, Crossover, SystemComponentConditions from libecalc.dto import FuelType -from libecalc.dto.components import ConsumerSystem, Crossover, SystemComponentConditions from libecalc.expression import Expression from libecalc.presentation.yaml.domain.reference_service import ReferenceService from libecalc.presentation.yaml.yaml_types.components.system.yaml_system_component_conditions import ( diff --git a/src/libecalc/presentation/yaml/yaml_types/components/train/yaml_train.py b/src/libecalc/presentation/yaml/yaml_types/components/train/yaml_train.py index 75b9f6fe2d..8ec2c844e0 100644 --- a/src/libecalc/presentation/yaml/yaml_types/components/train/yaml_train.py +++ b/src/libecalc/presentation/yaml/yaml_types/components/train/yaml_train.py @@ -7,7 +7,7 @@ from libecalc.common.component_type import ComponentType from libecalc.common.consumption_type import ConsumptionType from libecalc.common.time_utils import Period -from libecalc.dto.components import Stream, TrainComponent +from libecalc.domain.infrastructure.components import Stream, TrainComponent from libecalc.expression import Expression from libecalc.presentation.yaml.domain.reference_service import ReferenceService from libecalc.presentation.yaml.yaml_types.components.yaml_base import YamlConsumerBase diff --git a/src/libecalc/presentation/yaml/yaml_types/components/yaml_compressor.py b/src/libecalc/presentation/yaml/yaml_types/components/yaml_compressor.py index 54f2b9c1e4..9fb265393a 100644 --- a/src/libecalc/presentation/yaml/yaml_types/components/yaml_compressor.py +++ b/src/libecalc/presentation/yaml/yaml_types/components/yaml_compressor.py @@ -6,8 +6,8 @@ from libecalc.common.component_type import ComponentType from libecalc.common.consumption_type import ConsumptionType from libecalc.common.time_utils import Period, define_time_model_for_period +from libecalc.domain.infrastructure.components import CompressorComponent from libecalc.dto import FuelType -from libecalc.dto.components import CompressorComponent from libecalc.expression import Expression from libecalc.presentation.yaml.domain.reference_service import ReferenceService from libecalc.presentation.yaml.yaml_types.components.yaml_base import ( diff --git a/src/libecalc/presentation/yaml/yaml_types/components/yaml_pump.py b/src/libecalc/presentation/yaml/yaml_types/components/yaml_pump.py index f25a730de0..4c68ae6c16 100644 --- a/src/libecalc/presentation/yaml/yaml_types/components/yaml_pump.py +++ b/src/libecalc/presentation/yaml/yaml_types/components/yaml_pump.py @@ -6,8 +6,8 @@ from libecalc.common.component_type import ComponentType from libecalc.common.consumption_type import ConsumptionType from libecalc.common.time_utils import Period, define_time_model_for_period +from libecalc.domain.infrastructure.components import PumpComponent from libecalc.dto import FuelType -from libecalc.dto.components import PumpComponent from libecalc.expression import Expression from libecalc.presentation.yaml.domain.reference_service import ReferenceService from libecalc.presentation.yaml.yaml_types.components.yaml_base import ( diff --git a/tests/libecalc/core/consumers/conftest.py b/tests/libecalc/core/consumers/conftest.py index 8e92d6a0fc..89b51d88ff 100644 --- a/tests/libecalc/core/consumers/conftest.py +++ b/tests/libecalc/core/consumers/conftest.py @@ -4,6 +4,7 @@ import libecalc.common.energy_usage_type from libecalc import dto +from libecalc.domain.infrastructure import components from libecalc.common.component_type import ComponentType from libecalc.common.time_utils import Period from libecalc.common.utils.rates import RateType @@ -30,7 +31,7 @@ def variables_map(methane_values): @pytest.fixture -def tabulated_fuel_consumer(fuel_gas) -> dto.FuelConsumer: +def tabulated_fuel_consumer(fuel_gas) -> components.FuelConsumer: tabulated = dto.TabulatedConsumerFunction( model=dto.TabulatedData( headers=["RATE", "FUEL"], @@ -41,7 +42,7 @@ def tabulated_fuel_consumer(fuel_gas) -> dto.FuelConsumer: variables=[dto.Variables(name="RATE", expression=Expression.setup_from_expression(value="RATE"))], energy_usage_type=libecalc.common.energy_usage_type.EnergyUsageType.FUEL, ) - return dto.FuelConsumer( + return components.FuelConsumer( name="fuel_consumer", component_type=ComponentType.GENERIC, fuel=fuel_gas, @@ -52,8 +53,8 @@ def tabulated_fuel_consumer(fuel_gas) -> dto.FuelConsumer: @pytest.fixture -def direct_el_consumer() -> dto.ElectricityConsumer: - return dto.ElectricityConsumer( +def direct_el_consumer() -> components.ElectricityConsumer: + return components.ElectricityConsumer( name="direct_consumer", component_type=ComponentType.GENERIC, user_defined_category={Period(datetime(1900, 1, 1)): "FIXED-PRODUCTION-LOAD"}, @@ -104,8 +105,8 @@ def generator_set_sampled_model_1000mw() -> dto.GeneratorSetSampled: @pytest.fixture -def genset_2mw_dto(fuel_dto, direct_el_consumer, generator_set_sampled_model_2mw) -> dto.GeneratorSet: - return dto.GeneratorSet( +def genset_2mw_dto(fuel_dto, direct_el_consumer, generator_set_sampled_model_2mw) -> components.GeneratorSet: + return components.GeneratorSet( name="genset", user_defined_category={Period(datetime(1900, 1, 1)): "TURBINE-GENERATOR"}, fuel={Period(datetime(1900, 1, 1)): fuel_dto}, @@ -120,8 +121,8 @@ def genset_2mw_dto(fuel_dto, direct_el_consumer, generator_set_sampled_model_2mw @pytest.fixture def genset_1000mw_late_startup_dto( fuel_dto, direct_el_consumer, generator_set_sampled_model_1000mw -) -> dto.GeneratorSet: - return dto.GeneratorSet( +) -> components.GeneratorSet: + return components.GeneratorSet( name="genset_late_startup", user_defined_category={Period(datetime(1900, 1, 1)): "TURBINE-GENERATOR"}, fuel={Period(datetime(1900, 1, 1)): fuel_dto}, diff --git a/tests/libecalc/core/consumers/consumer_function/test_consumer_function.py b/tests/libecalc/core/consumers/consumer_function/test_consumer_function.py index e3bc5d89fb..3192eafac9 100644 --- a/tests/libecalc/core/consumers/consumer_function/test_consumer_function.py +++ b/tests/libecalc/core/consumers/consumer_function/test_consumer_function.py @@ -4,10 +4,10 @@ from libecalc.common.time_utils import Periods from libecalc.common.units import Unit -from libecalc.core.consumers.legacy_consumer.consumer_function import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function import ( ConsumerFunctionResult, ) -from libecalc.core.consumers.legacy_consumer.consumer_function.types import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function.types import ( ConsumerFunctionType, ) from libecalc.core.models.results import EnergyFunctionGenericResult diff --git a/tests/libecalc/core/consumers/consumer_function/test_direct_expression_consumer_function.py b/tests/libecalc/core/consumers/consumer_function/test_direct_expression_consumer_function.py index 3e8459a1ee..081d6e03f5 100644 --- a/tests/libecalc/core/consumers/consumer_function/test_direct_expression_consumer_function.py +++ b/tests/libecalc/core/consumers/consumer_function/test_direct_expression_consumer_function.py @@ -10,8 +10,8 @@ from libecalc.common.temporal_model import TemporalModel from libecalc.common.time_utils import Period from libecalc.common.variables import VariablesMap -from libecalc.core.consumers.legacy_consumer.component import Consumer -from libecalc.core.consumers.legacy_consumer.consumer_function.direct_expression_consumer_function import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.component import Consumer +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function.direct_expression_consumer_function import ( DirectExpressionConsumerFunction, ) from libecalc.expression import Expression diff --git a/tests/libecalc/core/consumers/system/conftest.py b/tests/libecalc/core/consumers/system/conftest.py index 886cef6613..c5a8fb79c6 100644 --- a/tests/libecalc/core/consumers/system/conftest.py +++ b/tests/libecalc/core/consumers/system/conftest.py @@ -5,18 +5,18 @@ from libecalc.common.time_utils import Period, Periods from libecalc.common.units import Unit -from libecalc.core.consumers.legacy_consumer.system.consumer_function import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system.consumer_function import ( CompressorSystemConsumerFunction, PumpSystemConsumerFunction, ) -from libecalc.core.consumers.legacy_consumer.system.operational_setting import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system.operational_setting import ( CompressorSystemOperationalSettingExpressions, PumpSystemOperationalSettingExpressions, ) -from libecalc.core.consumers.legacy_consumer.system.results import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system.results import ( ConsumerSystemConsumerFunctionResult, ) -from libecalc.core.consumers.legacy_consumer.system.types import ConsumerSystemComponent +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system.types import ConsumerSystemComponent from libecalc.core.models.chart.chart_area_flag import ChartAreaFlag from libecalc.core.models.results import ( CompressorStageResult, diff --git a/tests/libecalc/core/consumers/system/test_consumer_system.py b/tests/libecalc/core/consumers/system/test_consumer_system.py index 384b147d72..b2d1ffdad1 100644 --- a/tests/libecalc/core/consumers/system/test_consumer_system.py +++ b/tests/libecalc/core/consumers/system/test_consumer_system.py @@ -8,22 +8,22 @@ from libecalc.common.errors.exceptions import EcalcError from libecalc.common.serializable_chart import SingleSpeedChartDTO from libecalc.common.variables import VariablesMap -from libecalc.core.consumers.legacy_consumer.consumer_function.pump_consumer_function import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function.pump_consumer_function import ( PumpConsumerFunction, ) -from libecalc.core.consumers.legacy_consumer.system.consumer_function import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system.consumer_function import ( CompressorSystemConsumerFunction, ConsumerSystemConsumerFunction, PumpSystemConsumerFunction, ) -from libecalc.core.consumers.legacy_consumer.system.operational_setting import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system.operational_setting import ( CompressorSystemOperationalSetting, CompressorSystemOperationalSettingExpressions, ConsumerSystemOperationalSettingExpressions, PumpSystemOperationalSetting, PumpSystemOperationalSettingExpressions, ) -from libecalc.core.consumers.legacy_consumer.system.types import ConsumerSystemComponent +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system.types import ConsumerSystemComponent from libecalc.core.models.chart import SingleSpeedChart from libecalc.core.models.pump import PumpSingleSpeed from libecalc.expression import Expression diff --git a/tests/libecalc/core/consumers/system/test_operational_setting.py b/tests/libecalc/core/consumers/system/test_operational_setting.py index 7de7be8889..362a3d79b4 100644 --- a/tests/libecalc/core/consumers/system/test_operational_setting.py +++ b/tests/libecalc/core/consumers/system/test_operational_setting.py @@ -4,7 +4,7 @@ import pytest from libecalc.common.errors.exceptions import EcalcError -from libecalc.core.consumers.legacy_consumer.system.operational_setting import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system.operational_setting import ( ConsumerSystemOperationalSetting, ConsumerSystemOperationalSettingExpressions, ) diff --git a/tests/libecalc/core/consumers/system/test_system_results.py b/tests/libecalc/core/consumers/system/test_system_results.py index 17391d5a49..8d7d560bdf 100644 --- a/tests/libecalc/core/consumers/system/test_system_results.py +++ b/tests/libecalc/core/consumers/system/test_system_results.py @@ -1,6 +1,6 @@ import numpy as np -from libecalc.core.consumers.legacy_consumer.system.results import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system.results import ( ConsumerSystemComponentResult, ConsumerSystemConsumerFunctionResult, ConsumerSystemOperationalSettingResult, diff --git a/tests/libecalc/core/consumers/system/test_system_utils.py b/tests/libecalc/core/consumers/system/test_system_utils.py index 32435df6bf..15efa55382 100644 --- a/tests/libecalc/core/consumers/system/test_system_utils.py +++ b/tests/libecalc/core/consumers/system/test_system_utils.py @@ -1,14 +1,14 @@ import numpy as np from libecalc.common.units import Unit -from libecalc.core.consumers.legacy_consumer.system.operational_setting import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system.operational_setting import ( ConsumerSystemOperationalSetting, ) -from libecalc.core.consumers.legacy_consumer.system.results import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system.results import ( ConsumerSystemComponentResult, ConsumerSystemOperationalSettingResult, ) -from libecalc.core.consumers.legacy_consumer.system.utils import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.system.utils import ( assemble_operational_setting_from_model_result_list, get_operational_settings_number_used_from_model_results, ) diff --git a/tests/libecalc/core/consumers/test_consumer_utils.py b/tests/libecalc/core/consumers/test_consumer_utils.py index 7083ffa74c..d37a9fdf66 100644 --- a/tests/libecalc/core/consumers/test_consumer_utils.py +++ b/tests/libecalc/core/consumers/test_consumer_utils.py @@ -3,11 +3,11 @@ import numpy as np from libecalc.common.string.string_utils import generate_id -from libecalc.core.consumers.consumer_system import ConsumerSystem -from libecalc.core.consumers.legacy_consumer.consumer_function.utils import ( +from libecalc.domain.infrastructure.energy_components.consumer_system import ConsumerSystem +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function.utils import ( apply_condition, ) -from libecalc.dto.components import Crossover +from libecalc.domain.infrastructure.components import Crossover @dataclass diff --git a/tests/libecalc/core/consumers/test_crossover.py b/tests/libecalc/core/consumers/test_crossover.py index 168991d74a..6cad9932f9 100644 --- a/tests/libecalc/core/consumers/test_crossover.py +++ b/tests/libecalc/core/consumers/test_crossover.py @@ -4,7 +4,7 @@ from libecalc.common.time_utils import Period from libecalc.common.units import Unit -from libecalc.core.consumers.consumer_system import ConsumerSystem +from libecalc.domain.infrastructure.energy_components.consumer_system import ConsumerSystem from libecalc.domain.stream_conditions import Pressure, Rate, StreamConditions diff --git a/tests/libecalc/core/consumers/test_genset.py b/tests/libecalc/core/consumers/test_genset.py index c9f60f88b9..6b6dec1dd6 100644 --- a/tests/libecalc/core/consumers/test_genset.py +++ b/tests/libecalc/core/consumers/test_genset.py @@ -12,7 +12,7 @@ TimeSeriesStreamDayRate, ) from libecalc.common.variables import VariablesMap -from libecalc.core.consumers.generator_set import Genset +from libecalc.domain.infrastructure.energy_components.generator_set.generator_set import Genset from libecalc.core.models.generator import GeneratorModelSampled from libecalc.core.result.results import GenericComponentResult diff --git a/tests/libecalc/core/consumers/test_legacy_consumer.py b/tests/libecalc/core/consumers/test_legacy_consumer.py index 27c2467405..042ab98d32 100644 --- a/tests/libecalc/core/consumers/test_legacy_consumer.py +++ b/tests/libecalc/core/consumers/test_legacy_consumer.py @@ -13,11 +13,11 @@ TimeSeriesStreamDayRate, ) from libecalc.common.variables import VariablesMap -from libecalc.core.consumers.legacy_consumer.component import Consumer -from libecalc.core.consumers.legacy_consumer.consumer_function import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.component import Consumer +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function import ( ConsumerFunctionResult, ) -from libecalc.core.consumers.legacy_consumer.consumer_function_mapper import EnergyModelMapper +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function_mapper import EnergyModelMapper from libecalc.core.result import EcalcModelResult diff --git a/tests/libecalc/core/models/test_energy_function_results.py b/tests/libecalc/core/models/test_energy_function_results.py index 57f7dc7ef9..2d0dbfd5f7 100644 --- a/tests/libecalc/core/models/test_energy_function_results.py +++ b/tests/libecalc/core/models/test_energy_function_results.py @@ -6,7 +6,7 @@ import libecalc.dto as dto from libecalc.common.units import Unit from libecalc.common.variables import VariablesMap -from libecalc.core.consumers.legacy_consumer.consumer_function.compressor_consumer_function import ( +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function.compressor_consumer_function import ( CompressorConsumerFunction, ) from libecalc.core.models.compressor.sampled import CompressorModelSampled diff --git a/tests/libecalc/core/models/test_fuel_model.py b/tests/libecalc/core/models/test_fuel_model.py index 167c7ea4eb..676fd6ea9d 100644 --- a/tests/libecalc/core/models/test_fuel_model.py +++ b/tests/libecalc/core/models/test_fuel_model.py @@ -8,7 +8,7 @@ from libecalc.common.units import Unit from libecalc.common.utils.rates import RateType, TimeSeriesRate from libecalc.common.variables import VariablesMap -from libecalc.dto.components import FuelModel +from libecalc.domain.infrastructure.components import FuelModel from libecalc.expression import Expression diff --git a/tests/libecalc/dto/test_electricity_consumer.py b/tests/libecalc/dto/test_electricity_consumer.py index b5c9ab7e9d..08f42cf5ec 100644 --- a/tests/libecalc/dto/test_electricity_consumer.py +++ b/tests/libecalc/dto/test_electricity_consumer.py @@ -4,6 +4,7 @@ from pydantic import ValidationError from libecalc import dto +from libecalc.domain.infrastructure import components from libecalc.common.component_type import ComponentType from libecalc.common.energy_usage_type import EnergyUsageType from libecalc.common.time_utils import Period @@ -13,7 +14,7 @@ class TestElectricityConsumer: def test_invalid_energy_usage(self): with pytest.raises(ValidationError) as e: - dto.ElectricityConsumer( + components.ElectricityConsumer( name="Test", component_type=ComponentType.GENERIC, user_defined_category={Period(datetime(1900, 1, 1)): "MISCELLANEOUS"}, @@ -28,7 +29,7 @@ def test_invalid_energy_usage(self): def test_valid_electricity_consumer(self): # Should not raise ValidationError - dto.ElectricityConsumer( + components.ElectricityConsumer( name="Test", component_type=ComponentType.GENERIC, user_defined_category={Period(datetime(1900, 1, 1)): "MISCELLANEOUS"}, diff --git a/tests/libecalc/dto/test_fuel_consumer.py b/tests/libecalc/dto/test_fuel_consumer.py index a1247fec44..7cbbe909b4 100644 --- a/tests/libecalc/dto/test_fuel_consumer.py +++ b/tests/libecalc/dto/test_fuel_consumer.py @@ -6,6 +6,7 @@ import libecalc.dto.fuel_type import libecalc.dto.types from libecalc import dto +from libecalc.domain.infrastructure import components from libecalc.common.component_type import ComponentType from libecalc.common.energy_usage_type import EnergyUsageType from libecalc.common.time_utils import Period @@ -39,7 +40,7 @@ def get_fuel(fuel_name: str, emission_name: str) -> dict[Period, libecalc.dto.fu } -def get_installation(installation_name: str, fuel_consumer: dto.FuelConsumer) -> dto.Installation: +def get_installation(installation_name: str, fuel_consumer: components.FuelConsumer) -> components.Installation: """ Generates an installation dto for use in testing @@ -50,7 +51,7 @@ def get_installation(installation_name: str, fuel_consumer: dto.FuelConsumer) -> Returns: dto.Installation """ - return dto.Installation( + return components.Installation( name=installation_name, regularity=regularity, hydrocarbon_export={Period(datetime(1900, 1, 1)): Expression.setup_from_expression("sim1;var1")}, @@ -63,7 +64,7 @@ def get_fuel_consumer( consumer_name: str, fuel_type: dict[Period, libecalc.dto.fuel_type.FuelType], category: dict[Period, libecalc.dto.types.ConsumerUserDefinedCategoryType], -) -> dto.FuelConsumer: +) -> components.FuelConsumer: """ Generates a fuel consumer dto for use in testing @@ -75,7 +76,7 @@ def get_fuel_consumer( Returns: dto.FuelConsumer """ - return dto.FuelConsumer( + return components.FuelConsumer( name=consumer_name, fuel=fuel_type, component_type=ComponentType.GENERIC, @@ -93,7 +94,7 @@ def get_fuel_consumer( class TestFuelConsumer: def test_missing_fuel(self): with pytest.raises(ValidationError) as exc_info: - dto.FuelConsumer( + components.FuelConsumer( name="test", fuel={}, component_type=ComponentType.GENERIC, diff --git a/tests/libecalc/dto/test_generator_set.py b/tests/libecalc/dto/test_generator_set.py index 306d1db2f5..e6a2db5b9f 100644 --- a/tests/libecalc/dto/test_generator_set.py +++ b/tests/libecalc/dto/test_generator_set.py @@ -5,6 +5,7 @@ import libecalc.dto.fuel_type from libecalc import dto +from libecalc.domain.infrastructure import components from libecalc.common.component_type import ComponentType from libecalc.common.consumption_type import ConsumptionType from libecalc.common.energy_model_type import EnergyModelType @@ -39,11 +40,11 @@ def test_invalid_headers(self): class TestGeneratorSet: def test_valid(self): - generator_set_dto = dto.GeneratorSet( + generator_set_dto = components.GeneratorSet( name="Test", user_defined_category={Period(datetime(1900, 1, 1)): "MISCELLANEOUS"}, generator_set_model={ - Period(datetime(1900, 1, 1)): dto.GeneratorSetSampled( + Period(datetime(1900, 1, 1)): components.GeneratorSetSampled( headers=["FUEL", "POWER"], data=[[0, 0], [1, 2], [2, 4], [3, 6]], energy_usage_adjustment_constant=0.0, @@ -73,7 +74,7 @@ def test_genset_should_fail_with_fuel_consumer(self): name="fuel", emissions=[], ) - fuel_consumer = dto.FuelConsumer( + fuel_consumer = components.FuelConsumer( name="test", fuel={Period(datetime(2000, 1, 1)): fuel}, consumes=ConsumptionType.FUEL, @@ -88,7 +89,7 @@ def test_genset_should_fail_with_fuel_consumer(self): user_defined_category={Period(datetime(2000, 1, 1)): ConsumerUserDefinedCategoryType.MISCELLANEOUS}, ) with pytest.raises(ValidationError): - dto.GeneratorSet( + components.GeneratorSet( name="Test", user_defined_category={Period(datetime(1900, 1, 1)): ConsumerUserDefinedCategoryType.MISCELLANEOUS}, generator_set_model={}, @@ -104,7 +105,7 @@ def test_power_from_shore_wrong_category(self): # Check for CABLE_LOSS with pytest.raises(ValueError) as exc_info: - dto.GeneratorSet( + components.GeneratorSet( name="Test", user_defined_category={Period(datetime(1900, 1, 1)): ConsumerUserDefinedCategoryType.BOILER}, generator_set_model={}, @@ -118,7 +119,7 @@ def test_power_from_shore_wrong_category(self): # Check for MAX_USAGE_FROM_SHORE with pytest.raises(ValueError) as exc_info: - dto.GeneratorSet( + components.GeneratorSet( name="Test", user_defined_category={Period(datetime(1900, 1, 1)): ConsumerUserDefinedCategoryType.BOILER}, generator_set_model={}, @@ -133,7 +134,7 @@ def test_power_from_shore_wrong_category(self): ) with pytest.raises(ValueError) as exc_info: - dto.GeneratorSet( + components.GeneratorSet( name="Test", user_defined_category={Period(datetime(1900, 1, 1)): ConsumerUserDefinedCategoryType.BOILER}, generator_set_model={}, diff --git a/tests/libecalc/input/mappers/test_model_mapper.py b/tests/libecalc/input/mappers/test_model_mapper.py index 7585c05d4d..dd76bd9144 100644 --- a/tests/libecalc/input/mappers/test_model_mapper.py +++ b/tests/libecalc/input/mappers/test_model_mapper.py @@ -5,6 +5,7 @@ from pydantic import TypeAdapter from libecalc import dto +from libecalc.domain.infrastructure import components from libecalc.common.time_utils import Frequency, Period from libecalc.presentation.yaml.mappers.model import ModelMapper from libecalc.presentation.yaml.model import YamlModel @@ -294,7 +295,7 @@ def temporal_model_stream(temporal_model_source: str) -> ResourceStream: @pytest.fixture def temporal_yaml_model_factory(temporal_model_stream, resource_service_factory, configuration_service_factory): - def create_temporal_yaml_model(start: datetime, end: datetime) -> dto.Asset: + def create_temporal_yaml_model(start: datetime, end: datetime) -> components.Asset: period = Period( start=start, end=end, diff --git a/tests/libecalc/integration/test_all_consumer_with_time_slots_models.py b/tests/libecalc/integration/test_all_consumer_with_time_slots_models.py index ae7f4cdb46..ea58d3b137 100644 --- a/tests/libecalc/integration/test_all_consumer_with_time_slots_models.py +++ b/tests/libecalc/integration/test_all_consumer_with_time_slots_models.py @@ -9,8 +9,8 @@ from libecalc.common.temporal_model import TemporalModel from libecalc.common.time_utils import Period, Periods from libecalc.common.variables import VariablesMap -from libecalc.core.consumers.legacy_consumer.component import Consumer -from libecalc.core.consumers.legacy_consumer.consumer_function_mapper import EnergyModelMapper +from libecalc.domain.infrastructure.energy_components.legacy_consumer.component import Consumer +from libecalc.domain.infrastructure.energy_components.legacy_consumer.consumer_function_mapper import EnergyModelMapper from libecalc.core.result import CompressorModelResult, GenericModelResult diff --git a/tests/libecalc/output/flow_diagram/conftest.py b/tests/libecalc/output/flow_diagram/conftest.py index 9cd36e0f95..96526535cd 100644 --- a/tests/libecalc/output/flow_diagram/conftest.py +++ b/tests/libecalc/output/flow_diagram/conftest.py @@ -5,6 +5,7 @@ import libecalc.common.energy_usage_type import libecalc.dto.fuel_type from libecalc import dto +from libecalc.domain.infrastructure import components from libecalc.common.component_type import ComponentType from libecalc.common.time_utils import Period from libecalc.expression import Expression @@ -58,8 +59,8 @@ def fuel_type_fd() -> libecalc.dto.fuel_type.FuelType: @pytest.fixture -def compressor_system_consumer_dto_fd(fuel_type_fd) -> dto.FuelConsumer: - return dto.FuelConsumer( +def compressor_system_consumer_dto_fd(fuel_type_fd) -> components.FuelConsumer: + return components.FuelConsumer( name="Compressor system 1", component_type=ComponentType.COMPRESSOR_SYSTEM, user_defined_category={Period(datetime.datetime(1900, 1, 1), datetime.datetime(2021, 1, 1)): "COMPRESSOR"}, @@ -142,8 +143,8 @@ def compressor_system_consumer_dto_fd(fuel_type_fd) -> dto.FuelConsumer: @pytest.fixture -def compressor_consumer_dto_fd(fuel_type_fd) -> dto.FuelConsumer: - return dto.FuelConsumer( +def compressor_consumer_dto_fd(fuel_type_fd) -> components.FuelConsumer: + return components.FuelConsumer( name="Compressor 1", component_type=ComponentType.GENERIC, user_defined_category={Period(datetime.datetime(1900, 1, 1), datetime.datetime(2021, 1, 1)): "COMPRESSOR"}, @@ -162,13 +163,13 @@ def compressor_consumer_dto_fd(fuel_type_fd) -> dto.FuelConsumer: @pytest.fixture def installation_with_dates_dto_fd( - compressor_system_consumer_dto_fd: dto.FuelConsumer, - compressor_consumer_dto_fd: dto.FuelConsumer, -) -> dto.Asset: - return dto.Asset( + compressor_system_consumer_dto_fd: components.FuelConsumer, + compressor_consumer_dto_fd: components.FuelConsumer, +) -> components.Asset: + return components.Asset( name="installation_with_dates", installations=[ - dto.Installation( + components.Installation( name="Installation1", fuel_consumers=[compressor_system_consumer_dto_fd, compressor_consumer_dto_fd], regularity={ diff --git a/tests/libecalc/output/flow_diagram/test_ecalc_model_mapper.py b/tests/libecalc/output/flow_diagram/test_ecalc_model_mapper.py index ee67cce600..268832b2a6 100644 --- a/tests/libecalc/output/flow_diagram/test_ecalc_model_mapper.py +++ b/tests/libecalc/output/flow_diagram/test_ecalc_model_mapper.py @@ -3,7 +3,7 @@ import pytest -from libecalc import dto +from libecalc.domain.infrastructure import components from libecalc.fixtures import YamlCase from libecalc.presentation.flow_diagram.energy_model_flow_diagram import ( EnergyModelFlowDiagram, @@ -32,7 +32,9 @@ def test_all_energy_usage_models(self, all_energy_usage_models_yaml: YamlCase, s assert first_subdiagram.end_date == datetime(2021, 1, 1) @pytest.mark.snapshot - def test_case_with_dates(self, installation_with_dates_dto_fd: dto.Asset, snapshot, energy_model_from_dto_factory): + def test_case_with_dates( + self, installation_with_dates_dto_fd: components.Asset, snapshot, energy_model_from_dto_factory + ): model = energy_model_from_dto_factory(installation_with_dates_dto_fd) actual_fd = EnergyModelFlowDiagram( energy_model=model, model_period=list(installation_with_dates_dto_fd.installations[0].regularity.keys())[0] diff --git a/tests/libecalc/presentation/json_result/test_aggregators.py b/tests/libecalc/presentation/json_result/test_aggregators.py index 45b7ebfc33..3fed743232 100644 --- a/tests/libecalc/presentation/json_result/test_aggregators.py +++ b/tests/libecalc/presentation/json_result/test_aggregators.py @@ -6,6 +6,7 @@ import libecalc.dto.fuel_type import libecalc.dto.types from libecalc import dto +from libecalc.domain.infrastructure import components from libecalc.application.energy_calculator import EnergyCalculator from libecalc.application.graph_result import GraphResult from libecalc.common.time_utils import Period, Periods @@ -24,7 +25,7 @@ def get_installation( name_inst: str, name_consumer: str, name_fuel: str, co2_factor: float, fuel_rate: float -) -> dto.Installation: +) -> components.Installation: """Creates a simple installation object for use in asset setup Args: name_inst (str): Name of installation @@ -34,10 +35,10 @@ def get_installation( fuel_rate (float): Rate of fuel (Sm3/d) Returns: - dto.Installation + components.Installation """ - inst = dto.Installation( + inst = components.Installation( name=name_inst, regularity={Period(datetime(1900, 1, 1)): Expression.setup_from_expression(1)}, hydrocarbon_export={Period(datetime(1900, 1, 1)): Expression.setup_from_expression(1)}, @@ -70,7 +71,7 @@ def fuel(name: str, co2_factor: float) -> libecalc.dto.fuel_type.FuelType: ) -def direct_fuel_consumer(name: str, name_fuel: str, co2_factor: float, fuel_rate: float) -> dto.FuelConsumer: +def direct_fuel_consumer(name: str, name_fuel: str, co2_factor: float, fuel_rate: float) -> components.FuelConsumer: """Creates a simple direct fuel consumer object for use in installation setup Args: name (str): Name of direct fuel consumer @@ -79,12 +80,12 @@ def direct_fuel_consumer(name: str, name_fuel: str, co2_factor: float, fuel_rate fuel_rate (float): Rate of fuel (Sm3/d) Returns: - dto.FuelConsumer + components.FuelConsumer """ - return dto.FuelConsumer( + return components.FuelConsumer( name=name, - component_type=dto.components.ComponentType.GENERIC, + component_type=components.ComponentType.GENERIC, fuel={Period(datetime(2024, 1, 1)): fuel(name=name_fuel, co2_factor=co2_factor)}, regularity={Period(datetime(1900, 1, 1)): Expression.setup_from_expression(1)}, user_defined_category={ @@ -174,7 +175,7 @@ def test_aggregate_emissions_installations(self, energy_model_from_dto_factory): name_inst="INSTB", name_consumer="cons2", name_fuel="fuel2", co2_factor=10, fuel_rate=100 ) - asset = dto.Asset( + asset = components.Asset( name="Main asset", installations=[inst_a, inst_b], )