Skip to content

Temperature as a known or unknown expression/coefficient/field - #26

Merged
jorgensd merged 1 commit into
mainfrom
dokken/temperature-dependent-electrolyte-concentrations
Nov 12, 2026
Merged

jorgensd merged 1 commit into
mainfrom
dokken/temperature-dependent-electrolyte-concentrations

Conversation

@jorgensd

Copy link
Copy Markdown
Member

Temperature as a UFL expression

  • Electrolyte(temperature=...) now takes either:

    • a number, the default of the parameter "<name>.T", as before, so it acts as a known coefficient;
    • a UFL expression, used as given. This can be a known coefficient, such as a parameter shared with another model or a prescribed profile, or an unknown field, e.g. the temperature of a heat equation. The electrolyte's equations are then coupled to it.

    density and viscosity already worked this way.

  • Electrolyte.T returns a UFL expression instead of a Parameter.

  • Where the temperature enters:

    • Nernst-Planck migration, through F/(RT);
    • the ionic conductivity;
    • the Butler-Volmer factor nF/(RT);
    • the membrane conductivity.

    With a temperature field, all of these, and their Jacobians, depend on it.

  • ProtonExchangeMembrane(temperature=...) accepts an expression too and passes it to its electrolyte.

  • Not yet temperature-dependent: the diffusivities and rate constants. An Arrhenius law would be the next step for full thermal coupling.

Tests

  • test_conduction_and_transport_at_the_temperature_of_a_heat_equation (test_electrochemistry_from_ufl.py) compares the model with plain UFL on five cell types, residuals and Jacobians.
    • The model is electrolyte conduction and Nernst-Planck transport of V²⁺, V³⁺ and H⁺, with SO₄²⁻ by electroneutrality.
    • The temperature is the unknown of a heat equation.
    • The plain residual is written one equation at a time: charge, each ion, heat.
  • test_the_temperature_can_be_the_field_of_a_heat_equation (test_electrolyte.py) checks three things for a temperature field in kelvin:
    • the units are consistent;
    • "e.T" is no longer a parameter;
    • the temperature is an unknown of the system.

Other changes to the electrolyte

  • The Electrolyte docstring is restructured. It first says what an electrolyte is: a dilute, electroneutral solution whose ions move independently, with their concentrations and the temperature as its state. It then gives what the class computes, before the parameters it creates.
  • New labelled displays: electroneutrality ($\sum_k z_k c_k = 0$) and electrolyte-current, which states $\mathbf{i}_l = F \sum_k z_k \mathbf{N}_k = -\kappa \nabla \phi - F \sum_k z_k t D_k \nabla c_k$, with the conductivity $\kappa$.
    • electrolyte-current moves from ElectrolyteConduction to Electrolyte, which computes it. Its label is unchanged.
    • ElectrolyteConduction now states only charge conservation, $\nabla \cdot \mathbf{i}_l = 0$, and refers to it.
  • conductivity, diffusion_current and current_density refer to these displays instead of repeating the formulas in plain text.
  • The 1D vanadium demo renames its electroneutrality label to vanadium-electroneutrality, since it is the vanadium instance of the general law, and refers to the general one.

@jorgensd
jorgensd added this pull request to stack #25 November 12, 2026 09:59
@jorgensd
jorgensd force-pushed the dokken/temperature-dependent-electrolyte-concentrations branch 2 times, most recently from 314e414 to 0cdd5fc Compare November 12, 2026 10:47
Base automatically changed from dokken/revise-ions to main November 12, 2026 11:42
@jorgensd
jorgensd force-pushed the dokken/temperature-dependent-electrolyte-concentrations branch from 0cdd5fc to bc911ec Compare November 12, 2026 11:42
@jorgensd
jorgensd merged commit aeb1fd8 into main Nov 12, 2026
3 checks passed
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