Different BCs at different times

Hello! I want to simulate D2-gas loading phase, open-air phase and TDS phase. During gas loading and open-air phase, the Sievert’s law should be used, but in the TDS phase I want to apply RecombinationFlux bc. Is it possible to do this using only one input file or should I first simulate phase 1 and 2 (with Sievert’s law bc) and then transfer output data to the second input file with RecombinationFlux bc?

Hi @cruiseraurora and welcome to the FESTIM discourse! :tada:

The Sievert’s solubility law is nothing but a steady state simplification of having a recombination flux and a dissociation flux.

In your case, I would set both these fluxes for the whole simulation and “turn off” the gas pressure during the TDS phase:

Consider:

import festim as F
import sympy as sp
import numpy as np

my_model = F.Simulation()

nominal_pressure = 10
loading_time = 3
gas_pressure = sp.Piecewise((nominal_pressure, F.t < loading_time), (0, True))

my_model.boundary_conditions = [
    F.RecombinationFlux(Kr_0=1, E_Kr=0, order=2, surfaces=[1]),
    F.DissociationFlux(Kd_0=1, E_Kd=0, P=gas_pressure, surfaces=[1]),
    # equivalent sieverts BC (steady state)
    # F.SievertsBC(surfaces=[1], S_0=1, E_S=0, pressure=gas_pressure),
]

my_model.materials = F.Material(id=1, D_0=1, E_D=0)

my_model.mesh = F.MeshFromVertices(np.linspace(0, 1))

my_model.T = 500

my_model.settings = F.Settings(
    final_time=2 * loading_time,
    absolute_tolerance=1e-6,
    relative_tolerance=1e-6,
)

my_model.dt = F.Stepsize(loading_time/4000, stepsize_change_ratio=1.05, milestones=[loading_time])

surface_concentration = F.TotalSurface(field="solute", surface=1)
my_model.exports = [F.DerivedQuantities([surface_concentration])]

my_model.initialise()
my_model.run()

The surface concentration can then be plotted with:

import matplotlib.pyplot as plt
plt.plot(surface_concentration.t, surface_concentration.data)
plt.ylim(bottom=0)
plt.xlabel("Time")
plt.ylabel("Surface concentration")

If you run this with the SievertsBC you end up with the steady state value:

Thank you very much for your answer!

1 Like

Hi Remi,

Can the “turning off the gas pressure” be achieved in 2D problems?

Hi Xin,

Yes this not related to the dimensionality and F.DissociationFlux can be used for 2D problems as long as the surfaces are correctly tagged and passed to the surfaces argument of the BC.

Thank you very much!

@xinshen can you open a new topic with this please? Also could you include a full Minimal Working Example showing the issue you’re having?

Yes, I can open a new topic with this.

I thought this also belongs to the topic of setting different BCs at different times, so I put up the problem here. Sorry for that.

No problem! Since the original issue of @cruiseraurora has been resolved, it makes sense to open a new topic :slight_smile:

I see. Thanks a lot for reminding!