fix max limitu
This commit is contained in:
@@ -1782,5 +1782,62 @@ class LoadFirstDispatchTests(unittest.TestCase):
|
||||
self.assertEqual(r.export_mode, "PV_SURPLUS")
|
||||
|
||||
|
||||
class SitePowerCapTests(unittest.TestCase):
|
||||
"""Tvrdé limity site import a součtu nabíjení baterie."""
|
||||
|
||||
def test_grid_charge_respects_import_and_battery_caps(self) -> None:
|
||||
"""home-01 typ: CHARGE slot nesmí překročit 17 kW import ani 18 kW do baterie."""
|
||||
base = datetime(2026, 5, 22, 8, 45, tzinfo=timezone.utc)
|
||||
slots = [
|
||||
PlanningSlot(
|
||||
interval_start=base,
|
||||
buy_price=0.7,
|
||||
sell_price=2.5,
|
||||
pv_a_forecast_w=5000,
|
||||
pv_b_forecast_w=0,
|
||||
load_baseline_w=1961,
|
||||
ev1_connected=False,
|
||||
ev2_connected=False,
|
||||
is_predicted_price=False,
|
||||
allow_charge=True,
|
||||
allow_discharge_export=False,
|
||||
)
|
||||
]
|
||||
battery = _battery(uc_wh=64_000.0)
|
||||
battery.max_charge_power_w = 18_000
|
||||
battery.max_discharge_power_w = 18_000
|
||||
hp = SimpleNamespace(rated_heating_power_w=0, tuv_min_temp_c=45.0, tuv_target_temp_c=55.0)
|
||||
grid = SimpleNamespace(max_import_power_w=17_000, max_export_power_w=13_500)
|
||||
vehicles = [
|
||||
SimpleNamespace(max_charge_power_w=0, battery_capacity_kwh=1.0, default_target_soc_pct=80.0),
|
||||
SimpleNamespace(max_charge_power_w=0, battery_capacity_kwh=1.0, default_target_soc_pct=80.0),
|
||||
]
|
||||
soc0 = 0.5 * battery.usable_capacity_wh
|
||||
results, _, _ = solve_dispatch(
|
||||
slots,
|
||||
battery,
|
||||
hp,
|
||||
grid,
|
||||
[None, None],
|
||||
vehicles,
|
||||
soc0,
|
||||
50.0,
|
||||
operating_mode="AUTO",
|
||||
)
|
||||
r = results[0]
|
||||
self.assertLessEqual(
|
||||
r.grid_setpoint_w,
|
||||
17_000,
|
||||
msg="import ze site ≤ max_import_power_w",
|
||||
)
|
||||
self.assertGreaterEqual(r.grid_setpoint_w, 0)
|
||||
self.assertLessEqual(
|
||||
r.battery_setpoint_w,
|
||||
18_000,
|
||||
msg="nabíjení baterie ≤ max_charge_power_w",
|
||||
)
|
||||
self.assertGreater(r.battery_setpoint_w, 0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user