Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ crate-type = ["cdylib"]

[dependencies]
pyo3 = "0.27.1"
frequenz-microgrid-component-graph = "0.3.0"
frequenz-microgrid-component-graph = "0.4"
4 changes: 2 additions & 2 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Frequenz Microgrid Component Graph Library Release Notes

## New Features
## Upgrading

- It is now possible to create subclasses of the `ComponentGraph` and `ComponentGraphConfig` classes from python.
- This release updates the `frequenz-microgrid-component-graph` rust crate version to 0.4.
33 changes: 33 additions & 0 deletions python/frequenz/microgrid_component_graph/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ class ComponentGraphConfig:
allow_unconnected_components: bool = False,
allow_unspecified_inverters: bool = False,
disable_fallback_components: bool = False,
include_phantom_loads_in_consumer_formula: bool = False,
prefer_inverters_in_battery_formula: bool = False,
prefer_inverters_in_pv_formula: bool = False,
prefer_chp_in_chp_formula: bool = False,
prefer_ev_chargers_in_ev_formula: bool = False,
prefer_wind_turbines_in_wind_formula: bool = False,
) -> None:
"""Initialize this instance.

Expand All @@ -38,6 +44,33 @@ class ComponentGraphConfig:
disable_fallback_components: Whether to disable fallback components in
generated formulas. When this is `True`, the formulas will not include
fallback components.
include_phantom_loads_in_consumer_formula: Whether to consider phantom loads
in the consumer formula. Meters with successors can still have loads
not represented in the component graph. These are called phantom loads.
When this is `true`, phantom loads are included in formulas by excluding
the measurements of successor meters from the measurements of their
predecessor meters. When `false`, consumer formula is generated by
excluding production and battery components from the grid measurements.
prefer_inverters_in_battery_formula: Whether to prefer battery inverters
when generating Battery formulas. When this is `true`, battery inverters
will be the primary source and battery meters will be secondary. When
`false`, battery meters will be the primary source.
prefer_inverters_in_pv_formula: Whether to prefer PV inverters when
generating PV formulas. When this is `true`, PV inverters will be the
primary source and PV meters will be secondary. When `false`, PV meters
will be the primary source.
prefer_chp_in_chp_formula: Whether to prefer CHP when generating CHP
formulas. When this is `true`, CHPs will be the primary source and CHP
meters will be secondary. When `false`, CHP meters will be the primary
source.
prefer_ev_chargers_in_ev_formula: Whether to prefer EV chargers when
generating EV charger formulas. When this is `true`, EV chargers will be
the primary source and EV meters will be secondary. When `false`, EV
meters will be the primary source.
prefer_wind_turbines_in_wind_formula: Whether to prefer wind turbines when
generating wind turbine formulas. When this is `true`, wind turbines
will be the primary source and wind meters will be secondary. When
`false`, wind meters will be the primary source.
"""

class ComponentIdProtocol(Protocol):
Expand Down
20 changes: 19 additions & 1 deletion src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,38 @@ impl ComponentGraphConfig {
allow_component_validation_failures = false,
allow_unconnected_components = false,
allow_unspecified_inverters = false,
disable_fallback_components = false
disable_fallback_components = false,
include_phantom_loads_in_consumer_formula = false,
prefer_inverters_in_battery_formula = false,
prefer_inverters_in_pv_formula = false,
prefer_chp_in_chp_formula = false,
prefer_ev_chargers_in_ev_formula = false,
prefer_wind_turbines_in_wind_formula = false,
))]
fn new(
allow_component_validation_failures: bool,
allow_unconnected_components: bool,
allow_unspecified_inverters: bool,
disable_fallback_components: bool,
include_phantom_loads_in_consumer_formula: bool,
prefer_inverters_in_battery_formula: bool,
prefer_inverters_in_pv_formula: bool,
prefer_chp_in_chp_formula: bool,
prefer_ev_chargers_in_ev_formula: bool,
prefer_wind_turbines_in_wind_formula: bool,
) -> Self {
ComponentGraphConfig {
config: cg::ComponentGraphConfig {
allow_component_validation_failures,
allow_unconnected_components,
allow_unspecified_inverters,
disable_fallback_components,
include_phantom_loads_in_consumer_formula,
prefer_inverters_in_battery_formula,
prefer_inverters_in_pv_formula,
prefer_chp_in_chp_formula,
prefer_ev_chargers_in_ev_formula,
prefer_wind_turbines_in_wind_formula,
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_microgrid_component_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def test_wind_turbine_graph() -> None:
# References the Meter (ID 2) measuring the Turbine (ID 3).
assert (
graph.wind_turbine_formula(wind_turbine_ids={ComponentId(3)})
== "COALESCE(#3, #2, 0.0)"
== "COALESCE(#2, #3, 0.0)"
)

# 4. Test Topology (Successors/Predecessors)
Expand Down