Pre-loaded semi-infinite slab#
This verification case from case Val-1c of TMAP7’s V&V report [3] consists of a semi-infinite slab with no traps under a constant concentration \(c_0\) on the first \(10 \ \mathrm{m}\) of the slab. The concentration at the boundaries is set to zero.
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)
class Profile(F.Profile1DExport):
def __init__(self, field, volume, times=None):
super().__init__(field=field, subdomain=volume, times=times)
self.data = []
self.t = []
self.x = None
def compute(self, *args, **kwargs):
super().compute(*args, **kwargs)
last_profile = self.data[-1].copy()
self.data[-1] = last_profile
/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#
This is a comparison of the computed concentration profiles at different times with the exact analytical solution (shown in dashed lines).
The analytical solution is given by
\[
c(x, t) = \frac{c_0}{2}\left[
2\mathrm{erf}\left(\frac{x}{2 \sqrt{Dt}}\right)
- \mathrm{erf}\left(\frac{x - h}{2 \sqrt{Dt}}\right)
- \mathrm{erf}\left(\frac{x + h}{2 \sqrt{Dt}}\right)
\right]
\]
where \(h\) is the thickness of the pre-loaded region.
Warning
There is an existing bug with ProfileExport1D class. See (this associated issue for more details)[https://github.com/festim-dev/FESTIM/issues/1046].
The results can also be compared with the results obtained by TMAP7.