-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from RemDelaporteMathurin/kschmid_remarks
Reader 1's remarks
- Loading branch information
Showing
14 changed files
with
254 additions
and
6 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
k_B = 8.617e-5 # ev/K | ||
|
||
|
||
def trap_occupancy(p_0, E_p, k_0, E_k, c_m, T): | ||
p = p_0 * np.exp(-E_p / k_B / T) | ||
k = k_0 * np.exp(-E_k / k_B / T) | ||
return 1 / (p / k / c_m + 1) | ||
|
||
|
||
T = np.linspace(300, 1200, num=300) | ||
c_m = 1e22 # m-3 | ||
|
||
# trap 1 | ||
trap_1_occupancy = trap_occupancy( | ||
p_0=1e13, E_p=0.87, k_0=8.96e-17, E_k=0.2, c_m=c_m, T=T | ||
) | ||
trap_1_density = 1.1e-3 # at.fr | ||
trap_1_concentration = trap_1_density * trap_1_occupancy | ||
|
||
trap_2_occupancy = trap_occupancy( | ||
p_0=1e13, E_p=1.00, k_0=8.96e-17, E_k=0.2, c_m=c_m, T=T | ||
) | ||
trap_2_density = 4.0e-4 # at.fr | ||
trap_2_concentration = trap_2_density * trap_2_occupancy | ||
|
||
# equivalent trap | ||
trap_eq_density = trap_1_density + trap_2_density # at.fr | ||
|
||
trap_eq_occupancy = trap_occupancy( | ||
p_0=1e13, | ||
E_p=(0.87 * trap_1_density + 1 * trap_2_density) / trap_eq_density, | ||
k_0=8.96e-17, | ||
E_k=0.2, | ||
c_m=c_m, | ||
T=T, | ||
) | ||
trap_eq_concentration = trap_eq_density * trap_eq_occupancy | ||
|
||
# compute difference | ||
difference = 100 * trap_2_concentration / (trap_1_concentration + trap_2_concentration) | ||
|
||
print("Maximum error induced by neglecting trap 2 is {:.0f} %".format(difference.max())) | ||
|
||
|
||
# PLOTTING | ||
|
||
fig, axs = plt.subplots(2, 1, sharex=True) | ||
|
||
plt.sca(axs[0]) | ||
|
||
plt.fill_between(T, 0, trap_1_concentration, label="Trap 1", alpha=0.8) | ||
plt.fill_between( | ||
T, | ||
trap_1_concentration, | ||
trap_1_concentration + trap_2_concentration, | ||
label="Trap 2", | ||
alpha=0.8, | ||
) | ||
# plt.plot(T, trap_eq_concentration, label="Trap eq") | ||
# plt.annotate("Equivalent trap", (470, 0.0013), color="tab:blue") | ||
|
||
plt.annotate("Trap 1", (320, 0.0005), color="white") | ||
plt.annotate("Trap 2", (320, 0.0012), color="white") | ||
|
||
plt.ylabel("Trap concentration (at.fr.)") | ||
plt.ylim(bottom=0) | ||
|
||
|
||
plt.sca(axs[-1]) | ||
plt.plot(T, difference) | ||
plt.ylim(bottom=0, top=80) | ||
|
||
plt.xlabel("T (K)") | ||
plt.ylabel("Error (%) \n (neglecting trap 2)") | ||
plt.tight_layout() | ||
|
||
for ax in axs: | ||
ax.spines.right.set_visible(False) | ||
ax.spines.top.set_visible(False) | ||
|
||
plt.show() | ||
|
||
|
||
# 2D map | ||
|
||
c_m = np.logspace(20, 23) | ||
T = np.linspace(300, 1200) | ||
|
||
TT, cc = np.meshgrid(T, c_m) | ||
|
||
# trap 1 | ||
trap_1_occupancy = trap_occupancy( | ||
p_0=1e13, E_p=0.87, k_0=8.96e-17, E_k=0.2, c_m=cc, T=TT | ||
) | ||
trap_1_concentration = trap_1_density * trap_1_occupancy | ||
|
||
trap_2_occupancy = trap_occupancy( | ||
p_0=1e13, E_p=1.00, k_0=8.96e-17, E_k=0.2, c_m=cc, T=TT | ||
) | ||
trap_2_concentration = trap_2_density * trap_2_occupancy | ||
|
||
|
||
# compute difference | ||
difference = 100 * trap_2_concentration / (trap_1_concentration + trap_2_concentration) | ||
|
||
CF = plt.contourf(TT, cc, difference, levels=100) | ||
plt.yscale("log") | ||
plt.colorbar(label="Error (%)") | ||
plt.xlabel("T (K)") | ||
plt.ylabel("Mobile concentration (m$^{-3}$)") | ||
|
||
for c in CF.collections: | ||
c.set_edgecolor("face") | ||
|
||
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import numpy as np | ||
import matplotlib as mpl | ||
import matplotlib.pyplot as plt | ||
import matplotlib.animation | ||
import matplotx | ||
from matplotlib.ticker import FormatStrFormatter | ||
|
||
nb_frames_still_beg = 200 | ||
nb_frames_still_end = 100 | ||
|
||
y_lim_still_beginning = np.ones(nb_frames_still_beg) * 30 | ||
y_lim = np.linspace(30, 750, num=50) | ||
y_lim_still = np.ones(nb_frames_still_end) * 750 | ||
|
||
y_lim = np.concatenate([y_lim_still_beginning, y_lim, y_lim_still]) | ||
|
||
x_lim_still_beginning = np.ones(nb_frames_still_beg) * 2 | ||
x_lim = np.linspace(2, 5, num=50) | ||
x_lim_still = np.ones(nb_frames_still_end) * 5 | ||
x_lim = np.concatenate([x_lim_still_beginning, x_lim, x_lim_still]) | ||
|
||
with plt.style.context(matplotx.styles.dufte_bar): | ||
fig = plt.figure() | ||
ax = fig.add_subplot(1, 1, 1) | ||
pos = [-1.5, 0, 1.5] | ||
labels = ["calculated", r"80 % error", r"50 % Tritium"] | ||
(bar) = plt.bar(pos, [14, 14 * 1.8, 14 * 1.8 * 0.5]) | ||
plt.xticks(pos, labels) | ||
ax.set_ylim(0, y_lim[0]) | ||
ax.set_xlim(-x_lim[0], x_lim[0]) | ||
# matplotx.show_bar_values("{:.0f} g") | ||
plt.hlines(700, -4, 4, colors="tab:green", linestyles="dashed") | ||
plt.annotate("ITER safety limit", xy=(0, 725), color="tab:green", ha="center") | ||
plt.gca().yaxis.set_major_formatter(FormatStrFormatter("%d g")) | ||
|
||
|
||
def update(i): | ||
ax.set_ylim(0, y_lim[i]) | ||
ax.set_xlim(-x_lim[i], x_lim[i]) | ||
if i > nb_frames_still_beg: | ||
for child in ax.get_children(): | ||
if isinstance(child, matplotlib.text.Text): | ||
if child.get_text() != "ITER safety limit": | ||
child.set(visible=False) | ||
if i > nb_frames_still_beg + 15: | ||
plt.xticks([]) | ||
|
||
|
||
ani = mpl.animation.FuncAnimation( | ||
fig, update, frames=y_lim.size, blit=False, repeat=False | ||
) | ||
plt.tight_layout() | ||
ani.save("animation_divertor_inventories.gif", writer="imagemagick", fps=60) | ||
# plt.show() |