From 5a956f1c82b10f4283fa8bbfd52fd9c6c2a39bd9 Mon Sep 17 00:00:00 2001 From: Louis Date: Sun, 8 Nov 2026 15:20:31 +0100 Subject: Add Panasonic Aquarea, hot water and PV, step-by-step layout - Panasonic Aquarea J (WH-MDC05/07/09J3E5) and L (WH-WDG05/07/09LE5) monobloc capacity and COP tables from the service manuals. - Optional hot water (daily demand charged 11-15 h MEZ with priority over heating) and PV with battery from DWD 10-minute global/diffuse irradiation, each switched on separately; surplus fed in or curtailed. - Inputs in five steps with the key figures always visible on top and the matching chart beside each step; full results in the last step. - Bisect the bivalence point so no hour at exactly that temperature is left uncovered (seen with 1 K bins). - Average the duration curve between sample points instead of picking single hours, which showed hot water hours as spikes. - Make the hidden attribute override label display rules. Co-Authored-By: Claude Opus 5.5 --- README.md | 52 +++++-- scripts/prep.py | 180 +++++++++++++++++++++++- web/app.js | 420 ++++++++++++++++++++++++++++++++++++++++++++++++++------ web/devices.js | 90 ++++++++++++ web/index.html | 136 ++++++++++++++---- web/style.css | 91 ++++++++++-- 6 files changed, 877 insertions(+), 92 deletions(-) diff --git a/README.md b/README.md index bd66ed4..2e5ba83 100644 --- a/README.md +++ b/README.md @@ -4,31 +4,44 @@ Like BWP WPsim, but for every German postcode. Hourly DWD air temperatures 2007 (about 470 stations, nearest station per postcode) drive a simple model: - Heating load linear from Norm-Heizlast at Norm-Außentemperatur to 0 at the heating limit. -- Heat pumps: Remko LWM 80/110/150 with maximum capacity and COP per outdoor and flow - temperature (W35/W45/W55) from the installation manual, see `web/devices.js`. The - bivalence point follows from capacity and load; in bivalent-alternativ mode it is a - manual switching temperature. Load the heat pump cannot cover above it is shown as - uncovered. Hours below the minimum capacity are counted as cycling. +- Heat pumps: Remko LWM 80/110/150 (installation manual) and Panasonic Aquarea generation J + (WH-MDC05/07/09J3E5) and generation L (WH-WDG05/07/09LE5, service manual heating + capacity tables) with maximum capacity and COP per outdoor and flow temperature + (W35/W45/W55), see `web/devices.js`. The bivalence point + follows from capacity and load; in bivalent-alternativ mode it is a manual switching + temperature. Load the heat pump cannot cover above it is shown as uncovered. Hours below + the minimum capacity are counted as cycling (Remko only; Panasonic does not publish it). - Generic heat pump: capacity equals the load at a manual bivalence point and changes by a fixed %/K; COP of the LWM 110 (air) or Carnot-based (ground/water). - Modes: monovalent (heater rod), bivalent-parallel (optional cut-off temperature), bivalent-alternativ. Flow temperature fixed or weather-compensated. +- Inputs in five steps (location, building, heat pump, hot water & PV, costs), then the + full results; the key figures stay visible above every step and update live. - Backup fuel: heater rod, natural gas, LPG, oil, pellets or firewood, with amounts in kWh, m³, l, kg or rm. -- Results: heat demand, coverage shares, JAZ, electricity, costs; charts and CSV export. +- Optional hot water and PV, each switched on separately (step 4, results in their own section): + - Hot water: daily demand charged from 11 to 15 h MEZ at tank temperature + 5 K, with + priority over heating; the backup heater covers what the heat pump cannot. + - PV: hourly yield from DWD 10-minute global and diffuse irradiation (nearest solar + station per year), south, 30° tilt, Hay-Davies transposition, 14 % losses, module + temperature from the air temperature. Inputs are only kWp and battery kWh (90 % round + trip, 1 C) and whether surplus is fed in (otherwise curtailed). PV and battery supply + the heat pump and heater rod only, no household load. +- Results: heat demand, coverage shares, JAZ, electricity, self-consumption, autarky, + costs; charts and CSV export. The app is static HTML/JS; all calculations run in the browser. ## Quick start Requires [uv](https://docs.astral.sh/uv/). The weather data is not part of this -repository. Build it once from the original sources (downloads about 700 MB into -`.cache/`, writes about 150 MB to `web/data/`, takes a few minutes): +repository. Build it once from the original sources (downloads about 1.9 GB into +`.cache/`, writes about 190 MB to `web/data/`, takes about 30–60 minutes): ```sh uv run scripts/prep.py ``` -uv picks a suitable Python and installs the script's dependencies (numpy) from the +uv picks a suitable Python and installs the script's dependencies (numpy, pandas) from the metadata at the top of `scripts/prep.py`. Then serve the `web/` directory and open http://127.0.0.1:8765: @@ -49,17 +62,26 @@ fetch fresh data (for example after DWD publishes a new year). 3. Estimates the Norm-Außentemperatur per station as the two-day mean undercut on 10 days in 20 years. This is within about 0.5–2.5 K of the DIN/TS 12831-1 values (usually warmer); the user can override it. -4. Downloads [GeoNames postal codes](https://download.geonames.org/export/zip/) and assigns +4. Downloads the 10-minute solar archives from + [DWD](https://opendata.dwd.de/climate_environment/CDC/observations_germany/climate/10_minutes/solar/historical/), + sums them to hours (UTC, all six values required) and keeps years with global + irradiation under the same gap limits; missing hours are filled from the same hour of the + surrounding days, missing diffuse values with the Erbs correlation. Stations that only + record sunshine duration are skipped. The PV yield per kWp is computed here and written + to `web/data/pv/`; each temperature station uses the nearest solar station per year. +5. Downloads [GeoNames postal codes](https://download.geonames.org/export/zip/) and assigns each postcode to its nearest station. ## Limitations - No altitude correction between postcode and station. -- JAZ ignores cycling, circulation pump and hot water, so it is on the optimistic side. +- JAZ ignores cycling, circulation pump and tank losses beyond the hot water demand entered, + so it is on the optimistic side. +- PV orientation is fixed; the battery starts empty every year and is not charged from the grid. - Device data is full load at nominal conditions; part load, defrost beyond the datasheet - points and other devices are not modelled. Capacities were digitised from the manual's + points and other devices are not modelled. Remko capacities were digitised from the manual's diagrams (about ±0.2 kW). -- Not affiliated with BWP, Remko or DWD. +- Not affiliated with BWP, Remko, Panasonic or DWD. ## License and data sources @@ -67,7 +89,7 @@ Code: [MIT](LICENSE). The generated data is subject to its sources' terms: -- Weather data: Deutscher Wetterdienst (DWD), Climate Data Center, hourly air temperature, - see the [DWD terms of use](https://opendata.dwd.de/climate_environment/CDC/Terms_of_use.pdf). +- Weather data: Deutscher Wetterdienst (DWD), Climate Data Center, hourly air temperature + and 10-minute solar irradiation, see the [DWD terms of use](https://opendata.dwd.de/climate_environment/CDC/Terms_of_use.pdf). Attribution: "Datenbasis: Deutscher Wetterdienst". - Postcodes: [GeoNames](https://www.geonames.org/), CC BY 4.0. diff --git a/scripts/prep.py b/scripts/prep.py index 44f72aa..1c6c87b 100644 --- a/scripts/prep.py +++ b/scripts/prep.py @@ -1,6 +1,6 @@ # /// script # requires-python = ">=3.10" -# dependencies = ["numpy"] +# dependencies = ["numpy", "pandas"] # /// """Build the weather data for the web app from DWD open data and GeoNames. @@ -9,6 +9,9 @@ Output (web/data/): plz.json postcode -> [place, lat, lon, station id, distance km] t/.bin int16 hourly temperatures in 0.1 °C, YEARS x 8760 (Feb 29 dropped), MISSING for invalid years + pv/.bin uint16 hourly PV yield in Wh per kWp (before the module temperature + correction), YEARS x 8760, PV_MISSING for invalid years; hour i is the + interval from hour i to i+1 UTC """ import io @@ -22,8 +25,10 @@ from concurrent.futures import ThreadPoolExecutor from pathlib import Path import numpy as np +import pandas as pd DWD = "https://opendata.dwd.de/climate_environment/CDC/observations_germany/climate/hourly/air_temperature/historical/" +DWD_SOLAR = "https://opendata.dwd.de/climate_environment/CDC/observations_germany/climate/10_minutes/solar/historical/" GEONAMES = "https://download.geonames.org/export/zip/DE.zip" YEARS = list(range(2007, 2026)) HOURS = 8760 @@ -32,13 +37,26 @@ MAX_MISSING_SHARE = 0.03 # a year with more gaps is dropped MAX_GAP_HOURS = 72 # a longer single gap also drops the year MIN_YEARS = 10 # a station needs this many valid years to be used +# PV generator: south, 30° tilt, ground albedo 0.2, 14 % system losses (as PVGIS) +PV_TILT = math.radians(30) +PV_ALBEDO = 0.2 +PV_LOSSES = 0.14 +PV_MISSING = 65535 +# irradiation gaps are filled from the surrounding days, so it may have more of them +SOLAR_MAX_MISSING_SHARE = 0.10 +SOLAR_MAX_GAP_HOURS = 168 +SOLAR_FILL_DAYS = 10 +PV_MAX_DISTANCE = 100 # km between temperature and solar station + ROOT = Path(__file__).resolve().parent.parent OUT = ROOT / "web" / "data" CACHE = ROOT / ".cache" def fetch(url: str) -> bytes: - path = CACHE / (url.rsplit("/", 1)[1] or "index.html") + # directory listings are cached under their directory names + name = url.rsplit("/", 1)[1] or re.sub(r"\W+", "_", url.split("/CDC/")[-1]) + "index.html" + path = CACHE / name if not path.exists(): with urllib.request.urlopen(url, timeout=120) as r: path.write_bytes(r.read()) @@ -124,6 +142,150 @@ def load_station(sid: str, zip_name: str) -> np.ndarray: return out +def solar_zip_names() -> dict: + """Station id -> 10-minute solar archives that overlap YEARS.""" + html = fetch(DWD_SOLAR).decode() + names = {} + for m in re.finditer(r'href="(10minutenwerte_SOLAR_(\d{5})_(\d{8})_(\d{8})_hist\.zip)"', html): + if int(m.group(4)[:4]) >= YEARS[0] and int(m.group(3)[:4]) <= YEARS[-1]: + names.setdefault(m.group(2), []).append(m.group(1)) + return names + + +def read_solar_stations() -> dict: + text = fetch(DWD_SOLAR + "zehn_min_sd_Beschreibung_Stationen.txt").decode("latin1") + stations = {} + for line in text.splitlines()[2:]: + parts = line.split() + if len(parts) < 8: + continue + sid, lat, lon = parts[0], float(parts[4]), float(parts[5]) + stations[sid] = dict(id=sid, lat=lat, lon=lon, name=" ".join(parts[6:-2])) + return stations + + +# day of the non-leap year (0..364) for each month and day, -1 for Feb 29 +_DAY = np.full((13, 32), -1) +for (_m, _d, _h), _i in HOUR_INDEX.items(): + _DAY[_m, _d] = _i // 24 + + +def load_solar(zip_names: list) -> tuple: + """Hourly global and diffuse irradiation in Wh/m², YEARS x HOURS, NaN where missing. + The 10-minute sums (J/cm²) are stamped at the end of their interval in UTC.""" + ghi = np.zeros(len(YEARS) * HOURS) + dhi = np.zeros(len(YEARS) * HOURS) + n_g = np.zeros(len(YEARS) * HOURS) + n_d = np.zeros(len(YEARS) * HOURS) + for name in zip_names: + with zipfile.ZipFile(io.BytesIO(fetch(DWD_SOLAR + name))) as z: + product = next(n for n in z.namelist() if n.startswith("produkt_zehn_min")) + df = pd.read_csv(z.open(product), sep=";", usecols=[1, 3, 4], skipinitialspace=True) + stamp = pd.to_datetime(df.iloc[:, 0].astype(str), format="%Y%m%d%H%M") - pd.Timedelta(minutes=10) + year = stamp.dt.year.to_numpy() + day = _DAY[stamp.dt.month.to_numpy(), stamp.dt.day.to_numpy()] + keep = (year >= YEARS[0]) & (year <= YEARS[-1]) & (day >= 0) + idx = ((year - YEARS[0]) * HOURS + day * 24 + stamp.dt.hour.to_numpy())[keep] + for col, total, count in ((2, ghi, n_g), (1, dhi, n_d)): + v = df.iloc[:, col].to_numpy(dtype=float)[keep] + ok = v >= 0 + np.add.at(total, idx[ok], v[ok]) + np.add.at(count, idx[ok], 1) + j_per_cm2 = 10000 / 3600 # J/cm² -> Wh/m² + # an hour needs all six 10-minute values + ghi = np.where(n_g == 6, ghi * j_per_cm2, np.nan).reshape(len(YEARS), HOURS) + dhi = np.where(n_d == 6, dhi * j_per_cm2, np.nan).reshape(len(YEARS), HOURS) + return ghi, dhi + + +def fill_solar_year(values: np.ndarray) -> np.ndarray | None: + """Fill missing hours with the mean of the same hour within ±SOLAR_FILL_DAYS, or + return None if the year is too incomplete.""" + missing = np.isnan(values) + if missing.mean() > SOLAR_MAX_MISSING_SHARE: + return None + if not missing.any(): + return values + edges = np.diff(np.concatenate([[0], missing.astype(int), [0]])) + if (np.flatnonzero(edges == -1) - np.flatnonzero(edges == 1)).max() > SOLAR_MAX_GAP_HOURS: + return None + days = values.reshape(-1, 24) + out = days.copy() + for d, h in zip(*np.nonzero(np.isnan(days))): + window = days[max(0, d - SOLAR_FILL_DAYS):d + SOLAR_FILL_DAYS + 1, h] + out[d, h] = np.nanmean(window) if np.isfinite(window).any() else 0 + return out.ravel() + + +def pv_yield(year: int, lat: float, lon: float, ghi: np.ndarray, dhi: np.ndarray) -> np.ndarray: + """PV yield in Wh/kWp per hour from horizontal global and diffuse irradiation, with + the Hay-Davies model for the tilted plane. The sun position is taken at mid-hour. + Missing diffuse values (NaN) are estimated with the Erbs correlation.""" + days = np.array([(np.datetime64(f"{year}-{m:02d}-{d:02d}") - np.datetime64(f"{year}-01-01")).astype(int) + for (m, d, h) in HOUR_INDEX if h == 0]) + doy = np.repeat(days, 24) + 1 + hour = np.tile(np.arange(24) + 0.5, len(days)) + g = 2 * math.pi / 365 * (doy - 1 + (hour - 12) / 24) + decl = (0.006918 - 0.399912 * np.cos(g) + 0.070257 * np.sin(g) - 0.006758 * np.cos(2 * g) + + 0.000907 * np.sin(2 * g) - 0.002697 * np.cos(3 * g) + 0.00148 * np.sin(3 * g)) + eot = 229.18 * (0.000075 + 0.001868 * np.cos(g) - 0.032077 * np.sin(g) + - 0.014615 * np.cos(2 * g) - 0.040849 * np.sin(2 * g)) # minutes + omega = np.radians((hour * 60 + eot + 4 * lon) / 4 - 180) # hour angle + phi = math.radians(lat) + cosz = np.sin(phi) * np.sin(decl) + np.cos(phi) * np.cos(decl) * np.cos(omega) + # angle of incidence on a south-facing plane tilted by PV_TILT + cosi = (np.sin(phi - PV_TILT) * np.sin(decl) + + np.cos(phi - PV_TILT) * np.cos(decl) * np.cos(omega)) + up = cosz > 0.035 # sun more than 2° above the horizon + i0 = 1367 * (1 + 0.033 * np.cos(2 * math.pi * doy / 365)) + kt = np.where(up, np.clip(ghi / (i0 * np.maximum(cosz, 0.087)), 0, 1), 0) + erbs = np.where(kt <= 0.22, 1 - 0.09 * kt, + np.where(kt <= 0.8, 0.9511 - 0.1604 * kt + 4.388 * kt**2 - 16.638 * kt**3 + + 12.336 * kt**4, 0.165)) + dhi = np.minimum(np.where(np.isnan(dhi), erbs * ghi, dhi), ghi) + beam = np.where(up, ghi - dhi, 0) + diffuse = np.where(up, dhi, ghi) + rb = np.where(up, np.maximum(cosi, 0) / np.maximum(cosz, 0.087), 0) + ai = np.where(up, np.clip(beam / np.maximum(cosz, 0.087) / i0, 0, 1), 0) # anisotropy index + poa = (beam * rb + diffuse * (ai * rb + (1 - ai) * (1 + math.cos(PV_TILT)) / 2) + + ghi * PV_ALBEDO * (1 - math.cos(PV_TILT)) / 2) + return poa * (1 - PV_LOSSES) # 1 kWp delivers 1 kW at 1000 W/m² + + +def build_pv(stations: dict) -> list: + """Write pv/.bin for every solar station with global irradiation and return their + metadata with the valid years.""" + names = solar_zip_names() + candidates = [stations[sid] for sid in names if sid in stations] + print(f"{len(candidates)} candidate solar stations", file=sys.stderr) + + def work(s): + return s, load_solar(names[s["id"]]) + + used = [] + with ThreadPoolExecutor(4) as pool: + for i, (s, (ghi, dhi)) in enumerate(pool.map(work, candidates), 1): + out = np.full((len(YEARS), HOURS), PV_MISSING, dtype=np.uint16) + years = [] + for y, year in enumerate(YEARS): + g = fill_solar_year(ghi[y]) + if g is None: + continue + # diffuse: measured where available, otherwise estimated in pv_yield + d = dhi[y] + if np.isnan(d).mean() > SOLAR_MAX_MISSING_SHARE: + continue + out[y] = np.round(pv_yield(year, s["lat"], s["lon"], g, d)).astype(np.uint16) + years.append(year) + print(f"\r{i}/{len(candidates)} {s['name'][:30]:30} {len(years)} years", + end="", file=sys.stderr) + if years: + out.tofile(OUT / "pv" / f"{s['id']}.bin") + used.append(dict(id=s["id"], name=s["name"], lat=s["lat"], lon=s["lon"], years=years)) + print(f"\n{len(used)} solar stations with global irradiation", file=sys.stderr) + return used + + def norm_outdoor_temp(series: np.ndarray) -> float | None: """Estimate the Norm-Außentemperatur as in DIN EN 12831: the lowest two-day mean reached or undercut 10 times in 20 years (counted in days).""" @@ -167,6 +329,7 @@ def read_postcodes() -> dict: def main(): CACHE.mkdir(exist_ok=True) (OUT / "t").mkdir(parents=True, exist_ok=True) + (OUT / "pv").mkdir(parents=True, exist_ok=True) stations = read_station_list() zips = zip_names() @@ -192,6 +355,16 @@ def main(): tnorm=norm_outdoor_temp(series))) print(f"\n{len(used)} stations with at least {MIN_YEARS} valid years", file=sys.stderr) + # per temperature station and year the nearest solar station with data for that year + pv = build_pv(read_solar_stations()) + for s in used: + s["pv"] = [] + for year in YEARS: + near = [(haversine(s["lat"], s["lon"], p["lat"], p["lon"]), p["id"]) for p in pv + if year in p["years"]] + near = [n for n in near if n[0] <= PV_MAX_DISTANCE] + s["pv"].append(min(near)[1] if near else None) + plz = {} for code, (place, lat, lon) in sorted(read_postcodes().items()): best = min(used, key=lambda s: haversine(lat, lon, s["lat"], s["lon"])) @@ -199,7 +372,8 @@ def main(): round(haversine(lat, lon, best["lat"], best["lon"]), 1)] print(f"{len(plz)} postcodes", file=sys.stderr) - meta = dict(years=YEARS, hours=HOURS, missing=MISSING, stations=used) + meta = dict(years=YEARS, hours=HOURS, missing=MISSING, stations=used, pvMissing=PV_MISSING, + pvStations=[dict(id=p["id"], name=p["name"], lat=p["lat"], lon=p["lon"]) for p in pv]) (OUT / "stations.json").write_text(json.dumps(meta, ensure_ascii=False)) (OUT / "plz.json").write_text(json.dumps(plz, ensure_ascii=False, separators=(",", ":"))) diff --git a/web/app.js b/web/app.js index 3f70176..6468943 100644 --- a/web/app.js +++ b/web/app.js @@ -53,10 +53,19 @@ const FUELS = { wood: { unit: "rm", kwh: 1700, price: 110, priceUnit: "€/rm", perPrice: 1700, scale: 1, eff: 80 }, }; +// hot water is charged daily in these hours (UTC), i.e. 11 to 15 h MEZ +const WW_HOURS = [10, 11, 12, 13]; +const WW_LIFT = 5; // flow temperature above the tank temperature +// PV module: temperature coefficient per K and cell heating per W/m² (NOCT 45 °C); +// the stored yield includes 14 % losses, so irradiance is yield / 0.86 +const PV_GAMMA = -0.004, PV_HEATING = 25 / 800, PV_PR = 0.86; +const BATTERY_EFF = Math.sqrt(0.9); // per direction, 90 % round trip + const fmt = (v, digits = 0) => v.toLocaleString("de-DE", { minimumFractionDigits: digits, maximumFractionDigits: digits }); -let meta, plzMap, stationById; +let meta, plzMap, stationById, pvStationById; const seriesCache = new Map(); +const pvCache = new Map(); let station = null; let tnEdited = false; let lastResult = null; @@ -78,6 +87,18 @@ async function loadSeries(id) { return seriesCache.get(id); } +/** Hourly PV yield in Wh/kWp of a solar station for one year, or null without data. */ +async function loadPv(id, year) { + if (!id) return null; + if (!pvCache.has(id)) { + pvCache.set(id, fetch(`data/pv/${id}.bin`).then(async (res) => new Uint16Array(await res.arrayBuffer()))); + } + const raw = await pvCache.get(id); + const i = meta.years.indexOf(year); + const slice = raw.subarray(i * meta.hours, (i + 1) * meta.hours); + return slice[0] === meta.pvMissing ? null : slice; +} + /** Heating degree hours below 15 °C, used to find the coldest and warmest year. */ function degreeHours(slice) { let sum = 0; @@ -122,6 +143,9 @@ function temperatures(slice, resolution) { * alternative mode, where it is the user's switching temperature. * Below the bivalence point the backup heater is released (always when monovalent, * i.e. monoenergetic with heater rod); load neither of them covers stays uncovered. + * Hot water has priority: in its charging hours it takes the share of the capacity it + * needs at its own flow temperature, and the backup heater covers what is left. Below the + * bivalence point that share is missing for heating and the backup heater covers it too. */ function model(p) { const dev = p.type === "air" && p.device !== "generic" ? DEVICES[p.device] : null; @@ -132,57 +156,84 @@ function model(p) { const f = 20 + ((p.flowN - 20) * (20 - t)) / (20 - p.tn); return Math.min(p.flowN, Math.max(25, f)); }; - let capacity; + let capacityAt; if (dev) { - capacity = (t) => (t < dev.tmin ? 0 : interpFlow(dev.cap, t, flow(t))); + capacityAt = (t, f) => (t < dev.tmin ? 0 : interpFlow(dev.cap, t, f)); } else { const pb = load(tb); - capacity = (t) => Math.max(0, pb * (1 + p.slope * (t - tb))); + capacityAt = (t) => Math.max(0, pb * (1 + p.slope * (t - tb))); } - // highest outdoor temperature at which the heat pump alone no longer covers the load + const capacity = (t) => capacityAt(t, flow(t)); + // outdoor temperature below which the heat pump alone no longer covers the load: + // scan down in 0.1 K steps, then bisect, so every colder temperature lies strictly below it + const short = (t) => capacity(t) < load(t) - 1e-9; let limit = null; - for (let t = p.thg; t >= -30; t -= 0.1) { - if (capacity(t) < load(t) - 1e-9) { limit = Math.round(t * 10) / 10; break; } + for (let k = 1; p.thg - k / 10 >= -30; k++) { + let lo = p.thg - k / 10, hi = p.thg - (k - 1) / 10; + if (!short(lo)) continue; + for (let i = 0; i < 40; i++) { + const mid = (lo + hi) / 2; + if (short(mid)) lo = mid; else hi = mid; + } + limit = hi; + break; } if (dev && p.mode !== "alternative") tb = limit ?? -Infinity; - const heatPump = (t) => { - if (p.mode === "alternative" && t < tb) return 0; - if (p.mode === "parallel" && Number.isFinite(p.cutoff) && t < p.cutoff) return 0; - return Math.min(load(t), capacity(t)); - }; + const running = (t) => !(p.mode === "alternative" && t < tb) && + !(p.mode === "parallel" && Number.isFinite(p.cutoff) && t < p.cutoff); + // `share` is the part of the hour the heat pump spends on hot water + const heatPump = (t, share = 0) => (running(t) ? Math.min(load(t), capacity(t) * (1 - share)) : 0); const backupAllowed = (t) => p.mode === "mono" || t < tb; - const cop = (t) => { - if (p.type === "air") return deviceCop(dev || DEVICES.lwm110, t, flow(t)); + const copAt = (t, f) => { + if (p.type === "air") return deviceCop(dev || DEVICES.lwm110, t, f); const [source, eta] = SOURCE[p.type]; - return Math.min(COP_MAX, eta * carnot(flow(t), source)); + return Math.min(COP_MAX, eta * carnot(f, source)); }; - return { dev, tb, pb: Number.isFinite(tb) ? capacity(tb) : 0, load, capacity, heatPump, backupAllowed, flow, cop, limit }; + const cop = (t) => copAt(t, flow(t)); + const wwFlow = p.wwTemp + WW_LIFT; + /** Hot water of one charging hour: heat pump part, its share of the hour and electricity. */ + const hotWater = (t, need) => { + const cap = running(t) ? capacityAt(t, wwFlow) : 0; + const hp = Math.min(need, cap); + return { hp, share: cap > 0 ? hp / cap : 0, el: hp > 0 ? hp / copAt(t, wwFlow) : 0 }; + }; + return { dev, tb, pb: Number.isFinite(tb) ? capacity(tb) : 0, load, capacity, heatPump, backupAllowed, flow, cop, limit, hotWater, wwFlow, copAt }; } function simulate(series, years, p) { const m = model(p); const n = years.length; + const wwNeed = p.hotWater ? p.ww / WW_HOURS.length : 0; const r = { years, n, tb: m.tb, pb: m.pb, model: m, params: p, q: 0, hp: 0, backup: 0, uncovered: 0, el: 0, peak: 0, heatingHours: 0, backupHours: 0, uncoveredHours: 0, cyclingHours: 0, belowTn: 0, + ww: 0, wwHp: 0, wwBackup: 0, elWw: 0, months: Array.from({ length: 12 }, () => ({ hp: 0, backup: 0, uncovered: 0 })), + wwMonths: Array.from({ length: 12 }, () => ({ hp: 0, backup: 0 })), els: new Float32Array(n * 8760), bins: new Map(), loads: new Float32Array(n * 8760), hps: new Float32Array(n * 8760), backs: new Float32Array(n * 8760), + wwHps: new Float32Array(n * 8760), + wwBacks: new Float32Array(n * 8760), temps: [], }; + const isWw = new Uint8Array(8760); + if (wwNeed > 0) for (let i = 0; i < 8760; i++) isWw[i] = WW_HOURS.includes(i % 24) ? 1 : 0; // temperatures repeat a lot (0.1 K resolution), so evaluate the model once per value - const cache = new Map(); - const evaluate = (t) => { - let v = cache.get(t); + const caches = [new Map(), new Map()]; + const evaluate = (t, ww) => { + let v = caches[ww].get(t); if (!v) { - const q = m.load(t), hp = m.heatPump(t); + const w = ww ? m.hotWater(t, wwNeed) : { hp: 0, share: 0, el: 0 }; + // above the bivalence point the heat pump catches up on the heating pause afterwards + const q = m.load(t), hp = m.heatPump(t, m.backupAllowed(t) ? w.share : 0); const backup = m.backupAllowed(t) ? q - hp : 0; - v = { q, hp, backup, uncovered: q - hp - backup, el: hp > 0 ? hp / m.cop(t) : 0 }; - cache.set(t, v); + v = { q, hp, backup, uncovered: q - hp - backup, el: hp > 0 ? hp / m.cop(t) : 0, + wwHp: w.hp, wwBackup: ww ? wwNeed - w.hp : 0, wwEl: w.el }; + caches[ww].set(t, v); } return v; }; @@ -190,17 +241,25 @@ function simulate(series, years, p) { const t = temperatures(series.get(year), p.resolution); r.temps.push(t); for (let i = 0; i < t.length; i++) { - const { q, hp, backup, uncovered, el } = evaluate(t[i]); - r.loads[y * 8760 + i] = q; - r.hps[y * 8760 + i] = hp; - r.backs[y * 8760 + i] = backup; + const { q, hp, backup, uncovered, el, wwHp, wwBackup, wwEl } = evaluate(t[i], isWw[i]); + const j = y * 8760 + i; + r.loads[j] = q; + r.hps[j] = hp; + r.backs[j] = backup; + r.els[j] = el + wwEl; + if (isWw[i]) { + r.wwHps[j] = wwHp; + r.wwBacks[j] = wwBackup; + r.ww += wwNeed; r.wwHp += wwHp; r.wwBackup += wwBackup; r.elWw += wwEl; + r.wwMonths[HOUR_MONTH[i]].hp += wwHp; + r.wwMonths[HOUR_MONTH[i]].backup += wwBackup; + } if (q <= 0) continue; - r.els[y * 8760 + i] = el; r.q += q; r.hp += hp; r.backup += backup; r.uncovered += uncovered; r.el += el; r.heatingHours++; if (backup > 1e-9) r.backupHours++; if (uncovered > 1e-9) r.uncoveredHours++; - if (m.dev && hp > 0 && hp < m.dev.pmin) r.cyclingHours++; + if (m.dev?.pmin && hp > 0 && hp < m.dev.pmin) r.cyclingHours++; if (t[i] < p.tn) r.belowTn++; if (q > r.peak) r.peak = q; r.months[HOUR_MONTH[i]].hp += hp; @@ -214,8 +273,8 @@ function simulate(series, years, p) { }); // per-year averages for (const k of ["q", "hp", "backup", "uncovered", "el", "heatingHours", "backupHours", - "uncoveredHours", "cyclingHours", "belowTn"]) r[k] /= n; - for (const month of r.months) for (const k in month) month[k] /= n; + "uncoveredHours", "cyclingHours", "belowTn", "ww", "wwHp", "wwBackup", "elWw"]) r[k] /= n; + for (const month of [...r.months, ...r.wwMonths]) for (const k in month) month[k] /= n; for (const bin of r.bins.values()) for (const k in bin) bin[k] /= n; r.jaz = r.el > 0 ? r.hp / r.el : 0; r.costHp = (r.el * p.priceEl) / 100; @@ -225,9 +284,77 @@ function simulate(series, years, p) { r.costBackup = (r.backupFuel / fuel.perPrice) * p.priceBackup * fuel.scale; const loadTn = m.load(p.tn); r.powerShareTn = loadTn > 0 ? m.heatPump(p.tn) / loadTn : 0; + // heating and hot water together + r.heat = r.q + r.ww; + r.hpAll = r.hp + r.wwHp; + r.backupAll = r.backup + r.wwBackup; + r.elAll = r.el + r.elWw; + r.jazWw = r.elWw > 0 ? r.wwHp / r.elWw : 0; + r.jazAll = r.elAll > 0 ? r.hpAll / r.elAll : 0; + r.backupFuelAll = r.backupAll / p.effBackup; + r.backupAmountAll = r.backupFuelAll / fuel.kwh; + r.costBackupAll = (r.backupFuelAll / fuel.perPrice) * p.priceBackup * fuel.scale; + r.cost = (r.elAll * p.priceEl) / 100 + r.costBackupAll; return r; } +/** + * Hourly electricity balance of heat pump and (electric backup only) heater rod with PV + * and battery. `pvData` holds the yield in Wh/kWp per simulated year, or null. + * The battery starts empty each year, charges only from surplus PV and is limited to 1 C. + */ +function balance(r, p, series, pvData) { + const n = r.n, cap = p.battery; + const electric = p.fuel === "electric"; + const b = { + pv: 0, direct: 0, charge: 0, discharge: 0, feed: 0, grid: 0, demand: 0, gridCost: 0, noPvCost: 0, + months: Array.from({ length: 12 }, () => ({ pv: 0, direct: 0, battery: 0, grid: 0 })), + pvs: new Float32Array(n * 8760), grids: new Float32Array(n * 8760), feeds: new Float32Array(n * 8760), + missingYears: r.years.filter((_, y) => !pvData[y]), + }; + r.years.forEach((year, y) => { + const yieldWh = pvData[y], temps = series.get(year); + let soc = 0; + for (let i = 0; i < 8760; i++) { + const j = y * 8760 + i; + const hp = r.els[j]; + const rod = electric ? (r.backs[j] + r.wwBacks[j]) / p.effBackup : 0; + const d = hp + rod; + let pv = 0; + if (yieldWh && yieldWh[i] > 0) { + const cell = temps[i] / 10 + (PV_HEATING * yieldWh[i]) / PV_PR; + pv = ((p.kwp * yieldWh[i]) / 1000) * (1 + PV_GAMMA * (cell - 25)); + } + const direct = Math.min(pv, d); + const charge = Math.min(pv - direct, (cap - soc) / BATTERY_EFF, cap); + soc += charge * BATTERY_EFF; + const discharge = Math.min(d - direct, soc * BATTERY_EFF, cap); + soc -= discharge / BATTERY_EFF; + const grid = d - direct - discharge; + const feed = pv - direct - charge; + // grid electricity is priced per consumer in proportion to its demand + const price = d > 0 ? (hp * p.priceEl + rod * p.priceBackup) / d : 0; + b.gridCost += (grid * price) / 100; + b.noPvCost += (hp * p.priceEl + rod * p.priceBackup) / 100; + b.pv += pv; b.direct += direct; b.charge += charge; b.discharge += discharge; + b.feed += feed; b.grid += grid; b.demand += d; + const month = b.months[HOUR_MONTH[i]]; + month.pv += pv; month.direct += direct; month.battery += discharge; month.grid += grid; + b.pvs[j] = pv; b.grids[j] = grid; b.feeds[j] = feed; + } + }); + for (const k of ["pv", "direct", "charge", "discharge", "feed", "grid", "demand", "gridCost", "noPvCost"]) b[k] /= n; + for (const month of b.months) for (const k in month) month[k] /= n; + b.selfShare = b.pv > 0 ? (b.pv - b.feed) / b.pv : 0; + b.autarky = b.demand > 0 ? (b.direct + b.discharge) / b.demand : 0; + b.revenue = p.feedOn ? (b.feed * p.feedIn) / 100 : 0; + b.cycles = cap > 0 ? b.discharge / cap : 0; + // electricity from the grid replaces the electricity costs; fuels stay as they are + b.cost = b.gridCost - b.revenue + (electric ? 0 : r.costBackupAll); + b.saving = r.cost - b.cost; + return b; +} + // ---------- form ---------- /** Number from an input; NaN when it is empty or not a valid number (e.g. while typing "-"). */ @@ -255,6 +382,15 @@ function params() { fuel: $("fuel").value, priceBackup: num("priceBackup"), effBackup: num("effBackup") / 100, + hotWater: $("wwOn").checked, + pv: $("pvOn").checked, + extra: $("wwOn").checked || $("pvOn").checked, + ww: num("ww"), + wwTemp: num("wwTemp"), + kwp: num("kwp"), + battery: num("battery"), + feedOn: $("feedOn").checked, + feedIn: num("feedIn"), }; } @@ -267,6 +403,9 @@ function validate(p) { ]; if (p.mode !== "mono" && manualTbiv) required.push(["tbiv", $("tbivLabel").textContent]); if (generic) required.push(["slope", "Leistungsänderung der WP"]); + if (p.hotWater) required.push(["ww", "Warmwasserbedarf"], ["wwTemp", "Speichertemperatur"]); + if (p.pv) required.push(["kwp", "PV-Anlage"], ["battery", "Batteriespeicher"]); + if (p.pv && p.feedOn) required.push(["feedIn", "Einspeisevergütung"]); for (const [key, label] of required) { if (!Number.isFinite(p[key])) return `Bitte eine gültige Zahl für „${label}“ eingeben.`; } @@ -274,6 +413,11 @@ function validate(p) { if (!(p.flowN >= 25 && p.flowN <= 65)) return "Vorlauftemperatur muss zwischen 25 und 65 °C liegen."; if (!(p.effBackup > 0)) return "Wirkungsgrad der Zusatzheizung muss größer als 0 sein."; if (!(p.tn < p.thg)) return "Norm-Außentemperatur muss unter der Heizgrenztemperatur liegen."; + if (p.hotWater) { + if (!(p.ww >= 0)) return "Warmwasserbedarf darf nicht negativ sein."; + if (!(p.wwTemp >= 40 && p.wwTemp <= 60)) return "Speichertemperatur muss zwischen 40 und 60 °C liegen."; + } + if (p.pv && (!(p.kwp >= 0) || !(p.battery >= 0))) return "PV-Leistung und Speicher dürfen nicht negativ sein."; if (p.mode !== "mono" && manualTbiv && !(p.tbiv < p.thg)) return `${$("tbivLabel").textContent} muss unter der Heizgrenztemperatur liegen.`; return null; } @@ -318,6 +462,62 @@ function updateFieldVisibility() { $("tbivLabel").textContent = device ? "Umschalttemperatur" : "Bivalenzpunkt"; $("cutoffField").hidden = mode !== "parallel"; $("cutoffField").nextElementSibling.hidden = mode !== "parallel"; + const ww = $("wwOn").checked, pv = $("pvOn").checked; + $("wwFields").hidden = !ww; + $("pvFields").hidden = !pv; + $("feedInField").hidden = !(pv && $("feedOn").checked); + $("summaryBlock").hidden = !(ww || pv); + $("extraBlock").hidden = !(ww || pv); + $("extraHeading").textContent = ww && pv ? "Warmwasser & PV" : ww ? "Warmwasser" : "PV und Speicher"; + $("wwFigure").hidden = !ww; + if (!pv) $("powerFigure").hidden = true; +} + +// ---------- steps ---------- + +const steps = [...document.querySelectorAll(".step")]; +const figures = [...document.querySelectorAll("figure[data-step]")]; +let step = 1; + +/** Show one step; charts sit beside the inputs they depend on and all together under Ergebnisse. */ +function showStep(n) { + step = Math.min(Math.max(n, 1), steps.length); + steps.forEach((s) => { s.hidden = +s.dataset.step !== step; }); + const last = step === steps.length; + for (const f of figures) { + const target = last ? `figs-${f.dataset.group}` : +f.dataset.step === step ? `aside-${step}` : "figures"; + $(target).append(f); + } + $("stepper").querySelectorAll("button").forEach((b) => { + const k = +b.dataset.step; + b.setAttribute("aria-current", k === step ? "step" : "false"); + b.classList.toggle("done", k < step); + if (k === step) b.scrollIntoView({ block: "nearest", inline: "nearest" }); + }); + $("prev").hidden = step === 1; + $("next").hidden = last; + if (!last) $("next").textContent = `Weiter: ${steps[step].dataset.title}`; + try { history.replaceState(null, "", `#${step}`); } catch {} +} + +function buildStepper() { + $("stepper").innerHTML = steps.map((s) => + ``).join(""); + $("stepper").querySelectorAll("button").forEach((b) => b.addEventListener("click", () => showStep(+b.dataset.step))); + $("prev").addEventListener("click", () => { showStep(step - 1); scrollTo({ top: 0 }); }); + $("next").addEventListener("click", () => { showStep(step + 1); scrollTo({ top: 0 }); }); + showStep(parseInt(location.hash.slice(1), 10) || 1); +} + +/** Solar station used for the most recent simulated year, with its distance. */ +function pvStationText(years) { + const id = station.pv?.[meta.years.indexOf(years[years.length - 1])]; + const s = id && pvStationById[id]; + if (!s) return null; + const rad = Math.PI / 180; + const a = Math.sin(((s.lat - station.lat) * rad) / 2) ** 2 + + Math.cos(station.lat * rad) * Math.cos(s.lat * rad) * Math.sin(((s.lon - station.lon) * rad) / 2) ** 2; + return `${s.name} (${fmt(12742 * Math.asin(Math.sqrt(a)), 0)} km von der Temperaturstation)`; } function onFuelChange(resetValues = true) { @@ -351,17 +551,34 @@ async function run() { const p = params(); const error = validate(p); // keep the last results visible but greyed out until the input is valid again - $("results").classList.toggle("stale", !!error); + document.body.classList.toggle("stale", !!error); if (error) { $("status").innerHTML = `${error}`; return; } const token = ++runToken; const series = await loadSeries(station.id); if (token !== runToken) return; - const years = scenarioYears(series, $("scenario").value); + let years = scenarioYears(series, $("scenario").value); + let pvData = null, pvOnly = false; + if (p.pv && p.kwp > 0) { + // with PV the mean covers only the years with irradiation data, so both sides match + const pvId = (year) => station.pv?.[meta.years.indexOf(year)]; + const withPv = years.filter(pvId); + if (years.length > 1 && withPv.length && withPv.length < years.length) { years = withPv; pvOnly = true; } + pvData = await Promise.all(years.map((year) => loadPv(pvId(year), year))); + if (token !== runToken) return; + } const r = simulate(series, years, p); + r.pv = pvData ? balance(r, p, series, pvData) : null; lastResult = r; $("status").textContent = years.length > 1 - ? `Mittelwerte über ${years.length} Jahre (${years[0]}–${years[years.length - 1]}), Station ${station.name}.` + ? `Mittelwerte über ${years.length} Jahre${pvOnly ? " mit Strahlungsdaten" : ""} (${years[0]}–${years[years.length - 1]}), Station ${station.name}.` : `Wetterjahr ${years[0]}, Station ${station.name}.`; + if (r.pv) { + const text = pvStationText(years); + if (text) $("status").textContent += ` Strahlung: ${text}.`; + if (r.pv.missingYears.length) { + $("status").innerHTML += ` Keine Strahlungsdaten (Station bis 100 km) für ${r.pv.missingYears.join(", ")}, dort ohne PV gerechnet.`; + } + } if (r.model.dev) { const auto = p.mode !== "alternative"; $("tbivHint").textContent = r.model.limit == null @@ -376,10 +593,15 @@ async function run() { if (r.uncovered > 0.5) { $("status").innerHTML += ` ${fmt(r.uncovered)} kWh/a nicht gedeckt: Die WP schafft die Heizlast oberhalb des Bivalenzpunkts nicht.`; } + renderPreview(r); renderKpis(r); renderDuration(r); renderBins(r); renderMonths(r); + if (p.extra) { + renderSummary(r); + renderExtra(r); + } } // ---------- output ---------- @@ -388,6 +610,22 @@ function kpi(label, value, sub = "", cls = "") { return `
${label}
${value}
${sub}
`; } +/** The few numbers that stay visible above every step. */ +function renderPreview(r) { + const p = r.params, b = r.pv; + const heat = p.extra ? r.heat : r.q, hp = p.extra ? r.hpAll : r.hp; + const el = p.extra ? r.elAll : r.el, jaz = p.extra ? r.jazAll : r.jaz; + const cost = b ? b.cost : p.extra ? r.cost : r.costHp + r.costBackup; + $("previewKpis").innerHTML = [ + kpi(p.hotWater ? "Wärmebedarf" : "Heizwärmebedarf", `${fmt(heat)} kWh/a`), + kpi("Deckungsanteil WP", `${fmt(heat > 0 ? (100 * hp) / heat : 0, 1)} %`, "", "hp"), + kpi("Jahresarbeitszahl", fmt(jaz, 2), "", "hp"), + b ? kpi("Autarkie Strom", `${fmt(100 * b.autarky, 1)} %`, "", "pv") : kpi("Strombedarf WP", `${fmt(el)} kWh/a`, "", "hp"), + Number.isFinite(r.tb) ? kpi("Bivalenzpunkt", `${fmt(r.tb, 1)} °C`, "", "backup") : kpi("Bivalenzpunkt", "keiner", "", "backup"), + kpi("Energiekosten", `${fmt(cost)} €/a`), + ].join(""); +} + function renderKpis(r) { const share = (x) => (r.q > 0 ? (100 * x) / r.q : 0); const p = r.params; @@ -408,11 +646,58 @@ function renderKpis(r) { (r.model.dev && p.mode === "alternative" && r.model.limit != null ? ` · Leistungsgrenze ${fmt(r.model.limit, 1)} °C` : "")) : kpi("Bivalenzpunkt", "keiner", "WP deckt die Heizlast allein"), kpi("Heizstunden", `${fmt(r.heatingHours)} h/a`, `davon ${fmt(r.backupHours)} h mit Zusatzheizung` + - (r.model.dev ? `, ${fmt(r.cyclingHours)} h unter Mindestleistung ${fmt(r.model.dev.pmin, 1)} kW (Takten)` : "")), + (r.model.dev?.pmin ? `, ${fmt(r.cyclingHours)} h unter Mindestleistung ${fmt(r.model.dev.pmin, 1)} kW (Takten)` : "")), kpi("Stunden unter Norm-Außentemp.", `${fmt(r.belowTn)} h/a`, `max. Heizlast ${fmt(r.peak, 1)} kW`), ].join(""); } +/** Heating and hot water together, with PV and battery if there are any. */ +function renderSummary(r) { + const p = r.params, b = r.pv, fuel = FUELS[p.fuel]; + const share = (x) => (r.heat > 0 ? (100 * x) / r.heat : 0); + const uncovered = r.uncovered; + const cost = b ? b.cost : r.cost; + $("summaryKpis").innerHTML = [ + kpi("Wärmebedarf gesamt", `${fmt(r.heat)} kWh/a`, p.hotWater ? `Heizung ${fmt(r.q)} · Warmwasser ${fmt(r.ww)} kWh` : "nur Heizung"), + kpi("Deckungsanteil Wärmepumpe", `${fmt(share(r.hpAll), 1)} %`, `${fmt(r.hpAll)} kWh/a`, "hp"), + kpi("Deckungsanteil Zusatzheizung", `${fmt(share(r.backupAll), 1)} %`, `${fmt(r.backupAll)} kWh/a`, "backup"), + uncovered > 0.5 ? kpi("Nicht gedeckt", `${fmt(share(uncovered), 1)} %`, `${fmt(uncovered)} kWh/a Heizung`, "uncovered") : "", + kpi("Jahresarbeitszahl WP", fmt(r.jazAll, 2), p.hotWater ? `Heizung ${fmt(r.jaz, 2)} · Warmwasser ${fmt(r.jazWw, 2)}` : "", "hp"), + kpi("Strombedarf WP", `${fmt(r.elAll)} kWh/a`, p.hotWater ? `Heizung ${fmt(r.el)} · Warmwasser ${fmt(r.elWw)} kWh` : "", "hp"), + kpi(`Endenergie ${$("fuel").selectedOptions[0].text}`, + `${fmt(r.backupAmountAll, fuel.unit === "rm" ? 1 : 0)} ${fuel.unit}/a`, + `${p.fuel === "electric" ? "" : `${fmt(r.backupFuelAll)} kWh · `}${fmt(r.costBackupAll)} €/a${p.fuel === "electric" && b ? " ohne PV" : ""}`, "backup"), + b ? kpi("Autarkie Strom", `${fmt(100 * b.autarky, 1)} %`, `Netzbezug ${fmt(b.grid)} von ${fmt(b.demand)} kWh/a`, "pv") : "", + kpi("Energiekosten gesamt", `${fmt(cost)} €/a`, + `${fmt(r.heat > 0 ? (100 * cost) / r.heat : 0, 1)} ct/kWh Wärme` + (b ? ` · ohne PV ${fmt(r.cost)} €/a` : "")), + ].join(""); +} + +function renderExtra(r) { + const p = r.params, b = r.pv; + const wwShare = r.ww > 0 ? (100 * r.wwHp) / r.ww : 0; + $("extraKpis").innerHTML = [ + ...(p.hotWater ? [ + kpi("Warmwasser", `${fmt(r.ww)} kWh/a`, `Vorlauf ${fmt(r.model.wwFlow)} °C`, "ww"), + kpi("Warmwasser durch WP", `${fmt(wwShare, 1)} %`, `Zusatzheizung ${fmt(r.wwBackup)} kWh/a`, "ww"), + kpi("Arbeitszahl Warmwasser", fmt(r.jazWw, 2), `Strom ${fmt(r.elWw)} kWh/a`, "ww"), + ] : []), + ...(b ? [ + kpi("PV-Ertrag", `${fmt(b.pv)} kWh/a`, `${fmt(p.kwp > 0 ? b.pv / p.kwp : 0)} kWh/kWp`, "pv"), + kpi("Eigenverbrauch", `${fmt(100 * b.selfShare, 1)} %`, `${fmt(b.pv - b.feed)} kWh/a genutzt`, "pv"), + kpi("Autarkie Strom", `${fmt(100 * b.autarky, 1)} %`, `direkt ${fmt(b.direct)} · Speicher ${fmt(b.discharge)} kWh/a`, "pv"), + kpi("Netzbezug", `${fmt(b.grid)} kWh/a`, `${fmt(b.gridCost)} €/a`), + p.feedOn ? kpi("Einspeisung", `${fmt(b.feed)} kWh/a`, `${fmt(b.revenue)} €/a Vergütung`) + : kpi("Abgeregelt", `${fmt(b.feed)} kWh/a`, "ohne Einspeisung, keine Vergütung"), + p.battery > 0 ? kpi("Speicher", `${fmt(b.cycles)} Vollzyklen/a`, `${fmt(b.discharge)} kWh/a entladen`) : "", + kpi("Ersparnis durch PV", `${fmt(b.saving)} €/a`, p.feedOn ? "Strom für WP und Heizstab inkl. Einspeisung" : "Strom für WP und Heizstab"), + ] : []), + ].join(""); + $("powerFigure").hidden = !b; + if (b) renderPower(r); + if (p.hotWater) renderWwMonths(r); +} + const W = 760, H = 280, PAD = { l: 62, r: 12, t: 10, b: 32 }; function niceMax(v) { @@ -468,13 +753,20 @@ function renderDuration(r) { const yMax = niceMax(r.peak); const px = (h) => PAD.l + (iw * h) / xMax, py = (v) => PAD.t + ih - (ih * v) / yMax; const loadPts = [], coveredPts = [], hpPts = []; + // each point averages the hours up to the next one, so single hours (e.g. hot water + // charging) don't show up as spikes + const index = (s) => Math.min(total, Math.floor(((s / steps) * xMax) * r.n)); for (let s = 0; s <= steps; s++) { - const idx = Math.min(total - 1, Math.floor(((s / steps) * xMax) * r.n)); - const i = order[idx]; - const h = (s / steps) * xMax; - loadPts.push(`${px(h)},${py(r.loads[i])}`); - coveredPts.push(`${px(h)},${py(r.hps[i] + r.backs[i])}`); - hpPts.push(`${px(h)},${py(r.hps[i])}`); + const a = Math.min(total - 1, index(s)), b = Math.max(a + 1, index(s + 1)); + let load = 0, hp = 0, back = 0; + for (let k = a; k < b; k++) { + const i = order[k]; + load += r.loads[i]; hp += r.hps[i]; back += r.backs[i]; + } + const h = (s / steps) * xMax, c = b - a; + loadPts.push(`${px(h)},${py(load / c)}`); + coveredPts.push(`${px(h)},${py((hp + back) / c)}`); + hpPts.push(`${px(h)},${py(hp / c)}`); } const base = `${px(xMax)},${py(0)} ${px(0)},${py(0)}`; const ticks = []; @@ -545,6 +837,45 @@ function renderMonths(r) { legend(energyLegend(r)); } +/** Monthly electricity demand split into PV direct, battery and grid, PV yield as a line. */ +function renderPower(r) { + const b = r.pv; + const iw = W - PAD.l - PAD.r, ih = H - PAD.t - PAD.b, bw = iw / 12; + const yMax = niceMax(Math.max(...b.months.map((m) => Math.max(m.pv, m.direct + m.battery + m.grid)))); + const py = (v) => PAD.t + ih - (ih * v) / yMax; + let bars = ""; + const ticks = [], line = []; + b.months.forEach((m, i) => { + const x = PAD.l + i * bw; + ticks.push([x + bw / 2, MONTH_NAMES[i]]); + line.push(`${x + bw / 2},${py(m.pv)}`); + bars += `${MONTH_NAMES[i]}: PV direkt ${fmt(m.direct)} kWh, Speicher ${fmt(m.battery)} kWh, Netz ${fmt(m.grid)} kWh, PV-Ertrag ${fmt(m.pv)} kWh` + + stack(x + 4, bw - 8, py, [["pv", m.direct], ["battery", m.battery], ["grid-el", m.grid]]) + ``; + }); + $("power").innerHTML = + `` + + axes(ticks, yMax, "Strom [kWh]", "") + bars + `` + + legend([["pv", "PV direkt"], ["battery", "aus Speicher"], ["grid-el", "Netzbezug"], ["pv", "PV-Ertrag (Linie)"]]); +} + +function renderWwMonths(r) { + const iw = W - PAD.l - PAD.r, ih = H - PAD.t - PAD.b, bw = iw / 12; + const yMax = niceMax(Math.max(...r.wwMonths.map((m) => m.hp + m.backup))); + const py = (v) => PAD.t + ih - (ih * v) / yMax; + let bars = ""; + const ticks = []; + r.wwMonths.forEach((m, i) => { + const x = PAD.l + i * bw; + ticks.push([x + bw / 2, MONTH_NAMES[i]]); + bars += `${MONTH_NAMES[i]}: WP ${fmt(m.hp)} kWh, Zusatz ${fmt(m.backup)} kWh` + + stack(x + 4, bw - 8, py, [["ww", m.hp], ["backup", m.backup]]) + ``; + }); + $("wwMonths").innerHTML = + `` + + axes(ticks, yMax, "Wärme [kWh]", "") + bars + `` + + legend([["ww", "Wärmepumpe"], ["backup", "Zusatzheizung"]]); +} + // ---------- export ---------- function download(name, rows) { @@ -571,13 +902,16 @@ function exportBins() { function exportHours() { const r = lastResult; if (!r) return; - const rows = [["Jahr", "Monat", "Tag", "Stunde (UTC)", "Außentemperatur °C", "Heizlast kW", "WP kW", "Zusatzheizung kW", "nicht gedeckt kW", "Strom WP kW"]]; + const ww = r.params.hotWater, b = r.pv; + const rows = [["Jahr", "Monat", "Tag", "Stunde (UTC)", "Außentemperatur °C", "Heizlast kW", "WP kW", "Zusatzheizung kW", "nicht gedeckt kW", "Strom WP kW", + ...(ww ? ["Warmwasser WP kW", "Warmwasser Zusatz kW"] : []), ...(b ? ["PV kW", "Netzbezug kW", r.params.feedOn ? "Einspeisung kW" : "Abgeregelt kW"] : [])]]; r.years.forEach((year, y) => { let i = 0; MONTH_DAYS.forEach((days, month) => { for (let d = 1; d <= days; d++) for (let h = 0; h < 24; h++, i++) { const j = y * 8760 + i, q = r.loads[j], hp = r.hps[j], backup = r.backs[j]; - rows.push([year, month + 1, d, h, r.temps[y][i], q, hp, backup, q - hp - backup, r.els[j]]); + rows.push([year, month + 1, d, h, r.temps[y][i], q, hp, backup, q - hp - backup, r.els[j], + ...(ww ? [r.wwHps[j], r.wwBacks[j]] : []), ...(b ? [b.pvs[j], b.grids[j], b.feeds[j]] : [])]); } }); }); @@ -592,6 +926,7 @@ async function init() { fetch("data/plz.json").then((r) => r.json()), ]); stationById = Object.fromEntries(meta.stations.map((s) => [s.id, s])); + pvStationById = Object.fromEntries((meta.pvStations || []).map((s) => [s.id, s])); $("plz").addEventListener("input", () => { showLocation(); scheduleRun(); }); $("tn").addEventListener("input", () => { tnEdited = true; }); @@ -613,6 +948,7 @@ async function init() { $("form").addEventListener("submit", (e) => e.preventDefault()); $("exportBins").addEventListener("click", exportBins); $("exportHours").addEventListener("click", exportHours); + buildStepper(); showLocation(); run(); diff --git a/web/devices.js b/web/devices.js index b41a2cc..54f447f 100644 --- a/web/devices.js +++ b/web/devices.js @@ -7,6 +7,12 @@ // section 2.1 (EN 14511, 60 Hz) where those exist. // pmin: minimum heating capacity in kW; tmin: lowest outdoor temperature for heating. // Points are [outdoor °C, value]. +// +// Panasonic Aquarea, from the heating capacity tables of the service manuals (capacity and +// input power, COP = capacity / input power; points at +2 °C include defrost): +// - Generation J monobloc WH-MDC05/07/09J3E5: PAPAMY2003034CE. +// - Generation L WH-WDG05/07/09LE5 (with WH-SDC0509L3E5): PAPAMY2307068CE. +// Panasonic does not publish a minimum capacity, so pmin is missing for them. const DEVICES = { lwm80: { name: "Remko LWM 80", @@ -53,4 +59,88 @@ const DEVICES = { 55: [[-15, 2.12], [-12, 2.27], [-10, 2.38], [-7, 2.51], [-5, 2.57], [-2, 2.68], [0, 2.74], [5, 2.97], [7, 3.13], [10, 3.37], [12, 3.54]], }, }, + mdc05j: { + name: "Panasonic WH-MDC05J3E5", + tmin: -20, + cap: { + 35: [[-20, 4.16], [-15, 5], [-7, 5], [2, 5], [7, 5], [25, 5.04]], + 45: [[-20, 3.84], [-15, 4.75], [-7, 4.8], [2, 5], [7, 5], [25, 5.31]], + 55: [[-20, 3.43], [-15, 3.7], [-7, 5], [2, 5], [7, 5], [25, 5.61]], + }, + cop: { + 35: [[-20, 2.05], [-15, 2.3], [-7, 2.78], [2, 3.57], [7, 5.05], [25, 5.6]], + 45: [[-20, 1.62], [-15, 1.89], [-7, 2.22], [2, 2.76], [7, 3.82], [25, 4.58]], + 55: [[-20, 1.3], [-15, 1.51], [-7, 1.85], [2, 2.27], [7, 3.01], [25, 4.19]], + }, + }, + mdc07j: { + name: "Panasonic WH-MDC07J3E5", + tmin: -20, + cap: { + 35: [[-20, 4.66], [-15, 5.6], [-7, 6.8], [2, 7], [7, 7], [25, 6.67]], + 45: [[-20, 4.44], [-15, 5.3], [-7, 6.3], [2, 6.85], [7, 7], [25, 6.79]], + 55: [[-20, 4.23], [-15, 5], [-7, 6.3], [2, 6.3], [7, 7], [25, 6.7]], + }, + cop: { + 35: [[-20, 1.98], [-15, 2.33], [-7, 2.81], [2, 3.4], [7, 4.76], [25, 7.17]], + 45: [[-20, 1.61], [-15, 1.87], [-7, 2.23], [2, 2.74], [7, 3.57], [25, 4.92]], + 55: [[-20, 1.35], [-15, 1.51], [-7, 1.86], [2, 2.16], [7, 2.82], [25, 3.72]], + }, + }, + mdc09j: { + name: "Panasonic WH-MDC09J3E5", + tmin: -20, + cap: { + 35: [[-20, 6.43], [-15, 7.6], [-7, 7.5], [2, 7.45], [7, 9], [25, 7.88]], + 45: [[-20, 5.78], [-15, 7], [-7, 7.3], [2, 7], [7, 9], [25, 8.46]], + 55: [[-20, 4.83], [-15, 5.6], [-7, 7], [2, 7], [7, 8.95], [25, 7.6]], + }, + cop: { + 35: [[-20, 1.79], [-15, 2.23], [-7, 2.63], [2, 3.13], [7, 4.48], [25, 5.97]], + 45: [[-20, 1.51], [-15, 1.89], [-7, 2.17], [2, 2.46], [7, 3.45], [25, 4.55]], + 55: [[-20, 1.33], [-15, 1.47], [-7, 1.8], [2, 2.12], [7, 2.78], [25, 3.74]], + }, + }, + wdg05l: { + name: "Panasonic WH-WDG05LE5", + tmin: -25, + cap: { + 35: [[-25, 2.45], [-20, 4.7], [-15, 5], [-7, 5], [2, 5], [7, 5], [25, 5]], + 45: [[-25, 3.8], [-20, 4.5], [-15, 5], [-7, 5], [2, 5], [7, 5], [25, 5]], + 55: [[-25, 3.6], [-20, 4.25], [-15, 5], [-7, 5], [2, 5], [7, 5], [25, 5]], + }, + cop: { + 35: [[-25, 1.39], [-20, 2.15], [-15, 2.58], [-7, 3.01], [2, 3.52], [7, 5.05], [25, 8.33]], + 45: [[-25, 1.65], [-20, 1.9], [-15, 2.16], [-7, 2.58], [2, 2.92], [7, 3.94], [25, 5.81]], + 55: [[-25, 1.46], [-20, 1.65], [-15, 1.9], [-7, 2.12], [2, 2.34], [7, 3.07], [25, 4.55]], + }, + }, + wdg07l: { + name: "Panasonic WH-WDG07LE5", + tmin: -25, + cap: { + 35: [[-25, 4.75], [-20, 5.5], [-15, 6], [-7, 5.8], [2, 6.85], [7, 7], [25, 7]], + 45: [[-25, 4.3], [-20, 5.1], [-15, 5.5], [-7, 5.8], [2, 6.6], [7, 7], [25, 7]], + 55: [[-25, 3.95], [-20, 4.9], [-15, 5.2], [-7, 5.8], [2, 6.25], [7, 7], [25, 7]], + }, + cop: { + 35: [[-25, 1.88], [-20, 2.15], [-15, 2.4], [-7, 3.01], [2, 3.42], [7, 4.93], [25, 8.64]], + 45: [[-25, 1.62], [-20, 1.85], [-15, 2.12], [-7, 2.5], [2, 2.82], [7, 3.68], [25, 5.69]], + 55: [[-25, 1.42], [-20, 1.65], [-15, 1.8], [-7, 2.12], [2, 2.34], [7, 2.98], [25, 4.24]], + }, + }, + wdg09l: { + name: "Panasonic WH-WDG09LE5", + tmin: -25, + cap: { + 35: [[-25, 6.05], [-20, 7], [-15, 7.4], [-7, 7], [2, 7], [7, 9], [25, 9]], + 45: [[-25, 5.25], [-20, 6.2], [-15, 6.8], [-7, 7], [2, 7], [7, 9], [25, 9]], + 55: [[-25, 4.65], [-20, 5.6], [-15, 6.3], [-7, 7], [2, 7], [7, 8.9], [25, 9]], + }, + cop: { + 35: [[-25, 1.76], [-20, 1.97], [-15, 2.31], [-7, 2.8], [2, 3.41], [7, 4.55], [25, 7.03]], + 45: [[-25, 1.6], [-20, 1.77], [-15, 2], [-7, 2.35], [2, 2.8], [7, 3.49], [25, 5.2]], + 55: [[-25, 1.48], [-20, 1.63], [-15, 1.77], [-7, 2.13], [2, 2.41], [7, 3.03], [25, 4.09]], + }, + }, }; diff --git a/web/index.html b/web/index.html index bc22366..d3a0dbf 100644 --- a/web/index.html +++ b/web/index.html @@ -12,8 +12,16 @@

Heizwärmebedarf und Aufteilung Wärmepumpe / Zusatzheizung für jede Postleitzahl in Deutschland, auf Basis stündlicher DWD-Messwerte 2007–2025.

+
+
+
Lade Daten …
+
+ + +
-
+ + + + + +
+ -
-
Lade Daten …
+ + + + +
+ + +
+ +
+

Vereinfachtes Modell: Heizlast linear zwischen Norm-Heizlast bei Norm-Außentemperatur und 0 bei Heizgrenztemperatur. Wetterdaten: Deutscher Wetterdienst (DWD Climate Data Center, Stundenwerte Lufttemperatur, 10-Minuten-Werte Global- und Diffusstrahlung), Postleitzahlen: GeoNames (CC BY 4.0). Die Norm-Außentemperatur der Station ist eine Schätzung aus den Messdaten, nicht der Wert nach DIN/TS 12831-1.

+
diff --git a/web/style.css b/web/style.css index 20d6574..8d529fe 100644 --- a/web/style.css +++ b/web/style.css @@ -8,6 +8,10 @@ --backup: #d9822b; --uncovered: #c0392b; --accent: #2f7d6d; + --ww: #3d7cc9; + --pv: #d4a017; + --battery: #7a9a3a; + --grid-el: #8a8f8c; } @media (prefers-color-scheme: dark) { :root { @@ -20,9 +24,14 @@ --backup: #e89a4c; --uncovered: #e06456; --accent: #4fb39d; + --ww: #6aa2e8; + --pv: #e8c04a; + --battery: #9cbf5a; + --grid-el: #7b817e; } } * { box-sizing: border-box; } +[hidden] { display: none !important; } body { margin: 0; background: var(--bg); @@ -32,16 +41,75 @@ body { header { padding: 24px 16px 8px; max-width: 1200px; margin: 0 auto; } h1 { margin: 0 0 4px; font-size: 1.5rem; } header p { margin: 0; color: var(--muted); } -main { +main, footer { max-width: 1200px; margin: 0 auto; padding: 0 16px 16px; } +.preview { + position: sticky; + top: 0; + z-index: 2; + background: var(--bg); + border-bottom: 1px solid var(--line); + padding: 10px max(16px, calc((100% - 1200px) / 2 + 16px)) 8px; +} +.kpis.compact { grid-template-columns: repeat(6, minmax(0, 1fr)); margin: 0 0 6px; gap: 8px; } +.kpis.compact .kpi { padding: 6px 10px; } +.kpis.compact .value { font-size: 1.1rem; } +.kpis.compact .sub { display: none; } +@media (max-width: 800px) { + .kpis.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; } + .kpis.compact .kpi { padding: 4px 6px; } + .kpis.compact .label { font-size: 0.68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } + .kpis.compact .value { font-size: 0.92rem; white-space: nowrap; } + .preview #status { font-size: 0.72rem; } +} +.stepper { + display: flex; + gap: 4px; + max-width: 1200px; + margin: 14px auto; + padding: 0 16px; + overflow-x: auto; +} +.stepper button { + flex: 1 0 auto; + display: flex; + align-items: center; + gap: 8px; + border: 0; + border-bottom: 3px solid var(--line); + border-radius: 0; + background: none; + color: var(--muted); + padding: 6px 4px 8px; + white-space: nowrap; +} +.stepper .num { + display: inline-grid; + place-items: center; + width: 22px; + height: 22px; + border-radius: 50%; + border: 1px solid var(--line); + font-size: 0.8rem; +} +.stepper button.done { border-bottom-color: var(--hp); color: var(--text); } +.stepper button.done .num { background: var(--hp); border-color: var(--hp); color: var(--panel); } +.stepper button[aria-current="step"] { border-bottom-color: var(--accent); color: var(--text); font-weight: 600; } +.stepper button[aria-current="step"] .num { border-color: var(--accent); color: var(--accent); } +.step:not([hidden]) { display: grid; - grid-template-columns: 320px 1fr; + grid-template-columns: 340px minmax(0, 1fr); gap: 20px; - max-width: 1200px; - margin: 0 auto; - padding: 16px; + align-items: start; } -@media (max-width: 800px) { main { grid-template-columns: 1fr; } } -form, #results { min-width: 0; } +.step:not(:has(aside)), .step.results { grid-template-columns: minmax(0, 560px); } +.step.results:not([hidden]) { display: block; } +@media (max-width: 800px) { .step:not([hidden]) { grid-template-columns: minmax(0, 1fr); } } +.step fieldset { margin: 0; } +h2 { font-size: 1.1rem; margin: 18px 0 0; } +.results h2:first-child, .results > div:first-child h2 { margin-top: 0; } +.step-nav { display: flex; justify-content: space-between; gap: 8px; margin-top: 16px; } +.step-nav #next { margin-left: auto; } +button.primary { background: var(--accent); border-color: var(--accent); color: var(--panel); } fieldset { border: 1px solid var(--line); background: var(--panel); @@ -117,4 +185,11 @@ figcaption { font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; } .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; } .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; } button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--panel); } -#results.stale > :not(#status) { opacity: 0.35; pointer-events: none; } +body.stale .kpis, body.stale figure { opacity: 0.35; } +.chart .ww { fill: var(--ww); } +.chart .pv { fill: var(--pv); } +.chart .battery { fill: var(--battery); } +.chart .grid-el { fill: var(--grid-el); } +.chart .pvline { stroke: var(--pv); stroke-width: 2; fill: none; } +.kpi.pv { border-left: 4px solid var(--pv); } +.kpi.ww { border-left: 4px solid var(--ww); } -- cgit v1.3