component_graph
frequenz.sdk.microgrid.component_graph ¤
Component graph representation for a microgrid.
Classes¤
frequenz.sdk.microgrid.component_graph.ComponentGraph ¤
Bases: ComponentGraph[Component, ComponentConnection, ComponentId]
A representation of a microgrid's component graph.
Source code in src/frequenz/sdk/microgrid/component_graph.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
Functions¤
__init__ ¤
__init__(
components: Iterable[ComponentT],
connections: Iterable[ConnectionT],
config: ComponentGraphConfig = ComponentGraphConfig(),
) -> None
Initialize this instance.
| PARAMETER | DESCRIPTION |
|---|---|
components
|
The list of components to build the graph with.
TYPE:
|
connections
|
The list of connections between the components.
TYPE:
|
config
|
The configuration for the component graph.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
InvalidGraphError
|
if a valid graph cannot be constructed from the given components and connections, based on the given configs. |
battery_coalesce_formula ¤
Generate the battery coalesce formula for this component graph.
| PARAMETER | DESCRIPTION |
|---|---|
battery_ids
|
The set of battery inverter component IDs to include in
the formula. If
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The battery coalesced formula as a string. |
| RAISES | DESCRIPTION |
|---|---|
FormulaGenerationError
|
if the given component IDs don't exist or are not batteries. |
battery_formula ¤
Generate the battery formula for this component graph.
| PARAMETER | DESCRIPTION |
|---|---|
battery_ids
|
The set of battery component IDs to include in the
formula. If
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The battery formula as a string. |
| RAISES | DESCRIPTION |
|---|---|
FormulaGenerationError
|
if the given component IDs don't exist or are not batteries. |
chp_formula ¤
Generate the CHP formula for this component graph.
| PARAMETER | DESCRIPTION |
|---|---|
chp_ids
|
The set of CHP component IDs to include in the formula. If
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The CHP formula as a string. |
| RAISES | DESCRIPTION |
|---|---|
FormulaGenerationError
|
if the given component IDs don't exist or are not CHPs. |
component ¤
Fetch the component with the specified component_id.
| PARAMETER | DESCRIPTION |
|---|---|
component_id
|
The id of the component to look for.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ComponentT
|
The component with the given id. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
if no component exists with the given ID. |
components ¤
components(
matching_ids: (
Iterable[ComponentIdT] | ComponentIdT | None
) = None,
matching_types: (
Iterable[type[ComponentT]] | type[ComponentT] | None
) = None,
) -> set[ComponentT]
Fetch all components in this graph.
| RETURNS | DESCRIPTION |
|---|---|
set[ComponentT]
|
A set of all components in this graph. |
connections ¤
connections() -> Set[ConnectionT]
Fetch all connections in this graph.
| RETURNS | DESCRIPTION |
|---|---|
Set[ConnectionT]
|
A set of all connections in this graph. |
consumer_formula ¤
consumer_formula() -> str
Generate the consumer formula for this component graph.
| RETURNS | DESCRIPTION |
|---|---|
str
|
The consumer formula as a string. |
ev_charger_formula ¤
Generate the EV charger formula for this component graph.
| PARAMETER | DESCRIPTION |
|---|---|
ev_charger_ids
|
The set of EV charger component IDs to include in
the formula. If
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The EV charger formula as a string. |
| RAISES | DESCRIPTION |
|---|---|
FormulaGenerationError
|
if the given component IDs don't exist or are not EV chargers. |
grid_coalesce_formula ¤
grid_coalesce_formula() -> str
Generate the grid coalesce formula for this component graph.
| RETURNS | DESCRIPTION |
|---|---|
str
|
The grid coalesced formula as a string. |
grid_formula ¤
grid_formula() -> str
Generate the grid formula for this component graph.
| RETURNS | DESCRIPTION |
|---|---|
str
|
The grid formula as a string. |
is_battery_chain ¤
Check if the specified component is part of a battery chain.
A component is part of a battery chain if it is either a battery inverter or a battery meter.
| PARAMETER | DESCRIPTION |
|---|---|
component
|
The component to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether the specified component is part of a battery chain. |
Source code in src/frequenz/sdk/microgrid/component_graph.py
is_battery_inverter ¤
is_battery_meter ¤
is_battery_meter(
component: Component | ComponentId,
) -> bool
Check if the specified component is a battery meter.
| PARAMETER | DESCRIPTION |
|---|---|
component
|
The component or component ID to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether the specified component is a battery meter. |
Source code in src/frequenz/sdk/microgrid/component_graph.py
is_chp ¤
is_chp_chain ¤
Check if the specified component is part of a CHP chain.
A component is part of a CHP chain if it is either a CHP or a CHP meter.
| PARAMETER | DESCRIPTION |
|---|---|
component
|
The component to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether the specified component is part of a CHP chain. |
Source code in src/frequenz/sdk/microgrid/component_graph.py
is_chp_meter ¤
is_chp_meter(component: Component | ComponentId) -> bool
Check if the specified component is a CHP meter.
| PARAMETER | DESCRIPTION |
|---|---|
component
|
The component or component ID to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether the specified component is a CHP meter. |
Source code in src/frequenz/sdk/microgrid/component_graph.py
is_ev_charger ¤
is_ev_charger_chain ¤
Check if the specified component is part of an EV charger chain.
A component is part of an EV charger chain if it is either an EV charger or an EV charger meter.
| PARAMETER | DESCRIPTION |
|---|---|
component
|
The component to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether the specified component is part of an EV charger chain. |
Source code in src/frequenz/sdk/microgrid/component_graph.py
is_ev_charger_meter ¤
is_ev_charger_meter(
component: Component | ComponentId,
) -> bool
Check if the specified component is an EV charger meter.
| PARAMETER | DESCRIPTION |
|---|---|
component
|
The component or component ID to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether the specified component is an EV charger meter. |
Source code in src/frequenz/sdk/microgrid/component_graph.py
is_pv_chain ¤
Check if the specified component is part of a PV chain.
A component is part of a PV chain if it is either a PV inverter or a PV meter.
| PARAMETER | DESCRIPTION |
|---|---|
component
|
The component to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether the specified component is part of a PV chain. |
Source code in src/frequenz/sdk/microgrid/component_graph.py
is_pv_inverter ¤
is_pv_meter ¤
is_pv_meter(component: Component | ComponentId) -> bool
Check if the specified component is a PV meter.
| PARAMETER | DESCRIPTION |
|---|---|
component
|
The component or component ID to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether the specified component is a PV meter. |
Source code in src/frequenz/sdk/microgrid/component_graph.py
predecessors ¤
predecessors(component_id: ComponentIdT) -> Set[ComponentT]
Fetch all predecessors of the specified component ID.
| PARAMETER | DESCRIPTION |
|---|---|
component_id
|
ID of the component whose predecessors should be fetched.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Set[ComponentT]
|
A set of components that are predecessors of the given component ID. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
if no component exists with the given ID. |
producer_formula ¤
producer_formula() -> str
Generate the producer formula for this component graph.
| RETURNS | DESCRIPTION |
|---|---|
str
|
The producer formula as a string. |
pv_coalesce_formula ¤
Generate the PV coalesce formula for this component graph.
| PARAMETER | DESCRIPTION |
|---|---|
pv_inverter_ids
|
The set of PV inverter component IDs to include in
the formula. If
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The PV coalesced formula as a string. |
| RAISES | DESCRIPTION |
|---|---|
FormulaGenerationError
|
if the given component IDs don't exist or are not PV inverters. |
pv_formula ¤
Generate the PV formula for this component graph.
| PARAMETER | DESCRIPTION |
|---|---|
pv_inverter_ids
|
The set of PV inverter component IDs to include in
the formula. If
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The PV formula as a string. |
| RAISES | DESCRIPTION |
|---|---|
FormulaGenerationError
|
if the given component IDs don't exist or are not PV inverters. |
successors ¤
successors(component_id: ComponentIdT) -> Set[ComponentT]
Fetch all successors of the specified component ID.
| PARAMETER | DESCRIPTION |
|---|---|
component_id
|
ID of the component whose successors should be fetched.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Set[ComponentT]
|
A set of components that are successors of the given component ID. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
if no component exists with the given ID. |
wind_turbine_formula ¤
Generate the wind turbine formula for this component graph.
| PARAMETER | DESCRIPTION |
|---|---|
wind_turbine_ids
|
The set of wind turbine component IDs to include in
the formula. If
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The wind turbine formula as a string. |
| RAISES | DESCRIPTION |
|---|---|
FormulaGenerationError
|
if the given component IDs don't exist or are not wind turbines. |