Skip to content

Commit

Permalink
upd DWO case
Browse files Browse the repository at this point in the history
  • Loading branch information
KulaginVladimir committed May 8, 2024
1 parent eb2080e commit b50e7fd
Show file tree
Hide file tree
Showing 11 changed files with 3,202 additions and 3,302 deletions.
Binary file added Validation/DWO/Comparison.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
207 changes: 207 additions & 0 deletions Validation/DWO/D_in_WO.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
import festim as F
import fenics as f
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import sympy as sp
import warnings
global n_surf

warnings.filterwarnings("ignore")

################### PARAMETERS ###################
N_A_const = 6.022e23 # Avogadro, mol^-1
e = 1.602e-19
M_D2 = 4.028e-3 / N_A_const # the H2 mass, kg mol^-1

# Exposure conditions
P_D2 = 2e-5 # Pa
T0 = 300 # K
ramp = 5 # K/s
t_imp = 3000 # exposure duration, s
t_storage = 3600 # storage time, s
t_TDS = 100 # s
L = 2e-3 / 2 # half thickness, m

# W properties
rho_W = 6.3382e28 # W atomic concentration, m^-3
n_IS = 6 * rho_W # concentration of interstitial sites, m^-3
n_surf = 1.416e19 # concentration of adsorption sites, m^-2

nu0 = 1e13 # attempt frequency, s^-1

D0 = 1.9e-7 / np.sqrt(2) # diffusivity pre-factor, m^2 s^-1
E_diff = 0.2 # diffusion activation energy, eV

# Transitions
E_bs = E_diff # energy barrier from bulk to surface, eV
E_diss = 0 # energy barrier for D2 dissociation, eV
Q_sol = 1 # heat of solution, eV

# Fitting parameters
fits = {
"E0": [1.142, 1.111, 1.066],
"dE": [0.346, 0.289, 0.234],
"theta_D0": [0.253, 0.113, 0.161],
"dtheta_D": [0.180, 0.082, 0.057],
"alpha": [0.303, 0.460, 0.437],
"beta": [8.902, 7.240, 4.144]
}
################### FUNCTIONS ###################



################### MODEL ###################
colors = ["tab:blue", "tab:red", "tab:green"]
names = ["000O", "050O", "075O"]
labels = ["Clean", "0.5ML of O", "0.75ML of O"]
n_surfs = [n_surf, n_surf*(1-0.5), n_surf*(1-0.75)]
for i in range(3):
n_surf = n_surfs[i]
lamda_des = 1 / np.sqrt(n_surf) # average distance between adsorption sites, m
lambda_abs = n_surf / n_IS # distance between subsurface IS and adsorption sites, m

def E_des(surf_conc):
theta_D = surf_conc / n_surf
theta_D0 = fits["theta_D0"][i] #0.253
del_theta_D = fits["dtheta_D"][i] #0.180
E0 = fits["E0"][i] #1.142
dE = fits["dE"][i] #0.346
alpha = fits['alpha'][i] #0.303
beta = fits['beta'][i] #8.902

E_FD = E0 + dE / (1 + f.exp((theta_D - theta_D0) / del_theta_D))
E_des = E_FD * (1 - alpha * f.exp(-beta * (1 - theta_D)))
return E_des

def S0(T):
# the capturing coefficient
return f.exp(-E_diss / F.k_B / T)


def E_sb(surf_conc):
# energy barrier from surface to bulk, eV
return (E_des(surf_conc) - E_diss) / 2 + E_bs + Q_sol


def J_vs(surf_conc, T, t):
J_ads = (
2
* S0(T)
* (1 - surf_conc / n_surf) ** 2
* f.conditional(t <= t_imp, 1.52e18, 0)
)

J_des = (
2 * nu0 * (lamda_des * surf_conc) ** 2 * f.exp(-E_des(surf_conc) / F.k_B / T)
)
return J_ads - J_des

W_model = F.Simulation(log_level=40)

# Mesh
vertices = np.linspace(0, L, num=500)
W_model.mesh = F.MeshFromVertices(np.sort(vertices))

# Materials
tungsten = F.Material(id=1, D_0=D0, E_D=E_diff)
W_model.materials = tungsten

