uprava vypoctu slotu
This commit is contained in:
@@ -1359,5 +1359,67 @@ class SpreadGuardHome01EconomicsTests(unittest.TestCase):
|
||||
self.assertLessEqual(vt_before_nt.battery_setpoint_w, 2_000)
|
||||
|
||||
|
||||
class ChargeAcquisitionArbitrageTests(unittest.TestCase):
|
||||
"""Mezi-slotová arbitráž: večerní export při nízké charge_acquisition z SQL."""
|
||||
|
||||
def test_evening_battery_export_when_sell_above_acquisition(self) -> None:
|
||||
base = datetime(2026, 5, 21, 10, 0, tzinfo=timezone.utc)
|
||||
cheap = (0.75, 0.25)
|
||||
peak = (7.0, 4.8)
|
||||
slots: list[PlanningSlot] = []
|
||||
for i in range(6):
|
||||
buy, sell = cheap if i < 2 else peak
|
||||
slots.append(
|
||||
PlanningSlot(
|
||||
interval_start=base + timedelta(minutes=15 * i),
|
||||
buy_price=buy,
|
||||
sell_price=sell,
|
||||
pv_a_forecast_w=0,
|
||||
pv_b_forecast_w=0,
|
||||
load_baseline_w=800,
|
||||
ev1_connected=False,
|
||||
ev2_connected=False,
|
||||
is_predicted_price=False,
|
||||
allow_charge=i < 2,
|
||||
allow_discharge_export=i >= 2,
|
||||
charge_acquisition_buy_czk_kwh=0.75,
|
||||
charge_acquisition_cutoff_at=base + timedelta(minutes=30),
|
||||
)
|
||||
)
|
||||
battery = _battery(uc_wh=64_000.0, terminal_soc_value_factor=0.5)
|
||||
battery.max_charge_power_w = 17_000
|
||||
battery.max_discharge_power_w = 17_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=20_000, max_export_power_w=20_000)
|
||||
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.78 * battery.usable_capacity_wh
|
||||
results, _ms, snap = solve_dispatch(
|
||||
slots,
|
||||
battery,
|
||||
hp,
|
||||
grid,
|
||||
[None, None],
|
||||
vehicles,
|
||||
soc0,
|
||||
50.0,
|
||||
operating_mode="AUTO",
|
||||
)
|
||||
self.assertAlmostEqual(
|
||||
snap["inputs"]["charge_acquisition_buy_czk_kwh"],
|
||||
0.75,
|
||||
places=2,
|
||||
)
|
||||
evening = results[3]
|
||||
self.assertLess(
|
||||
evening.grid_setpoint_w,
|
||||
-1_000,
|
||||
msg="high sell vs low acquisition should motivate grid export",
|
||||
)
|
||||
self.assertLess(evening.battery_setpoint_w, -500)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user