Skip to content
Merged
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
16 changes: 16 additions & 0 deletions docs/api/electrochemistry.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@

.. autoclass:: SchloeglFlow
:members:

.. autoclass:: MembraneProtonFlux
:members:
```

## Half-cells
Expand All @@ -75,3 +78,16 @@
.. autoclass:: RedoxHalfCell
:members:
```

## Full cells

```{eval-rst}
.. autoclass:: FullCell
:members:

.. autoclass:: HalfCellSpec
:members:

.. autoclass:: MembraneSpec
:members:
```
2 changes: 2 additions & 0 deletions docs/api/symbolic.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@

.. autofunction:: input_or_parameter

.. autofunction:: expression_or_parameter

.. autoclass:: Residual
:members:

Expand Down
13 changes: 11 additions & 2 deletions src/sumfem/electrochemistry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@
on :class:`ElectrodeReaction`, with the Butler-Volmer equation
:func:`~sumfem.models.butler_volmer`.
- Membranes: :class:`ProtonExchangeMembrane`, with the flow of water of
:class:`SchloeglFlow`.
:class:`SchloeglFlow`, whose current the protons of an electrode carry
through its face, :class:`MembraneProtonFlux`.
- Half-cells of a redox flow battery: :class:`RedoxHalfCell`, negative or
positive, of any :class:`RedoxCouple` and electrolyte.
- Full cells: :class:`FullCell`, two half-cells, each a
:class:`HalfCellSpec`, and a membrane between them, a
:class:`MembraneSpec`.

The package imports from the core of :mod:`sumfem`, and never the other
way around.
Expand All @@ -22,6 +26,7 @@
from .charge import ElectrolyteConduction
from .couple import RedoxCouple
from .electrolyte import Electrolyte, Ion
from .full_cell import FullCell, HalfCellSpec, MembraneSpec
from .half_cell import RedoxHalfCell
from .kinetics import (
ButlerVolmer,
Expand All @@ -30,7 +35,7 @@
MassTransferButlerVolmer,
PistonVelocityButlerVolmer,
)
from .membrane import ProtonExchangeMembrane, SchloeglFlow
from .membrane import MembraneProtonFlux, ProtonExchangeMembrane, SchloeglFlow
from .porous import PorousElectrode, Region
from .transport import NernstPlanck, TransientNernstPlanck

Expand All @@ -44,8 +49,12 @@
"TransientNernstPlanck",
"ProtonExchangeMembrane",
"SchloeglFlow",
"MembraneProtonFlux",
"RedoxCouple",
"RedoxHalfCell",
"FullCell",
"HalfCellSpec",
"MembraneSpec",
"ButlerVolmer",
"ElectrodeReaction",
"ExchangeCurrentButlerVolmer",
Expand Down
49 changes: 18 additions & 31 deletions src/sumfem/electrochemistry/electrolyte.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@
import sympy.physics.units as syu
import ufl

from sumfem.symbolic import FARADAY, GAS_CONSTANT, Domain, Field, Parameter
from sumfem.symbolic import (
FARADAY,
GAS_CONSTANT,
Domain,
Field,
Parameter,
expression_or_parameter,
)
from sumfem.symbolic.si import to_si

__all__ = ["Electrolyte", "Ion"]
Expand Down Expand Up @@ -219,16 +226,8 @@ def __init__(
unit=syu.joule / (syu.mol * syu.kelvin),
doc="Universal gas constant",
)
self._T = (
temperature
if isinstance(temperature, ufl.core.expr.Expr)
else Parameter(
f"{name}.T",
domain,
default=temperature,
unit=syu.kelvin,
doc="Temperature",
)
self._T = expression_or_parameter(
f"{name}.T", temperature, domain, unit=syu.kelvin, doc="Temperature"
)
self._floor = Parameter(
f"{name}.floor",
Expand All @@ -237,27 +236,15 @@ def __init__(
unit=CONCENTRATION,
doc="Regularization of positive concentrations",
)
self._density = (
density
if isinstance(density, ufl.core.expr.Expr)
else Parameter(
f"{name}.density",
domain,
default=density,
unit=syu.kg / syu.m**3,
doc="Density",
)
self._density = expression_or_parameter(
f"{name}.density", density, domain, unit=syu.kg / syu.m**3, doc="Density"
)
self._viscosity = (
viscosity
if isinstance(viscosity, ufl.core.expr.Expr)
else Parameter(
f"{name}.viscosity",
domain,
default=viscosity,
unit=syu.pascal * syu.second,
doc="Dynamic viscosity",
)
self._viscosity = expression_or_parameter(
f"{name}.viscosity",
viscosity,
domain,
unit=syu.pascal * syu.second,
doc="Dynamic viscosity",
)
self._ions = types.MappingProxyType({ion.name: ion for ion in ions})
self._diffusivities = {
Expand Down
Loading
Loading