Conversation
Node-to-edge shifts and boundary extrapolation in FiniteVolume2D need at least two nodes per direction, so a 2D submesh with one node (e.g. BasicDFN2D with z_2d = 1) failed deep in harmonic_mean with an opaque scipy ValueError. build() now raises a DiscretisationError up front; ghost-cell submeshes are exempt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
| Project | PyBaMM |
| Branch | fix/fv2d-single-tb-node |
| Testbed | bare-metal |
🐰 View full continuous benchmarking report in Bencher
⚠️ WARNING: Truncated view!The full continuous benchmarking report exceeds the maximum length allowed on this platform.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5838 +/- ##
=======================================
Coverage 98.09% 98.09%
=======================================
Files 346 346
Lines 35354 35361 +7
=======================================
+ Hits 34680 34687 +7
Misses 674 674 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Description
pybamm.lithium_ion.BasicDFN2D()solved withz_2dset to 1 point failed deep inFiniteVolume2D.harmonic_meanwith an opaque scipyValueError: axis 1 index 139 exceeds matrix dimension 70.A single node in either direction can't be supported by the 2D finite volume method as written. The node-to-edge shifts (harmonic and arithmetic mean) and the boundary extrapolation all estimate the exterior edges by linear extrapolation from the first or last two nodes. With one node there are no interior edges and no second node to extrapolate from. Supporting it would need a constant-extrapolation special case in several operators, and a 2D model with one node in a direction doesn't vary in that direction, so it is the 1D model.
FiniteVolume2D.buildnow checks everySubMesh2Dand raises apybamm.DiscretisationErrorwhen either direction has fewer than 2 nodes. The error names the direction and domain and points to refining the mesh or using a 1D model. Ghost-cell submeshes are one node thick by construction and are skipped. Unstructured submeshes, which reportnpts_tb = 1, are notSubMesh2Dand are unaffected. Meshes with at least 2 nodes in both directions behave exactly as before.Meshes with exactly 2 nodes in a direction still hit an
IndexErrorinboundary_value_or_flux. That case is handled separately and is not touched here.Type of change
## Bug fixes.Important checks:
pre-commit runon the changed filestest_single_node_direction_raisescovers 1 node intband inlr🤖 Generated with Claude Code