TARIFF-30: wind-down hold released when the meter exports; rows for release and maintenance; Dutch texts
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -141,7 +141,11 @@ class TradeMixin:
|
||||
elif names:
|
||||
if until is None:
|
||||
until = now + timedelta(seconds=self.LOSSY_WIND_S)
|
||||
if now >= until or float(self.target or 0.0) >= 0.0:
|
||||
# The tail is a charge FROM the grid: the meter still imports.
|
||||
# A negative target with the meter exporting is the loop soaking
|
||||
# a surplus, which is not the trade's and is never held.
|
||||
exporting = self.grid is not None and float(self.grid) <= 0.0
|
||||
if now >= until or float(self.target or 0.0) >= 0.0 or exporting:
|
||||
names, until = frozenset(), None
|
||||
self._lossy_hold = (names, until)
|
||||
if len(self.inverters) <= 1:
|
||||
|
||||
@@ -2013,7 +2013,7 @@ LABELS_NL = {
|
||||
"max_w": "Vermogen van de omvormer",
|
||||
"bms_soc_floor": "Uitschakelniveau van de batterij",
|
||||
"capacity_kwh": "Bruikbare capaciteit",
|
||||
"round_trip_eff": "Rendement heen en terug",
|
||||
"round_trip_eff": "Heen-en-terugrendement",
|
||||
"inverters": "Lijst met omvormers",
|
||||
"name": "Naam",
|
||||
"meter_source": "Waar de meterstand vandaan komt",
|
||||
|
||||
@@ -18,7 +18,7 @@ by what a cycle needs. Not set, behaviour is exactly what it was.
|
||||
8. the status page (T41, T42)
|
||||
|
||||
Every check names the T/N row of the test plan it grades. The mutants run for
|
||||
this file are listed in the pull request (MUTATION.md).
|
||||
this file are listed in the dev report.
|
||||
"""
|
||||
import hashlib
|
||||
import json
|
||||
@@ -119,10 +119,12 @@ def prices_for(start, night=0.2333, day=0.2801):
|
||||
|
||||
def drive(etas, *, start=None, dur=40.0, load=500.0, soc0=None, peak_cap=20000,
|
||||
thr=0.0, variant="arb_only", limits=None, each=None, extra=None,
|
||||
n=None):
|
||||
n=None, house=None):
|
||||
"""The real Controller (read_inputs + cycle) over `dur` s on a plant that
|
||||
charges and a meter that reads it. Returns (rows, controller): one row per
|
||||
cycle with what arbitrage decided, what each unit was given and does."""
|
||||
cycle with what arbitrage decided, what each unit was given and does.
|
||||
`house`: [(seconds from start, W)] steps instead of the constant `load`
|
||||
(negative W is a solar surplus)."""
|
||||
start = start or local(2026, 11, 1, 22, 5)
|
||||
n = n or len(etas)
|
||||
rows = []
|
||||
@@ -145,7 +147,9 @@ def drive(etas, *, start=None, dur=40.0, load=500.0, soc0=None, peak_cap=20000,
|
||||
opt = {"cycle_cost_threshold_eur": thr, "peak_cap_w": peak_cap,
|
||||
"inverters": entries(etas, n)}
|
||||
opt.update(extra or {})
|
||||
_stats, c = rp.run(variant, [(start.timestamp() - 10, load)],
|
||||
steps = [(start.timestamp() - 10, load)] + [
|
||||
(start.timestamp() + s, w) for s, w in (house or [])]
|
||||
_stats, c = rp.run(variant, steps,
|
||||
prices_for(start), start, dur, check=cb, n=n,
|
||||
soc0=soc0 or {"a": 50.0, "b": 50.0, "c": 50.0},
|
||||
extra=opt, limits=limits)
|
||||
@@ -363,6 +367,105 @@ def _t6():
|
||||
share(settled(rows2), A) == -3000)
|
||||
|
||||
|
||||
def _grid_export_wh(rows, house_steps, base_load, tick=5.0):
|
||||
"""Wh the meter exported over `rows` (one cycle each), the house being
|
||||
`base_load` W until the first step and then each step's W."""
|
||||
out = 0.0
|
||||
for r in rows:
|
||||
load = base_load
|
||||
for s, w in house_steps:
|
||||
if r["t"] >= s:
|
||||
load = w
|
||||
out += max(0.0, -(load - sum(r["plant"].values()))) * tick / 3600.0
|
||||
return out
|
||||
|
||||
|
||||
@guarded("F1")
|
||||
def _f1():
|
||||
# After a trade on A ends (A reads full), a surplus must be soaked by B as
|
||||
# on base: the wind-down hold binds the trade's own tail, never the loop's
|
||||
# soak of an export.
|
||||
steps = [(20.0, -3000.0)]
|
||||
for soc_a, ceil, surplus, tag in ((99.9, 100, 3000.0, "3000 W"),
|
||||
(94.9, 95, 7000.0, "7000 W")):
|
||||
steps = [(20.0, -surplus)]
|
||||
kw = dict(dur=200.0, soc0={"a": soc_a, "b": 50.0},
|
||||
extra={"arbitrage_soc_ceiling": ceil}, house=steps)
|
||||
r1, _c1 = drive(ETA, **kw)
|
||||
r0, _c0 = drive(NONE2, **kw)
|
||||
e1 = _grid_export_wh(r1, steps, 500.0)
|
||||
e0 = _grid_export_wh(r0, steps, 500.0)
|
||||
check(f"F1 a {tag} surplus after the trade ends: export {e1:.1f} Wh "
|
||||
f"against base {e0:.1f} Wh (the hold does not block the soak)",
|
||||
len(r1) > 20 and e1 <= e0 + 1.0)
|
||||
late = [r for r in r1 if r["t"] >= 60]
|
||||
check(f"F1 {tag}: B takes the surplus within a minute of it, as on "
|
||||
f"base", any(r["plant"][B[-1]] < -1000.0 for r in late)
|
||||
and any(r["plant"][B[-1]] < -1000.0
|
||||
for r in r0 if r["t"] >= 60))
|
||||
|
||||
|
||||
def _hold_case():
|
||||
"""A controller whose site trade has just charged with B's leg failed."""
|
||||
c = mk(ETA, arb=True, now=NIGHT)
|
||||
mkd = lambda act: arbitrage.ArbitrageDecision( # noqa: E731
|
||||
action=act, power_w=-5000.0 if act else None, reason="x",
|
||||
spread_eur_kwh=0.04, required_eur_kwh=0.0, price_now_eur_kwh=0.23)
|
||||
return c, mkd
|
||||
|
||||
|
||||
def _held_units(c, claims):
|
||||
return sorted(cl.actuator for cl in claims)
|
||||
|
||||
|
||||
@guarded("F2")
|
||||
def _f2():
|
||||
from app.maintenance import DRAIN, IDLE
|
||||
ok = [types.SimpleNamespace(phase=IDLE)] * 2
|
||||
legs = {A: True, B: False}
|
||||
c, mkd = _hold_case()
|
||||
c.arb = mkd(arbitrage.CHARGE)
|
||||
cl = []
|
||||
c._hold_out_lossy(cl, ok, legs, 5000.0, 9600.0, 10.0, 95.0, NIGHT)
|
||||
check("F2 while the site charges, B (leg failed) is held, A is not",
|
||||
_held_units(c, cl) == [B])
|
||||
|
||||
def tail(secs, target, grid, phases=ok):
|
||||
c, mkd = _hold_case()
|
||||
c.arb = mkd(arbitrage.CHARGE)
|
||||
c._hold_out_lossy([], ok, legs, 5000.0, 9600.0, 10.0, 95.0, NIGHT)
|
||||
c.arb = mkd(None)
|
||||
c.target = -2000.0 # the tail starts: still charging
|
||||
c.grid = 1500.0
|
||||
c._hold_out_lossy([], phases, None, 0.0, 9600.0, 10.0, 95.0, NIGHT)
|
||||
c.target, c.grid = target, grid
|
||||
cl = []
|
||||
c._hold_out_lossy(cl, phases, None, 0.0, 9600.0, 10.0, 95.0,
|
||||
NIGHT + timedelta(seconds=secs))
|
||||
return _held_units(c, cl)
|
||||
check("F2 the tail of the trade (target still charging, meter importing, "
|
||||
"30 s on) is still held", tail(30, -2000.0, 1500.0) == [B])
|
||||
check("F2 released when the site target is 0 or above",
|
||||
tail(30, 0.0, 1500.0) == [] and tail(30, 800.0, 1500.0) == [])
|
||||
check("F2 released at 120 s whatever the target",
|
||||
tail(119, -2000.0, 1500.0) == [B]
|
||||
and tail(121, -2000.0, 1500.0) == [])
|
||||
check("F1 released when the meter exports: a negative target then is the "
|
||||
"loop soaking a surplus, not the trade's tail",
|
||||
tail(30, -2000.0, -3000.0) == [] and tail(30, -2000.0, 0.0) == [])
|
||||
# F3: a unit in a maintenance phase keeps its own claim, never the hold
|
||||
both = [types.SimpleNamespace(phase=IDLE),
|
||||
types.SimpleNamespace(phase=DRAIN)]
|
||||
c3, mkd3 = _hold_case()
|
||||
c3.arb = mkd3(arbitrage.CHARGE)
|
||||
cl3 = []
|
||||
c3._hold_out_lossy(cl3, both, legs, 5000.0, 9600.0, 10.0, 95.0, NIGHT)
|
||||
check("F3 B in a maintenance phase (drain) is not given the hold limit",
|
||||
_held_units(c3, cl3) == [])
|
||||
check("F3 ...also in the tail of the trade",
|
||||
tail(30, -2000.0, 1500.0, both) == [])
|
||||
|
||||
|
||||
@guarded("T7")
|
||||
def _t7():
|
||||
start = local(2026, 11, 1, 7, 0, 5)
|
||||
@@ -994,7 +1097,7 @@ def _t33():
|
||||
and "round_trip_eff" in text and text.count(". ") <= 1
|
||||
and len(text) < 200)
|
||||
check("T33 the Dutch label exists (the refusals name it by key too)",
|
||||
'Rendement heen en terug' in open(os.path.join(
|
||||
'Heen-en-terugrendement' in open(os.path.join(
|
||||
HERE, "app", "messages.py"), encoding="utf-8").read())
|
||||
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ configuration:
|
||||
name: "Bruikbare capaciteit (kWh) (optioneel)"
|
||||
description: "De bruikbare capaciteit van deze batterij, van het datablad. Vul ze bij elke omvormer in of bij geen. Dan verdeelt de add-on het werk volgens de energie in elke batterij."
|
||||
round_trip_eff:
|
||||
name: "Rendement heen en terug (optioneel)"
|
||||
name: "Heen-en-terugrendement (0,5 tot 1) (optioneel)"
|
||||
description: "Het deel energie dat de batterij teruggeeft, bijvoorbeeld 0,86. Leeg laten als onbekend. Stelt u het rendement in, verlaag dan de kosten van een batterijcyclus tot alleen slijtage."
|
||||
estop_fitted:
|
||||
name: "Hardware · RS485-noodstop is geplaatst"
|
||||
@@ -203,7 +203,7 @@ configuration:
|
||||
description: "Laden in het goedkoopste uur en de batterij laten leveren in het duurste, als het verschil de kosten dekt. Dit uitzetten zet de prijsfeed niet uit."
|
||||
cycle_cost_threshold_eur:
|
||||
name: "Tarief · Kosten van een batterijcyclus (EUR/kWh)"
|
||||
description: "Wat één cyclus per kWh kost. Een kleiner prijsverschil wordt niet verhandeld. Stelt u het rendement in, verlaag dan de kosten van een batterijcyclus tot alleen slijtage."
|
||||
description: "Wat één cyclus per kWh kost. Kleinere verschillen worden niet verhandeld. Een productkeuze, geen meting. Stelt u het rendement in, verlaag dan de kosten van een batterijcyclus tot alleen slijtage."
|
||||
arbitrage_soc_floor:
|
||||
name: "Tarief · Handel houdt minstens (%)"
|
||||
description: "Prijshandel laat de batterij niet onder dit niveau zakken. Dit staat los van de onderhoudsinstellingen."
|
||||
|
||||
Reference in New Issue
Block a user