Repository navigation
Conversation
A charger without discharge_segments can never return energy to the house, so what it charges is consumption, like a deferrable load. It was nevertheless credited in soc_credit_eur at the average import price, with an implicit discharge efficiency of 1.0, and its terminal SOC was valued in the objective, which drove the solver to charge beyond the target whenever the price was below the horizon average. _compute_soc_credit now skips a charge-only EV, and EvDevice.terminal_soc_var returns None for one, so the target SOC alone decides how much is charged. No scenario golden file changes. Fixes jsimonetti#209
…rgy value The household view mirrors _compute_soc_credit to value energy left in storage per day. It still credited a charge-only EV at an implicit discharge efficiency of 1.0, so its per-day savings disagreed with the solver after the previous commit. The cross-check against the solver now includes a charge-only EV with a charging target. Refs jsimonetti#209
SolveResult.soc_credit_eur still described a credit across all EVs, and the terminal_soc_var docstring claimed the target alone decides how much is charged, which a negative import price contradicts. Refs jsimonetti#209
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #209.
Problem
An EV charger without V2H (empty
discharge_segments) was treated as storage:_compute_soc_creditcredited its SOC gain at the average import price, with an implicit discharge efficiency of 1.0 (the empty-segment fallback of_avg_discharge_efficiency), so a charge-only car was valued above a battery.EvDevice.terminal_soc_varreturnedsoc[T-1]for any plugged-in EV, so the objective rewarded charging beyond the target whenever the price was below the horizon average.The car can never return that energy to the house, so for the household it is consumption, like a deferrable load.
Changes
As agreed in the issue:
_compute_soc_creditskips an EV charger with nodischarge_segments, as it already skips an unplugged EV.EvDevice.terminal_soc_varreturnsNonefor a charge-only charger. Its docstring now covers both cases that returnNone, and states that energy beyond the target is charged only when that lowers the cost on its own, for example at a negative import price.Two follow-on changes keep the rest of the code base consistent with the fix:
_discharge_pathinmimirheim_helpers/reporter/reporter/household.py) mirrors_compute_soc_creditto value energy left in storage per day. It now leaves a charge-only EV out too; otherwise its daily savings would disagree with the solver.SolveResult.soc_credit_eurdocstring no longer says the credit covers all EVs.The fairer naive baseline (car charging at full power from plug-in, deferrable load starting at the start of its window) is left for a separate issue, as discussed.
Tests
test_soc_credit_skips_a_charge_only_ev, next totest_soc_credit_skips_an_unavailable_ev.test_charge_only_ev_is_charged_to_its_target_and_not_credited: the reproduction from the issue throughbuild_and_solve. Before the fix the car ended at 42 kWh (22 kWh charged); now it charges exactly the 10 kWh it needs in the cheap hours,optimised_cost_euris 1.40 andsoc_credit_euris 0.test_ev_charge_only_has_no_terminal_soc_varandtest_ev_v2h_has_terminal_soc_var.test_household_against_solver.py) now includes a charge-only EV with a charging target, and asserts that the van gains SOC so the exclusion is actually exercised.No scenario golden file changes.
Behaviour change
A plugged-in charge-only EV without a
target_soc_kwhno longer charges at all, including from PV surplus (unless the import price is negative). Before, it charged whenever the price was below the horizon average, because the terminal value made stored energy look profitable. Users who relied on that opportunistic charging should set a target.Still draft, so I can see if this really solves my issue in the comming days