refactor: drop PV synthesis, model raw P1 net signal directly
The simulator used to reconstruct "gross household demand" by adding
back a synthesized PV trace (irradiance × kWp peak-match) to the P1 net
meter, then re-subtract a different synthesized PV per scenario. That
reconstruction was leaky — Michiel's horizontal pyranometer is at a
different location and orientation than dad's SE-facing array, so the
synthesis can't reproduce dad's actual production curve. Result: 511
hours of negative "gross demand" and phantom export inflation up to
~6 kW peak in scenarios where pv_kwp ≠ 3.
New shape: simulator works on a single signed signal, raw_demand_kw
(the P1 reading as recorded). No solar synthesis. Whatever the meter
shows is the input.
Concretely:
- sim.py: drop synthesize_pv, reconstruct_gross_demand,
schedule_with_planning_pv, no_foresight_schedule, groundhog_schedule,
_oracle_daily_schedule_legacy. Rename column convention demand_kwh →
raw_demand_kw. Plug-in discharge cap becomes max(0, raw_demand_kw).
- web.py: drop pv_kwp/pv_yield/strategy form params. Demand slider
now applies as an *additive* baseline shift (not multiplicative —
multiplying scaled the export bursts too, which is wrong since dad's
PV stays the same regardless of household consumption). Default
demand_kwh = 2325 (dad's actual full-year net per his quote;
extrapolated 8-month window comes out to ~1515, partial coverage).
Saturation metric now measures (surplus ≥ pc_max), not (charge ≥
pc_max) — the latter conflated arbitrage top-off with power-bottleneck.
- templates/index.html: drop PV input, drop strategy radios, drop
irradiance chart. Modal charts collapsed from 4 to 3: price, net
meter (toggles between with/without battery), SoC.
- app.js: mirror the above, drop pv_kwp/strategy plumbing.
- tests: rebase fixtures on raw_demand_kw, drop synthesize_pv test.
- scripts: drop --pv-kwp/--pv-yield flags throughout, switch column
references to raw_demand_kw.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e2fb72a0ab
commit
fc90e65271
12 changed files with 296 additions and 476 deletions
|
|
@ -10,8 +10,8 @@ Examples:
|
|||
python scripts/compare_with_store.py --capacity 5.12 --power 0.8 --cost 1339 --retail 0.25
|
||||
python scripts/compare_with_store.py --capacity 5.12 --power 2.5 --cost 1339 --retail 0.25
|
||||
|
||||
# PV scenario, fixed retail, no saldering:
|
||||
python scripts/compare_with_store.py --pv-kwp 3.0 --fixed --retail 0.28
|
||||
# Fixed retail, no saldering:
|
||||
python scripts/compare_with_store.py --fixed --retail 0.28
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
|
|
@ -23,7 +23,6 @@ from pluginbattery.sim import (
|
|||
load_hourly,
|
||||
oracle_daily_schedule,
|
||||
simulate,
|
||||
synthesize_pv,
|
||||
)
|
||||
from pluginbattery.store_calc import (
|
||||
Scenario,
|
||||
|
|
@ -47,10 +46,6 @@ def main() -> None:
|
|||
help="Fixed-rate mode (no time-of-day variation; kills arbitrage)")
|
||||
p.add_argument("--saldering", action="store_true",
|
||||
help="Full saldering on (export = retail). Default: no saldering.")
|
||||
# Solar
|
||||
p.add_argument("--pv-kwp", type=float, default=0.0, help="PV size in kWp; 0 = no PV")
|
||||
p.add_argument("--pv-yield", type=float, default=875.0,
|
||||
help="Annual PV yield in kWh/kWp (store uses 875 in their footer)")
|
||||
# Inflation
|
||||
p.add_argument("--inflation", type=float, default=0.03)
|
||||
args = p.parse_args()
|
||||
|
|
@ -59,9 +54,10 @@ def main() -> None:
|
|||
base = load_hourly("data/raw"); base = apply_nl_tariff(base)
|
||||
df = base.copy()
|
||||
|
||||
# Demand scaling.
|
||||
annual_demand = base["demand_kwh"].sum() * (8766.0 / len(base))
|
||||
df["demand_kwh"] = base["demand_kwh"] * (args.demand / annual_demand)
|
||||
# Demand scaling — scale the entire signed signal so existing-PV exports
|
||||
# scale with the household.
|
||||
annual_net_demand = base["raw_demand_kw"].sum() * (8766.0 / len(base))
|
||||
df["raw_demand_kw"] = base["raw_demand_kw"] * (args.demand / annual_net_demand)
|
||||
|
||||
# Retail price.
|
||||
if args.fixed:
|
||||
|
|
@ -73,16 +69,14 @@ def main() -> None:
|
|||
df["epex_eur_per_kwh"] = base["epex_eur_per_kwh"] * scale
|
||||
epex_in_use = df["epex_eur_per_kwh"]
|
||||
|
||||
# PV.
|
||||
if args.pv_kwp > 0:
|
||||
df = synthesize_pv(df, kwp=args.pv_kwp, target_kwh_per_kwp_per_year=args.pv_yield)
|
||||
|
||||
# Saldering.
|
||||
if args.saldering:
|
||||
df["export_eur_per_kwh"] = df["eur_per_kwh"]
|
||||
else:
|
||||
df["export_eur_per_kwh"] = 0.0 # post-saldering default in this script
|
||||
|
||||
has_existing_pv = bool((df["raw_demand_kw"] < 0).any())
|
||||
|
||||
bat = Battery(
|
||||
capacity_kwh=args.capacity,
|
||||
max_charge_kw=args.power,
|
||||
|
|
@ -102,7 +96,7 @@ def main() -> None:
|
|||
max_charge_kw=args.power,
|
||||
battery_cost_eur=args.cost,
|
||||
avg_retail_eur_per_kwh=args.retail,
|
||||
has_pv=args.pv_kwp > 0,
|
||||
has_pv=has_existing_pv,
|
||||
has_saldering=args.saldering,
|
||||
dynamic_rate=not args.fixed,
|
||||
)
|
||||
|
|
@ -114,9 +108,8 @@ def main() -> None:
|
|||
print(f" Tariff : avg retail €{args.retail}, "
|
||||
f"{'FIXED' if args.fixed else 'DYNAMIC'} rate, "
|
||||
f"{'WITH' if args.saldering else 'NO'} saldering")
|
||||
print(f" PV : {args.pv_kwp} kWp"
|
||||
f"{' @ ' + str(args.pv_yield) + ' kWh/kWp/yr' if args.pv_kwp else ''}")
|
||||
print(f" Demand : {args.demand:.0f} kWh/yr")
|
||||
print(f" PV : {'existing PV in meter signal' if has_existing_pv else 'no measurable existing PV'}")
|
||||
print(f" Net demand : {args.demand:.0f} kWh/yr")
|
||||
print(f" Inflation : {args.inflation*100:.1f}%/yr")
|
||||
print()
|
||||
print(f"{'':22s} {'year-1 €':>10s} {'payback':>9s}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue