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

Ver 1kb #201

wants to merge 8 commits into from

Conversation

Lee01Atom
Copy link
Contributor

@Lee01Atom Lee01Atom commented Oct 25, 2024

(Ref. #12)

@Lee01Atom Lee01Atom changed the title Add ver-1kb case (Ref. #12) Ver-1kb case (Ref. #12) Oct 25, 2024
@Lee01Atom Lee01Atom changed the title Ver-1kb case (Ref. #12) Ver-1kb case Oct 25, 2024
@Lee01Atom Lee01Atom changed the title Ver-1kb case Ver 1kb Oct 25, 2024
@simopier simopier self-assigned this Oct 25, 2024
@simopier simopier added the V&V Relevant to V&V label Oct 25, 2024
@simopier
Copy link
Collaborator

@Lee01Atom, please update the comment at the top of the page to list the related issue (see what i did on your previous PR).

Copy link
Collaborator

@simopier simopier left a comment

Choose a reason for hiding this comment

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

Here are some general comments after a rapid preliminary review:

  • Please add a couple metrics to make this a verification case (we need comparison to an analytical solution. You could add a postprocessor to keep track of mass conservation (see tests in interfaceSorption), and another to measure the concentration jump at the interface and make sure that it is equal to the expected value from Henry's law (see tests in interfaceSorption).
  • Please explain why you use both InterfaceDiffusion and InterfaceSorption. InterfaceSorption should be enough since it also accounts for diffusion through the interface. This might be over constraining your system. Note that InterfaceSorption also takes in the diffusivities (see Add val 2c to TMAP8 for Test Cell Experiment #197).
  • You will need a tests file to run this case
  • Your nl_abs_tol = 1e-6 and nl_rel_tol = 1e-6 are quite large (defaults are 1e-30 and 1e-8, respectively). Do you really need them to be this high? (see input files in interfaceSorption)
  • I think your petsc options should be more like what is used in interfaceSorption tests

@moosebuild
Copy link

moosebuild commented Oct 25, 2024

Job Documentation, step Sync to remote on bd6bdc6 wanted to post the following:

View the site here

This comment will be updated on new commits.

@moosebuild
Copy link

Job Coverage, step Generate coverage on 7365d5e wanted to post the following:

Coverage

Coverage did not change

Full coverage report

This comment will be updated on new commits.

@simopier
Copy link
Collaborator

You currently get the following error:

##########################################################################
ERROR: The following files contain trailing whitespace after applying your patch:
	test/tests/ver-1kb/ver-1kb.i

Run the "delete_trailing_whitespace.sh" script in your $MOOSE_DIR/scripts directory.
##########################################################################

Check both these links out to automatically solve these issues in VSCode:

  1. https://mooseframework.inl.gov/help/development/VSCode.html
  2. https://stackoverflow.com/questions/30884131/remove-trailing-spaces-automatically-or-with-a-shortcut

Copy link
Collaborator

@simopier simopier left a comment

Choose a reason for hiding this comment

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

Thanks for the update @Lee01Atom!

  1. you are missing the alias for comparison_ver-1kb.py in the doc/content/verification_and_validation/figures folder.
  2. The documentation currently does not show any verification, in the sense that it does not verify mass conservation or the fact that the solubility law is properly computed. You need to check these metrics in a quantitative way to make it a valuable verification case. (see the last figure in the documentation in Clean up and Update val-2b #202 as an example).


## 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.

doc/content/verification_and_validation/ver-1kb.md Outdated Show resolved Hide resolved
test/tests/ver-1kb/tests Outdated Show resolved Hide resolved
doc/content/verification_and_validation/ver-1kb.md Outdated Show resolved Hide resolved
doc/content/verification_and_validation/ver-1kb.md Outdated Show resolved Hide resolved
test/tests/ver-1kb/ver-1kb.i Outdated Show resolved Hide resolved
test/tests/ver-1kb/ver-1kb.i Outdated Show resolved Hide resolved
test/tests/ver-1kb/ver-1kb.i Show resolved Hide resolved
test/tests/ver-1kb/ver-1kb.i Outdated Show resolved Hide resolved
[]
[]

[Postprocessors]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Plot and discuss some of the values of the pps in the documentation to show that the case is being properly modeled. Of particular interest are mass conservation and the fact that the solubility law is properly computed.

initial_pressure_2 = ${units 1e-10 Pa}
initial_concentration_1 = ${fparse initial_pressure_1 / (R*T)} # mol/m^3
initial_concentration_2 = ${fparse initial_pressure_2 / (R*T)} # mol/m^3
solubility = ${fparse 1.082e20/Na} # Henry's law constant
Copy link
Collaborator

Choose a reason for hiding this comment

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

Units?

Copy link
Collaborator

@simopier simopier left a comment

Choose a reason for hiding this comment

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

You're getting there. The main remaining gaps are (1) the documentation, which meeds more more content to detail the case and explain the results and quantitatively show that TMAP8 accurately models this case in a way (see specific comments), and (2) the solubility value.

I looked at the input file and the case a little bit, and I think I understand why you are not getting the expected results.

Henry's law states C2 = KP1, and the TMAP7 case explains that the pressures of the two enclosures are expected to equilibrate at the same value, which is also shown in their figure with the results. For that reason, I believe that they defined the solubility Kin a way that ensured that at equilibrium: P1=P2, or C2 = C1. Since C2 = KP1 = K C R T, I think they picked K = 1/R/T. The reason you are not getting the same result as them with the same K value is because you are not using the same units. If you set up K = 1 / R / T, you will be able to reproduce their results.

However, I don't think this is a a very interested result since the concentration jump at the interface is effectively 0. So here's what I think would make this case more valuable:

Create two different sub-cases within this case, one with (a) K = 1 / R / T, and one with (b) K = 10 / R / T or any other value to show that TMAP8 can reproduce the TMAP7 case without any jump (i.e., a) and model a concentration jump at the interface (i.e., b). For both case, plot the pressure evolution over time in both enclosure, show that mass is conserved, and show that the concentration jump is properly simulated (0 for sub-case a, and KRT for sub-case b).

You can create subcase (b) simply by creating a new test in the tests file and update the solubility value with the cli_agrs argument (see case ver-1jb as an example on how to do that).

Please let me know if you have any questions, or if anything is unclear.

test/tests/ver-1kb/ver-1kb.i Outdated Show resolved Hide resolved
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.

@@ -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.

test/tests/ver-1kb/tests Outdated Show resolved Hide resolved
test/tests/ver-1kb/tests Outdated Show resolved Hide resolved
test/tests/ver-1kb/ver-1kb.i Outdated Show resolved Hide resolved
test/tests/ver-1kb/ver-1kb.i Show resolved Hide resolved
test/tests/ver-1kb/ver-1kb.i Outdated Show resolved Hide resolved
test/tests/ver-1kb/ver-1kb.i Outdated Show resolved Hide resolved
test/tests/ver-1kb/ver-1kb.i Outdated Show resolved Hide resolved
Copy link
Collaborator

@simopier simopier left a comment

Choose a reason for hiding this comment

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

@Lee01Atom, here are some additional comments that should help you fix the failure in the test environment and improve this case.

Let me know if you have any questions. You're on the right track!

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.


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)
C_1 = K P_2^n = K \left( \frac{C_2 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$.


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)
C_1 = K P_2^n = K \left( \frac{C_2 RT}{n} \right)
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
C_1 = K P_2^n = K \left( \frac{C_2 RT}{n} \right)
C_1 = K P_2^n = K \left( C_2 RT \right)^n

The diffusion process in each of the two enclosures can be described by the following equations:

\begin{equation}
\frac{\partial C_1}{\partial t} = D \nabla^2 C_1
Copy link
Collaborator

@simopier simopier Nov 4, 2024

Choose a reason for hiding this comment

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

Suggested change
\frac{\partial C_1}{\partial t} = D \nabla^2 C_1
\frac{\partial C_1}{\partial t} = \nabla D \nabla C_1

Copy link
Collaborator

@simopier simopier Nov 4, 2024

Choose a reason for hiding this comment

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

D \nabla^2 C_1 is only valid if the diffusion coefficient does not depend on the position. The expression I am proposing is more general.

\end{equation}

\begin{equation}
\frac{\partial C_1}{\partial t} = D \nabla^2 C_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
\frac{\partial C_1}{\partial t} = D \nabla^2 C_1
\frac{\partial C_1}{\partial t} = - \nabla D \nabla C_1

cli_args = 'solubility=${fparse 10/(8.31446261815324*500)}
Outputs/file_base=ver-1kb_out_k10'
csvdiff = ver-1kb_out_k10.csv
requirement = 'The system shall be able to model the diffusion of H2 across a membrane separating two enclosures in accordance with Henry’s law. Model a concentration jump at the interface'
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
requirement = 'The system shall be able to model the diffusion of H2 across a membrane separating two enclosures in accordance with Henry’s law. Model a concentration jump at the interface'
requirement = 'The system shall be able to model the diffusion of H2 across a membrane separating two enclosures in accordance with Henry’s law with a concentration jump at the interface'

@@ -0,0 +1,25 @@
[Tests]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add an exodus test for the case K=10/RT.

You can look at tests specification files in other verification cases to see how to do it.

[ver-1kb_csv_concentration_jump]
type = CSVDiff
input = ver-1kb.i
cli_args = 'solubility=${fparse 10/(8.31446261815324*500)}
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
cli_args = 'solubility=${fparse 10/(8.31446261815324*500)}
cli_args = "solubility='${fparse 10/(R*temperature)}'

You should b able to leverage the values you have already defined for R and the temperature. This makes sure things are (and remain) consistent.
When using cli_args, you need to make sure to use ' [...] ' around arguments that have spaces in them to pass it as a string. Right now, your tests are failing because of this.

type = CSVDiff
input = ver-1kb.i
cli_args = 'solubility=${fparse 10/(8.31446261815324*500)}
Outputs/file_base=ver-1kb_out_k10'
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
Outputs/file_base=ver-1kb_out_k10'
Outputs/file_base=ver-1kb_out_k10"

Copy link
Collaborator

Choose a reason for hiding this comment

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

You might want to re-gold this file, it is currently failing - the predictions in the testing environment are different from this gold file. Make sure it is up to date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
V&V Relevant to V&V
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants