TDS simulation

Contents

TDS simulation#

Thermo-desorption spectra (TDS) are a valuble source of experimental data for understanding the mechanics of hydrogen transport. The nature of the spectra produced by thermo-desorption experiments can give insight to the trapping properties of a given material. There are three stages in a TDS experiment; The implantation stage, the resting stage and the desorption stage. Each stage can be modelled, and the desportion flux spectra reproduced.

In this task, we’ll simulate a thermo-desorption experiment for a sample of tungsten.

Objectives

  • Make a locally refined 1D mesh

  • Define several traps

  • Add a time-dependent temperature

  • Accelerate simulations with adaptive timestepping

  • Understand the concept of derived quantities

  • Perform post-processing of derived quantities with matplotlib

import festim as F
my_model = F.Simulation()

Let’s create a mesh from a list of vertices with more refinement close to \(x=0\).

import numpy as np

vertices = np.concatenate([
    np.linspace(0, 30e-9, num=200),
    np.linspace(30e-9, 3e-6, num=300),
    np.linspace(3e-6, 20e-6, num=200),
])

my_model.mesh = F.MeshFromVertices(vertices)

The material we want to simulate is tungsten. The only property we need is the diffusion coefficient.

tungsten = F.Material(
    id=1,
    D_0=4.1e-07,  # m2/s
    E_D=0.39,  # eV
)

my_model.materials = tungsten

The source term is defined as:

\[ \begin{equation} S_{ext} = \varphi \cdot f(x) \quad \forall \, t<400 \text{s} \end{equation} \]

where \(\varphi =2.5 \times 10^{19} \text{m}^{-2}\text{s}^{-1}\) and \(f(x)\) is a Gaussian spatial distribution with a mean value of \(4.5 \: \text{nm}\) and a width of \(2.5 \: \text{nm}\).

FESTIM has a special class for this case: ImplantationFlux.

The ion flux is temporally defined using a Sympy Piecewise expression, to be active for the implantation_time.

Below, t is a built-in FESTIM variable that represent time in \(\text{s}\).

import sympy as sp

implantation_time = 400  # s

ion_flux = sp.Piecewise((2.5e19, F.t <= implantation_time), (0, True))

source_term = F.ImplantationFlux(
    flux=ion_flux,  # H/m2/s
    imp_depth=4.5e-9,  # m
    width=2.5e-9,  # m
    volume=1
)

