mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-11-25 23:16:18 +01:00
feat(devices): add load-dependent DC-to-AC efficiency curve for GENETIC inverters (#1375)
* feat(devices): add load-dependent DC-to-AC efficiency curve for GENETIC inverters Real inverters are much less efficient at low load than at rated power (e.g. 0.80 at 2 % vs. 0.93 at 7 % load). A constant dc_to_ac_efficiency overrates night-time battery discharge into a small base load and, with it, arbitrage and grid charging. Add two optional inverter settings for the GENETIC optimizer: - dc_to_ac_efficiency_curve: list of (load_fraction, efficiency) points, load fraction = AC power / max_power_w. Points must be strictly increasing in [0, 1] with efficiencies in (0, 1]; at least two points. Linear interpolation, clamped at both ends. When set, the curve replaces dc_to_ac_efficiency. - dc_to_ac_efficiency_reference_load_fraction (default 0.06): load at which the curve values stored energy without a specific conversion. Battery discharges in Inverter.process_energy() use the efficiency at the AC energy of each conversion. The end-of-horizon value, the terminal and tail value curves and the AC charge break-even penalty use Inverter.reference_dc_to_ac_efficiency. Without a curve, dc_to_ac_efficiency_at() and the reference efficiency return dc_to_ac_efficiency itself, so results are bit-identical to the previous model. GENETIC0 is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(devices): evaluate the efficiency curve at the delivered AC load When the battery limits a discharge (low state of charge or its power limit), the conversion ran with the efficiency of the requested AC energy. With a 1000 Wh battery at 10 % SoC, a 1000 W inverter and the curve [(0, .8), (.5, .95), (1, .95)], a request of 500 Wh AC returned 95 Wh AC from the available 100 Wh DC, although the curve gives 82.5 % at that load. The delivered AC energy now solves a = dc * efficiency(a / rated) exactly on the piecewise-linear curve (solve_ac_for_dc_energy), bounded by the request. Unlimited discharges and inverters without a curve are unchanged. Regression tests use a real Battery: low SoC and a power-limited discharge, each with 60- and 15-minute slots, battery discharge losses, the load path through process_energy, and constant efficiency. * docs: regenerate OpenAPI for the efficiency-curve fix --------- Co-authored-by: Christin <christin@BigBrother.bikini.bottom.zone> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Andreas <drbacke@gmx.de>
This commit is contained in:
co-authored by
Christin
Claude Opus 5.5
Andreas
parent
560370281f
commit
7f26ea3f3f
@@ -1002,7 +1002,7 @@ class GeneticOptimization(OptimizationBase):
|
||||
self._terminal_value_reason = "terminal_value_mode is FIXED"
|
||||
return None
|
||||
|
||||
dc_to_ac = inverter.dc_to_ac_efficiency if inverter else 1.0
|
||||
dc_to_ac = inverter.reference_dc_to_ac_efficiency if inverter else 1.0
|
||||
# A full battery, expressed in the same unit as the curve: AC energy
|
||||
# that can actually leave the house.
|
||||
max_energy_wh = (
|
||||
@@ -1125,7 +1125,7 @@ class GeneticOptimization(OptimizationBase):
|
||||
# Usable DC energy, converted to the AC energy that can serve a load.
|
||||
energy_wh = battery.current_energy_content()
|
||||
if self.simulation.inverter:
|
||||
energy_wh *= self.simulation.inverter.dc_to_ac_efficiency
|
||||
energy_wh *= self.simulation.inverter.reference_dc_to_ac_efficiency
|
||||
|
||||
curve = getattr(self, "_terminal_value_curve", None)
|
||||
if curve is not None and curve.energy_wh:
|
||||
@@ -3129,12 +3129,15 @@ class GeneticOptimization(OptimizationBase):
|
||||
inv = self.simulation.inverter
|
||||
bat = self.simulation.battery
|
||||
|
||||
# Full round-trip efficiency: 1 Wh drawn from grid → η Wh delivered to AC load
|
||||
# Full round-trip efficiency: 1 Wh drawn from grid → η Wh delivered to AC load.
|
||||
# The later discharge has no known size here, so the DC-to-AC part
|
||||
# is the efficiency at the inverter's reference load (equal to
|
||||
# dc_to_ac_efficiency without an efficiency curve).
|
||||
round_trip_eff = (
|
||||
inv.ac_to_dc_efficiency
|
||||
* bat.charging_efficiency
|
||||
* bat.discharging_efficiency
|
||||
* inv.dc_to_ac_efficiency
|
||||
* inv.reference_dc_to_ac_efficiency
|
||||
)
|
||||
|
||||
# Configurable penalty multiplier (default 1 = economic loss in €)
|
||||
@@ -3160,7 +3163,7 @@ class GeneticOptimization(OptimizationBase):
|
||||
free_ac_wh = (
|
||||
max(0.0, initial_soc_wh - bat.min_soc_wh)
|
||||
* bat.discharging_efficiency
|
||||
* inv.dc_to_ac_efficiency
|
||||
* inv.reference_dc_to_ac_efficiency
|
||||
)
|
||||
|
||||
# Prices/loads/free energy are constant within one optimization
|
||||
@@ -3186,7 +3189,8 @@ class GeneticOptimization(OptimizationBase):
|
||||
# corresponding cost per useful/exported AC Wh.
|
||||
lcos_per_wh_dc = getattr(bat, "levelized_cost_of_storage_kwh", 0.0) / 1000.0
|
||||
break_even_price = (
|
||||
charge_price / round_trip_eff + lcos_per_wh_dc / inv.dc_to_ac_efficiency
|
||||
charge_price / round_trip_eff
|
||||
+ lcos_per_wh_dc / inv.reference_dc_to_ac_efficiency
|
||||
)
|
||||
|
||||
best_uncovered_price = best_prices[hour]
|
||||
|
||||
@@ -128,7 +128,7 @@ class TailValueCurve(TerminalValueCurve):
|
||||
battery=bat,
|
||||
slot_duration_h=context["slot_duration_h"],
|
||||
)
|
||||
conversion = bat.discharging_efficiency * inv.dc_to_ac_efficiency
|
||||
conversion = bat.discharging_efficiency * inv.reference_dc_to_ac_efficiency
|
||||
state_wh = bat.min_soc_wh + (energy_wh / conversion if conversion > 0 else 0.0)
|
||||
state_wh = float(np.clip(state_wh, bat.min_soc_wh, bat.max_soc_wh))
|
||||
plan: list[TailPlanSlot] = []
|
||||
@@ -231,7 +231,9 @@ def build_tail_value_curve(
|
||||
bat.charge_array = np.zeros(1, dtype=float)
|
||||
inv = Inverter(inverter.parameters, battery=bat, slot_duration_h=battery.slot_duration_h)
|
||||
states = np.linspace(bat.min_soc_wh, bat.max_soc_wh, grid_points)
|
||||
usable = (states - bat.min_soc_wh) * bat.discharging_efficiency * inv.dc_to_ac_efficiency
|
||||
usable = (
|
||||
(states - bat.min_soc_wh) * bat.discharging_efficiency * inv.reference_dc_to_ac_efficiency
|
||||
)
|
||||
continuation_values = np.array([continuation.value(e) for e in usable])
|
||||
operating_values = np.zeros(len(states))
|
||||
values = continuation_values.copy()
|
||||
|
||||
Reference in New Issue
Block a user