Repository navigation
Make the storage take exactly the flux law's heat at its wall (F-056) - #51
Merged
Merged
Conversation
The storage's heat-flux condition divided the flux law's flux by the conductivity at the extrapolated wall enthalpy, while the heat entering it is k grad(T) on the wall face, with k extrapolated from the nodes. While the PCM by the wall melted, with a sharp melting point and a conductivity dropping from 0.4 to 0.15 W.m-1.K-1, the packed bed took a fifth of the flux law's heat, and its fluid temperatures overshot and fell by 1 K to 2 K during a charge. Energy stayed exactly conserved, so no test saw it. The condition now divides by the face conductivity itself. The charge is monotonic and converges with the capsule mesh, the Nallusamy fit improves at every height, and the finned tubes move by at most 0.006 K, so the regression reference is regenerated (F-056, DESIGN D6). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #51 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 47 47
Lines 1768 1767 -1
Branches 157 157
=========================================
- Hits 1768 1767 -1
🚀 New features to boost your workflow:
|
This was referenced Nov 1, 2026
Merged
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 the bumps in the packed-bed fluid temperatures seen in the tutorials: during a charge, the fluid at each height rose, fell by 1.2 K to 2.1 K, then rose again. Model flaw (numerics), logged as F-056; DESIGN D6 updated.
Cause
The storage's heat-flux condition turned the flux law's flux into a gradient with the conductivity at the extrapolated wall enthalpy,
k(H_surf). The heat that enters the storage isk grad(T)on the wall face, where PyBaMM extrapolates the node values ofk. The two agree whenkvaries smoothly. The default paraffin melts at a sharp point and its conductivity drops from 0.4 to 0.15 W.m-1.K-1, so while the cells by the wall melted, the capsules took only 19 % to 29 % of the flux law's heat. That sent a pulse of overly warm fluid up the bed.Energy stayed exactly conserved (the ledger counts the heat that actually crosses), so no test could see it, and the coupling's docstring said the two "differ slightly". D6 had accepted the factor
k_face / k_surfaceas harmless.It was numerics, not physics: the dips grew as the capsule mesh was refined (0.5 K on 10 cells, 3 K on 160), and vanished with equal solid and liquid conductivities or with a 2 K melting range.
Fix
One line in
EnthalpyStorage: the condition divides bypybamm.boundary_value(k), the conductivityk grad(T)uses on the wall face, so exactly the flux law's flux enters.Changes
src/pytes/submodels/storage.py: the fix, with a comment.src/pytes/submodels/coupling.py: the docstring now says the fluid's heat is the flux times the wall area.tests/models/test_packed_bed.py(both fail before the fix): the fluid's heat equals the flux law's flux over the capsule surface at every position and time; the default charge heats the fluid monotonically at four heights.tests/data/reference_regression.npzregenerated (finned-tube results move by up to 0.006 K).docs/design/findings.md(F-056) and DESIGN D6.51.breaking.md(packed-bed results change) and51.fix.md.Not in this PR
The example notebooks' saved outputs show the old curves, and some of their text quotes numbers that may move (the packed-bed RMS, the lumped capsule's charge time, the design study's delivered fraction). Re-running them is a follow-up after #47 and #48 merge, since the tutorials live there.
Locally: 769 fast tests and the slow test pass, ruff is clean.
🤖 Generated with Claude Code