test_peak_margin: read the month peak on the runs' clock, not today's
Part 3 read the simulated September's peak with the wall clock, so from
2026-10-01 it read no peak and crashed on every tree (4ad8298 too).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
4ad8298ead
commit
513183aba3
@@ -173,14 +173,15 @@ check("...and decide() sizes the floor to land the quarter 50 W under it "
|
|||||||
# ============================================================================ #
|
# ============================================================================ #
|
||||||
print("\n3. the bill and the reports keep the real cap")
|
print("\n3. the bill and the reports keep the real cap")
|
||||||
_c = _runs["n1_off", None][1]
|
_c = _runs["n1_off", None][1]
|
||||||
_pk = _c.peak.peak().peak_w
|
_t = rig.rig.BASE # the runs' clock, not the wall clock (a new month)
|
||||||
|
_pk = _c.peak.peak(_t).peak_w
|
||||||
print(f" month peak {_pk:.0f} W, tracker cap {_c.peak.cap_w:.0f} W, "
|
print(f" month peak {_pk:.0f} W, tracker cap {_c.peak.cap_w:.0f} W, "
|
||||||
f"warning {_c.peak.warning_frac():.3f}, headroom "
|
f"warning {_c.peak.warning_frac(_t):.3f}, headroom "
|
||||||
f"{_c.peak.headroom_w():.0f} W")
|
f"{_c.peak.headroom_w(_t):.0f} W")
|
||||||
check("test_billing_uses_cap: the month-peak tracker (bill, headroom, 80 % "
|
check("test_billing_uses_cap: the month-peak tracker (bill, headroom, 80 % "
|
||||||
"warning) is built on the real cap, not cap - margin",
|
"warning) is built on the real cap, not cap - margin",
|
||||||
_c.peak.cap_w == CAP and _c.peak.warning_frac() == _pk / CAP
|
_c.peak.cap_w == CAP and _c.peak.warning_frac(_t) == _pk / CAP
|
||||||
and _c.peak.headroom_w() == CAP - _pk)
|
and _c.peak.headroom_w(_t) == CAP - _pk)
|
||||||
_eng = [g for r in _runs["n1_off", None][0] for g in (r[-1][1],)
|
_eng = [g for r in _runs["n1_off", None][0] for g in (r[-1][1],)
|
||||||
if g and g[0] and g[1]]
|
if g and g[0] and g[1]]
|
||||||
print(f" {len(_eng)} engaged cycles; one: {_eng[0][4] if _eng else None}")
|
print(f" {len(_eng)} engaged cycles; one: {_eng[0][4] if _eng else None}")
|
||||||
|
|||||||
Reference in New Issue
Block a user