Boundary conditions#
- class DirichletBC(surfaces, value, field)[source]#
Bases:
BoundaryConditionClass to enforce the solution on boundaries.
- Parameters:
surfaces (list or int) – the surfaces of the BC
value (float or sp.Expr) – the value of the boundary condition.
field (int or str) – the field the boundary condition is applied to. 0 and “solute” stand for the mobile concentration, “T” for temperature
- create_dirichletbc(V, T, surface_markers, chemical_pot=False, materials=None, volume_markers=None)[source]#
creates a list of fenics.DirichletBC and stores it in self.dirichlet_bc
- Parameters:
V (fenics.FunctionSpace) – the function space of the field
T (fenics.Constant or fenics.Expression or fenics.Function) – the temperature
surface_markers (fenics.MeshFunction) – the surface markers
chemical_pot (bool, optional) – if True, conservation of chemical pot will be assumed. Defaults to False.
materials (festim.Materials) – The materials, only needed when chemical_pot is True. Defaults to None.
volume_markers (fenics.MeshFunction, optional) – the volume markers, only needed when chemical_pot is True. Defaults to None.
- create_expression(T)[source]#
Assigns a value to self.expression
- Parameters:
T (fenics.Function) – temperature
- normalise_by_solubility(materials, volume_markers, T)[source]#
Normalise self.expression by the solubility theta = c/S
- Parameters:
materials (festim.Materials) – the materials
volume_markers (fenics.MeshFunction) – the volume markers
T (fenics.Function) – the temperature
- class CustomDirichlet(surfaces, function, field=0, **prms)[source]#
Bases:
DirichletBCSubclass of DirichletBC allowing the use of a user-defined function.
- Parameters:
surfaces (list or int) – the surfaces of the BC
function (callable) – the custom function
field (int, optional) – the field the boundary condition is applied to. Defaults to 0.
Example:
def fun(T, solute, param1): return 2*T + solute - param1 my_bc = CustomDirichlet( surfaces=[1, 2], function=fun, param1=2*festim.x + festim.t )
- class ImplantationDirichlet(surfaces, phi, R_p, D_0, E_D, Kr_0=None, E_Kr=None, Kd_0=None, E_Kd=None, P=None)[source]#
Bases:
DirichletBCSubclass of DirichletBC representing an approximation of an implanted flux of hydrogen. The details of the approximation can be found in https://www.nature.com/articles/s41598-020-74844-w
c = phi*R_p/D + ((phi+Kd*P)/Kr)**0.5
- Parameters:
surfaces (list or int) – the surfaces of the BC
phi (float or sp.Expr) – implanted flux (H/m2/s)
R_p (float or sp.Expr) – implantation depth (m)
D_0 (float) – diffusion coefficient pre-exponential factor (m2/s)
E_D (float) – diffusion coefficient activation energy (eV)
Kr_0 (float, optional) – recombination coefficient pre-exponential factor (m^4/s). If None, instantaneous recombination will be assumed. Defaults to None.
E_Kr (float, optional) – recombination coefficient activation energy (eV). Defaults to None.
Kd_0 (float, optional) – dissociation coefficient pre-exponential factor (m-2 s-1 Pa-1). If None, instantaneous dissociation will be assumed. Defaults to None.
E_Kd (float, optional) – dissociation coefficient activation energy (eV). Defaults to None.
P (float or sp.Expr, optional) – partial pressure of H (Pa). Defaults to None.
- class HenrysBC(surfaces, H_0, E_H, pressure)[source]#
Bases:
DirichletBCSubclass of DirichletBC for Henry’s law: cm = H*pressure
- Parameters:
surfaces (list or int) – the surfaces on which the BC is applied
H_0 (float) – Henry’s constant pre-exponential factor (m-3.Pa-1)
E_H (float) – Henry’s constant solution energy (eV)
pressure (float or sp.Expr) – hydrogen partial pressure (Pa)
- class SievertsBC(surfaces, S_0, E_S, pressure)[source]#
Bases:
DirichletBCSubclass of DirichletBC for Sievert’s law
- Parameters:
surfaces (list or int) – the surfaces of the BC
S_0 (float) – Sievert’s constant pre-exponential factor (m-3/Pa0.5)
E_S (float) – Sievert’s constant activation energy (eV)
pressure (float or sp.Expr) – hydrogen partial pressure (Pa)
- class FluxBC(surfaces, value=None, **kwargs)[source]#
Bases:
BoundaryConditionBoundary condition ensuring the gradient of the solution so that: -D * grad(c) * n = f or -lambda * grad(T) * n = f depending if applied to mobile concentration or temperature
- Parameters:
surfaces (list or int) – the surfaces of the BC
value (sp.Expr or float, optional) – value of the flux. Defaults to None.
- class CustomFlux(surfaces, function, field, **prms)[source]#
Bases:
FluxBCFluxBC subclass allowing the use of a user-defined function.
- Parameters:
surfaces (list or int) – the surfaces of the BC
function (callable) – the function.
Example:
def fun(T, solute, param1): return 2*T + solute - param1 my_bc = CustomFlux( surfaces=[1, 2], function=fun, param1=2*festim.x + festim.t )
- class RecombinationFlux(Kr_0, E_Kr, order, surfaces)[source]#
Bases:
FluxBCFluxBC subclass for hydrogen recombination flux. -D(T) * grad(c) * n = -Kr(T) * c**order
- Parameters:
Kr_0 (float or sp.Expr) – recombination coefficient pre-exponential factor (m^(6-order)/s)
E_Kr (float or sp.Expr) – recombination coefficient activation energy (eV)
order (float) – order of the recombination (typically 1 or 2)
surfaces (list or int) – the surfaces of the BC
- class DissociationFlux(Kd_0, E_Kd, P, surfaces)[source]#
Bases:
FluxBCFluxBC subclass for hydrogen dissociation flux. -D(T) * grad(c) * n = Kd(T) * P
- Parameters:
Kd_0 (float or sp.Expr) – dissociation coefficient pre-exponential factor (m-2 s-1 Pa-1)
E_Kd (float or sp.Expr) – dissociation coefficient activation energy (eV)
P (float or sp.Expr) – partial pressure of H (Pa)
surfaces (list or int) – the surfaces of the BC
- class ConvectiveFlux(h_coeff, T_ext, surfaces)[source]#
Bases:
FluxBCFluxBC subclass for convective heat flux -lambda * grad(T) * n = h_coeff * (T - T_ext)
- Parameters:
h_coeff (float or sp.Expr) – heat exchange coefficient (W/m2/K)
T_ext (float or sp.Expr) – fluid temperature (K)
surfaces (list or int) – the surfaces of the BC
- class MassFlux(h_coeff, c_ext, surfaces)[source]#
Bases:
FluxBCFluxBC subclass for advective mass flux -D * grad(c) * n = h_mass * (c - c_ext)
- Parameters:
h_mass (float or sp.Expr) – mass transfer coefficient (m/s)
c_ext (float or sp.Expr) – external concentration (1/m3)
surfaces (list or int) – the surfaces of the BC
Reference: Bergman, T. L., Bergman, T. L., Incropera, F. P., Dewitt, D. P., & Lavine, A. S. (2011). Fundamentals of heat and mass transfer. John Wiley & Sons.
- class SurfaceKinetics(k_sb, k_bs, lambda_IS, n_surf, n_IS, J_vs, surfaces, initial_condition, **prms)[source]#
Bases:
FluxBCFluxBC subclass allowing to include surface processes in 1D H transport simulations:
\[\dfrac{d c_{\mathrm{s}}}{dt} = J_{\mathrm{bs}} - J_{\mathrm{sb}} + J_{\mathrm{vs}};\]\[-D \nabla c_\mathrm{m} \cdot \mathbf{n} = \lambda_{\mathrm{IS}} \dfrac{\partial c_{\mathrm{m}}}{\partial t} + J_{\mathrm{bs}} - J_{\mathrm{sb}},\]where \(c_{\mathrm{m}}\) is the concentration of mobile hydrogen (\(\mathrm{H \ m}^{-3}\)), \(c_{\mathrm{s}}\) is the surface concentration of adsorbed hydrogen (\(\mathrm{H \ m}^{-2}\)), the H flux from subsurface to surface \(J_{\mathrm{bs}}\) (in \(\mathrm{m}^{-2} \ \mathrm{s}^{-1}\)) is:
\[J_{\mathrm{bs}} = k_{\mathrm{bs}} c_{\mathrm{m}} \left(1 - \dfrac{c_\mathrm{s}}{n_{\mathrm{surf}}}\right),\]the H flux from surface to subsurface \(J_{\mathrm{sb}}\) (in \(\mathrm{m}^{-2} \ \mathrm{s}^{-1}\)) is:
\[J_{\mathrm{sb}} = k_{\mathrm{sb}} c_{\mathrm{s}} \left(1 - \dfrac{c_{\mathrm{m}}}{n_\mathrm{IS}}\right),\]- For more details see:
E.A. Hodille et al 2017 Nucl. Fusion 57 056002; Y. Hamamoto et al 2020 Nucl. Mater. Energy 23 100751
Warning
The SurfaceKinetics boundary condition can be used only in 1D simulations!
- Parameters:
k_sb (float or callable) – rate constant for the surface-to-subsurface transition (\(\mathrm{s}^{-1}\)), can accept additional parameters (see example)
k_bs (float or callable) – rate constant for the subsurface-to-surface transition (\(\mathrm{m} \ \mathrm{s}^{-1}\)), can accept additional parameters (see example)
lambda_IS (float) – characteristic distance between two iterstitial sites (\(\mathrm{m}\))
n_surf (float) – surface concentration of adsorption sites (\(\mathrm{m}^{-2}\))
n_IS (float) – bulk concentration of interstitial sites (\(\mathrm{m}^{-3}\))
J_vs (float or callable) – the net adsorption flux from vacuum to surface (\(\mathrm{m}^{-2} \ \mathrm{s}^{-1}\)), can accept additional parameters (see example)
surfaces (int or list) – the surfaces for which surface processes are considered
initial_condition (int or float) – the initial value of the H surface concentration (\(\mathrm{m}^{-2}\))
- Variables:
previous_solutions (list) – list containing solutions (fenics.Function or ufl.Indexed) on each surface for “previous” timestep
test_functions (list) – list containing test functions (fenics.TestFunction or ufl.Indexed) for each surface
post_processing_solutions (list) – list containing solutions (fenics.Function or ufl.Indexed) on each surface used for post-processing
Example:
def K_sb(T, surf_conc, mobile_conc, prm1, prm2): return 1e13 * f.exp(-2.0/F.k_B/T) + mobile_conc def K_bs(T, surf_conc, mobile_conc, prm1, prm2): return 1e13 * f.exp(-0.2/F.k_B/T) def J_vs(T, surf_conc, mobile_conc, prm1, prm2): return (1-surf_conc/5) ** 2 * fenics.exp(-2/F.k_B/T) + prm1 * prm2 my_surf_model = SurfaceKinetics( k_sb=K_sb, k_bs=K_bs, lambda_IS=110e-12, n_surf=2e19, n_IS=6e28, J_vs=J_vs, surfaces=[1, 2], initial_condition=0, prm1=2e16, prm2=F.t )
- create_form(solute, solute_prev, solute_test_function, T, ds, dt)[source]#
Creates the general form associated with the surface species
- Parameters:
solute (fenics.Function or ufl.Indexed) – mobile solution for “current” timestep
solute_prev (fenics.Function or ufl.Indexed) – mobile solution for “previous” timestep
solute_test_function (fenics.TestFunction or ufl.Indexed) – mobile test function
T (festim.Temperature) – the temperature of the simulation
ds (fenics.Measure) – the ds measure of the sim
dt (festim.Stepsize) – the step-size