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

Add ver-1kc-2 #231

Merged
merged 25 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from 6 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
8 changes: 4 additions & 4 deletions doc/content/verification_and_validation/ver-1kc-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Two enclosures are separated by a membrane that allows diffusion according to Si

This verification problem is taken from [!cite](ambrosek2008verification).

Unlike the (ver-1kc-1)[ver-1kc-1.md] case, which only considers tritium T$_2$, this setup describes a diffusion system in which tritium T$_2$, dihydrogen H$_2$ and HT are modeled across a one-dimensional domain split into two enclosures. The total system length is $2.5 \times 10^{-4}$ m, divided into 100 segments. The system operates at a constant temperature of 500 Kelvin. Initial tritium T$_2$ and dihydrogen H$_2$ pressures are specified as $10^{5}$ Pa for Enclosure 1 and $10^{-10}$ Pa for Enclosure 2. Initially, there is no HT in either enclosure.
Unlike the [ver-1kc-1](ver-1kc-1.md) case, which only considers tritium T$_2$, this setup describes a diffusion system in which tritium T$_2$, dihydrogen H$_2$ and HT are modeled across a one-dimensional domain split into two enclosures. The total system length is $2.5 \times 10^{-4}$ m, divided into 100 segments. The system operates at a constant temperature of 500 Kelvin. Initial tritium T$_2$ and dihydrogen H$_2$ pressures are specified as $10^{5}$ Pa for Enclosure 1 and $10^{-10}$ Pa for Enclosure 2. Initially, there is no HT in either enclosure.

The reaction between the species is described as follows

Expand Down Expand Up @@ -81,11 +81,11 @@ We assume that $K = 10/\sqrt{RT}$, which is expected to result in $C_1 = 10 \sqr
As illustrated in [ver-1kc-2_comparison_time_k10], similarly to ver-1kc-1, T$_2$ and H$_2$ pressures reach equilibrium in both enclosures. What is new, however, is that HT is produced in both enclosures following the sorption law.

Thus, it is crucial to ensure that the chemical equilibrium between HT, T$_2$ and H$_2$ is achieved. This can be verified in both enclosures by examining the ratio between $P_{\text{HT}}$ and $\sqrt{P_{\text{H}_2} P_{\text{T}_2}}$, which must equal $\eta=2$.
As shown in [ver-1kc-2_equilibrium_constant_k10], this ratio approaches $\eta=2$ for both enclosures, as observed in TMAP7. However, achieving this balance involves a compromise. On one hand, $K_1$ must be sufficiently large to ensure that the chemical kinetics in Enclosure 1 are significantly faster than other processes, such as diffusion and surface sorption. On the other hand, $K_2$ should not be excessively large, as this could hinder the diffusion of species into Enclosure 2, where no species are initially present.
As shown in [ver-1kc-2_equilibrium_constant_k10], this ratio approaches $\eta=2$ for both enclosures, as observed in TMAP7. However, achieving this balance involves a compromise to reproduce TMAP7's results. The ratio of $K_1$ and $K_2$ must respect [eq:eta]. The values of $K_1$ and $K_2$ must also be large enough to ensure that the kinetics of chemical reactions are faster than diffusion or surface permeation to be closer to the equilibrium assumption used in TMAP7. Here, the equilibrium in enclosure 1 is achieved rapidly. Increasing $K_1$ and $K_2$ would also enable a quicker attainment of equilibrium in enclosure 2. However, using very high values for $K_1$ and $K_2$ would lead to an unnecessary increase in computational costs.

The concentration ratios for T$_2$, H$_2$, and HT between enclosures 1 and 2, shown in [ver-1kc-2_concentration_ratio_T2_k10], [ver-1kc-2_concentration_ratio_H2_k10], and [ver-1kc-2_concentration_ratio_HT_k10], demonstrate that the results obtained with TMAP8 are consistent with the analytical results derived from the sorption law for $K \sqrt{RT} = 10$.

As shown in [ver-1kc-2_mass_conservation_k10], mass is conserved between the two enclosures over time. The variation in mass is only $0.2$ %. This variation in mass can be further minimized by refining the mesh, i.e., increasing the number of segments in the domain.
As shown in [ver-1kc-2_mass_conservation_k10], mass is conserved between the two enclosures over time. The variation in mass is only $0.4$ %. This variation in mass can be further minimized by refining the mesh, i.e., increasing the number of segments in the domain.

!media comparison_ver-1kc-2.py
image_name=ver-1kc-2_comparison_time_k10.png
Expand All @@ -97,7 +97,7 @@ As shown in [ver-1kc-2_mass_conservation_k10], mass is conserved between the two
image_name=ver-1kc-2_equilibrium_constant_k10.png
style=width:50%;margin-bottom:2%;margin-left:auto;margin-right:auto
id=ver-1kc-2_equilibrium_constant_k10
caption=Equilibrium constant as a function of time.
caption=Equilibrium constant as a function of time for $\eta = \sqrt{2K_1/K_2}=2$.

!media comparison_ver-1kc-2.py
image_name=ver-1kc-2_concentration_ratio_T2_k10.png
Expand Down
6 changes: 4 additions & 2 deletions test/tests/ver-1kc-2/comparison_ver-1kc-2.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@
ax.yaxis.set_major_formatter(plt.FuncFormatter(lambda val, pos: '{:.3e}'.format(val)))
ax.set_xlabel('Time (s)')
ax.set_ylabel(r"Mass Conservation Sum Encl 1 and 2 (mol/m$^3$)")
ax.legend(loc="best")
ax.grid(which='major', color='0.65', linestyle='--', alpha=0.3)
mass_variation_percentage = (np.max(mass_conservation_sum_encl1_encl2_k10)-np.min(mass_conservation_sum_encl1_encl2_k10))/np.max(mass_conservation_sum_encl1_encl2_k10)*100
print("Percentage of mass variation: ", mass_variation_percentage)
Expand All @@ -154,13 +153,16 @@
gs = gridspec.GridSpec(1,1)
ax = fig.add_subplot(gs[0])

ax.plot(TMAP8_time_k10, equilibrium_constant_encl_1, label = r"Enclosure 1", c='tab:blue')
ax.plot(TMAP8_time_k10, equilibrium_constant_encl_2, label = r"Enclosure 2", c='tab:red')
ax.plot(TMAP8_time_k10, equilibrium_constant_encl_1, label = r"Enclosure 1", c='tab:blue')
ax.axhline(y=2, color='tab:green', linestyle='--', label='TMAP7 Equilibrium Constant')
ax.set_xlabel('Time (s)')
ax.set_ylabel(r"Equilibrium constant $P_{\text{HT}} / \sqrt{P_{\text{H}_2} P_{\text{T}_2}}$")
ax.set_ylim(bottom=0)
ax.legend(loc="best")
ax.grid(which='major', color='0.65', linestyle='--', alpha=0.3)
print("Relative variation to equilibrium constant in enclosure 1", abs(equilibrium_constant_encl_1[len(equilibrium_constant_encl_1)-1]-2)/2 * 100)
print("Relative variation to equilibrium constant in enclosure 2", abs(equilibrium_constant_encl_2[len(equilibrium_constant_encl_2)-1]-2)/2 * 100)
fig.savefig('ver-1kc-2_equilibrium_constant_k10.png', bbox_inches='tight', dpi=300)


Expand Down
Loading