From fa8d8cf4e1da8c29e2d59272936cc07652ba4494 Mon Sep 17 00:00:00 2001 From: Rob Hammond <13874373+RHammond2@users.noreply.github.com> Date: Wed, 11 Dec 2024 16:26:56 -0800 Subject: [PATCH] Bug Fix: Address Inconsistenty in Turbine vs. Wind Farm Availability (#161) * fix inconsistent substation accounting for turbine vs wind farm availability --- .pre-commit-config.yaml | 4 ++-- CHANGELOG.md | 6 ++++++ wombat/core/environment.py | 9 +++++++-- wombat/core/post_processor.py | 2 -- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 24ae135b..75b5c889 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,14 +6,14 @@ repos: hooks: - id: isort name: isort - stages: [commit] + stages: [pre-commit] - repo: https://github.com/asottile/pyupgrade rev: v3.15.2 hooks: - id: pyupgrade args: [--py39-plus] - stages: [commit] + stages: [pre-commit] - repo: https://github.com/charliermarsh/ruff-pre-commit rev: v0.4.2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 482d9fea..02892d50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# CHANGELOG + +## Unreleased (TBD) + +- Fixes a discrepancy where the wind farm vs turbine availability losses do not match. A slight difference in total availability will be noticeable as a result. + ## 0.9.5 (6 August 2024) - Fixes a bug that causes delayed mobilizations. The underlying cause was the lack of diff --git a/wombat/core/environment.py b/wombat/core/environment.py index 2c514b7d..2e607e77 100644 --- a/wombat/core/environment.py +++ b/wombat/core/environment.py @@ -790,8 +790,7 @@ def _calculate_windfarm_total( turbines = self.windfarm.turbine_weights[t_id].values * op[t_id] total = np.sum( [ - op[[sub]] - * np.array( + np.array( [ [math.fsum(row)] for _, row in turbines[val["turbines"]].iterrows() @@ -855,6 +854,12 @@ def load_operations_log_dataframe(self) -> pd.DataFrame: .set_index("datetime") .sort_values("datetime") ) + + # Adjust the turbine operational values to account for substation downtime + for sub, val in self.windfarm.substation_turbine_map.items(): + log_df[val["turbines"]] *= log_df[[sub]].values + + # Calculate the wind farm aggregate operational value log_df["windfarm"] = self._calculate_windfarm_total(log_df) return log_df diff --git a/wombat/core/post_processor.py b/wombat/core/post_processor.py index 9e25b770..378e30d3 100644 --- a/wombat/core/post_processor.py +++ b/wombat/core/post_processor.py @@ -369,8 +369,6 @@ def time_based_availability(self, frequency: str, by: str) -> pd.DataFrame: # Determine the operational capacity of each turbine with substation downtime operations_cols = ["year", "month", "day", "windfarm"] + self.turbine_id turbine_operations = self.operations[operations_cols].copy() - for sub, val in self.substation_turbine_map.items(): - turbine_operations[val["turbines"]] *= self.operations[[sub]].values hourly = turbine_operations.loc[:, self.turbine_id]