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

Ver 1kb #201

Open
wants to merge 8 commits into
base: devel
Choose a base branch
from
Open
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You already ran into this issue in your previous PR (#183) and the solution was (here adapted for ver-1kb):

We do not want the absolute path because Users/lee/ is very specific to your local machine.
Please run:

cd ~/projects/TMAP8/doc/content/verification_and_validation/figures/
rm -rf comparison_ver-1kb.py
ln -s ../../../../test/tests/ver-1kb/comparison_ver-1kb.py comparison_ver-1kb.py

That should do it and solve the current documentation failure.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is not fixed yet.

1 change: 1 addition & 0 deletions doc/content/verification_and_validation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ TMAP8 also contains [example cases](examples/tmap_index.md), which showcase how
| ver-1ja | [Radioactive Decay of Mobile Tritium in a Slab](ver-1ja.md) |
| ver-1jb | [Radioactive Decay of Mobile Tritium in a Slab with a Distributed Trap Concentration](ver-1jb.md) |
| ver-1ka | [Simple Volumetric Source](ver-1ka.md) |
| ver-1kb | [Henry’s Law Boundaries with No Volumetric Source](ver-1kb.md) |

# List of benchmarking cases

Expand Down
39 changes: 39 additions & 0 deletions doc/content/verification_and_validation/ver-1kb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# ver-1kb

# Henry’s Law Boundaries with No Volumetric Source

## General Case Description

Two enclosures are separated by a membrane that allows diffusion according to Henry’s law, with no volumetric source present. Enclosure 2 has twice the volume of Enclosure 1.

## Case Set Up
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should document the values used in this case, like the system dimensions, the initial pressures, the diffusivities and solubilities used, etc. With all the corresponding units, of course.

Make sure to also add the equation for diffusion.


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

Over time, the pressures of T$_2$, which diffuses across the membrane in accordance with Henry’s law, will gradually equilibrate between the two enclosures.

The concentration in Enclosure 1 is related to the partial pressure and concentration in Enclosure 2 via the interface sorption law:

\begin{equation}
C_s = K P^n = K \left( \frac{C_g RT}{n} \right)
\end{equation}

where $R$ is the ideal gas constant in J/mol/K, $T$ is the temperature in K, $K$ is the solubility, and $n$ is the exponent of the sorption law. For the Henry’s law, $n=1$.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
where $R$ is the ideal gas constant in J/mol/K, $T$ is the temperature in K, $K$ is the solubility, and $n$ is the exponent of the sorption law. For the Henry’s law, $n=1$.
where $R$ is the ideal gas constant in J/mol/K, $T$ is the temperature in K, $K$ is the solubility, and $n$ is the exponent of the sorption law. For Henry’s law, $n=1$.



## Results

The TMAP8 pressure evolutions in the two enclosures are shown in [ver-1kb_comparison_time] as a function of time.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please discuss how the results compare to the expected behavior. In particular, you'll want to check that the concentration values at the interface are properly computed based on the sorption law, and that mass is conserved.


!media comparison_ver-1kb.py
image_name=ver-1kb_comparison_time.png
style=width:50%;margin-bottom:2%;margin-left:auto;margin-right:auto
id=ver-1kb_comparison_time
caption=Equilibration of species pressures under Henry’s law as predicted by TMAP8.

## Input files

!style halign=left
The input file for this case can be found at [/ver-1kb.i], which is also used as tests in TMAP8 at [/ver-1kb/tests].

!bibtex bibliography
64 changes: 64 additions & 0 deletions test/tests/ver-1kb/comparison_ver-1kb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import numpy as np
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new figures created here need to be added to the documentation and commented there.

import pandas as pd
import os
from matplotlib import gridspec
import matplotlib.pyplot as plt

# Changes working directory to script directory (for consistent MooseDocs usage)
script_folder = os.path.dirname(__file__)
os.chdir(script_folder)

# Extract columns for time, pressures, concentration_enclosure_1_at_interface, and concentration_enclosure_2_at_interface
if "/TMAP8/doc/" in script_folder: # if in documentation folder
csv_folder = "../../../../test/tests/ver-1kb/gold/ver-1kb_out.csv"
else: # if in test folder
csv_folder = "./gold/ver-1kb_out.csv"
Comment on lines +13 to +15
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
csv_folder = "../../../../test/tests/ver-1kb/gold/ver-1kb_out.csv"
else: # if in test folder
csv_folder = "./gold/ver-1kb_out.csv"
csv_folder = "../../../../test/tests/ver-1kb/gold/ver-1kb_out_k1.csv"
else: # if in test folder
csv_folder = "./gold/ver-1kb_out_k1.csv"

expt_data = pd.read_csv(csv_folder)
TMAP8_time = expt_data['time']
TMAP8_pressure_enclosure_1 = expt_data['pressure_enclosure_1']
TMAP8_pressure_enclosure_2 = expt_data['pressure_enclosure_2']
concentration_enclosure_1_at_interface = expt_data['concentration_enclosure_1_at_interface']
pressure_enclosure_2_at_interface = expt_data['pressure_enclosure_2_at_interface']

# Create a figure with 3 subplots
fig = plt.figure(figsize=[12, 5.5])
gs = gridspec.GridSpec(1, 3, width_ratios=[1, 1, 1])

# Subplot 1: Time vs Pressure
ax1 = fig.add_subplot(gs[0])
ax1.plot(TMAP8_time/3600, TMAP8_pressure_enclosure_1, label=r"H2 Encl 1", c='tab:gray', linestyle='-')
ax1.plot(TMAP8_time/3600, TMAP8_pressure_enclosure_2, label=r"H2 Encl 2", c='black', linestyle='-')
ax1.yaxis.set_major_formatter(plt.FuncFormatter(lambda val, pos: '{:.1e}'.format(val)))
ax1.set_xlabel('Time (hr)')
ax1.set_ylabel('Pressure (Pa)')
ax1.set_xlim(0, 3)
ax1.set_ylim(bottom=0)
ax1.legend(loc="best")
ax1.grid(which='major', color='0.65', linestyle='--', alpha=0.3)

# Subplot 2: Pressure Encl 2 vs Concentration Encl 1 at interface
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to also calculate the difference between the expected final results and the calculated final results, and discuss how accurate TMAP8 is in the documentation.

k = np.sum(concentration_enclosure_1_at_interface * pressure_enclosure_2_at_interface) / np.sum(pressure_enclosure_2_at_interface ** 2)
print(f"K (après ajustement d'échelle) : {k:.2e}")
line_fit = k * pressure_enclosure_2_at_interface[1:]
print(f'k = {k:.2e}')
ax2 = fig.add_subplot(gs[1])
ax2.plot(pressure_enclosure_2_at_interface[1:], concentration_enclosure_1_at_interface[1:], marker='o', linestyle='None', c='tab:blue')
ax2.plot(pressure_enclosure_2_at_interface[1:], line_fit, label=f'Fit: y = {k:.2e}x\n', c='tab:red', linestyle='--')
ax2.set_xlabel(r"Pressure Encl 2 at interface (Pa)")
ax2.set_ylabel(r"Concentration Encl 1 at interface (mol/m^3)")
ax2.legend(loc="best")
ax2.grid(which='major', color='0.65', linestyle='--', alpha=0.3)

# Subplot 3: Mass Conservation Sum Encl 1 and 2 vs Time
mass_conservation_sum_encl1_encl2 = expt_data['mass_conservation_sum_encl1_encl2'].values
ax3 = fig.add_subplot(gs[2])
ax3.plot(TMAP8_time/3600, mass_conservation_sum_encl1_encl2, '-', color='tab:blue')
ax3.set_xlabel('Time (hr)')
ax3.set_ylabel(r"Mass Conservation Sum Encl 1 and 2 (mol/m^3)")
ax3.legend(loc="best")
ax3.grid(which='major', color='0.65', linestyle='--', alpha=0.3)

# Save the figure
plt.tight_layout()
plt.savefig('ver-1kb_comparison_time.png', bbox_inches='tight')
plt.show()
Loading