Component Module

Defines the component class and helpers.

The component class is the base class for all other components.

class component.CapexCostDataClass(capex_investment_cost_in_euro: float, device_co2_footprint_in_kg: float, lifetime_in_years: float, capex_investment_cost_for_simulated_period_in_euro: float, device_co2_footprint_for_simulated_period_in_kg: float, maintenance_costs_in_euro: float = 0.0, maintenance_cost_per_simulated_period_in_euro: float = 0.0, subsidy_as_percentage_of_investment_costs: float = 0.0, kpi_tag: KpiTagEnumClass | None = None)

Bases: object

Return element of type CapexCostDataClass in function get_capex_cost from Component.

capex_investment_cost_for_simulated_period_in_euro: float
capex_investment_cost_in_euro: float
device_co2_footprint_for_simulated_period_in_kg: float
device_co2_footprint_in_kg: float
classmethod get_default_capex_cost_data_class() CapexCostDataClass

Return the Default for all Components without Capex Costs.

kpi_tag: KpiTagEnumClass | None = None
lifetime_in_years: float
maintenance_cost_per_simulated_period_in_euro: float = 0.0
maintenance_costs_in_euro: float = 0.0
subsidy_as_percentage_of_investment_costs: float = 0.0
class component.Component(name: str, my_simulation_parameters: SimulationParameters, my_config: ConfigBase, my_display_config: DisplayConfig)

Bases: object

Base class for all components.

add_default_connections(connections: List[ComponentConnection]) None

Adds a default connection list definition.

add_input(object_name: str, field_name: str, load_type: LoadTypes, unit: Units, mandatory: bool) ComponentInput

Adds an input definition.

add_output(object_name: str, field_name: str, load_type: LoadTypes, unit: Units, postprocessing_flag: List[Any] | None = None, sankey_flow_direction: bool | None = None, output_description: str | None = None) ComponentOutput

Adds an output definition.

calc_maintenance_cost() float

Calc maintenance_cost per simulated period as share of capex of component.

connect_dynamic_input(input_fieldname: str, src_object: ComponentOutput) None

For connecting an input to a dynamic output.

connect_input(input_fieldname: str, src_object_name: str, src_field_name: str) None

Connecting an input to an output.

connect_only_predefined_connections(*source_components)

Wrapper for default connections and connect with connections list.

connect_with_connections_list(connections: List[ComponentConnection]) None

Connect all inputs based on a connections list.

classmethod get_classname()

Gets the class name. Helper function for default connections.

get_component_kpi_entries(all_outputs: List, postprocessing_results: DataFrame) List[KpiEntry]

Calculates KPIs for the respective component and return all KPI entries as list.

get_component_name()

Create component name.

static get_cost_capex(config: ConfigBase, simulation_parameters: SimulationParameters) CapexCostDataClass

Calculates lifetime, total capital expenditure cost and total co2 footprint of production of device.

get_cost_opex(all_outputs: List, postprocessing_results: DataFrame) OpexCostDataClass

Calculates operational cost, operational co2 footprint and consumption in kWh (for Diesel in l) during simulation time frame.

get_default_connections(source_component: Component) List[ComponentConnection]

Gets the default connections for this component.

classmethod get_full_classname()

Gets the class name. Helper function for default connections.

get_input_definitions() List[ComponentInput]

Gets the input definitions.

get_outputs() List[ComponentOutput]

Delivers a list of outputs.

i_doublecheck(timestep: int, stsv: SingleTimeStepValues) None

Abstract. Gets called after the iterations are finished at each time step for potential debugging purposes.

i_prepare_simulation() None

Gets called before the simulation to prepare the calculation.

i_restore_state() None

Abstract. Restores the state of the component. Can be called many times while iterating.

i_save_state() None

Abstract. Gets called at the beginning of a timestep to save the state.

i_simulate(timestep: int, stsv: SingleTimeStepValues, force_convergence: bool) None

Performs the actual calculation.

set_sim_repo(simulation_repository: SimRepository) None

Sets the SimRepository.

write_to_report() Any

Abstract function for writing the report entry for this component.

class component.ComponentConnection(target_input_name: str, source_class_name: str, source_output_name: str, source_instance_name: str | None = None)

Bases: object

Used in the component class for defining a connection.

source_class_name: str
source_instance_name: str | None = None
source_output_name: str
target_input_name: str
class component.ComponentInput(object_name: str, field_name: str, load_type: LoadTypes, unit: Units, mandatory: bool)

Bases: object

Used in the component class for defining an input.

class component.ComponentOutput(object_name: str, field_name: str, load_type: LoadTypes, unit: Units, postprocessing_flag: List[Any] | None = None, sankey_flow_direction: bool | None = None, output_description: str | None = None, source_component_class: str | None = None)

Bases: object

Used in the component class for defining an output.

get_pretty_name() str

Gets a pretty name for a component output.

class component.ConfigBase(name: str, building_name: str = 'BUI1')

Bases: JSONSerializable

Base class for all configurations.

building_name: str
classmethod get_config_classname()

Gets the class name. Helper function for default connections.

classmethod get_main_classname()

Returns the fully qualified class name for the class that is getting configured. Used for Json.

get_string_dict() List[str]

Turns the config into a str list for the report.

name: str
class component.Coordinates(latitude: float, longitude: float)

Bases: object

Coordinates.

latitude: float
longitude: float
class component.DisplayConfig(pretty_name: str | None = None, display_in_webtool: bool = False)

Bases: object

Configure how to display this component in postprocessing.

display_in_webtool: bool = False
pretty_name: str | None = None
classmethod show(pretty_name)

Shortcut for showing in webtool with a specified name.

class component.OpexCostDataClass(opex_energy_cost_in_euro: float, opex_maintenance_cost_in_euro: float, co2_footprint_in_kg: float, total_consumption_in_kwh: float, loadtype: LoadTypes, consumption_for_space_heating_in_kwh: float = 0.0, consumption_for_domestic_hot_water_in_kwh: float = 0.0, kpi_tag: KpiTagEnumClass | None = None)

Bases: object

Return element of type OpexCostDataClass in function get_opex_cost from Component.

co2_footprint_in_kg: float
consumption_for_domestic_hot_water_in_kwh: float = 0.0
consumption_for_space_heating_in_kwh: float = 0.0
classmethod get_default_opex_cost_data_class() OpexCostDataClass

Return the Default for all Components without Opex Costs.

kpi_tag: KpiTagEnumClass | None = None
loadtype: LoadTypes
opex_energy_cost_in_euro: float
opex_maintenance_cost_in_euro: float
total_consumption_in_kwh: float
class component.SingleTimeStepValues(number_of_values: int)

Bases: object

Contains the values for a single time step.

clone()

Makes a copy of the current object.

copy_values_from_other(other)

Copy all values from a single time step values.

get_differences_for_error_msg(previous_values: Any, outputs: List[ComponentOutput]) str

Gets a pretty error message for the differences between two time steps.

get_input_value(component_input: ComponentInput) float

Gets a value for an input from the single time step values.

is_close_enough_to_previous(previous_values: SingleTimeStepValues) bool

Checks if the values are sufficiently similar to another array.

set_output_value(output: ComponentOutput, value: float) None

Sets a single output value in the single time step values array.