Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

## Features

- Added basic unstructured 2D/3D DFN models (`BasicDFN2DUnstructured`, `BasicDFN3DUnstructured`). ([#5690](https://github.com/pybamm-team/PyBaMM/pull/5690))
- Added VTK-based plotting (`VTKQuickPlot`) for unstructured mesh solutions, including headless CI OpenGL setup. ([#5689](https://github.com/pybamm-team/PyBaMM/pull/5689))
- Added `FiniteVolumeUnstructured` spatial method and unstructured processed-variable support for cell-centered data on arbitrary meshes. The TPFA Laplacian carries an implicit non-orthogonal correction (`"non-orthogonal correction"` option: `"over-relaxed"` or `"minimum"`) and gradients use a least-squares reconstruction, so both are exact on linear fields and second-order on skewed triangle and tetrahedral meshes. Diffusion coefficients reach faces through the distance-weighted harmonic mean, as in `FiniteVolume`, so material interfaces carry the exact series flux. ([#5688](https://github.com/pybamm-team/PyBaMM/pull/5688))
- Added unstructured mesh support (`UnstructuredSubMesh`, generators, and interface coupling) for arbitrary 2D/3D domains. Hexahedra must have planar faces (warped hexes raise a `GeometryError`), and `UserSuppliedUnstructuredMesh` accepts tetrahedral, triangular, and quadrilateral cells only. ([#5687](https://github.com/pybamm-team/PyBaMM/pull/5687))
Expand Down
6 changes: 6 additions & 0 deletions docs/source/api/models/lithium_ion/dfn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@ Doyle-Fuller-Newman (DFN)
.. autoclass:: pybamm.lithium_ion.BasicDFNHalfCell
:members:

.. autoclass:: pybamm.lithium_ion.BasicDFN2DUnstructured
:members:

.. autoclass:: pybamm.lithium_ion.BasicDFN3DUnstructured
:members:

.. footbibliography::
1 change: 0 additions & 1 deletion packages/pybamm/src/pybamm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@
UserSuppliedSubmesh3D,
)


from .meshes.unstructured_submesh import (
UnstructuredSubMesh,
UnstructuredMeshGenerator,
Expand Down
32 changes: 28 additions & 4 deletions packages/pybamm/src/pybamm/expression_tree/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,8 +719,32 @@ def log10(child: pybamm.Symbol):
return log(child, base=10)


class Max(SpecificFunction):
"""Max function."""
class Reduction(SpecificFunction):
"""Base class for reduction operations that collapse a spatial
field to a scalar (e.g. max, min). Automatically clears domains
and returns scalar shape."""

def __init__(self, function: Callable, child: pybamm.Symbol):
super().__init__(function, child)
self.clear_domains()

@classmethod
def _from_json(cls, snippet: dict):
"""See :meth:`pybamm.SpecificFunction._from_json()`.

``SpecificFunction._from_json`` bypasses ``__init__``, so the domains
inherited from the child have to be cleared again here.
"""
instance = super()._from_json(snippet)
instance.clear_domains()
return instance

def _evaluate_for_shape(self):
return np.nan * np.ones((1, 1))


class Max(Reduction):
"""Max function (reduction to scalar)."""

def __init__(self, child):
super().__init__(np.max, child)
Expand Down Expand Up @@ -750,8 +774,8 @@ def max(child: pybamm.Symbol):
return pybamm.simplify_if_constant(Max(child))


class Min(SpecificFunction):
"""Min function."""
class Min(Reduction):
"""Min function (reduction to scalar)."""

def __init__(self, child):
super().__init__(np.min, child)
Expand Down
8 changes: 8 additions & 0 deletions packages/pybamm/src/pybamm/expression_tree/symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,20 @@ def domain_size(domain: list[str] | str):
fixed_domain_sizes = {
"current collector": 3,
"negative particle": 5,
"negative primary particle": 5,
"negative secondary particle": 5,
"positive particle": 7,
"positive primary particle": 7,
"positive secondary particle": 7,
"negative electrode": 11,
"separator": 13,
"positive electrode": 17,
"negative particle size": 19,
"negative primary particle size": 19,
"negative secondary particle size": 19,
"positive particle size": 23,
"positive primary particle size": 23,
"positive secondary particle size": 23,
}
if domain in [[], None]:
size = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
from .newman_tobias import NewmanTobias
from .basic_dfn import BasicDFN
from .basic_dfn_2d import BasicDFN2D
from .basic_dfn_2d_unstructured import BasicDFN2DUnstructured
from .basic_dfn_3d_unstructured import BasicDFN3DUnstructured
from .basic_spm import BasicSPM
from .basic_spm_with_3d_thermal import Basic3DThermalSPM
from .basic_dfn_half_cell import BasicDFNHalfCell
Expand Down
Loading
Loading