Skip to content

flixopt.effects

This module contains the effects of the flixopt framework. Furthermore, it contains the EffectCollection, which is used to collect all effects of a system. Different Datatypes are used to represent the effects with assigned values by the user, which are then transformed into the internal data structure.

Attributes

EffectValuesUser module-attribute

EffectValuesUser = Union[NumericDataTS, Dict[str, NumericDataTS]]

This datatype is used to define the share to an effect by a certain attribute.

EffectValuesUserScalar module-attribute

EffectValuesUserScalar = Union[Scalar, Dict[str, Scalar]]

This datatype is used to define the share to an effect by a certain attribute. Only scalars are allowed.

Classes

Effect

Effect(label: str, unit: str, description: str, meta_data: Optional[Dict] = None, is_standard: bool = False, is_objective: bool = False, specific_share_to_other_effects_operation: Optional[EffectValuesUser] = None, specific_share_to_other_effects_invest: Optional[EffectValuesUser] = None, minimum_operation: Optional[Scalar] = None, maximum_operation: Optional[Scalar] = None, minimum_invest: Optional[Scalar] = None, maximum_invest: Optional[Scalar] = None, minimum_operation_per_hour: Optional[NumericDataTS] = None, maximum_operation_per_hour: Optional[NumericDataTS] = None, minimum_total: Optional[Scalar] = None, maximum_total: Optional[Scalar] = None)

Bases: Element

Effect, i.g. costs, CO2 emissions, area, ... Components, FLows, and so on can contribute to an Effect. One Effect is chosen as the Objective of the Optimization

Parameters:

Name Type Description Default
label str

The label of the Element. Used to identify it in the FlowSystem

required
unit str

The unit of effect, i.g. €, kg_CO2, kWh_primaryEnergy

required
description str

The long name

required
is_standard bool

true, if Standard-Effect (for direct input of value without effect (alternatively to dict)) , else false

False
is_objective bool

true, if optimization target

False
specific_share_to_other_effects_operation Optional[EffectValuesUser]

{effectType: TS, ...}, i.g. 180 €/t_CO2, input as {costs: 180}, optional share to other effects (only operation)

None
specific_share_to_other_effects_invest Optional[EffectValuesUser]

{effectType: TS, ...}, i.g. 180 €/t_CO2, input as {costs: 180}, optional share to other effects (only invest).

None
minimum_operation Optional[Scalar]

minimal sum (only operation) of the effect.

None
maximum_operation Optional[Scalar]

maximal sum (nur operation) of the effect.

None
minimum_operation_per_hour Optional[NumericDataTS]

max. value per hour (only operation) of effect (=sum of all effect-shares) for each timestep!

None
maximum_operation_per_hour Optional[NumericDataTS]

min. value per hour (only operation) of effect (=sum of all effect-shares) for each timestep!

None
minimum_invest Optional[Scalar]

minimal sum (only invest) of the effect

None
maximum_invest Optional[Scalar]

maximal sum (only invest) of the effect

None
minimum_total Optional[Scalar]

min sum of effect (invest+operation).

None
maximum_total Optional[Scalar]

max sum of effect (invest+operation).

None
meta_data Optional[Dict]

used to store more information about the Element. Is not used internally, but saved in the results. Only use python native types.

None

Functions

infos
infos(use_numpy: bool = True, use_element_label: bool = False) -> Dict

Generate a dictionary representation of the object's constructor arguments. Excludes default values and empty dictionaries and lists. Converts data to be compatible with JSON.

Parameters:

Name Type Description Default
use_numpy bool

Whether to convert NumPy arrays to lists. Defaults to True. If True, numeric numpy arrays (np.ndarray) are preserved as-is. If False, they are converted to lists.

True
use_element_label bool

Whether to use the element label instead of the infos of the element. Defaults to False. Note that Elements used as keys in dictionaries are always converted to their labels.

False

Returns:

Type Description
Dict

A dictionary representation of the object's constructor arguments.

to_json
to_json(path: Union[str, Path])

Saves the element to a json file. This not meant to be reloaded and recreate the object, but rather used to document or compare the object.

Parameters:

Name Type Description Default
path Union[str, Path]

The path to the json file.

required
to_dict
to_dict() -> Dict

Convert the object to a dictionary representation.

from_dict classmethod
from_dict(data: Dict) -> Interface

Create an instance from a dictionary representation.

Parameters:

Name Type Description Default
data Dict

Dictionary containing the data for the object.

required

EffectCollection

EffectCollection(*effects: List[Effect])

Handling all Effects

Functions

create_effect_values_dict
create_effect_values_dict(effect_values_user: EffectValuesUser) -> Optional[EffectValuesDict]

Converts effect values into a dictionary. If a scalar is provided, it is associated with a default effect type.

Examples

effect_values_user = 20 -> {None: 20} effect_values_user = None -> None effect_values_user = {effect1: 20, effect2: 0.3} -> {effect1: 20, effect2: 0.3}

Returns

dict or None A dictionary with None or Effect as the key, or None if input is None.

EffectCollectionModel

EffectCollectionModel(model: SystemModel, effects: EffectCollection)

Bases: Model

Handling all Effects

Attributes

label_full property
label_full: str

Used to construct the names of variables and constraints

Functions

add
add(item: Union[Variable, Constraint, Model], short_name: Optional[str] = None) -> Union[linopy.Variable, linopy.Constraint, Model]

Add a variable, constraint or sub-model to the model

Parameters:

Name Type Description Default
item Union[Variable, Constraint, Model]

The variable, constraint or sub-model to add to the model

required
short_name Optional[str]

The short name of the variable, constraint or sub-model. If not provided, the full name is used.

None

Functions