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 option to advect enthalpy instead of cp T for non constant cp fluids #29569

Open
wants to merge 8 commits into
base: next
Choose a base branch
from

Conversation

GiudGiud
Copy link
Contributor

We already had a correction in the time derivative for non-constant cp. But @freiler spotted that we did not in the advection term.

This should eventually be the default. I ll do that when I transition the nonlinear fluid heat transfer Physics to use this formulation

@GiudGiud GiudGiud self-assigned this Dec 18, 2024
@tanoret
Copy link
Contributor

tanoret commented Dec 18, 2024

Please add realistic testing or more extended verification against analytical solutions. Let's try avoiding the same issues that we had in the past. Thank you!

@tanoret
Copy link
Contributor

tanoret commented Dec 18, 2024

Please add the same tests than for the linear problem:

  • 1D problem with cp=a+bT and verification against analytical solution
  • 2D problem with wall heating and verifying enthalpy balances (h_dot_out = h_dot_in + q''_wall * A_wall)
  • Equivalent problem in 3D and test against the previous 2D problem (this is important to see that we are not blowing up the size of the AD container by advecting enthalpy)
  • Body with variable cp and rho cooling at a fixed heat rate and verify against the analytical solution (this is verifying the implementation of the time derivative)

Thank you!

@GiudGiud
Copy link
Contributor Author

we should be good for this one

Equivalent problem in 3D and test against the previous 2D problem (this is important to see that we are not blowing up the size of the AD container by advecting enthalpy)

whether rho cp T or h, you have the same dependencies on pressure and temperature. We are not adding new ones by switching to h

For the time derivative we probably want to do more work than this if we want a conservative scheme.
I ll see what I can do for 1D / 2D

@freiler
Copy link
Contributor

freiler commented Dec 18, 2024

We can use the 1D and 2D cases I have for enthalpy to eventually check the accuracy of the new kernel. In addition, I will also build a transient case to test the time derivative kernel.

@GiudGiud
Copy link
Contributor Author

@freiler do you want to test this PR to provide 1 and 2? Or should I use your inputs?

@freiler
Copy link
Contributor

freiler commented Dec 18, 2024

I can push the input for the 1D and 2D cases to your branch so we at least run the same test cases and compare.

@moosebuild
Copy link
Contributor

moosebuild commented Dec 19, 2024

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

Framework coverage

Coverage did not change

Modules coverage

Fluid properties

e193a3 #29569 b22431
Total Total +/- New
Rate 85.11% 85.13% +0.02% 100.00%
Hits 7850 7863 +13 14
Misses 1373 1373 - 0

Diff coverage report

Full coverage report

Navier stokes

e193a3 #29569 b22431
Total Total +/- New
Rate 84.72% 84.74% +0.02% 95.83%
Hits 17494 17527 +33 46
Misses 3156 3157 +1 2

Diff coverage report

Full coverage report

Full coverage reports

Reports

This comment will be updated on new commits.

@moosebuild
Copy link
Contributor

moosebuild commented Dec 19, 2024

Job Documentation, step Docs: sync website on b22431f wanted to post the following:

View the site here

This comment will be updated on new commits.

@idaholab idaholab deleted a comment from moosebuild Dec 19, 2024
@idaholab idaholab deleted a comment from moosebuild Dec 19, 2024
- balance to 1e-8
- error to T_out in analytical solution down to 5e-6
@GiudGiud
Copy link
Contributor Author

GiudGiud commented Dec 24, 2024

I think the transient case should be done in a PR on time integration. As explained in the thread on slack, I dont expect the time derivative discretization rho_new cp_new T_new - rho_new cp_new T_old to be conservative.

I also do not think we would be able to distinguish this time discretization conservation error from the regular order error of a first order time integrator

@GiudGiud GiudGiud marked this pull request as ready for review December 24, 2024 22:25
@lindsayad
Copy link
Member

@freiler @tanoret can one of you review this please?

Copy link
Contributor

@grmnptr grmnptr 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 to me! - did the code review. I think the test cases are also convincing.

INSFVEnergyTimeDerivative should be correct if you pass the new functor to it.
WCNSFVEnergyTimeDerivative should also work I think.

Could you please add a test to verify that they work?

@@ -23,7 +24,7 @@ INSFVEnthalpyFunctorMaterial::validParams()
params.addClassDescription(
"This is the material class used to compute enthalpy for the "
"incompressible/weakly-compressible finite-volume implementation of the Navier-Stokes "
"equations. Note that this class assumes that cp is a constant");
"equations.");
Copy link
Contributor

Choose a reason for hiding this comment

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

