Diffusion through a semi-infinite slab#
This verification case from TMAP7’s V&V report [3] consists of a semi-infinite slab with no traps under a constant concentration \(C_0\) boundary condition on the left.
FESTIM Code#
import festim as F
from dolfinx.geometry import bb_tree, compute_colliding_cells, compute_collisions_points
class PointValue(F.VolumeQuantity):
def __init__(self, field, volume, x0, filename=None):
super().__init__(field, volume, filename)
self.x0 = x0
def compute(self):
u = self.field.solution
mesh = u.function_space.mesh
tree = bb_tree(mesh, mesh.geometry.dim)
cell_candidates = compute_collisions_points(tree, self.x0)
cell = compute_colliding_cells(mesh, cell_candidates, self.x0).array
assert len(cell) > 0
first_cell = cell[0]
self.value = self.field.solution.eval(self.x0, first_cell)
self.data.append(self.value)
/home/docs/checkouts/readthedocs.org/user_builds/festim-vv-report/conda/festim-2/lib/python3.11/site-packages/festim/coupled_heat_hydrogen_problem.py:1: TqdmExperimentalWarning: Using `tqdm.autonotebook.tqdm` in notebook mode. Use `tqdm.tqdm` instead to force console mode (e.g. in jupyter console)
import tqdm.autonotebook
Comparison with exact solution#
The exact solution is given by
\[
c(x, t) = c_0 \left( 1 - \mathrm{erf}\left( \frac{x}{2\sqrt{Dt}} \right) \right)
\]