fix: skip discharge-calibration samples that cross the low-SoC derating threshold#97
Open
bvweerd wants to merge 1 commit into
Open
fix: skip discharge-calibration samples that cross the low-SoC derating threshold#97bvweerd wants to merge 1 commit into
bvweerd wants to merge 1 commit into
Conversation
…ng threshold The charge-efficiency calibration already skips samples whose planned step crosses the high-SoC charge derating threshold, because the BMS throttles power mid-step and the actual/planned ratio then reflects derating rather than real efficiency. The discharge-efficiency calibration lacked the mirrored guard: on batteries with low-SoC discharge derating (e.g. Marstek Venus), every discharge step crossing the threshold produced a spuriously low ratio, dragging the persisted discharge correction down and making the DP plan systematically less discharge than the battery can deliver. Add the symmetric low-SoC threshold check before sampling. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XWQRQEJXUxbp2CGFS18U9i
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.
Description
The charge-efficiency calibration skips samples whose planned step crosses the high-SoC charge derating threshold, because the BMS throttles power mid-step and the actual/planned ratio then reflects derating rather than real efficiency. The discharge-efficiency calibration was missing the mirrored guard for the low-SoC discharge derating threshold.
Impact: on batteries with low-SoC discharge derating configured (e.g. Marstek Venus), every discharge step that crosses the threshold produces a spuriously low actual/planned ratio. The rolling 20-sample average drags the persisted discharge correction down (surviving restarts), making the DP plan systematically less discharge than the battery can actually deliver — even far away from the derating region.
Fix: add the symmetric skip in
_update_discharge_eff_calibration(planned_next_soc < threshold_kwh <= prev_soc→ no sample), identical in structure to the existing high-SoC guard in_update_charge_eff_calibration.Type of change
fix:Bug fix (patch version bump)feat:New feature (minor version bump)feat!:/BREAKING CHANGE:Breaking change (major version bump)chore:/docs:/ci:Maintenance or documentation (no version bump)Checklist
feat:,fix:,chore:, etc.)devbranch (notmain, unless this is a hotfix)Screenshots / Logs (optional)
New tests:
test_discharge_calibration_skips_when_crossing_low_soc_derating,test_discharge_calibration_samples_above_low_soc_derating.🤖 Generated with Claude Code
https://claude.ai/code/session_01XWQRQEJXUxbp2CGFS18U9i
Generated by Claude Code