From 9f3223c0908f0e3f6658b15c44e595e82a4a78cb Mon Sep 17 00:00:00 2001 From: Trefor Southwell <48591903+springfall2008@users.noreply.github.com> Date: Sun, 8 Dec 2024 19:24:27 +0000 Subject: [PATCH] Fix bug related to export slot timing on AC Coupled mode (#1707) * Fix bug related to export slot timing on AC Coupled mode https://github.com/springfall2008/batpred/issues/1704 * [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/prediction.py | 2 +- apps/predbat/unit_test.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/predbat/prediction.py b/apps/predbat/prediction.py index 2eaeb607..edfbae67 100644 --- a/apps/predbat/prediction.py +++ b/apps/predbat/prediction.py @@ -695,7 +695,7 @@ def run_prediction(self, charge_limit, charge_window, export_window, export_limi pv_dc = 0 diff = get_diff(0, pv_dc, pv_ac, load_yesterday, inverter_loss) - required_for_load = load_yesterday / inverter_loss_ac + required_for_load = load_yesterday / inverter_loss if inverter_hybrid: potential_to_charge = pv_now else: diff --git a/apps/predbat/unit_test.py b/apps/predbat/unit_test.py index 4b1e3357..b1fdbf45 100644 --- a/apps/predbat/unit_test.py +++ b/apps/predbat/unit_test.py @@ -2906,6 +2906,9 @@ def run_model_tests(my_predbat): failed |= simple_scenario("load_only", my_predbat, 1, 0, assert_final_metric=import_rate * 24, assert_final_soc=0, with_battery=False) failed |= simple_scenario("load_bat_ac", my_predbat, 4, 0, assert_final_metric=import_rate * 24 * 3.2, assert_final_soc=100 - 24, with_battery=True, battery_soc=100.0, inverter_loss=0.8) failed |= simple_scenario("load_bat_dc", my_predbat, 4, 0, assert_final_metric=import_rate * 24 * 3.2, assert_final_soc=100 - 24, with_battery=True, battery_soc=100.0, inverter_loss=0.8, hybrid=True) + failed |= simple_scenario("load_bat_ac2", my_predbat, 0.5, 0, assert_final_metric=0, assert_final_soc=100 - 12 / 0.8, with_battery=True, battery_soc=100.0, inverter_loss=0.8) + failed |= simple_scenario("load_bat_dc2", my_predbat, 0.5, 0, assert_final_metric=0, assert_final_soc=100 - 12 / 0.8, with_battery=True, battery_soc=100.0, inverter_loss=0.8, hybrid=True) + failed |= simple_scenario( "load_bat_dc_pv", my_predbat,