Diffusion from a Depleting Source#
This verification case [3] consists of an enclosure containing an initial quantity of hydrogen gas (at an initial pressure \(P_0\)). The hydrogen can dissociate on the inner surface of the enclosure and then permeate through the walls. As hydrogen particles escape the enclosure, the pressure decreases and as a result, so does the surface concentration on the inner walls. This 1D problem is, therefore, coupled. At each time step, the flux of particles escaping the enclosure is computed, and the internal pressure is updated.
An analytical solution to this problem can be obtained. The analytical expression of the concentration in the wall is given by Ambrosek et al [3]:
where \(L = \dfrac{K_H \ T \ A \ k_B}{V}\), \(K_H\) is the solubility of the material, \(T\) is the temperature, \(A\) is the enclosure surface area, \(V\) is the volume of the enclosure, \(l\) is the thickness of the wall, and \(\alpha_n\) are the roots of:
The flux at the non-exposed surface can be expressed as:
The cumulative release \(R\) is then:
Multiplying by the area and normalising by the initial quantity in the enclosure, one can obtain the fractional release:
FESTIM Code#
import festim as F
import numpy as np
encl_vol = 5.20e-11 # m^3
encl_surf = 2.16e-6 # m^2
l = 3.3e-5 # m
R = 8.314 #
avogadro = 6.022e23 # mol-1
temperature = 2373 # K
initial_pressure = 1e6 # Pa
solubility = 7.244e22 / temperature # H/m3/Pa
diffusivity = 2.6237e-11 # m2/s
class PressureExport(F.SurfaceQuantity):
def __init__(self):
super().__init__(field=F.Species(), surface=left_surface)
def compute(self):
self.value = left_bc.value / solubility
self.data.append(self.value)
class CustomHydrogenTransportProblem(F.HydrogenTransportProblem):
def iterate(self):
super().iterate()
# Update pressure based on flux
left_flux_val = -left_flux.value
old_pressure = left_bc.value / solubility
new_pressure = (
old_pressure
- (left_flux_val * encl_surf / encl_vol * R * self.temperature / avogadro)
* self.dt.value
)
left_bc.value = new_pressure * solubility
self.bc_forms[0] = self.create_dirichletbc_form(left_bc)
model = CustomHydrogenTransportProblem()
vertices = np.linspace(0, l, 150)
model.mesh = F.Mesh1D(vertices)
material = F.Material(D_0=diffusivity, E_D=0.0)
left_surface = F.SurfaceSubdomain1D(id=1, x=0)
right_surface = F.SurfaceSubdomain1D(id=2, x=l)
volume = F.VolumeSubdomain1D(id=3, borders=[0, l], material=material)
model.subdomains = [left_surface, volume, right_surface]
H = F.Species("H")
model.species = [H]
left_bc = F.DirichletBC(
subdomain=left_surface, value=initial_pressure * solubility, species=H
)
model.boundary_conditions = [
left_bc,
F.DirichletBC(subdomain=right_surface, value=0, species=H),
]
model.temperature = temperature
left_flux = F.SurfaceFlux(field=H, surface=left_surface)
right_flux = F.SurfaceFlux(field=H, surface=right_surface)
pressure_export = PressureExport()
tot_vol = F.TotalVolume(field=H, volume=volume)
model.exports = [left_flux, right_flux, pressure_export]
model.settings = F.Settings(atol=1e8, rtol=1e-10, final_time=140)
model.settings.stepsize = F.Stepsize(0.05)
model.initialise()
model.run()
/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#
RMSPE = 0.22%
RMSPE = 0.29%