diff --git a/Cargo.lock b/Cargo.lock index 57169cd..6e252c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,9 +16,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "frequenz-microgrid-component-graph" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19d722b8c2fafea0a9288ee68cbac8820cbbfab2484a8f625c0b45ce6cfd5c6f" +checksum = "68e96362c8f8633732ad09b6c7f95edb6e401a0f8c025b5a0c4bf12871ddf103" dependencies = [ "petgraph", "tracing", @@ -26,7 +26,7 @@ dependencies = [ [[package]] name = "frequenz-microgrid-component-graph-python-bindings" -version = "0.5.1" +version = "0.5.2" dependencies = [ "frequenz-microgrid-component-graph", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 3a11ea1..4895957 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "frequenz-microgrid-component-graph-python-bindings" -version = "0.5.1" +version = "0.5.2" edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -10,4 +10,4 @@ crate-type = ["cdylib"] [dependencies] pyo3 = "0.29.0" -frequenz-microgrid-component-graph = "0.6.2" +frequenz-microgrid-component-graph = "0.6.3" diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index cfd9715..182e4b5 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -2,14 +2,11 @@ ## Summary -This release lets formulas take a component's operational mode into account. A component that provides no telemetry is not used as a measurement source. It is still used to classify the meter that measures it, and is measured through that meter instead. +This release updates the [`frequenz-microgrid-component-graph`](https://github.com/frequenz-floss/frequenz-microgrid-component-graph-rs) Rust crate to [v0.6.3](https://github.com/frequenz-floss/frequenz-microgrid-component-graph-rs/releases/tag/v0.6.3), which stops clamping the consumer and producer formulas. ## Upgrading -- The `microgrid` extra now needs `frequenz-client-microgrid >= 0.18.4`, up from `>= 0.18.3`. A component's operational mode is read from its `provides_telemetry()` and `accepts_control()` methods, and 0.18.3 has neither, so the feature below would do nothing there. If you pin the client yourself, move the pin to `>= 0.18.4, < 0.19`. - -## New Features - -- Formulas now take a component's operational mode into account. A component that provides no telemetry is not used as a measurement source. It is still used to classify the meter that measures it (e.g. as a PV meter or a CHP meter), so it can still be measured through that meter. - - The mode is read from the component's `provides_telemetry()` and `accepts_control()` methods. A component that does not have both methods, or does not specify both values, is treated as providing telemetry and is used exactly as before. A component built from the microgrid API carries the mode the API reports for it, so formulas can change for a site that has an inactive or control-only component. +- `ComponentGraph.consumer_formula()` and `ComponentGraph.producer_formula()` no longer clamp their results. The clamps assumed the sign of active power, so they replaced valid values of other metrics, such as reactive power, with zero. + - The consumer formula was wrapped in `MAX(…, 0.0)`. It can now be negative, for example when unmodeled production or a measurement mismatch is larger than the consumption. To get the old result, wrap the formula as `MAX(, 0.0)`. + - Each producer term was wrapped in `MIN(…, 0.0)`. A producer that draws power now adds a positive value instead of zero, so the total can be positive. For example, PV producing 10 kW and a CHP drawing 2 kW used to give -10 kW and now give -8 kW. There is one exception: when the two share a meter below the grid meter, that meter sends data, and `disable_fallback_components` is off, the meter measures them together, so they gave -8 kW before too. Wrapping the total as `MIN(, 0.0)` clamps the total at zero, but it still differs from the old result when one producer draws power while another produces. + - With `include_phantom_loads_in_consumer_formula=True`, the consumer formula is unchanged: it still clamps each of its terms at zero. diff --git a/tests/test_microgrid_component_graph.py b/tests/test_microgrid_component_graph.py index 3a9b797..ed45642 100644 --- a/tests/test_microgrid_component_graph.py +++ b/tests/test_microgrid_component_graph.py @@ -213,8 +213,8 @@ def test_consumer_formula_meter_subtraction() -> None: ) # The PV group behind meter #3 is subtracted from the grid meter #2 as - # one COALESCE term, and consumption is clamped at zero. - assert graph.consumer_formula() == "MAX(#2 - COALESCE(#3, #4, 0.0), 0.0)" + # one COALESCE term. + assert graph.consumer_formula() == "#2 - COALESCE(#3, #4, 0.0)" def test_relay_is_passthrough() -> None: