EV-05 round 2: the peak cut waits 15 s while a battery can give
Owner 2026-11-18 (dev finding 1, brief v4 Expected 8): while a battery is above its cut-out, the car's peak cut waits until the guard has wanted power for 15 s in a row (CUT_WAIT_S), so a cloud edge the batteries catch does not pause the car. It cuts at once with no battery able, or with 120 s or less of the 15-minute period left (CUT_NEAR_END_S: waiting 15 s then costs at most 8/7 of the cut, taken off the car at once). Tests: T21/T22 cut at 15 s and not sooner, the period lands under the aim; T21b a house step and a cloud edge the batteries catch: no cut, no pause; T24 (c) late in the period: the cut at once, under the aim; T12's cut row with the batteries at their cut-out. The harness's battery level model was 1000x too fast (round 1); fixed. The 10-hour day: 0 cut pauses in both priorities. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -577,41 +577,99 @@ ABLE = {"a": 60.0, "b": 60.0}
|
||||
CUTOUT = {"a": 10.0, "b": 10.0} # the batteries' own cut-out: no giving
|
||||
|
||||
|
||||
def quarters(r, aim):
|
||||
"""(start, import average, car average) of each whole quarter."""
|
||||
out = []
|
||||
tr = r["trace"]
|
||||
for q0 in range(0, int(tr[-1]["t"]) + 1 - 900, 900):
|
||||
xs = [x for x in tr if q0 <= x["t"] < q0 + 900]
|
||||
if len(xs) < 890:
|
||||
continue
|
||||
g = sum(max(0.0, x["grid"]) for x in xs) / len(xs)
|
||||
car = sum(x["car"] for x in xs) / len(xs)
|
||||
out.append((q0, g, car))
|
||||
return out
|
||||
|
||||
|
||||
def first_cut(r, after):
|
||||
return next((x for x in r["trace"] if x["t"] >= after and x["cut"] > 0),
|
||||
None)
|
||||
|
||||
|
||||
# Car first, house 500 W, sun 2900 W: 2300 W = 10 A on 1 phase.
|
||||
# The step: 500 -> 6000 W early in the period, about 800 W over the aim.
|
||||
r21 = S.drive(house=steps((0, 500.0), (200, 6000.0)), sun=const(2900.0),
|
||||
first="car", socs=ABLE, dur=260)
|
||||
# Round 2 (owner 2026-11-18): while a battery can still give, the cut waits
|
||||
# until the guard has wanted power for 15 s in a row (CUT_WAIT_S).
|
||||
# T21b: a step the batteries catch within 15 s (500 -> 6000 W): no cut.
|
||||
r21b = S.drive(house=steps((0, 500.0), (200, 6000.0)), sun=const(2900.0),
|
||||
first="car", socs=ABLE, dur=400)
|
||||
want21b = [x["t"] for x in r21b["trace"] if x["since"] is not None]
|
||||
# The step also takes the sun from the car, so the normal hold (6 A) follows.
|
||||
check(f"T21b: a house step the batteries catch within 15 s: the guard wanted "
|
||||
f"power for {len(want21b)} s, no cut, no pause; only the hold's 6 A "
|
||||
f"({cur(r21b)})",
|
||||
0 < len(want21b) < 15 and not first_cut(r21b, 0)
|
||||
and [v for _t, v in cur(r21b)] == [10.0, 6.0])
|
||||
# A cloud edge with the car at high power on 3 phases (sun 13 kW -> 3 kW for
|
||||
# 120 s, house 500 W), 10 s into a period so the 10 kW import does head over
|
||||
# the aim: the guard wants power until the batteries ramp; at the shipped
|
||||
# `slew_w` 0 they catch it within 15 s, so the car is not cut and not paused
|
||||
# (owner 2026-11-18).
|
||||
r21c = S.drive(house=const(500.0), sun=steps((0, 13000.0), (910, 3000.0),
|
||||
(1030, 13000.0)),
|
||||
first="car", socs=ABLE, dur=1150, opts={"slew_w": 0})
|
||||
w21c = [(t, v) for t, v in cur(r21c) if 900 <= t < 1150]
|
||||
want21c = [x["t"] for x in r21c["trace"] if x["since"] is not None
|
||||
and 905 <= x["t"] <= 960]
|
||||
check(f"T21b: a cloud edge the batteries catch within 15 s gives no cut and "
|
||||
f"no pause: the guard wanted power for {len(want21c)} s (writes {w21c}, "
|
||||
f"phases {ph(r21c)})",
|
||||
0 < len(want21c) < 15
|
||||
and not first_cut(r21c, 900) and 0.0 not in [v for _t, v in w21c]
|
||||
and nonzero(r21c) and nonzero(r21c)[-1][1] >= 6.0)
|
||||
# T21: a step the batteries cannot catch (500 -> 15500 W for 90 s): the cut
|
||||
# comes 15 s after the guard first wants power, not sooner.
|
||||
r21 = S.drive(house=steps((0, 500.0), (200, 15500.0), (290, 500.0)),
|
||||
sun=const(2900.0), first="car", socs=ABLE, dur=920)
|
||||
x21 = first_cut(r21, 200)
|
||||
w21 = [(t, v) for t, v in cur(r21) if t >= 200]
|
||||
since21 = next((x["since"] for x in r21["trace"] if x["since"] is not None),
|
||||
None)
|
||||
w21 = [] if x21 is None else [(t, v) for t, v in cur(r21) if t >= x21["t"]]
|
||||
lim21 = None if x21 is None else math.floor((2300.0 - x21["cut"]) / 230.0)
|
||||
check(f"T21: a house step takes the period over the aim with the batteries "
|
||||
f"able: the car is cut within 1 cycle, to at most floor((2300 - cut) / "
|
||||
f"230) A (cut {None if x21 is None else round(x21['cut'])} W at "
|
||||
check(f"T21: a house step beyond the batteries: no cut in the first 15 s the "
|
||||
f"guard wants power, then the car is cut within 1 cycle, to at most "
|
||||
f"floor((2300 - cut) / 230) A (wants from {since21}, cut "
|
||||
f"{None if x21 is None else round(x21['cut'])} W at "
|
||||
f"{None if x21 is None else x21['t']}, writes {w21})",
|
||||
x21 is not None and x21["t"] <= 202 and w21
|
||||
and w21[0][0] <= x21["t"] + 1 and w21[0][1] <= max(lim21, 0))
|
||||
x21 is not None and since21 is not None
|
||||
and 15 <= x21["t"] - since21 <= 16 and w21
|
||||
and w21[0][0] <= x21["t"] + 2 and w21[0][1] <= max(lim21, 0)
|
||||
and not [t for t, v in cur(r21) if 200 <= t < x21["t"] and v == 0.0])
|
||||
q21 = [g for q, g, _c in quarters(r21, 3400.0) if q == 0]
|
||||
check(f"T21: the period still lands under the aim ({[round(g) for g in q21]} "
|
||||
f"W against 3400 W)", q21 and q21[0] <= 3410.0)
|
||||
_after = [x for x in r21["trace"] if x21 and x["t"] == x21["t"] + 5]
|
||||
check(f"T21: 5 s later, what must still come off the meter is at most the "
|
||||
f"excess less the cut ({[round(x['excess'] or 0) for x in _after]})",
|
||||
_after and (_after[0]["excess"] or 0.0) <= max(
|
||||
0.0, (x21["excess"] or 0.0) - x21["cut"]) + 60.0)
|
||||
r22 = S.drive(house=steps((0, 500.0), (200, 7500.0), (260, 500.0)),
|
||||
sun=const(2900.0), first="car", socs=ABLE, dur=600)
|
||||
r22 = S.drive(house=steps((0, 500.0), (200, 17500.0), (290, 500.0)),
|
||||
sun=const(2900.0), first="car", socs=ABLE, dur=700)
|
||||
# (a hold's 6 A may come first: the step also takes the car's sun)
|
||||
x22 = first_cut(r22, 200)
|
||||
w22 = [(t, v) for t, v in cur(r22) if t >= 200]
|
||||
since22 = next((x["since"] for x in r22["trace"] if x["since"] is not None),
|
||||
None)
|
||||
w22 = [] if x22 is None else [(t, v) for t, v in cur(r22) if t >= x22["t"]]
|
||||
last_cut22 = max((x["t"] for x in r22["trace"] if x["cut"] > 0), default=None)
|
||||
check(f"T22: an excess of 920 W or more: 0 A at once, no 5-min hold "
|
||||
f"({w22}, cut {None if x22 is None else round(x22['cut'])})",
|
||||
x22 is not None and w22 and w22[0] == (w22[0][0], 0.0)
|
||||
and w22[0][0] <= x22["t"] + 1)
|
||||
check(f"T22: an excess of 920 W or more: 0 A, no 5-min hold, after the 15 s "
|
||||
f"wait and not sooner ({w22}, wants from {since22}, cut "
|
||||
f"{None if x22 is None else round(x22['cut'])})",
|
||||
x22 is not None and since22 is not None
|
||||
and 15 <= x22["t"] - since22 <= 16 and w22
|
||||
and w22[0][1] == 0.0 and w22[0][0] <= x22["t"] + 2
|
||||
and not [t for t, v in cur(r22) if 200 <= t < x22["t"] and v == 0.0])
|
||||
check(f"T22: no restart before the period is under the aim (last cut "
|
||||
f"{last_cut22}) and the 120 s start rule has run",
|
||||
last_cut22 is not None and len(w22) >= 2
|
||||
last_cut22 is not None and len(w22) >= 2 and w22[1][1] > 0
|
||||
and w22[1][0] - last_cut22 >= 120)
|
||||
# T23: the house alone over the aim, the batteries at their cut-out, the car
|
||||
# at 6 A (started at 1700 W, then sun 2000, house 500, margin 100: 1400 W).
|
||||
@@ -645,26 +703,24 @@ check(f"T24 (a): cut at :13:4x ({cuts24[:3]}), no further cut from :15:00, "
|
||||
r24b = S.drive(house=steps((0, 500.0), (900, 6500.0)), sun=const(2900.0),
|
||||
first="car", socs=CUTOUT, dur=960)
|
||||
c24b = first_cut(r24b, 899)
|
||||
# T24 (c): batteries able, 85 s before the period's end a step whose import,
|
||||
# held, takes the period over the aim: inside CUT_NEAR_END_S (120 s) the cut
|
||||
# comes at once, and the period lands under the aim.
|
||||
r24c = S.drive(house=steps((0, 500.0), (815, 49000.0), (830, 500.0)),
|
||||
sun=const(2900.0), first="car", socs=ABLE, dur=920)
|
||||
c24c = first_cut(r24c, 815)
|
||||
q24c = [g for q, g, _c in quarters(r24c, 3400.0) if q == 0]
|
||||
check(f"T24 (c): late in the period with the batteries able the cut does not "
|
||||
f"wait ({None if c24c is None else c24c['t']}, {cur(r24c)[-2:]}), and "
|
||||
f"the period lands under the aim ({[round(g) for g in q24c]} W)",
|
||||
c24c is not None and c24c["t"] <= 817 and q24c and q24c[0] <= 3410.0
|
||||
and ctl_car.CUT_NEAR_END_S >= 120.0)
|
||||
check(f"T24 (b): the new period heads over from its first second (N=2, "
|
||||
f"next_quarter): the cut comes in its first cycles "
|
||||
f"({None if c24b is None else c24b['t']}, {cur(r24b)[-1:]})",
|
||||
c24b is not None and c24b["t"] <= 902 and cur(r24b)[-1][1] == 0.0)
|
||||
|
||||
|
||||
def quarters(r, aim):
|
||||
"""(start, import average, car average) of each whole quarter."""
|
||||
out = []
|
||||
tr = r["trace"]
|
||||
for q0 in range(0, int(tr[-1]["t"]) + 1 - 900, 900):
|
||||
xs = [x for x in tr if q0 <= x["t"] < q0 + 900]
|
||||
if len(xs) < 890:
|
||||
continue
|
||||
g = sum(max(0.0, x["grid"]) for x in xs) / len(xs)
|
||||
car = sum(x["car"] for x in xs) / len(xs)
|
||||
out.append((q0, g, car))
|
||||
return out
|
||||
|
||||
|
||||
def day25(t):
|
||||
"""Clouds and house steps, 2 hours."""
|
||||
clouds = [(400, 520), (1500, 1530), (2600, 3100), (4000, 4060),
|
||||
@@ -1101,8 +1157,9 @@ for name, trig in (("Off", lambda p, c: c.handle_action("car_mode",
|
||||
check(f"T12 {name} 2 s after a normal write: the 0 A goes out within 1 "
|
||||
f"cycle, the 30 s rule does not delay it ({cur(r12)})",
|
||||
"t2" in s12 and z12 and s12["t2"] <= z12[0] <= s12["t2"] + 1)
|
||||
# Batteries at their cut-out: nothing can give, so the cut does not wait.
|
||||
r12c = S.drive(house=steps((0, 500.0), (154, 7500.0)), sun=steps(
|
||||
(0, 2900.0), (150, 3600.0)), first="car", socs=ABLE, dur=260)
|
||||
(0, 2900.0), (150, 3600.0)), first="car", socs=CUTOUT, dur=260)
|
||||
_nz12 = [t for t, v in cur(r12c) if v > 0]
|
||||
_z12 = [t for t, v in cur(r12c) if v == 0.0]
|
||||
check(f"T12 the peak cut 2 s after a normal write: 0 A within 1 cycle "
|
||||
|
||||
Reference in New Issue
Block a user