TARIFF-30: per-unit round-trip efficiency in the grid-charge decisions
Optional per-inverter key round_trip_eff (0.5-1). A unit's buy leg is priced at price / eta; the site trade, battery modes, day plan and Home use each unit's own. Not set: byte-identical to before. The discharge split is unchanged (part B is TARIFF-34). Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -23,7 +23,6 @@ from dataclasses import dataclass
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
from . import arbitrage, dayplan, modetrade, packshare, priceruns
|
||||
from .dayplan import EFF
|
||||
from .price import required_spread, uncertainty_of
|
||||
|
||||
SLOT_S = 900 # a price slot
|
||||
@@ -32,7 +31,7 @@ LIMIT = 24 # rolls at most (a day of one-hour runs)
|
||||
|
||||
|
||||
def roll_end(run, points, packs_at, *, required, floor_pct, ceiling_pct,
|
||||
targets=None, limit=LIMIT):
|
||||
targets=None, limit=LIMIT, legs=None):
|
||||
"""Where the cheap run `run` ends once control has rolled it on.
|
||||
|
||||
`packs_at(end)` gives the `modetrade.Pack`s as they stand when a run
|
||||
@@ -43,7 +42,7 @@ def roll_end(run, points, packs_at, *, required, floor_pct, ceiling_pct,
|
||||
end_t = run.end
|
||||
for _ in range(limit):
|
||||
e = modetrade.energy(packs_at(end_t), floor_pct, ceiling_pct,
|
||||
targets=targets)
|
||||
targets=targets, legs=legs)
|
||||
if e[0] <= 1e-6:
|
||||
break
|
||||
new = priceruns.plan(points, end_t, required_eur_kwh=required,
|
||||
@@ -89,7 +88,9 @@ class _Charge:
|
||||
the room the peak limit leaves: `min(sum of ratings, aim - house)`, shared
|
||||
by room left to full as control does (`_shares()`), each stopping at `modetrade.charge_to()`."""
|
||||
|
||||
def __init__(self, packs, t0, ceiling_pct, targets, aim_w, house):
|
||||
def __init__(self, packs, t0, ceiling_pct, targets, aim_w, house,
|
||||
legs=None):
|
||||
self.legs = legs
|
||||
self.packs = {p.name: p for p in packs}
|
||||
self.t = t0
|
||||
self.ceil = ceiling_pct
|
||||
@@ -147,7 +148,7 @@ class _Charge:
|
||||
|
||||
def _charge(self, s, e, hour):
|
||||
ch = modetrade.chargers(list(self.packs.values()), self.ceil,
|
||||
targets=self.targets)
|
||||
targets=self.targets, legs=self.legs)
|
||||
total = sum(abs(p.rating_w) for p in ch)
|
||||
if not ch or total <= 0.0:
|
||||
return
|
||||
@@ -159,7 +160,7 @@ class _Charge:
|
||||
if not p.capacity_kwh:
|
||||
continue
|
||||
to = modetrade.charge_to(p, self.ceil, self.targets)
|
||||
kwh = share[p.name] * hrs / 1000.0 * EFF
|
||||
kwh = share[p.name] * hrs / 1000.0 * dayplan.eff_of(p.eta)
|
||||
room = (to - p.soc) / 100.0 * float(p.capacity_kwh)
|
||||
if kwh <= 0.0:
|
||||
continue
|
||||
@@ -185,9 +186,10 @@ def for_today(c, rp, now):
|
||||
return None
|
||||
floor, ceil = arbitrage.soc_bounds(c.o)
|
||||
hp = getattr(c, "house_profile", None)
|
||||
legs = getattr(c, "charge_legs", lambda *_a: None)(plan, now)
|
||||
sim = _Charge(c._mode_packs(), max(now, rp.cheap.start), ceil,
|
||||
c.plan_targets(), c.peak_aim_w(),
|
||||
None if hp is None else hp.estimator())
|
||||
None if hp is None else hp.estimator(), legs)
|
||||
required = required_spread(
|
||||
arbitrage.threshold_eur_kwh(c.o),
|
||||
uncertainty_of(plan.read.product)
|
||||
@@ -195,7 +197,7 @@ def for_today(c, rp, now):
|
||||
bool(c.weather_held(now))))
|
||||
end = roll_end(rp.cheap, plan.read.points, sim.at, required=required,
|
||||
floor_pct=floor, ceiling_pct=ceil,
|
||||
targets=c.plan_targets())
|
||||
targets=c.plan_targets(), legs=legs)
|
||||
if end <= rp.cheap.end:
|
||||
return None
|
||||
return Roll(end, dict(sim.stops))
|
||||
|
||||
Reference in New Issue
Block a user