flixopt.elements
This module contains the basic elements of the flixopt framework.
Attributes
Classes
Component
Component(label: str, inputs: Optional[List[Flow]] = None, outputs: Optional[List[Flow]] = None, on_off_parameters: Optional[OnOffParameters] = None, prevent_simultaneous_flows: Optional[List[Flow]] = None, meta_data: Optional[Dict] = None)
Bases: Element
A Component contains incoming and outgoing Flows
. It defines how these Flows interact with each other.
The On or Off state of the Component is defined by all its Flows. Its on, if any of its FLows is On.
It's mathematically advisable to define the On/Off state in a FLow rather than a Component if possible,
as this introduces less binary variables to the Model
Constraints to the On/Off state are defined by the on_off_parameters
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
label
|
str
|
The label of the Element. Used to identify it in the FlowSystem |
required |
inputs
|
Optional[List[Flow]]
|
input flows. |
None
|
outputs
|
Optional[List[Flow]]
|
output flows. |
None
|
on_off_parameters
|
Optional[OnOffParameters]
|
Information about on and off state of Component. Component is On/Off, if all connected Flows are On/Off. Induces On-Variable in all FLows! See class OnOffParameters. |
None
|
prevent_simultaneous_flows
|
Optional[List[Flow]]
|
Define a Group of Flows. Only one them can be on at a time. Induces On-Variable in all Flows! If possible, use OnOffParameters in a single Flow instead. |
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
to_json
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 |
Bus
Bus(label: str, excess_penalty_per_flow_hour: Optional[NumericDataTS] = 100000.0, meta_data: Optional[Dict] = None)
Bases: Element
A Bus represents a nodal balance between the flow rates of its incoming and outgoing Flows.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
label
|
str
|
The label of the Element. Used to identify it in the FlowSystem |
required |
excess_penalty_per_flow_hour
|
Optional[NumericDataTS]
|
excess costs / penalty costs (bus balance compensation) (none/ 0 -> no penalty). The default is 1e5. (Take care: if you use a timeseries (no scalar), timeseries is aggregated if calculation_type = aggregated!) |
100000.0
|
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
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 ( |
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
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 |
Flow
Flow(label: str, bus: str, size: Union[Scalar, InvestParameters] = None, fixed_relative_profile: Optional[NumericDataTS] = None, relative_minimum: NumericDataTS = 0, relative_maximum: NumericDataTS = 1, effects_per_flow_hour: Optional[EffectValuesUser] = None, on_off_parameters: Optional[OnOffParameters] = None, flow_hours_total_max: Optional[Scalar] = None, flow_hours_total_min: Optional[Scalar] = None, load_factor_min: Optional[Scalar] = None, load_factor_max: Optional[Scalar] = None, previous_flow_rate: Optional[NumericData] = None, meta_data: Optional[Dict] = None)
Bases: Element
A Flow moves energy (or material) between a Bus and a Component in a predefined direction. The flow-rate is the main optimization variable of the Flow.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
label
|
str
|
The label of the FLow. Used to identify it in the FlowSystem. Its |
required |
bus
|
str
|
blabel of the bus the flow is connected to. |
required |
size
|
Union[Scalar, InvestParameters]
|
size of the flow. If InvestmentParameters is used, size is optimized. If size is None, a default value is used. |
None
|
relative_minimum
|
NumericDataTS
|
min value is relative_minimum multiplied by size |
0
|
relative_maximum
|
NumericDataTS
|
max value is relative_maximum multiplied by size. If size = max then relative_maximum=1 |
1
|
load_factor_min
|
Optional[Scalar]
|
minimal load factor general: avg Flow per nominalVal/investSize
(e.g. boiler, kW/kWh=h; solarthermal: kW/m²;
def: :math: |
None
|
load_factor_max
|
Optional[Scalar]
|
maximal load factor (see minimal load factor) |
None
|
effects_per_flow_hour
|
Optional[EffectValuesUser]
|
operational costs, costs per flow-"work" |
None
|
on_off_parameters
|
Optional[OnOffParameters]
|
If present, flow can be "off", i.e. be zero (only relevant if relative_minimum > 0) Therefore a binary var "on" is used. Further, several other restrictions and effects can be modeled through this On/Off State (See OnOffParameters) |
None
|
flow_hours_total_max
|
Optional[Scalar]
|
maximum flow-hours ("flow-work") (if size is not const, maybe load_factor_max is the better choice!) |
None
|
flow_hours_total_min
|
Optional[Scalar]
|
minimum flow-hours ("flow-work") (if size is not predefined, maybe load_factor_min is the better choice!) |
None
|
fixed_relative_profile
|
Optional[NumericDataTS]
|
fixed relative values for flow (if given). flow_rate(t) := fixed_relative_profile(t) * size(t) With this value, the flow_rate is no optimization-variable anymore. (relative_minimum and relative_maximum are ignored) used for fixed load or supply profiles, i.g. heat demand, wind-power, solarthermal If the load-profile is just an upper limit, use relative_maximum instead. |
None
|
previous_flow_rate
|
Optional[NumericData]
|
previous flow rate of the component. |
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
to_json
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 |
FlowModel
Bases: ElementModel
Attributes
absolute_flow_rate_bounds
property
Returns absolute flow rate bounds. Important for OnOffModel
relative_flow_rate_bounds
property
Returns relative flow rate bounds.
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
|
ComponentModel
Bases: ElementModel
Attributes
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
|