Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase code readability #32

Merged
merged 4 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 16 additions & 19 deletions D_EUROFER/D_EUROFER.ipynb

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions D_EUROFER/reference_data/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Description of files

- **143hplasma.json** - TESSIM simulation data and experimental TDS data for the case of 143 h exposure of Eurofer without damaged-induced traps
- **DPA+48hplasma.json** - TESSIM simulation data and experimental TDS data for the case of 48 h exposure of Eurofer with damaged-induced traps
- **DPA+143hplasma.json** - TESSIM simulation data and experimental TDS data for the case of 143 h exposure of Eurofer with damaged-induced traps
- **DPA+D+48hplasma.json** - TESSIM simulation data and experimental TDS data for the case of 48 h exposure of Eurofer with damaged-induced traps. Damaging was performed with already D-loaded sample.
- **143hplasma.json** - TESSIM-X simulation data and experimental TDS data for the case of 143 h exposure of Eurofer without damaged-induced traps
- **DPA+48hplasma.json** - TESSIM-X simulation data and experimental TDS data for the case of 48 h exposure of Eurofer with damaged-induced traps
- **DPA+143hplasma.json** - TESSIM-X simulation data and experimental TDS data for the case of 143 h exposure of Eurofer with damaged-induced traps
- **DPA+D+48hplasma.json** - TESSIM-X simulation data and experimental TDS data for the case of 48 h exposure of Eurofer with damaged-induced traps. Damaging was performed with already D-loaded sample.
210 changes: 108 additions & 102 deletions D_WO/D_WO.ipynb

Large diffs are not rendered by default.

74 changes: 33 additions & 41 deletions D_damagedW/D_damagedW.ipynb

Large diffs are not rendered by default.

