diff --git a/goodwe_controller/test_opt27.py b/goodwe_controller/test_opt27.py index 6989dda..62ac848 100644 --- a/goodwe_controller/test_opt27.py +++ b/goodwe_controller/test_opt27.py @@ -508,6 +508,33 @@ check("03:30 (after midnight + 3 h): a figure from before the night is not " present(lf) and lf["fc_none"] and lf["runs_on"] is False and lf["reason"] == "not_worth" and not any(r["charging"] for r in rf)) +# g. OPT-28's shortfall sizing on a kept figure: Leftover solar (A) is sized +# from the kept forecast exactly as from a fresh one, not "no forecast" +def fresh_all(now, ent): + return st(0.4 if ent == T_ENT else 12.0, now) + + +cg, rg, pg = drive27(opts(), fresh_all, pre=EVENING + [at(DAY3, 21, 55)], + start=NIGHT_START) +kp, fp_ = ca.day_plan, cg.day_plan +print(f" g. kept : short={kp and kp.short_kwh} uncovered=" + f"{kp and kp.uncovered_kwh} targets={kp and kp.targets} " + f"need={kp and kp.need_kwh} sun={kp and kp.sun_kwh}") +print(f" fresh : short={fp_ and fp_.short_kwh} uncovered=" + f"{fp_ and fp_.uncovered_kwh} targets={fp_ and fp_.targets} " + f"need={fp_ and fp_.need_kwh} sun={fp_ and fp_.sun_kwh}") +check("a kept figure sizes the night by OPT-28's shortfall, with a level for " + "Leftover solar (A): not 'no forecast', which has no plan at all", + kp is not None and A in kp.targets and kp.short_kwh > 0.0 + and cb.day_plan is None and not cg.solar_fc.kept) +check("... and the level, the grid need, the shortfall and the sun counted " + "are those a fresh figure gives (counted once, from the right time)", + fp_ is not None and kp.targets == fp_.targets + and kp.need_kwh == fp_.need_kwh and kp.share_kwh == fp_.share_kwh + and abs(kp.short_kwh - fp_.short_kwh) < 1e-9 + and abs(kp.uncovered_kwh - fp_.uncovered_kwh) < 1e-9 + and abs(kp.sun_kwh - fp_.sun_kwh) < 1e-9) + # --------------------------------------------------------------------------- # print("\n3. The screens") blk = ca.block