Skip to content

Deprecate pybamm.Magnitude in favour of Component - #5691

Open
aabills wants to merge 8 commits into
ufv-4-modelsfrom
ufv-5-deprecate-magnitude
Open

Deprecate pybamm.Magnitude in favour of Component#5691
aabills wants to merge 8 commits into
ufv-4-modelsfrom
ufv-5-deprecate-magnitude

Conversation

@aabills

@aabills aabills commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Deprecate pybamm.Magnitude with a DeprecationWarning pointing users to pybamm.Component(symbol, 0|1).
  • Migrate internal callers (BasicDFN2D, 2D FV / processed-variable tests) to Component.
  • Teach FiniteVolume2D edge-averaging to accept Component indices so the replacement works for flux products.

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. Add unstructured 2D/3D DFN battery models #5690 — Unstructured DFN models
  6. This PR (Deprecate pybamm.Magnitude in favour of Component #5691) — Deprecate Magnitude

Test plan

  • test_vector_field_and_magnitude.py (Component + deprecation)
  • test_process_binary_operators, test_processed_variable_2D_fvm, 2D integration tests
  • CI unit suite

aabills and others added 8 commits July 31, 2026 14:37
Support 3D vector fields via N-component VectorField, Component/Norm
operators, and matching discretisation/solution handling. Extracted from
the unstructured finite-volume work for review in isolation.

Co-authored-by: Cursor <cursoragent@cursor.com>
Introduce UnstructuredSubMesh, mesh generators, and Mesh interface
coupling so arbitrary 2D/3D domains can be discretised later. Extracted
from the unstructured finite-volume stack for isolated review.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	CHANGELOG.md
Add FiniteVolumeUnstructured, discretisation hooks, and unstructured
processed variables so cell-centered solutions can be formed on the new
meshes. Extracted from the unstructured finite-volume stack.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add VTKQuickPlot, QuickPlot/dynamic_plot hooks, the vtk optional extra,
and headless OSMesa CI setup for GIF export. Extracted from the
unstructured finite-volume stack.

Co-authored-by: Cursor <cursoragent@cursor.com>
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>
Emit DeprecationWarning from Magnitude and migrate internal 2D call
sites to Component. Teach FiniteVolume2D edge-averaging to read
Component indices so the replacement works for flux products.

Co-authored-by: Cursor <cursoragent@cursor.com>
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.84%. Comparing base (5e1d810) to head (47e87fd).

Files with missing lines Patch % Lines
...amm/src/pybamm/spatial_methods/finite_volume_2d.py 70.00% 3 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##           ufv-4-models    #5691   +/-   ##
=============================================
  Coverage         96.84%   96.84%           
=============================================
  Files               344      344           
  Lines             34489    34499   +10     
=============================================
+ Hits              33402    33412   +10     
  Misses             1087     1087           

☔ 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
aabills force-pushed the ufv-4-models branch 2 times, most recently from 240b105 to b6dcc1a Compare September 5, 2026 00:28
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.

2 participants