153 changes: 88 additions & 65 deletions H_Ti/H_Ti.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,53 +24,15 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Defining initial values\n",
"Defining variational problem\n",
"Defining source terms\n",
"Defining boundary conditions\n",
"Time stepping...\n",
"Calling FFC just-in-time (JIT) compiler, this may take some time.\n",
"Calling FFC just-in-time (JIT) compiler, this may take some time.\n",
"100.0 % 1.5e+03 s Elapsed time so far: 8.5 s\n",
"Defining initial values\n",
"Defining variational problem\n",
"Defining source terms\n",
"Defining boundary conditions\n",
"Time stepping...\n",
"100.0 % 1.5e+03 s Elapsed time so far: 6.0 s\n",
"Defining initial values\n",
"Defining variational problem\n",
"Defining source terms\n",
"Defining boundary conditions\n",
"Time stepping...\n",
"100.0 % 1.5e+03 s Elapsed time so far: 5.2 s\n",
"Defining initial values\n",
"Defining variational problem\n",
"Defining source terms\n",
"Defining boundary conditions\n",
"Time stepping...\n",
"100.0 % 1.5e+03 s Elapsed time so far: 5.2 s\n",
"Defining initial values\n",
"Defining variational problem\n",
"Defining source terms\n",
"Defining boundary conditions\n",
"Time stepping...\n",
"100.0 % 1.5e+03 s Elapsed time so far: 4.9 s\n"
]
}
],
"outputs": [],
"source": [
"import festim as F\n",
"import fenics as f\n",
"import numpy as np\n",
"import h_transport_materials as htm\n",
"import matplotlib.pyplot as plt\n",
"\n",
"################### PARAMETERS ###################\n",
"N_A_const = 6.022e23 # Avogadro, mol^-1\n",
Expand All @@ -83,7 +45,7 @@
"V = A * L # Ti volume (1cm x 1.3cm x 1mm), m^-3\n",
"\n",
"# Ti properties\n",
"X_max = 3\n",
"X_max = 3 # maximum number of H atoms per a Ti atom in the bulk\n",
"n_b = 9.4e4 * N_A_const # the number of atomic sites per unit of volume of Ti, m^-3\n",
"n_surf = (\n",
" X_max * 2.16e-5 * N_A_const\n",
Expand All @@ -98,7 +60,7 @@
"E_diff = D.act_energy.magnitude # diffusion activation energy, eV\n",
"\n",
"E_des = F.kJmol_to_eV(1.17e5 / 1e3) # activateion energy for desorption, eV\n",
"k_des = 1.08e8 * N_A_const # frequency factor for the surface desorption\n",
"k_des = 1.08e8 * N_A_const / n_surf**2 # desorption rate, m^2 s^-1\n",
"\n",
"E_sb = F.kJmol_to_eV(\n",
" 1.18e2\n",
Expand All @@ -114,14 +76,6 @@
"V_ch = 2.95e-3 # the chamber volume, m^3\n",
"P0 = 1.3e4 # the initial pressure, Pa\n",
"\n",
"T_list = [\n",
" 450 + 273,\n",
" 500 + 273,\n",
" 550 + 273,\n",
" 600 + 273,\n",
" 650 + 273,\n",
"] # reference data is given in deg C\n",
"\n",
"\n",
"################### FUNCTIONS ###################\n",
"def S0(T):\n",
Expand All @@ -143,7 +97,7 @@
" * P_H2(T, X)\n",
" / (2 * np.pi * M_H2 * F.k_B * T * e) ** 0.5\n",
" )\n",
" J_des = 2 * k_des * (surf_conc / n_surf) ** 2 * f.exp(-E_des / F.k_B / T)\n",
" J_des = 2 * k_des * surf_conc**2 * f.exp(-E_des / F.k_B / T)\n",
" return J_ads - J_des\n",
"\n",
"\n",
Expand All @@ -168,10 +122,22 @@
" X = 2 * (f.assemble(self.mobile.solution * self.mesh.dx) + surf) * A\n",
"\n",
" # Normalised content parameter\n",
" self.h_transport_problem.boundary_conditions[0].prms[\"X\"].assign(X)\n",
"\n",
"\n",
"################### MODEL ###################\n",
" self.h_transport_problem.boundary_conditions[0].prms[\"X\"].assign(X)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can now define a function that will run a FESTIM model for different cases:"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"def run_sim(T0):\n",
" Ti_model_impl = CustomSimulation()\n",
"\n",
Expand Down Expand Up @@ -223,8 +189,68 @@
" Ti_model_impl.initialise()\n",
" Ti_model_impl.run()\n",
"\n",
" return derived_quantities\n",
"\n",
" return derived_quantities"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We now run the FESTIM model for the five cases with different material temperatures:"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Defining initial values\n",
"Defining variational problem\n",
"Defining source terms\n",
"Defining boundary conditions\n",
"Time stepping...\n",
"Calling FFC just-in-time (JIT) compiler, this may take some time.\n",
"Calling FFC just-in-time (JIT) compiler, this may take some time.\n",
"100.0 % 1.5e+03 s Elapsed time so far: 8.0 s\n",
"Defining initial values\n",
"Defining variational problem\n",
"Defining source terms\n",
"Defining boundary conditions\n",
"Time stepping...\n",
"100.0 % 1.5e+03 s Elapsed time so far: 5.8 s\n",
"Defining initial values\n",
"Defining variational problem\n",
"Defining source terms\n",
"Defining boundary conditions\n",
"Time stepping...\n",
"100.0 % 1.5e+03 s Elapsed time so far: 5.2 s\n",
"Defining initial values\n",
"Defining variational problem\n",
"Defining source terms\n",
"Defining boundary conditions\n",
"Time stepping...\n",
"100.0 % 1.5e+03 s Elapsed time so far: 5.3 s\n",
"Defining initial values\n",
"Defining variational problem\n",
"Defining source terms\n",
"Defining boundary conditions\n",
"Time stepping...\n",
"100.0 % 1.5e+03 s Elapsed time so far: 5.4 s\n"
]
}
],
"source": [
"T_list = [\n",
" 450 + 273,\n",
" 500 + 273,\n",
" 550 + 273,\n",
" 600 + 273,\n",
" 650 + 273,\n",
"] # reference data is given in deg C\n",
"\n",
"results = {}\n",
"for T0 in T_list:\n",
Expand All @@ -247,7 +273,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 11,
"metadata": {},
"outputs": [
{
Expand All @@ -262,9 +288,6 @@
}
],
"source": [
"import matplotlib.pyplot as plt\n",
"\n",
"\n",
"def plot_inventory(T0, FESTIM_data):\n",
" retention = np.array(FESTIM_data[1].data) + np.array(\n",
" FESTIM_data[0].data\n",
Expand Down Expand Up @@ -315,7 +338,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 12,
"metadata": {},
"outputs": [
{
Expand All @@ -338,7 +361,6 @@
}
],
"source": [
"import matplotlib.pyplot as plt\n",
"from pypalettes import load_cmap\n",
"\n",
"cmap = load_cmap(\"Sunset2\")\n",
Expand All @@ -354,6 +376,8 @@
" ),\n",
" \"font.size\": 8,\n",
" \"font.family\": \"Times New Roman\",\n",
" \"axes.spines.right\": False,\n",
" \"axes.spines.top\": False,\n",
"}\n",
"plt.rcParams.update(params)\n",
"\n",
Expand Down Expand Up @@ -386,7 +410,6 @@
" va=\"center\",\n",
" color=cmap(i),\n",
" )\n",
" axis.spines[[\"right\", \"top\"]].set_visible(False)\n",
"\n",
"(dummy_line,) = axs[0].plot([-1], [-1], color=\"black\", lw=1.5, label=\"FESTIM\")\n",
"dummy_dot = axs[0].scatter([-1], [-1], color=\"black\", s=10, label=\"Exp.\")\n",
Expand Down
3 changes: 1 addition & 2 deletions MMS/MMS.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -305,7 +305,6 @@
}
],
"source": [
"import matplotlib.pyplot as plt\n",
"from pypalettes import load_cmap\n",
"\n",
"cmap = load_cmap(\"Sunset2\", reverse=False)\n",
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ The repository includes several validation cases and one verification test on th

[2] [D adsorption on oxidised W](./D_WO): The case reproduces simulation results of [E. A. Hodille et al.](https://iopscience.iop.org/article/10.1088/1741-4326/ad2a29) on the D adsorption/desorption on/from oxidised W. The simulations are based on experiments performed by [A. Dunand et al.](https://iopscience.iop.org/article/10.1088/1741-4326/ac583a)

[3] [D implantation in damaged W](./D_damagedW): The case reproduces simulation results of [E. A. Hodille et al.](https://iopscience.iop.org/article/10.1088/1741-4326/aa5aa5/meta) on the isothermal D implantation in self-damaged W, followed by isothermal desorption. The simulations are based on experiments performed by [S. Markelj et al.](https://www.sciencedirect.com/science/article/pii/S0022311515303470?via%3Dihub)
[3] [D atom exposure of self-damaged W](./D_damagedW): The case reproduces simulation results of [E. A. Hodille et al.](https://iopscience.iop.org/article/10.1088/1741-4326/aa5aa5/meta) on the isothermal D implantation in self-damaged W, followed by isothermal desorption. The simulations are based on experiments performed by [S. Markelj et al.](https://www.sciencedirect.com/science/article/pii/S0022311515303470?via%3Dihub)

[4] [D implantation in damaged EUROFER](./D_EUROFER): The case reproduces experimental results of [K. Schmid et al.](https://www.sciencedirect.com/science/article/pii/S2352179122002228) on the D implantation in damaged EUROFER, followed by TDS measurements. The FESTIM model is mainly based on the simulations of [K. Schmid et al.](https://www.sciencedirect.com/science/article/pii/S2352179123001333?via%3Dihub)
[4] [D implantation in W-damaged EUROFER](./D_EUROFER): The case reproduces experimental results of [K. Schmid et al.](https://www.sciencedirect.com/science/article/pii/S2352179122002228) on the D implantation in damaged EUROFER, followed by TDS measurements. The FESTIM model is mainly based on the simulations of [K. Schmid et al.](https://www.sciencedirect.com/science/article/pii/S2352179123001333?via%3Dihub)

[5] [MMS](./MMS) test

Expand Down
Loading