From f5373d5c1f760c987c1d526650c75bb5c2bc5856 Mon Sep 17 00:00:00 2001 From: Trefor Southwell <48591903+springfall2008@users.noreply.github.com> Date: Mon, 20 May 2024 18:46:45 +0100 Subject: [PATCH] Fix battery scaling computation to account for buy rate in export (#1130) * Fix battery scaling computation to account for buy rate in export * [pre-commit.ci lite] apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> --- apps/predbat/predbat.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/apps/predbat/predbat.py b/apps/predbat/predbat.py index 5a754288..d8363441 100644 --- a/apps/predbat/predbat.py +++ b/apps/predbat/predbat.py @@ -28,7 +28,7 @@ if not "PRED_GLOBAL" in globals(): PRED_GLOBAL = {} -THIS_VERSION = "v7.19.6" +THIS_VERSION = "v7.19.7" PREDBAT_FILES = ["predbat.py"] TIME_FORMAT = "%Y-%m-%dT%H:%M:%S%z" TIME_FORMAT_SECONDS = "%Y-%m-%dT%H:%M:%S.%f%z" @@ -9972,17 +9972,9 @@ def compute_metric( # Balancing payment to account for battery left over # ie. how much extra battery is worth to us in future, assume it's the same as low rate rate_min = self.rate_min_forward.get(end_record, self.rate_min) / self.inverter_loss / self.battery_loss + self.metric_battery_cycle - metric -= ( - (soc + final_iboost) - * max(rate_min, 1.0, self.rate_export_min * self.inverter_loss * self.battery_loss_discharge - self.metric_battery_cycle) - * self.metric_battery_value_scaling - ) - metric10 -= ( - (soc10 + final_iboost10) - * max(rate_min, 1.0, self.rate_export_min * self.inverter_loss * self.battery_loss_discharge - self.metric_battery_cycle) - * self.metric_battery_value_scaling - ) - + rate_export_min = self.rate_export_min * self.inverter_loss * self.battery_loss_discharge - self.metric_battery_cycle - rate_min + metric -= (soc + final_iboost) * max(rate_min, 1.0, rate_export_min) * self.metric_battery_value_scaling + metric10 -= (soc10 + final_iboost10) * max(rate_min, 1.0, rate_export_min) * self.metric_battery_value_scaling # Metric adjustment based on 10% outcome weighting if metric10 > metric: metric_diff = metric10 - metric