surf_conc = F.SurfaceConcentration(
k_sb=nu0,
E_sb=E_sb,
k_bs=nu0,
E_bs=E_bs,
l_abs=lambda_abs,
N_s=n_surf,
N_b=n_IS,
J_vs=J_vs,
surfaces=1,
initial_condition=F.InitialCondition(field="adsorbed", value=0),
t=F.t,
)

W_model.surface_concentrations = [surf_conc]

traps = F.Traps(
[
F.Trap(
k_0=nu0 / n_IS,
E_k=E_diff,
p_0=nu0,
E_p=0.912,
density=7.7e-6,
materials=tungsten,
),
F.Trap(
k_0=nu0 / n_IS,
E_k=E_diff,
p_0=nu0,
E_p=1.176,
density=7.9e-7,
materials=tungsten,
),
]
)
W_model.traps = traps

W_model.T = F.Temperature(
value=sp.Piecewise(
(T0, F.t < t_imp + t_storage), (T0 + ramp * (F.t - t_imp - t_storage), True)
)
)

W_model.dt = F.Stepsize(
initial_value=1e-7,
stepsize_change_ratio=1.25,
max_stepsize=lambda t: 10 if t < t_imp + t_storage-10 else 0.5,
dt_min=1e-9,
)

W_model.settings = F.Settings(
absolute_tolerance=1e8,
relative_tolerance=1e-7,
maximum_iterations=50,
final_time=t_imp + t_storage + t_TDS,
)

# Exports
results_folder = "./results/"

derived_quantities = F.DerivedQuantities(
[F.AdsorbedHydrogen(surface=1), F.TotalSurface(field="T", surface=1)],
nb_iterations_between_compute=1,
filename=results_folder + names[i] + ".csv",
)

W_model.exports = [derived_quantities]

W_model.initialise()
W_model.run()

results = pd.read_csv(results_folder + names[i] + ".csv", header=0)
results["Flux"] = results["Concentration of adsorbed H on surface 1"]
for j in range(len(results)):
surf_conc = results["Concentration of adsorbed H on surface 1"][j]
T = results["Total T surface 1"][j]
results["Flux"][j] = (
2 * nu0 * (lamda_des * surf_conc) ** 2 * np.exp(-E_des(surf_conc) / F.k_B / T)
)


plt.plot(
results["Total T surface 1"][results["t(s)"] >= t_imp + t_storage],
results["Flux"][results["t(s)"] >= t_imp + t_storage],
linewidth=3,
label='FESTIM: '+labels[i],
)

exp = pd.read_csv(f"./exp_data/"+names[i]+".csv", header=None, skiprows=1, sep=",")
plt.scatter(exp[0], exp[1], marker="x", s=75, linewidths=1.2, label = "exp. "+labels[i])