With these changes this will look similar to @freiler 's functor material. Do you see value in having only one? Or should we keep two? I think if it can be done cleanly, we should have only one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I havent been keeping track with his PR but I think his functor material might be focusing on computing T from h rather than h from T

Copy link
Contributor

Choose a reason for hiding this comment

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

If the class assumes that cp is constant, please add it to the name of the functormaterial, e.g., INSFVConstantCpEnthalpyFunctorMaterial or something. Otherwise, this is can lead to errors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the assumptions depend on the parameter

addFunctorProperty<ADReal>(
"rho_cp_temp", [&rho_h](const auto & r, const auto & t) -> ADReal { return rho_h(r, t); });
addFunctorProperty<ADReal>(
"rho_cp_temp", [&rho_h](const auto & r, const auto & t) -> ADReal { return rho_h(r, t); });
Copy link
Contributor

Choose a reason for hiding this comment

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

If we are making this more general, I'd not call it rho_cp_temp anymore. Most of the code fetches this under the hood so I hope not a lot of input files need changing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok let's just not define these functors anymore.

added the transient test too

- stop defining cpT and rho cp T functors
- add a transient test
+ add an exception test
Copy link
Contributor

@tanoret tanoret left a comment

Choose a reason for hiding this comment

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

Thank you for the work. I am suggesting a couple of changes in the tests. Please let me know if further clarification is needed for anything. Thanks again!

Real pressure, Real temperature, Real & cp, Real & dcp_dp, Real & dcp_dT) const
{
// Correlation needs pressure in bar
Real pbar = pressure * 10.0e-5;
Copy link
Contributor

Choose a reason for hiding this comment

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

Conversion to bar should be 1e-5 (1 bar = 1e5 Pa)

Copy link
Contributor Author

@GiudGiud GiudGiud Jan 12, 2025

Choose a reason for hiding this comment

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

very true. this is like this in the original property :O ( I copy pasted that line)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

// Halite isobaric heat capacity
cp = 1148.81 + 0.551548 * (Tc - Tt) + 2.64309e-4 * (Tc - Tt) * (Tc - Tt) + r3 * pbar +
r4 * pbar * pbar;
dcp_dp = r3 * 10.e-5 + 2 * r4 * pbar * 10.e-5;
Copy link
Contributor

Choose a reason for hiding this comment

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

Conversion to bar may also be wrong here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

return 1148.81 + 0.551548 * (Tc - Tt) + 2.64309e-4 * (Tc - Tt) * (Tc - Tt) + r3 * pbar +
r4 * pbar * pbar;
}

void
NaClFluidProperties::cp_from_p_T(
Real pressure, Real temperature, Real & cp, Real & dcp_dp, Real & dcp_dT) const
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we please add unit test to compare the computed cp against tabulated values for a few points in the input sapce?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

they already exist, the dependence on pressure is just so small it did not catch it

[]
[T_analytical]
type = Receiver
default = ${fparse (-A_cp+sqrt(A_cp^2-2*B_cp*(-q_source/rho/bulk_u*L-A_cp*T_in-B_cp/2*T_in*T_in)))/B_cp}
Copy link
Contributor

Choose a reason for hiding this comment

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

I verified by hand calculation that this analytical solution is correct. However, please add a couple comments of the steps of the derivation for future reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ramiro did the derivation. @freiler do you want to add that as a suggestion?

@@ -0,0 +1,231 @@
L = 30
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an excellent test! Exactly the kind of things we need. Thank you!

@@ -0,0 +1,101 @@
[Mesh]
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the purpose of this test? Let's compute the enthalpies by hand and compare the code result against the hand calculation. That way we know that things are being done properly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's the original regression test. I ll add the hand calc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done. Had to change to PbBiFPs because Water97 is quite complex in terms of computing a specific fluid property

Comment on lines +252 to +255
[balance_in_percent]
type = ParsedPostprocessor
expression = '(H_out + H_in - Q - Q_wall) / H_in * 100'
pp_names = 'H_in H_out Q Q_wall'
Copy link
Contributor

Choose a reason for hiding this comment

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

This test is currently formulated as a non-regression test. However, this is the only postprocessor that we actually need to check. Let's please compare in the test this pp against 0 with a certain tolerance

Copy link
Contributor Author

Choose a reason for hiding this comment

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

comparing stuff to 0 (or to this small value) makes it awkward with the tolerances (relative does not work). I'd almost want to compare the 4 (far from zero) terms without comparing that one? (though it works right now so no need to change it)

@idaholab idaholab deleted a comment from moosebuild Jan 12, 2025
- rename a boolean
- rename a postprocessor
- fix conversion to bar in NaCl cp computation
- simplify enthalpy computation test to add a "hand" calc of the enthalpy

Co-authored-by: Mauricio Tano <mauriciotano@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants