Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes related to export planning #1725

Merged
merged 4 commits into from
Dec 13, 2024
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
2 changes: 1 addition & 1 deletion apps/predbat/predbat.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import asyncio
import json

THIS_VERSION = "v8.8.5"
THIS_VERSION = "v8.8.6"

# fmt: off
PREDBAT_FILES = ["predbat.py", "config.py", "prediction.py", "gecloud.py","utils.py", "inverter.py", "ha.py", "download.py", "unit_test.py", "web.py", "predheat.py", "futurerate.py", "octopus.py", "solcast.py","execute.py", "plan.py", "fetch.py", "output.py", "userinterface.py"]
Expand Down
6 changes: 1 addition & 5 deletions apps/predbat/prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,11 +586,7 @@ def run_prediction(self, charge_limit, charge_window, export_window, export_limi
if export_window_n >= 0:
discharge_min = max(self.soc_max * export_limits[export_window_n] / 100.0, self.reserve, self.best_soc_min)

if not self.set_export_freeze_only and (export_window_n >= 0) and export_limits[export_window_n] < 100.0 and (soc - step * self.battery_rate_max_discharge_scaled) < discharge_min:
# Export runs out of battery - give penalty for this case, we might not stop it in time
metric_keep += step * self.battery_rate_max_discharge_scaled * rate_import.get(minute_absolute, 0) * 0.5

if not self.set_export_freeze_only and (export_window_n >= 0) and export_limits[export_window_n] < 100.0 and (soc - step * self.battery_rate_max_discharge_scaled) >= discharge_min:
if not self.set_export_freeze_only and (export_window_n >= 0) and export_limits[export_window_n] < 99.0 and (soc - step * self.battery_rate_max_discharge_scaled) >= discharge_min:
# Discharge enable
discharge_rate_now = self.battery_rate_max_discharge # Assume discharge becomes enabled here
discharge_rate_now_curve = get_discharge_rate_curve(soc, discharge_rate_now, self.soc_max, self.battery_rate_max_discharge, self.battery_discharge_power_curve, self.battery_rate_min) * self.battery_rate_max_scaling_discharge
Expand Down
13 changes: 7 additions & 6 deletions apps/predbat/unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,8 @@ def run_single_debug(my_predbat, debug_file):
# Force off combine export XXX:
print("Combined export slots {}".format(my_predbat.combine_export_slots))
# my_predbat.combine_export_slots = False
my_predbat.best_soc_keep = 1.0
# my_predbat.best_soc_keep = 1.0
my_predbat.metric_min_improvement_export = 5

if re_do_rates:
# Find discharging windows
Expand Down Expand Up @@ -2436,7 +2437,7 @@ def run_optimise_all_windows(
expect_export_limit=[],
expect_best_price=0.0,
rate_import=10.0,
rate_export=5.0,
rate_export=5.5,
battery_size=100.0,
battery_soc=0.0,
hybrid=False,
Expand Down Expand Up @@ -3384,7 +3385,7 @@ def run_model_tests(my_predbat):
with_battery=True,
discharge=0,
battery_soc=10,
assert_keep=14 * import_rate * 0.5 * KEEP_SCALE + 1 * import_rate * KEEP_SCALE,
assert_keep=1 * import_rate * KEEP_SCALE,
keep=1.0,
)
failed |= simple_scenario(
Expand All @@ -3397,7 +3398,7 @@ def run_model_tests(my_predbat):
with_battery=True,
discharge=0,
battery_soc=10,
assert_keep=14 * import_rate * 0.5 * KEEP_SCALE + 1 * import_rate * KEEP_SCALE,
assert_keep=1 * import_rate * KEEP_SCALE,
keep=1.0,
save="test",
)
Expand All @@ -3411,7 +3412,7 @@ def run_model_tests(my_predbat):
with_battery=True,
discharge=0,
battery_soc=10,
assert_keep=14 * import_rate * 0.5 * KEEP_SCALE + 1 * import_rate * KEEP_SCALE,
assert_keep=1 * import_rate * KEEP_SCALE,
keep=1.0,
save="none",
)
Expand Down Expand Up @@ -4056,7 +4057,7 @@ def run_model_tests(my_predbat):
battery_size=10,
keep=1.0,
assert_final_iboost=0,
assert_keep=import_rate * 14 * 0.5 * KEEP_SCALE + import_rate * 1 * KEEP_SCALE,
assert_keep=import_rate * 1 * KEEP_SCALE,
)

# Alternating high/low rates
Expand Down
Loading