EV-05 round 9: one test of control; another writer's phases are a hold
SolarWriter.in_control is the single test of "Solar has the charger": writing, read-back current and phases are Solar's own, no hold, no write refused, given up or owed. Alarm grading, banking, the own-pause grace and the cut use it. A phase change Solar did not make is another writer: nothing written over it, hold after 30 s, no select back after 10 min. While Solar's own switch waits, a lower current is written at once, and the arithmetic uses the phases the car draws on. A car another writer starts inside the own-pause grace is no longer graded out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VSY9UpTaUYnjJF5oVtbM1w
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
e348a808ff
commit
c9a95f3c10
@@ -2174,6 +2174,97 @@ for H8 in (40000.0, 42000.0):
|
||||
f"{None if cut8 is None else cut8['t']})",
|
||||
want8 is not None and cut8 is not None and head8 is True
|
||||
and cut8["t"] - want8 <= 1)
|
||||
# =========================================================================== #
|
||||
print("\nROUND 9. ONE TEST OF CONTROL: THE READ-BACK CURRENT AND PHASES ARE SOLAR'S")
|
||||
# =========================================================================== #
|
||||
|
||||
|
||||
# 1. The review's p_blocked: Solar starts in auto on a charger at 3 phases, so
|
||||
# its own select to 1 phase comes at about 122 s. Another writer selects 3
|
||||
# phases at T and leaves the current. N=2 at the cut-out, the grid takes it.
|
||||
# The twin is Off with the car at Solar's 12 A on 3 phases from T.
|
||||
def phases_vs_off(T, dur, label):
|
||||
kw = dict(house=const(500.0), sun=const(3500.0), first="car", socs=CUT10,
|
||||
dur=dur, opts={"slew_w": 0}, phases=3)
|
||||
|
||||
def oth(p, c):
|
||||
p.ch.set_phases(3)
|
||||
p.ch.set_current(12)
|
||||
rs = S.drive(events={T: lambda p, c: p.ch.set_phases(3)},
|
||||
sim=SimCharger(setpoint_a=0), **kw)
|
||||
ro = S.drive(events={T: oth}, mode="off", sim=SimCharger(setpoint_a=0),
|
||||
**kw)
|
||||
own = [t for t, _v in S.writes(rs, "phases") if t < T]
|
||||
late = after(rs, T) + [x for x in S.writes(rs, "phases") if x[0] >= T]
|
||||
a_s, a_o = first_alarm(rs, T), first_alarm(ro, T)
|
||||
ex = sum(1 for x in rs["trace"] if x["t"] > T and x["explains"])
|
||||
w = rs["c"].car_solar
|
||||
check(f"R9 another writer selects 3 phases {label}: Solar writes nothing "
|
||||
f"over it ({late}), holds ({w.hold}), alarms as Off (+2 s) "
|
||||
f"({a_s} vs {a_o}), the car never explained away ({ex} cycles)",
|
||||
late == [] and w.hold and a_s is not None and a_o is not None
|
||||
and abs(a_s - a_o) <= 2 and ex == 0)
|
||||
return rs, ro, own
|
||||
|
||||
|
||||
r9a, _r9ao, own9 = phases_vs_off(300, 1000, "inside Solar's 10 minutes")
|
||||
check(f"R9 (precondition) Solar's own select came less than "
|
||||
f"{carmode.PHASE_GAP_S:.0f} s before ({own9})",
|
||||
own9 and 300 - own9[-1] < carmode.PHASE_GAP_S)
|
||||
check(f"R9 the quarter the other writer's phases ran in is banked as the "
|
||||
f"car's ({r9a['c'].car_peak_q})", len(r9a["c"].car_peak_q) == 1)
|
||||
r9b, _r9bo, own9b = phases_vs_off(800, 1300, "after Solar's 10 minutes")
|
||||
check(f"R9 (precondition) Solar's own select came more than "
|
||||
f"{carmode.PHASE_GAP_S:.0f} s before ({own9b})",
|
||||
own9b and 800 - own9b[-1] > carmode.PHASE_GAP_S)
|
||||
# 2. The review's p_young: Solar's own 0 A pause at about 603 s, another
|
||||
# writer starts the car at T inside OWN_PAUSE_MAX_S of it. The read-back is
|
||||
# not Solar's 0 A, so the grace does not cover it.
|
||||
for T9 in (615, 640):
|
||||
r9y = paused_vs_off(T9, f"another writer starts the car at {T9} s, "
|
||||
f"inside the grace of Solar's own 0 A",
|
||||
sun=steps((0, 7000.0), (300, 0.0)))
|
||||
_own9 = [t for t, v in cur(r9y) if v == 0.0 and t < T9]
|
||||
check(f"R9 (precondition) Solar's own 0 A came less than "
|
||||
f"{ctl_car.OWN_PAUSE_MAX_S:.0f} s before {T9} s ({_own9[-1:]})",
|
||||
_own9 and T9 - _own9[-1] < ctl_car.OWN_PAUSE_MAX_S)
|
||||
|
||||
|
||||
# 3. Solar holds control while its phases settle: its own select to 3 phases
|
||||
# returns False although the charger took it (Home Assistant's answer was
|
||||
# lost), so the plan stays on 1 phase and the next switch waits 10 minutes.
|
||||
# A cut in that time is written at once, worked out on the 3 phases the car
|
||||
# draws on.
|
||||
def _lost_select(p, c):
|
||||
orig = p.ch.request_phases
|
||||
|
||||
def rp(n):
|
||||
orig(n)
|
||||
return False
|
||||
p.ch.request_phases = rp
|
||||
|
||||
|
||||
r9c = S.drive(house=lambda t: 15000.0 if t >= 650 else 500.0,
|
||||
sun=const(9000.0), first="car", socs=CUT10, dur=700,
|
||||
opts={"slew_w": 0}, phases=1, events={0: _lost_select})
|
||||
w9c = r9c["c"].car_solar
|
||||
c9 = next((x for x in r9c["trace"] if x["t"] >= 650 and x["cut"] > 0), None)
|
||||
pre9 = next((x for x in r9c["trace"] if x["t"] == 649), {})
|
||||
check(f"R9 (precondition) the plan is on 1 phase, the charger on 3, the "
|
||||
f"switch waits (n {pre9.get('n')}, phases {pre9.get('ph')}, current "
|
||||
f"{pre9.get('sp')}, blocked {w9c.blocked})",
|
||||
pre9.get("n") == 1 and pre9.get("ph") == 3 and w9c.blocked
|
||||
and (pre9.get("sp") or 0) >= 6)
|
||||
if c9 is not None:
|
||||
w9 = math.floor((pre9["car"] - c9["cut"]) / (carmode.VOLTS * 3))
|
||||
got9 = after(r9c, c9["t"], c9["t"] + 3)
|
||||
else:
|
||||
w9, got9 = None, None
|
||||
check(f"R9 a cut while Solar's own phases settle is written at once, on the 3 "
|
||||
f"phases the car draws on (cut at {None if c9 is None else c9['t']}, "
|
||||
f"wanted {w9} A, written {got9})",
|
||||
c9 is not None and w9 is not None and w9 >= 6
|
||||
and got9 == [(got9[0][0], float(w9))] if got9 else False)
|
||||
print("\n(T39, T44, T45, T50 and T51, the long runs, are in test_ev05_long.py)")
|
||||
|
||||
print()
|
||||
|
||||
Reference in New Issue
Block a user