-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
base: next
Are you sure you want to change the base?
Conversation
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! |
Please add the same tests than for the linear problem:
Thank you! |
we should be good for this one
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. |
bb2c1a6
to
ac93fc1
Compare
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. |
ac93fc1
to
c488692
Compare
@freiler do you want to test this PR to provide 1 and 2? Or should I use your inputs? |
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. |
Job Coverage, step Generate coverage on b22431f wanted to post the following: Framework coverageCoverage did not change Modules coverageFluid properties
Navier stokes
Full coverage reportsReports
This comment will be updated on new commits. |
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. |
0a0aa7d
to
f0a01b1
Compare
f0a01b1
to
97db47a
Compare
97db47a
to
d0d9f2f
Compare
d0d9f2f
to
4d8a100
Compare
- balance to 1e-8 - error to T_out in analytical solution down to 5e-6
6879736
to
5b7a658
Compare
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 |
76e7282
to
367bbf8
Compare
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.
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."); |
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.
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.
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.
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
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.
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
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.
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); }); |
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.
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.
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.
will do
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.
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
dfcac83
to
c9faf9e
Compare
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.
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; |
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.
Conversion to bar should be 1e-5 (1 bar = 1e5 Pa)
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.
very true. this is like this in the original property :O ( I copy pasted that line)
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.
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; |
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.
Conversion to bar may also be wrong here
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.
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 |
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.
Could we please add unit test to compare the computed cp against tabulated values for a few points in the input sapce?
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.
they already exist, the dependence on pressure is just so small it did not catch it
modules/navier_stokes/include/functormaterials/INSFVEnthalpyFunctorMaterial.h
Outdated
Show resolved
Hide resolved
modules/navier_stokes/src/functormaterials/INSFVEnthalpyFunctorMaterial.C
Outdated
Show resolved
Hide resolved
modules/navier_stokes/test/tests/finite_volume/wcns/materials/1d_test_cpT.i
Outdated
Show resolved
Hide resolved
[] | ||
[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} |
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.
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.
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.
Ramiro did the derivation. @freiler do you want to add that as a suggestion?
@@ -0,0 +1,231 @@ | |||
L = 30 |
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.
This is an excellent test! Exactly the kind of things we need. Thank you!
@@ -0,0 +1,101 @@ | |||
[Mesh] |
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.
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
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.
it's the original regression test. I ll add the hand calc
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.
done. Had to change to PbBiFPs because Water97 is quite complex in terms of computing a specific fluid property
[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' |
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.
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
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.
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)
modules/navier_stokes/test/tests/finite_volume/wcns/materials/1d_test_cpT.i
Show resolved
Hide resolved
modules/navier_stokes/test/tests/finite_volume/wcns/materials/1d_test_cpT.i
Outdated
Show resolved
Hide resolved
modules/navier_stokes/test/tests/finite_volume/wcns/materials/2d-steady-wall-balance.i
Outdated
Show resolved
Hide resolved
modules/navier_stokes/test/tests/finite_volume/wcns/materials/tests
Outdated
Show resolved
Hide resolved
modules/navier_stokes/test/tests/finite_volume/wcns/materials/tests
Outdated
Show resolved
Hide resolved
modules/navier_stokes/test/tests/finite_volume/wcns/materials/gold/1d_test_cpT_out.csv
Outdated
Show resolved
Hide resolved
- 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>
f73eb16
to
b22431f
Compare
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