-
Notifications
You must be signed in to change notification settings - Fork 19
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
base: devel
Are you sure you want to change the base?
Ver 1kb #201
Changes from 6 commits
06038bc
bda1e65
7365d5e
ce50a86
381e41d
72bfe63
913e354
bd6bdc6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one is not fixed yet. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/Users/lee/projects/TMAP8/test/tests/ver-1kb/comparison_ver-1kb.py |
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 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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$. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
|
||||||
## Results | ||||||
|
||||||
The TMAP8 pressure evolutions in the two enclosures are shown in [ver-1kb_comparison_time] as a function of time. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,64 @@ | ||||||||||||||
import numpy as np | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
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 | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() |
There was a problem hiding this comment.
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:
That should do it and solve the current documentation failure.