uprava zbytecne setreni baterie a brani zadraho ze site
Some checks failed
CI and deploy / migration-check (push) Failing after 14s
CI and deploy / deploy (push) Has been skipped

This commit is contained in:
Dusan Vojacek
2026-05-22 15:26:33 +02:00
parent cb638b9302
commit f960e08307
3 changed files with 50 additions and 4 deletions

View File

@@ -1323,9 +1323,18 @@ def solve_dispatch(
pv_surplus_w=pv_surplus_w,
):
prob += ge_pv[t] == 0
# Drahý nákup oproti horizontu: import jen na load + EV + TČ, ne na grid-nabíjení.
if buy_t >= 0 and buy_t > ref_buy_horizon + min_spread:
prob += gi[t] <= load_t + ev_cap_t + hp_rated_w
# Drahý nákup: dům + TČ z baterie (ne import ze sítě); síť jen EV (+ případně TČ).
# Spot: buy > min horizontu. Fixní tarif (KV1): buy > charge_acquisition (jinak je vše „stejně drahé“).
expensive_import_slot = buy_t > ref_buy_horizon + min_spread or (
buy_t > charge_acquisition_czk_kwh + min_spread
)
if expensive_import_slot and t not in charge_slots:
prob += gi[t] <= ev_cap_t + hp_rated_w
if om == "AUTO":
prob += (
bd[t] + pv_ld[t]
>= float(s.load_baseline_w) + hp_rated_w
)
# Anti souběžný vývoz FVE + významný import (mikrocyklus).
if buy_t > sell_t + min_spread and pv_surplus_w > 0:
prob += ge_pv[t] <= pv_surplus_w

View File

@@ -1153,9 +1153,45 @@ class AutoPassiveSelfConsumptionTests(unittest.TestCase):
0,
msg="expensive slot should discharge for self-consumption before cheap charge",
)
self.assertGreaterEqual(results[0].grid_setpoint_w, 0)
self.assertLessEqual(
results[0].grid_setpoint_w,
0,
msg="expensive slot: baseline load ze baterie, ne import ze sítě",
)
self.assertEqual(results[0].deye_physical_mode, "PASSIVE")
def test_fixed_tariff_expensive_slot_discharges_not_grid_load(self) -> None:
"""KV1 typ: konstantní buy — porovnání vůči charge_acquisition, ne min(buy)."""
slots = [
PlanningSlot(
interval_start=datetime(2026, 5, 21, 22, 0, tzinfo=timezone.utc),
buy_price=6.35,
sell_price=2.0,
pv_a_forecast_w=0,
pv_b_forecast_w=0,
load_baseline_w=320,
ev1_connected=False,
ev2_connected=False,
allow_charge=False,
allow_discharge_export=False,
charge_acquisition_buy_czk_kwh=0.55,
)
]
battery = _battery(uc_wh=20_000.0, min_pct=10.0, arb_pct=20.0)
battery.planner_terminal_soc_value_factor = 0.0
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=8000)
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.4 * battery.usable_capacity_wh
results, _, _ = solve_dispatch(
slots, battery, hp, grid, [None, None], vehicles, soc0, 50.0, operating_mode="AUTO"
)
self.assertLessEqual(results[0].grid_setpoint_w, 0)
self.assertLess(results[0].battery_setpoint_w, -100)
class AutoPassiveNoLoadFollowingDischargeTests(unittest.TestCase):
"""AUTO bez allow_discharge_export: žádný export do sítě (Deye PASSIVE)."""