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

Add ver-1kc-2 #231

merged 25 commits into from
Jan 30, 2025

Conversation

lkadz
Copy link
Collaborator

@lkadz lkadz commented Dec 24, 2024

(Ref. #12)

@moosebuild
Copy link

moosebuild commented Dec 24, 2024

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

View the site here

This comment will be updated on new commits.

@simopier simopier self-assigned this Dec 25, 2024
@simopier simopier added the V&V Relevant to V&V label Dec 25, 2024
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.

This is not a full review, I'm just providing suggestions to solve the current test failures.

Also, make sure to add a reference to the issue number in the PR message at the top of the page.

@lkadz
Copy link
Collaborator Author

lkadz commented Dec 25, 2024

Hi @simopier ,

I had a question regarding the reaction $H_2 + T_2 \longleftrightarrow 2HT$. In TMAP8, using MatReactionFlexible, we rely on a kinetic law (e.g. for HT, $\frac{d(c_{HT})}{dt} = 2K \cdot c_{H_2} \cdot c_{T_2}$), whereas in TMAP7, we use an equilibrium formula: $P_{HT} = \eta \cdot \bigl(P_{H_2}\bigr)^{0.5} \cdot \bigl(P_{T_2}\bigr)^{0.5}$

Could you please advise on how to ensure the equilibrium law is respected in TMAP8? I tried to illustrate this in the last Python subplot figure, but the equilibrium isn’t fully reached yet.

Also, I set an arbitrary reaction rate constant K and would appreciate any insight into how its value is usually determined. I compared it to other cases that use MatReactionFlexible but couldn’t figure out how those values were obtained.

Thanks in advance for your help!
Best

@moosebuild
Copy link

moosebuild commented Dec 25, 2024

Job Coverage, step Generate coverage on 510ae3c wanted to post the following:

Coverage

Coverage did not change

Full coverage report

This comment will be updated on new commits.

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 on the right track!
Here's a partial review with some suggestions. I'll need to do a deeper review once you have all the pieces together.

@simopier

This comment was marked as duplicate.

1 similar comment
@simopier
Copy link
Collaborator

simopier commented Dec 26, 2024

Hi @simopier ,

I had a question regarding the reaction H 2 + T 2 ⟷ 2 H T . In TMAP8, using MatReactionFlexible, we rely on a kinetic law (e.g. for HT, d ( c H T ) d t = 2 K ⋅ c H 2 ⋅ c T 2 ), whereas in TMAP7, we use an equilibrium formula: P H T = η ⋅ ( P H 2 ) 0.5 ⋅ ( P T 2 ) 0.5

Could you please advise on how to ensure the equilibrium law is respected in TMAP8? I tried to illustrate this in the last Python subplot figure, but the equilibrium isn’t fully reached yet.

Also, I set an arbitrary reaction rate constant K and would appreciate any insight into how its value is usually determined. I compared it to other cases that use MatReactionFlexible but couldn’t figure out how those values were obtained.

Great questions!

You correctly identified that while TMAP7 uses an equilibrium condition, we probably want to use a kinetic description in TMAP8 to be more general. However, we need to reconcile the two to obtain the same equilibrium condition.
You currently struggle to reconcile the kinetic equation with the equilibrium formula because you are missing a piece in your kinetic equation. The reaction goes in both directions, and you are currently missing the decomposition of HT into H2 and T2:
$\frac{dc_{HT}}{dt} = 2 K_1 c_{H2}c_{T2} - K_2c_{HT}^2$
and similarly:
$\frac{dc_{H2}}{dt} = - K_1 c_{H2}c_{T2} + \frac{1}{2} K_2c_{HT}^2$
and
$\frac{dc_{T2}}{dt} = - K_1 c_{H2}c_{T2} + \frac{1}{2} K_2c_{HT}^2$

at equilibrium:
$\frac{dc_{HT}}{dt} = \frac{dc_{HT}}{dt} = \frac{dc_{HT}}{dt} = 0$,
which leads to
$2 K_1 c_{H2}c_{T2} - K_2c_{HT}^2 = 0$,
which can be rearranged into
$P_{HT}=\eta \sqrt{P_{H2}P_{T2}}$
with
$\eta = \sqrt{\frac{2K_1}{K_2}}$.

So, to obtain the same equilibrium as in TMAP7, you can define $K_1$ and $K_2$ in several ways, as long as you get $\eta = \sqrt{\frac{2K_1}{K_2}}$. However, if you also want to ensure that the equilibrium condition is obtained quickly knowing that it is assumed to be immediate in TMAP7, then you'll want to define $K_1$ and $K_2$ large enough so that it is much faster than other kinetics such as diffusion and/or surface reactions or other kinetics relevant to whatever case you are working on at that time.

Please double check the math above, but that should give you all you need to address your questions above. Here, you'll need to add blocks for the chemical reactions (feel free to check other cases if you are unsure how to do it), and select appropriate values for $K_1$ and $K_2$.

I hope that helps! Let me know if you have other questions.

@lkadz
Copy link
Collaborator Author

lkadz commented Dec 28, 2024

Hi @simopier,
Thank you for your valuable insights! In the updated commits, I have ensured that the chemical reactions respect the TMAP7 equilibrium.
In this branch (ver-1kc-2), I renamed ver-1kc.md to ver-1kc-1.md, but I noticed there is still a documentation error. Should I also add ver-1kc-1.md to the ver-1kc branch to resolve this issue?

@simopier
Copy link
Collaborator

The ver-1kc branch has already been merged in your previous PR. Right now, you are getting failures because you have not updated ver-1kc.md into ver-1kc-1.md everywhere. For example, in the test specification file for ver-1kc-1, it still says

verification = `ver-1kc.md`

instead of

verification = `ver-1kc-1.md`

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's a new round of reviews. Let me know if you have any questions.

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.

Things are looking good!

My main remaining concerns are:

  • the very loose tolerances. They should be much smaller.
  • the fact that we do not match the right equilibrium condition (very likely due to large tolerances and large time steps)
  • The discussion about K1 and K2 in the documentation, where we are not exactly on the same page.

As you try to refine the tolerances, feel free to play with the values of K_1 and K_2. Try to make them lower and higher (still with eta=2) to understand their impact on the results and on convergence.

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.

The equilibrium is much better with tighter tolerances! But I think we still have some room for improvement, especially for enclosure 2.

What was your experience playing with the tolerances and seeing their impact on the results?

@lkadz
Copy link
Collaborator Author

lkadz commented Jan 3, 2025

The equilibrium is much better with tighter tolerances! But I think we still have some room for improvement, especially for enclosure 2.

What was your experience playing with the tolerances and seeing their impact on the results?

Compared to the previous solving parameters, the results are noticeably better and faster. Specifically, increasing the growth factor has helped reduce the testing time, as larger time steps can be used.

In this case, I set K1=1000, but I also experimented with K1=5000. As expected, this resulted in a better chemical equilibrium in enclosure 2. However, the drawback is that the simulation takes more than 300 seconds to complete, exceeding the time limit even for the heavy test.

Moreover, this is quite strange that, while both the standard and heavy tests fail here, running them locally works without issues (no mismatches in the CSV files).

@lkadz
Copy link
Collaborator Author

lkadz commented Jan 6, 2025

Hi @simopier,
I have refined the parameters by setting nl_abs_tol = 1e-8, nl_rel_tol = 1e-6, and dtmax = 1e-4, and utilized solve_type = JFNK to achieve quicker convergence. This adjustment has resulted in better chemical equilibrium in Enclosure 2. However, the trade-off is an increase in RMSPE for the sorption law as well as a rise in mass variation.

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.

I played around locally and realized the heavy test did not pass on my machine.
I also cleaned up a couple things as simple review suggestions.

@simopier
Copy link
Collaborator

Hey @lkadz,

we usually don't use JFNK. NEWTON and PJFNK often provide much better performances in terms of accuracy and costs. See some of the solve type descriptions in https://mooseframework.inl.gov/TMAP8/source/executioners/Steady.html#steady.

So I moved to PJFNK with a pre-conditioner and it allowed me to tighten the tolerance a lot (from 1e-8 to 1e-50 for nl-abs and from 1e-6 to 1e-8 for nl_rel, which are the default values) while making the tests a lot faster.

Using smaller tolerances might help with the tests failures we were experiencing before (fingers crossed, we'll see how testing goes).

Please look at my latest commits to make sure to learn from these changes.

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.

Looks good, thank you!

@simopier
Copy link
Collaborator

@cticenhour, this looks good to me. But could you please take a look at my latest commits and either (1) agree that these correspond to review suggestions and do not require a secondary review, or (2) review my commits.
Feel free to review the whole PR if you have time and feel like it, too. :-)
Thank you!

@cticenhour
Copy link
Member

I went ahead and reviewed everything. Looks good. Thanks @lkadz!

@cticenhour cticenhour merged commit fd3e8bb into idaholab:devel Jan 30, 2025
8 checks passed
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.

4 participants