plt.ylabel(r"Desorption flux (m$^{-2}$ s$^{-1}$)")
plt.xlabel(r"Temperature (K)")
plt.legend()
plt.xlim(300, 800)
plt.savefig("Comparison.png")
plt.show()
File renamed without changes.
67 changes: 67 additions & 0 deletions Validation/DWO/exp_data/050O.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
x, y
307.1428843906948, -6060629413513603
322.32142857142856, 0
315.17861230032787, -3030256908311076.5
329.4643129621233, 3030372505202311
340.1785714285714, 18181888240540164
340.1785714285714, 18181888240540164
349.99998637608115, 54545433527838020
346.42861230032787, 42424290297702480
359.8214694431849, 90909094412026900
362.5, 93939466917229420
362.5, 93939466917229420
369.64288439069475, 136363641618040450
375.0000136239188, 160606043675202750
380.35714285714283, 203030333972905250
384.82142857142856, 227272736030067550
391.071469443185, 233333365443580930
394.6428435189383, 281818169557905570
404.46432658604215, 309090944120269950
402.67857142857144, 312121201028581060
414.2857415335519, 269697026327770020
418.75002724783764, 224242479121756480
424.9999999999999, 184848561329256320
429.4642857142857, 151515157353378300
434.82141494750977, 124242498387904910
444.64289801461354, 112121239560878130
451.78571428571433, 93939466917229420
457.1428435189383, 78787951181891570
463.3928843906947, 78787951181891570
474.9999863760812, 69696949263175870
483.0357142857142, 54545433527838020
495.535727909633, 45454547206013550
505.3571428571428, 45454547206013550
511.6071837288992, 33333403975878012
518.75, 42424290297702480
526.785727909633, 27272774562364624
534.8214558192662, 33333403975878012
546.4285578046525, 24242402057162316
553.5714421953473, 33333403975878012
568.7499863760811, 12121258827026774
568.7499863760811, 12121258827026774
577.6785578046527, 12121258827026774
588.3928843906947, 6060629413513387
598.2142993382045, 3030372505202311
605.3571837288991, 3030372505202311
611.6071564810616, 18181888240540164
619.6428843906947, 9090886321824464
619.6428843906947, 9090886321824464
626.7857006617953, -3030256908311076.5
634.8214285714286, 6060629413513387
647.3214421953473, 0
647.3214421953473, 0
656.2500136239188, -9090886321824678
663.3928980146135, 9090886321824464
672.3214694431849, -3030256908311076.5
688.3928571428571, -3030256908311076.5
696.4285850524902, 12121258827026774
704.4643129621232, 6060629413513387
713.3928843906947, 0
721.4286123003278, 0
727.6785850524901, 0
744.6428843906947, 3030372505202311
744.6428843906947, 3030372505202311
755.3571428571429, -3030256908311076.5
764.2857142857142, 3030372505202311
781.2500136239188, 12121258827026774
791.9642720903668, 0
67 changes: 67 additions & 0 deletions Validation/DWO/exp_data/075O.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
x, y
310.7143265860421, 3030256324497606
325.89287076677596, 6060743842733139
325.89287076677596, 6060743842733139
337.5000408717564, 3030256324497606
336.60712923322404, 21212256658957804
341.07141494750977, 24242512983454980
346.42861230032787, 21212256658957804
351.78574153355186, 24242512983454980
354.46427209036693, 27272769307952584
354.46427209036693, 27272769307952584
361.6071564810616, 51515282291407570
361.6071564810616, 51515282291407570
369.64288439069475, 45454538448674856
379.4642993382045, 78787820405621800
384.82142857142856, 72727307756627000
384.82142857142856, 72727307756627000
391.071469443185, 72727307756627000
398.2142857142857, 63636307589396696
405.3571701049804, 51515282291407570
416.07142857142856, 39394025799680070
416.07142857142856, 39394025799680070
429.4642857142857, 48484794773172030
429.4642857142857, 48484794773172030
434.82141494750977, 33333281956946936
443.7499863760811, 18181769140722270
443.7499863760811, 18181769140722270
456.25, 18181769140722270
460.71428571428567, 39394025799680070
470.53570066179554, 21212256658957804
478.57142857142856, 33333281956946936
484.8214694431849, 18181769140722270
495.535727909633, 21212256658957804
503.57145581926613, 12121256491727920
516.0714694431849, 15151512816225096
516.0714694431849, 15151512816225096
525.0000408717564, 18181769140722270
535.7142993382045, 12121256491727920
545.5357142857142, 24242512983454980
553.5714421953473, 9091000167230314
562.5000136239188, 12121256491727920
571.4285850524902, 9091000167230314
585.7142857142857, 9091000167230314
593.7500136239187, 15151512816225096
600.8928980146136, 9091000167230314
609.8214694431849, 0
618.7500408717565, 9091000167230314
625.0000136239187, 9091000167230314
632.1428980146135, 3030256324497606
638.3928707667759, 0
648.2142857142856, 0
657.1428571428571, 0
669.6428707667759, 3030256324497606
669.6428707667759, 3030256324497606
677.6785986764089, 3030256324497606
694.6428980146134, -15151512816224666
698.2142720903669, 9091000167230314
705.3571564810616, -15151512816224666
714.2857279096329, 3030256324497606
721.4286123003278, -15151512816224666
729.4642720903669, 0
744.6428843906947, -3030256324497175.5
754.4642993382045, 3030256324497606
761.6071837288991, -3030256324497175.5
767.8571564810616, 6060743842733139
776.7857279096331, 3030256324497606
783.0357006617953, -6060512648994781
Loading

0 comments on commit b50e7fd

Please sign in to comment.