Skip to content

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

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

Add unstructured 2D/3D DFN battery models#5690
aabills wants to merge 2 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.
⚠️ Please upload report for BASE (ufv-3-plotting@101a306). Learn more about missing BASE report.

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                  ?   96.84%           
=================================================
  Files                     ?      344           
  Lines                     ?    34489           
  Branches                  ?        0           
=================================================
  Hits                      ?    33402           
  Misses                    ?     1087           
  Partials                  ?        0           

☔ 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 and others added 2 commits September 3, 2026 12:13
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