Skip to content

Add unstructured 2D/3D DFN battery models - #5690

Open
aabills wants to merge 6 commits into
ufv-3-plottingfrom
ufv-4-models
Open

Add unstructured 2D/3D DFN battery models#5690
aabills wants to merge 6 commits into
ufv-3-plottingfrom
ufv-4-models

Conversation

@aabills

@aabills aabills commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add BasicDFN2DUnstructured and BasicDFN3DUnstructured.
  • Include Max/MinReduction and primary/secondary domain_size helpers used by those models.
  • Part of the Unstructured finite volume #5397 split; original full branch kept for comparison.

Stack

  1. Generalise VectorField to N components #5686 — VectorField N-comp
  2. Add unstructured mesh infrastructure #5687 — Meshing
  3. Add unstructured finite volume spatial method #5688 — Spatial method + ProcessedVariable
  4. Add VTK plotting for unstructured meshes #5689 — VTK plotting
  5. This PR (Add unstructured 2D/3D DFN battery models #5690) — Unstructured DFN models
  6. Deprecate pybamm.Magnitude in favour of Component #5691 — Deprecate Magnitude

After this stack merges, #5397 can be closed as superseded. Compare against preserved unstructured-finite-volume / backup/unstructured-finite-volume-full.

Test plan

  • Unit basic-model + mesh + spatial + VTK tests (175 passed locally)
  • Integration basic-model tests in CI
  • Diff against preserved full branch (non-CHANGELOG paths match)

@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.72385% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.25%. Comparing base (038195d) to head (3b9a302).

Files with missing lines Patch % Lines
...ry_models/lithium_ion/basic_dfn_3d_unstructured.py 93.04% 8 Missing ⚠️
...ry_models/lithium_ion/basic_dfn_2d_unstructured.py 94.49% 6 Missing ⚠️
...ges/pybamm/src/pybamm/expression_tree/functions.py 92.30% 1 Missing ⚠️
Additional details and impacted files
@@                Coverage Diff                 @@
##           ufv-3-plotting    #5690      +/-   ##
==================================================
+ Coverage           98.20%   98.25%   +0.05%     
==================================================
  Files                 343      345       +2     
  Lines               34505    34742     +237     
==================================================
+ Hits                33885    34136     +251     
+ Misses                620      606      -14     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

aabills added a commit that referenced this pull request Aug 5, 2026
- framework errors raise pybamm exceptions (GeometryError,
  DiscretisationError, DomainError) instead of bare
  ValueError/KeyError/RuntimeError/TypeError
- concise NumPy-style docstrings for the public FiniteVolumeUnstructured
  operators; from __future__ import annotations in both new modules
- meshio and matplotlib load via pybamm.import_optional_dependency so
  minimal installs get a guided error
- dead code removed: _disc_state_vector plumbing (written, never read),
  n_fpc dead assignment, duplicate cKDTree import; the _hex_gen_params
  regen branch is documented as the PR #5690 protocol; 3D
  UnstructuredMeshGenerator honours element_type (docstring previously
  promised tets while the code always built hexes)
- np.unique(..., axis=0) inverse reshaped to 1D (numpy 2.0.0 regression)
- comment blocks trimmed to the two-line cap; CHANGELOG bullets carry PR
  links; Component/Norm/VectorField documented in the API reference

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@aabills
aabills force-pushed the ufv-4-models branch 2 times, most recently from b6dcc1a to adbc716 Compare September 7, 2026 21:03
aabills and others added 2 commits September 7, 2026 14:53
Add BasicDFN2DUnstructured and BasicDFN3DUnstructured on top of the
meshing, spatial-method, and plotting stack, plus Max/Min reduction and
domain-size helpers needed by those models.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant