Skip to content

Add tutorials for FESTIM 2.2-rc.2 features - #182

Merged
RemDelaporteMathurin merged 8 commits into
mainfrom
festim-2.2rc2-tutorials
Sep 5, 2026
Merged

Add tutorials for FESTIM 2.2-rc.2 features#182
RemDelaporteMathurin merged 8 commits into
mainfrom
festim-2.2rc2-tutorials

Conversation

@RemDelaporteMathurin

Copy link
Copy Markdown
Collaborator

Covers the four user-facing features of v2.2-rc.2, which the book had no page for, and moves the rest of the book onto the new API.

environment.yml: festim==2.2rc12.2rc2. A clean drop-in — no new packages, so no effect on the Binder image layer size.

New chapter: Drift terms (content/drift/)

Nothing covered Soret or electromigration; advection appeared only inside two application pages.

  • soret.md — a closed slab in a temperature gradient, run with and without the term. Checked against the analytical steady state c ∝ exp(Q*/k_BT) (9e-8) and the inventory conserved to 6e-14.
  • electromigration.md — a charge sweep over z ∈ {−1, 0, +1}, checked against the Boltzmann distribution (1e-5).
  • advection.md — the divergence form and OutflowBC, taught by running one channel twice: with no outlet condition the concentration peaks at 15.5× the inlet value against the now-closed end; with OutflowBC it maxes at 1.0. Then a uniform-field case where the diffusive flux is identically zero, so the SurfaceFlux reading of ⅔·v_max·L_y is provably the drift contribution.

New chapter: Manifold subdomains (content/manifolds/)

  • manifold_basics.md — declaring a codim-1 subdomain, the bulk exchange pair and its units, codim-2 boundary conditions, trapping, and derived quantities in all three places. A grain boundary carrying 4.5× what the whole square does.
  • pipe_wall.md — a coolant channel as a manifold: advection along it, a codim-2 inlet and an OutflowBC outlet. Pickup rate matches the wall permeation to 1.3%.

Reactions and exports

  • species_reactions/generic_reactions.md — the ReactionBase / GenericReaction / ArrheniusReaction / DecayReaction hierarchy, rate coefficients as callables of T or of another species, and tritium → He-3 decay with T+He conserved to 1e-10.
  • post_process/exports.md rewritten around SpeciesExport/TemperatureExport and the format argument (vtx / vtkhdf / xdmf / checkpoint), including a single-file vtkhdf multi-material export and a checkpoint round-trip.
  • initial_conditions/concentration.md now does its checkpoint round-trip through FESTIM instead of raw io4dolfinx.

Deprecation sweep

F.ReactionF.ArrheniusReaction, VTX*/XDMFExportSpeciesExport/TemperatureExport, advection_termsdrift_terms, model.method_interfaceInterface(method=...). No notebook emits a DeprecationWarning any more.

One physics fix

task06 was wrong under 2.2. Drift is now assembled in divergence form, so the boundary term constrains the total flux and an untagged boundary is a wall. Its right-hand boundary (id=3) was declared but never given a condition, and the flow leaves through it — so hydrogen was piling up against a closed end. It now carries an OutflowBC.

cfd.md needed only the rename: the lid-driven cavity has Dirichlet BCs on all four sides and a divergence-free field, so its results are unaffected.

Verification

  • Every new and rewritten page executes clean with its asserts passing.
  • All 9 modified notebooks re-execute clean: task01, task02, task04, task06, task08, task10, reactions, paraview, microstructure.
  • Sphinx build passes; the 8 warnings are all pre-existing (surrogate.md, heat_transfer.md) or from untracked local scratch files — none from anything touched here.
  • Not run: cfd.md, which needs the OpenFOAM cavity data that is untracked locally. Its change is the rename plus prose. Worth a run before merge, as it is the only untested file.
  • A full jupyter-book build with execution on was not run (it force-executes the ML and CFD pages).

Upstream note

FESTIM's docs/source/userguide/subdomains.rst carries a note claiming SurfaceFlux is diffusive-only on a manifold carrying an AdvectionTerm. That is stale: pipe_wall.md measures +9.31e-3 at the manifold outlet, matching v·c_out = 9.33e-3, where diffusive-only would give −1.8e-5 — opposite sign, 500× smaller. The note predates the drift work by two days (f26b6677 vs f24bb099), and no matching warning exists in the source. Upstream's own test_outlet_flux_of_a_manifold_carrying_advection cannot catch it because it fixes c=0 at the outlet.

🤖 Generated with Claude Code

RemDelaporteMathurin and others added 8 commits September 3, 2026 22:08
Covers the four user-facing features of the 2.2-rc.2 release and moves the
whole book onto the new API.

New Fundamentals chapter "Drift terms" (content/drift/):
- soret.md, electromigration.md: closed-slab redistribution validated against
  the analytical steady states, exp(Q*/kT) and the Boltzmann distribution
- advection.md: the divergence form and OutflowBC, shown by running a channel
  with and without an outlet condition, plus a check that SurfaceFlux reports
  the total (drift-inclusive) flux

New Fundamentals chapter "Manifold subdomains" (content/manifolds/):
- manifold_basics.md: declaring a codim-1 subdomain, the bulk exchange pair and
  its units, codim-2 boundary conditions, trapping, derived quantities
- pipe_wall.md: a coolant channel as a manifold, with advection along it and an
  OutflowBC at the outlet; pickup rate checked against the wall permeation

New page species_reactions/generic_reactions.md: the ReactionBase /
GenericReaction / ArrheniusReaction / DecayReaction hierarchy, rate
coefficients as callables of T or of another species, and tritium decay
checked against exp(-lambda t).

post_process/exports.md rewritten around SpeciesExport/TemperatureExport and
the format argument (vtx, vtkhdf, xdmf, checkpoint), including a single-file
vtkhdf multi-material export and a checkpoint round-trip with
read_function_from_file. initial_conditions/concentration.md now does its
checkpoint round-trip through FESTIM rather than raw io4dolfinx.

Deprecation sweep: F.Reaction -> F.ArrheniusReaction, VTX*/XDMFExport ->
SpeciesExport/TemperatureExport, advection_terms -> drift_terms,
model.method_interface -> Interface(method=...).

task06 also needed a physics fix: drift is now assembled in divergence form,
so its untagged right-hand boundary had become a closed end and hydrogen piled
up against it. It now carries an OutflowBC.

environment.yml: festim 2.2rc1 -> 2.2rc2 (a clean drop-in; no new packages, so
no effect on the Binder image layer size).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The Read the Docs build for this PR (34390215) was terminated by the
inactivity watchdog while apt-get update hung, before the conda install or
the book build ran. No code change; this empty commit just re-fires the
webhook.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Read the Docs failed in conda env create with a Cython compile error in
harmonic/model_legacy.pyx. harmonic 1.3.0 publishes only a cp311 macOS wheel
and no Linux wheel at all, so pip falls back to its sdist, which no longer
compiles on Linux/py3.12. 1.3.1 ships a cp312 manylinux wheel and needs no
compilation.

harmonic arrives transitively via autoemulate >=2.1. Nothing in the pip
section had changed -- RTD's fresh resolve simply backtracked one release
further than a local one does -- so this is a pre-existing break that affects
main equally, not something this branch introduced.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The harmonic>=1.3.1 floor turned the failure into ResolutionImpossible:
harmonic cannot be satisfied alongside fenics-dolfinx 0.11.0 at any version.
1.3.1 conflicts outright, and 1.3.0 was only ever reachable as a backtrack
candidate whose sdist no longer compiles on Linux/py3.12.

harmonic enters via autoemulate >=2.1. pip used to escape the conflict by
backtracking past autoemulate 2.1 to 2.0.0, which has no harmonic dependency
-- that is the version this repo's working environment actually has. Pinning
<2.1 states that outcome explicitly rather than relying on the resolver
finding it, and avoids a long backtracking search on every env build.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The checkpoint section ran a second model built on a freshly created mesh
while its initial condition came from read_function_from_file, whose function
lives on the mesh stored in the checkpoint. Interpolating between two distinct
mesh objects raises RuntimeError in create_initial_conditions on dolfinx
0.11.0, which is what Read the Docs installs; it happened to be tolerated on
the older dolfinx this was written against.

The page now demonstrates the round-trip (checkpoint export plus
read_function_from_file) and points at ic-functions for using the result,
matching the structure it had before, with a warning documenting the mesh
constraint.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Removed, having shipped in 2.0 or 2.1: the Machine Learning page, custom
derived quantities, exporting a custom field, exporting a reaction rate, and
weakly enforced Dirichlet boundary conditions.

Kept: gas enclosures and the pumped-interspace application built on them,
which are 2.2 features.

Added for 2.2: the Drift terms and Manifold subdomains chapters, the reworked
reaction hierarchy, and the two new sections on selectable export formats.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@RemDelaporteMathurin
RemDelaporteMathurin merged commit b440b86 into main Sep 5, 2026
3 checks passed
@RemDelaporteMathurin
RemDelaporteMathurin deleted the festim-2.2rc2-tutorials branch September 5, 2026 10:58
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