my_model.sources = [source_term]
/home/docs/checkouts/readthedocs.org/user_builds/festim-workshop/conda/festim1/lib/python3.11/site-packages/mpmath/libmp/libintmath.py:75: DeprecationWarning: bitcount function is deprecated
  warnings.warn("bitcount function is deprecated",
/home/docs/checkouts/readthedocs.org/user_builds/festim-workshop/conda/festim1/lib/python3.11/site-packages/mpmath/libmp/libintmath.py:75: DeprecationWarning: bitcount function is deprecated
  warnings.warn("bitcount function is deprecated",
/home/docs/checkouts/readthedocs.org/user_builds/festim-workshop/conda/festim1/lib/python3.11/site-packages/mpmath/libmp/libintmath.py:75: DeprecationWarning: bitcount function is deprecated
  warnings.warn("bitcount function is deprecated",
/home/docs/checkouts/readthedocs.org/user_builds/festim-workshop/conda/festim1/lib/python3.11/site-packages/mpmath/libmp/libintmath.py:75: DeprecationWarning: bitcount function is deprecated
  warnings.warn("bitcount function is deprecated",
/home/docs/checkouts/readthedocs.org/user_builds/festim-workshop/conda/festim1/lib/python3.11/site-packages/mpmath/libmp/libintmath.py:75: DeprecationWarning: bitcount function is deprecated
  warnings.warn("bitcount function is deprecated",
/home/docs/checkouts/readthedocs.org/user_builds/festim-workshop/conda/festim1/lib/python3.11/site-packages/mpmath/libmp/libintmath.py:75: DeprecationWarning: bitcount function is deprecated
  warnings.warn("bitcount function is deprecated",
/home/docs/checkouts/readthedocs.org/user_builds/festim-workshop/conda/festim1/lib/python3.11/site-packages/mpmath/libmp/libintmath.py:75: DeprecationWarning: bitcount function is deprecated
  warnings.warn("bitcount function is deprecated",
/home/docs/checkouts/readthedocs.org/user_builds/festim-workshop/conda/festim1/lib/python3.11/site-packages/mpmath/libmp/libintmath.py:75: DeprecationWarning: bitcount function is deprecated
  warnings.warn("bitcount function is deprecated",
/home/docs/checkouts/readthedocs.org/user_builds/festim-workshop/conda/festim1/lib/python3.11/site-packages/mpmath/libmp/libintmath.py:75: DeprecationWarning: bitcount function is deprecated
  warnings.warn("bitcount function is deprecated",
/home/docs/checkouts/readthedocs.org/user_builds/festim-workshop/conda/festim1/lib/python3.11/site-packages/mpmath/libmp/libintmath.py:75: DeprecationWarning: bitcount function is deprecated
  warnings.warn("bitcount function is deprecated",
/home/docs/checkouts/readthedocs.org/user_builds/festim-workshop/conda/festim1/lib/python3.11/site-packages/mpmath/libmp/libintmath.py:75: DeprecationWarning: bitcount function is deprecated
  warnings.warn("bitcount function is deprecated",
/home/docs/checkouts/readthedocs.org/user_builds/festim-workshop/conda/festim1/lib/python3.11/site-packages/mpmath/libmp/libintmath.py:75: DeprecationWarning: bitcount function is deprecated
  warnings.warn("bitcount function is deprecated",
/home/docs/checkouts/readthedocs.org/user_builds/festim-workshop/conda/festim1/lib/python3.11/site-packages/mpmath/libmp/libintmath.py:75: DeprecationWarning: bitcount function is deprecated
  warnings.warn("bitcount function is deprecated",
/home/docs/checkouts/readthedocs.org/user_builds/festim-workshop/conda/festim1/lib/python3.11/site-packages/mpmath/libmp/libintmath.py:75: DeprecationWarning: bitcount function is deprecated
  warnings.warn("bitcount function is deprecated",
/home/docs/checkouts/readthedocs.org/user_builds/festim-workshop/conda/festim1/lib/python3.11/site-packages/mpmath/libmp/libintmath.py:75: DeprecationWarning: bitcount function is deprecated
  warnings.warn("bitcount function is deprecated",
/home/docs/checkouts/readthedocs.org/user_builds/festim-workshop/conda/festim1/lib/python3.11/site-packages/mpmath/libmp/libintmath.py:75: DeprecationWarning: bitcount function is deprecated
  warnings.warn("bitcount function is deprecated",
/home/docs/checkouts/readthedocs.org/user_builds/festim-workshop/conda/festim1/lib/python3.11/site-packages/mpmath/libmp/libintmath.py:75: DeprecationWarning: bitcount function is deprecated
  warnings.warn("bitcount function is deprecated",
/home/docs/checkouts/readthedocs.org/user_builds/festim-workshop/conda/festim1/lib/python3.11/site-packages/mpmath/libmp/libintmath.py:75: DeprecationWarning: bitcount function is deprecated
  warnings.warn("bitcount function is deprecated",

In FESTIM, each trap is defined by a Trap object. Relevent arguments for each trap include:

k_0 and E_k are the trapping rate pre-exponential factor in \(\text{m}^{3} \text{s}^{-1}\) and activation energy in \(\text{eV}\), respectively.

p_0 and E_p are the detrapping rate pre-exponential factor in \(\text{s}^{-1}\) and activation energy in \(\text{eV}\), respectively.

materials is a list of the materials in which the trap is located. Here, it’s only tungsten.

In FESTIM, traps are intrinsic by default. However, traps can also be implemented as extrinsic, as shown in the example hereafter corresponding to 2 intrinsic and 1 extrinsic trap.

The time evolution of extrinsic traps density \(n_i\) expressed in \(\text{m}^{-3}\) is defined as:

\[ \begin{equation} \frac{dn_i}{dt} = \varphi_0\:\left[\left(1-\frac{n_i}{n_{a_{max}}}\right)\:\eta_a \:f_a(x)+\left(1-\frac{n_i}{n_{b_{max}}}\right)\:\eta_b \:f_b(x)\right] \end{equation} \]
w_atom_density = 6.3e28  # atom/m3

trap_1 = F.Trap(
        k_0=4.1e-7/(1.1e-10**2*6*w_atom_density),
        E_k=0.39,
        p_0=1e13,
        E_p=0.87,
        density=1.3e-3*w_atom_density,
        materials=tungsten
    )
trap_2 = F.Trap(
        k_0=4.1e-7/(1.1e-10**2*6*w_atom_density),
        E_k=0.39,
        p_0=1e13,
        E_p=1.0,
        density=4e-4*w_atom_density,
        materials=tungsten
    )

center = 4.5e-9
width = 2.5e-9
distribution = 1/(width*(2*sp.pi)**0.5) * sp.exp(-0.5*((F.x-center)/width)**2)
trap_3 = F.ExtrinsicTrap(
        k_0=4.1e-7/(1.1e-10**2*6*w_atom_density),
        E_k=0.39,
        p_0=1e13,
        E_p=1.5,
        phi_0=ion_flux,
        n_amax=1e-01*w_atom_density, f_a=distribution, eta_a=6e-4,
        n_bmax=1e-02*w_atom_density, f_b=sp.Piecewise((1e6, F.x < 1e-6), (0, True)), eta_b=2e-4,
        materials=tungsten
    )

my_model.traps = [trap_1, trap_2, trap_3]

Boundary conditions (BCs) can be of several types in FESTIM, the most simple of them being the DirichletBC where an analytical expression is given in the argument: value. The argument surfaces contains a list of all the surfaces on which the BC is applied. If no BC is applied on a surface, it will be considered as a non flux surface (ie \(\frac{\partial c}{\partial\textbf{n}} = 0\)).

In this case, the solute concentration is set to zero on surfaces 1 and 2 (left and right).

my_model.boundary_conditions = [
    F.DirichletBC(surfaces=[1, 2], value=0, field=0)
]

In this example, the temperature is constant from \(t=0\) to \(t=450 \text{s}\) (implantation + resting phase), then increases from \(t=450 \text{s}\) to \(t=500 \text{s}\) in order to perform the thermo-desorption (TDS phase).

\begin{equation} T(t) = \begin{cases} 300, & \text{if} : t < 450 \ 300 + 8(t - 450), & \text{else} \ \end{cases} \end{equation}

\(T\) is expressed in \(\text{K}\).

implantation_temp = 300  # K
temperature_ramp = 8  # K/s

start_tds = implantation_time + 50  # s

my_model.T = sp.Piecewise(
        (implantation_temp, F.t < start_tds),
        (implantation_temp + temperature_ramp*(F.t-start_tds), True))

The Stepsize object defines the simulation stepsize.

The argument initial_value is the initial stepsize is expressed in \(\text{s}\).

An adaptive stepsize algorithm has been implemented in order to save computational cost. stepsize_change_ratio defines by how much the stepsize is increased or decreased after each iteration (depending on the number of Newton iterations required to converged). dt_min is the lower limit for the stepsize below which the computation will stop.

The optional argument max_stepsize sets the maximum stepsize. It takes a function of time. In this case, we cap the stepsize at 0.5 s after the start of the TDS. We also set milestones in order to make sure the simulation doesn’t over step the end of the implantation and the start of the TDS.

my_model.dt = F.Stepsize(
    initial_value=0.5,
    stepsize_change_ratio=1.1,
    max_stepsize=lambda t: 0.5 if t > start_tds else None,
    dt_min=1e-05,
    milestones=[implantation_time, start_tds],
)
my_model.settings = F.Settings(
    absolute_tolerance=1e10,
    relative_tolerance=1e-09,
    final_time=500
)

We want to plot the evolution of the surface fluxes as a function of time.

To do so, we’ll use ‘derived quantities’ objects. There is a wide range of derived quantities available in FESTIM.

Here, we’ll use TotalVolume (volume integration) and HydrogenFlux.

list_of_derived_quantities = [
        F.TotalVolume("solute", volume=1),
        F.TotalVolume("retention", volume=1),
        F.TotalVolume("1", volume=1),
        F.TotalVolume("2", volume=1),
        F.TotalVolume("3", volume=1),
        F.HydrogenFlux(surface=1),
        F.HydrogenFlux(surface=2)
    ]

derived_quantities = F.DerivedQuantities(
    list_of_derived_quantities,
    # filename="tds/derived_quantities.csv"  # optional set a filename to export the data to csv
    show_units=True,
)


my_model.exports = [derived_quantities]
my_model.initialise()
my_model.run()

Hide code cell output

Calling FFC just-in-time (JIT) compiler, this may take some time.
Defining initial values
Calling FFC just-in-time (JIT) compiler, this may take some time.
Defining variational problem
Defining source terms
Defining boundary conditions
Time stepping...
Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
0.1 %        5.0e-01 s    Elapsed time so far: 2.9 s
Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
0.2 %        9.5e-01 s    Elapsed time so far: 4.4 s
0.3 %        1.4e+00 s    Elapsed time so far: 4.4 s
0.3 %        1.7e+00 s    Elapsed time so far: 4.4 s
0.4 %        2.2e+00 s    Elapsed time so far: 4.4 s
0.5 %        2.6e+00 s    Elapsed time so far: 4.5 s
0.6 %        3.1e+00 s    Elapsed time so far: 4.5 s
0.7 %        3.7e+00 s    Elapsed time so far: 4.5 s
0.8 %        4.3e+00 s    Elapsed time so far: 4.6 s
1.0 %        4.9e+00 s    Elapsed time so far: 4.6 s
1.1 %        5.7e+00 s    Elapsed time so far: 4.6 s
1.3 %        6.5e+00 s    Elapsed time so far: 4.6 s
1.5 %        7.4e+00 s    Elapsed time so far: 4.7 s
1.7 %        8.3e+00 s    Elapsed time so far: 4.7 s
1.9 %        9.4e+00 s    Elapsed time so far: 4.7 s
2.1 %        1.1e+01 s    Elapsed time so far: 4.8 s
2.4 %        1.2e+01 s    Elapsed time so far: 4.8 s
2.6 %        1.3e+01 s    Elapsed time so far: 4.8 s
2.9 %        1.4e+01 s    Elapsed time so far: 4.8 s
3.2 %        1.6e+01 s    Elapsed time so far: 4.9 s
3.5 %        1.7e+01 s    Elapsed time so far: 4.9 s
3.8 %        1.9e+01 s    Elapsed time so far: 4.9 s
4.1 %        2.1e+01 s    Elapsed time so far: 5.0 s
4.5 %        2.2e+01 s    Elapsed time so far: 5.0 s
4.8 %        2.4e+01 s    Elapsed time so far: 5.0 s
5.3 %        2.6e+01 s    Elapsed time so far: 5.1 s
5.7 %        2.8e+01 s    Elapsed time so far: 5.1 s
6.1 %        3.0e+01 s    Elapsed time so far: 5.1 s
6.5 %        3.3e+01 s    Elapsed time so far: 5.1 s
7.0 %        3.5e+01 s    Elapsed time so far: 5.2 s
7.4 %        3.7e+01 s    Elapsed time so far: 5.2 s
7.9 %        4.0e+01 s    Elapsed time so far: 5.2 s
8.4 %        4.2e+01 s    Elapsed time so far: 5.3 s
8.9 %        4.4e+01 s    Elapsed time so far: 5.3 s
9.4 %        4.7e+01 s    Elapsed time so far: 5.3 s
9.9 %        5.0e+01 s    Elapsed time so far: 5.4 s
10.5 %        5.2e+01 s    Elapsed time so far: 5.4 s
11.1 %        5.6e+01 s    Elapsed time so far: 5.4 s
11.7 %        5.8e+01 s    Elapsed time so far: 5.4 s
12.3 %        6.1e+01 s    Elapsed time so far: 5.5 s
12.9 %        6.5e+01 s    Elapsed time so far: 5.5 s
13.6 %        6.8e+01 s    Elapsed time so far: 5.5 s
14.2 %        7.1e+01 s    Elapsed time so far: 5.6 s
15.0 %        7.5e+01 s    Elapsed time so far: 5.6 s
15.6 %        7.8e+01 s    Elapsed time so far: 5.6 s
16.4 %        8.2e+01 s    Elapsed time so far: 5.7 s
17.2 %        8.6e+01 s    Elapsed time so far: 5.7 s
17.9 %        9.0e+01 s    Elapsed time so far: 5.7 s
18.8 %        9.4e+01 s    Elapsed time so far: 5.7 s
19.5 %        9.7e+01 s    Elapsed time so far: 5.8 s
20.3 %        1.0e+02 s    Elapsed time so far: 5.8 s
21.2 %        1.1e+02 s    Elapsed time so far: 5.8 s
22.0 %        1.1e+02 s    Elapsed time so far: 5.9 s
22.9 %        1.1e+02 s    Elapsed time so far: 5.9 s
23.9 %        1.2e+02 s    Elapsed time so far: 5.9 s
24.8 %        1.2e+02 s    Elapsed time so far: 6.0 s
25.8 %        1.3e+02 s    Elapsed time so far: 6.0 s
26.7 %        1.3e+02 s    Elapsed time so far: 6.0 s
27.7 %        1.4e+02 s    Elapsed time so far: 6.0 s
28.7 %        1.4e+02 s    Elapsed time so far: 6.1 s
29.7 %        1.5e+02 s    Elapsed time so far: 6.1 s
30.8 %        1.5e+02 s    Elapsed time so far: 6.1 s
31.8 %        1.6e+02 s    Elapsed time so far: 6.2 s
32.9 %        1.6e+02 s    Elapsed time so far: 6.2 s
34.1 %        1.7e+02 s    Elapsed time so far: 6.2 s
35.1 %        1.8e+02 s    Elapsed time so far: 6.2 s
36.3 %        1.8e+02 s    Elapsed time so far: 6.3 s
37.4 %        1.9e+02 s    Elapsed time so far: 6.3 s
38.6 %        1.9e+02 s    Elapsed time so far: 6.3 s
39.9 %        2.0e+02 s    Elapsed time so far: 6.4 s
41.1 %        2.1e+02 s    Elapsed time so far: 6.4 s
42.4 %        2.1e+02 s    Elapsed time so far: 6.4 s
43.6 %        2.2e+02 s    Elapsed time so far: 6.5 s
44.9 %        2.2e+02 s    Elapsed time so far: 6.5 s
46.4 %        2.3e+02 s    Elapsed time so far: 6.5 s
47.7 %        2.4e+02 s    Elapsed time so far: 6.5 s
49.1 %        2.5e+02 s    Elapsed time so far: 6.6 s
50.4 %        2.5e+02 s    Elapsed time so far: 6.6 s
51.9 %        2.6e+02 s    Elapsed time so far: 6.6 s
53.5 %        2.7e+02 s    Elapsed time so far: 6.7 s
54.9 %        2.7e+02 s    Elapsed time so far: 6.7 s
56.5 %        2.8e+02 s    Elapsed time so far: 6.7 s
57.9 %        2.9e+02 s    Elapsed time so far: 6.8 s
59.5 %        3.0e+02 s    Elapsed time so far: 6.8 s
61.0 %        3.0e+02 s    Elapsed time so far: 6.8 s
62.5 %        3.1e+02 s    Elapsed time so far: 6.9 s
64.3 %        3.2e+02 s    Elapsed time so far: 6.9 s
65.9 %        3.3e+02 s    Elapsed time so far: 6.9 s
67.6 %        3.4e+02 s    Elapsed time so far: 6.9 s
69.2 %        3.5e+02 s    Elapsed time so far: 7.0 s
71.0 %        3.5e+02 s    Elapsed time so far: 7.0 s
72.9 %        3.6e+02 s    Elapsed time so far: 7.0 s
74.6 %        3.7e+02 s    Elapsed time so far: 7.1 s
76.5 %        3.8e+02 s    Elapsed time so far: 7.1 s
78.3 %        3.9e+02 s    Elapsed time so far: 7.1 s
80.0 %        4.0e+02 s    Elapsed time so far: 7.1 s
81.9 %        4.1e+02 s    Elapsed time so far: 7.2 s
83.6 %        4.2e+02 s    Elapsed time so far: 7.2 s
85.5 %        4.3e+02 s    Elapsed time so far: 7.2 s
87.5 %        4.4e+02 s    Elapsed time so far: 7.3 s
89.8 %        4.5e+02 s    Elapsed time so far: 7.3 s
90.0 %        4.5e+02 s    Elapsed time so far: 7.3 s
90.2 %        4.5e+02 s    Elapsed time so far: 7.3 s
90.3 %        4.5e+02 s    Elapsed time so far: 7.4 s
90.4 %        4.5e+02 s    Elapsed time so far: 7.4 s
90.5 %        4.5e+02 s    Elapsed time so far: 7.4 s
90.6 %        4.5e+02 s    Elapsed time so far: 7.4 s
90.7 %        4.5e+02 s    Elapsed time so far: 7.5 s
90.8 %        4.5e+02 s    Elapsed time so far: 7.5 s
90.9 %        4.5e+02 s    Elapsed time so far: 7.5 s
91.0 %        4.6e+02 s    Elapsed time so far: 7.5 s
91.1 %        4.6e+02 s    Elapsed time so far: 7.6 s
91.2 %        4.6e+02 s    Elapsed time so far: 7.6 s
91.3 %        4.6e+02 s    Elapsed time so far: 7.6 s
91.4 %        4.6e+02 s    Elapsed time so far: 7.6 s
91.5 %        4.6e+02 s    Elapsed time so far: 7.7 s
91.6 %        4.6e+02 s    Elapsed time so far: 7.7 s
91.7 %        4.6e+02 s    Elapsed time so far: 7.7 s
91.8 %        4.6e+02 s    Elapsed time so far: 7.8 s
91.9 %        4.6e+02 s    Elapsed time so far: 7.8 s
92.0 %        4.6e+02 s    Elapsed time so far: 7.8 s
92.1 %        4.6e+02 s    Elapsed time so far: 7.8 s
92.2 %        4.6e+02 s    Elapsed time so far: 7.9 s
92.3 %        4.6e+02 s    Elapsed time so far: 7.9 s
92.4 %        4.6e+02 s    Elapsed time so far: 7.9 s
92.5 %        4.6e+02 s    Elapsed time so far: 8.0 s
92.6 %        4.6e+02 s    Elapsed time so far: 8.0 s
92.7 %        4.6e+02 s    Elapsed time so far: 8.0 s
92.8 %        4.6e+02 s    Elapsed time so far: 8.0 s
92.9 %        4.6e+02 s    Elapsed time so far: 8.1 s
93.0 %        4.7e+02 s    Elapsed time so far: 8.1 s
93.1 %        4.7e+02 s    Elapsed time so far: 8.1 s
93.2 %        4.7e+02 s    Elapsed time so far: 8.2 s
93.3 %        4.7e+02 s    Elapsed time so far: 8.2 s
93.4 %        4.7e+02 s    Elapsed time so far: 8.2 s
93.5 %        4.7e+02 s    Elapsed time so far: 8.2 s
93.6 %        4.7e+02 s    Elapsed time so far: 8.3 s
93.7 %        4.7e+02 s    Elapsed time so far: 8.3 s
93.8 %        4.7e+02 s    Elapsed time so far: 8.3 s
93.9 %        4.7e+02 s    Elapsed time so far: 8.3 s
94.0 %        4.7e+02 s    Elapsed time so far: 8.4 s
94.1 %        4.7e+02 s    Elapsed time so far: 8.4 s
94.2 %        4.7e+02 s    Elapsed time so far: 8.4 s
94.3 %        4.7e+02 s    Elapsed time so far: 8.4 s
94.4 %        4.7e+02 s    Elapsed time so far: 8.5 s
94.5 %        4.7e+02 s    Elapsed time so far: 8.5 s
94.6 %        4.7e+02 s    Elapsed time so far: 8.5 s
94.7 %        4.7e+02 s    Elapsed time so far: 8.5 s
94.8 %        4.7e+02 s    Elapsed time so far: 8.6 s
94.9 %        4.7e+02 s    Elapsed time so far: 8.6 s
95.0 %        4.8e+02 s    Elapsed time so far: 8.6 s
95.1 %        4.8e+02 s    Elapsed time so far: 8.6 s
95.2 %        4.8e+02 s    Elapsed time so far: 8.7 s
95.3 %        4.8e+02 s    Elapsed time so far: 8.7 s
95.4 %        4.8e+02 s    Elapsed time so far: 8.7 s
95.5 %        4.8e+02 s    Elapsed time so far: 8.7 s
95.6 %        4.8e+02 s    Elapsed time so far: 8.8 s
95.7 %        4.8e+02 s    Elapsed time so far: 8.8 s
95.8 %        4.8e+02 s    Elapsed time so far: 8.8 s
95.9 %        4.8e+02 s    Elapsed time so far: 8.8 s
96.0 %        4.8e+02 s    Elapsed time so far: 8.9 s
96.1 %        4.8e+02 s    Elapsed time so far: 8.9 s
96.2 %        4.8e+02 s    Elapsed time so far: 8.9 s
96.3 %        4.8e+02 s    Elapsed time so far: 8.9 s
96.4 %        4.8e+02 s    Elapsed time so far: 9.0 s
96.5 %        4.8e+02 s    Elapsed time so far: 9.0 s
96.6 %        4.8e+02 s    Elapsed time so far: 9.0 s
96.7 %        4.8e+02 s    Elapsed time so far: 9.0 s
96.8 %        4.8e+02 s    Elapsed time so far: 9.1 s
96.9 %        4.8e+02 s    Elapsed time so far: 9.1 s
97.0 %        4.9e+02 s    Elapsed time so far: 9.1 s
97.1 %        4.9e+02 s    Elapsed time so far: 9.1 s
97.2 %        4.9e+02 s    Elapsed time so far: 9.1 s
97.3 %        4.9e+02 s    Elapsed time so far: 9.2 s
97.4 %        4.9e+02 s    Elapsed time so far: 9.2 s
97.5 %        4.9e+02 s    Elapsed time so far: 9.2 s
97.6 %        4.9e+02 s    Elapsed time so far: 9.2 s
97.7 %        4.9e+02 s    Elapsed time so far: 9.3 s
97.8 %        4.9e+02 s    Elapsed time so far: 9.3 s
97.9 %        4.9e+02 s    Elapsed time so far: 9.3 s
98.0 %        4.9e+02 s    Elapsed time so far: 9.3 s
98.1 %        4.9e+02 s    Elapsed time so far: 9.4 s
98.2 %        4.9e+02 s    Elapsed time so far: 9.4 s
98.3 %        4.9e+02 s    Elapsed time so far: 9.4 s
98.4 %        4.9e+02 s    Elapsed time so far: 9.4 s
98.5 %        4.9e+02 s    Elapsed time so far: 9.5 s
98.6 %        4.9e+02 s    Elapsed time so far: 9.5 s
98.7 %        4.9e+02 s    Elapsed time so far: 9.5 s
98.8 %        4.9e+02 s    Elapsed time so far: 9.5 s
98.9 %        4.9e+02 s    Elapsed time so far: 9.6 s
99.0 %        5.0e+02 s    Elapsed time so far: 9.6 s
99.1 %        5.0e+02 s    Elapsed time so far: 9.6 s
99.2 %        5.0e+02 s    Elapsed time so far: 9.6 s
99.3 %        5.0e+02 s    Elapsed time so far: 9.7 s
99.4 %        5.0e+02 s    Elapsed time so far: 9.7 s
99.5 %        5.0e+02 s    Elapsed time so far: 9.7 s
99.6 %        5.0e+02 s    Elapsed time so far: 9.7 s
99.7 %        5.0e+02 s    Elapsed time so far: 9.8 s
99.8 %        5.0e+02 s    Elapsed time so far: 9.8 s
99.9 %        5.0e+02 s    Elapsed time so far: 9.8 s
100.0 %        5.0e+02 s    Elapsed time so far: 9.8 s
t = derived_quantities.t
flux_left = derived_quantities.filter(fields="solute", surfaces=1).data
flux_right = derived_quantities.filter(fields="solute", surfaces=2).data

flux_total = -np.array(flux_left) - np.array(flux_right)
import matplotlib.pyplot as plt
plt.plot(t, flux_total, linewidth=3)

plt.ylabel(r"Desorption flux (m$^{-2}$ s$^{-1}$)")
plt.xlabel(r"Time (s)")
plt.show()
../_images/6e0c0e9cac7ce49ccc48e7d364da2e8172f3e2289819077a05b80210c04d0009.png

Make use of numpy to compute the time derivative of the traps inventories!

trap_1 = derived_quantities.filter(fields="1").data
trap_2 = derived_quantities.filter(fields="2").data
trap_3 = derived_quantities.filter(fields="3").data

contribution_trap_1 = -np.diff(trap_1)/np.diff(t)
contribution_trap_2 = -np.diff(trap_2)/np.diff(t)
contribution_trap_3 = -np.diff(trap_3)/np.diff(t)

We can now plot the TDS spectrum with the 3 traps contributions

plt.plot(t, flux_total, linewidth=3)
plt.plot(t[1:], contribution_trap_1, linestyle="--", color="grey")
plt.fill_between(t[1:], 0, contribution_trap_1, facecolor='grey', alpha=0.1)
plt.plot(t[1:], contribution_trap_2, linestyle="--", color="grey")
plt.fill_between(t[1:], 0, contribution_trap_2, facecolor='grey', alpha=0.1)
plt.plot(t[1:], contribution_trap_3, linestyle="--", color="grey")
plt.fill_between(t[1:], 0, contribution_trap_3, facecolor='grey', alpha=0.1)

plt.xlim(450, 500)
plt.ylim(bottom=-1.25e18, top=0.6e19)
plt.ylabel(r"Desorption flux (m$^{-2}$ s$^{-1}$)")
plt.xlabel(r"Time (s)")

plt.ylabel(r"Desorption flux (m$^{-2}$ s$^{-1}$)")
plt.xlabel(r"Time (s)")
plt.show()
../_images/7be7a180e41dd7155510d537bd38d0c2c43617239ee13457b7c309c635b6076d.png

Task#

  1. Increase the implantation temperature to 500 K and see how the TDS spectrum is affected

  2. Vary the detrapping energy of the first trap

  3. At the end of the implantation phase, what is the proportion of hydrogen trapped in trap 2?

Hide code cell content

t = derived_quantities.t
trap_1 = derived_quantities.filter(fields="1").data
trap_2 = derived_quantities.filter(fields="2").data
trap_3 = derived_quantities.filter(fields="3").data
mobile = derived_quantities.filter(fields="solute", instances=F.TotalVolume).data
total = derived_quantities.filter(fields="retention").data

plt.stackplot(t, trap_1, trap_2, trap_3, mobile)
[<matplotlib.collections.FillBetweenPolyCollection at 0x71c1dc502a10>,
 <matplotlib.collections.FillBetweenPolyCollection at 0x71c1dc307150>,
 <matplotlib.collections.FillBetweenPolyCollection at 0x71c1dc314390>,
 <matplotlib.collections.FillBetweenPolyCollection at 0x71c1dc2c67d0>]
../_images/3e88b4a9e3835548180b8c41a2b5dc907111726d1e1a2110187acb0644086498.png