-
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?
Changes from all commits
c4dbe49
02dc1c9
4c3f05c
fb7cf27
5b7a658
367bbf8
c9faf9e
b22431f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
|
||
#include "INSFVEnthalpyFunctorMaterial.h" | ||
#include "NS.h" | ||
#include "SinglePhaseFluidProperties.h" | ||
|
||
registerMooseObjectRenamed("NavierStokesApp", | ||
INSFVEnthalpyMaterial, | ||
|
@@ -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 commentThe 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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. the assumptions depend on the parameter |
||
params.addRequiredParam<MooseFunctorName>(NS::density, "The value for the density"); | ||
params.addRequiredParam<MooseFunctorName>("temperature", "the temperature"); | ||
params.addParam<MooseFunctorName>( | ||
|
@@ -32,31 +33,92 @@ INSFVEnthalpyFunctorMaterial::validParams() | |
NS::enthalpy_density, NS::enthalpy_density, "the name of the (extensive) enthalpy"); | ||
params.addParam<MooseFunctorName>( | ||
NS::specific_enthalpy, NS::specific_enthalpy, "the name of the specific enthalpy"); | ||
|
||
// To handle non constant cp | ||
params.addParam<bool>("assumed_constant_cp", true, "Whether to assume cp is constant"); | ||
params.addParam<UserObjectName>( | ||
NS::fluid, "Fluid properties, to be used when cp is not constant to compute enthalpy"); | ||
params.addParam<MooseFunctorName>( | ||
NS::pressure, "Pressure functor, to be used when cp is not constant to compute enthalpy"); | ||
params.addParam<MooseFunctorName>( | ||
NS::specific_enthalpy + "_in", | ||
"Specific enthalpy functor, to be used when cp is not constant to compute the enthalpy, as " | ||
"an alternative to using a 'fp' FluidProperties object"); | ||
|
||
return params; | ||
} | ||
|
||
INSFVEnthalpyFunctorMaterial::INSFVEnthalpyFunctorMaterial(const InputParameters & parameters) | ||
: FunctorMaterial(parameters), | ||
_assumed_constant_cp(getParam<bool>("assumed_constant_cp")), | ||
_fp(isParamValid(NS::fluid) | ||
? &UserObjectInterface::getUserObject<SinglePhaseFluidProperties>(NS::fluid) | ||
: nullptr), | ||
_rho(getFunctor<ADReal>(NS::density)), | ||
_temperature(getFunctor<ADReal>("temperature")), | ||
_cp(getFunctor<ADReal>(NS::cp)) | ||
_pressure(isParamValid("pressure") ? &getFunctor<ADReal>("pressure") : nullptr), | ||
_cp(getFunctor<ADReal>(NS::cp)), | ||
_h(isParamValid(NS::specific_enthalpy + "_in") | ||
? &getFunctor<ADReal>(NS::specific_enthalpy + "_in") | ||
: nullptr) | ||
{ | ||
const auto & rho_h = | ||
addFunctorProperty<ADReal>(NS::enthalpy_density, | ||
[this](const auto & r, const auto & t) | ||
{ return _rho(r, t) * _cp(r, t) * _temperature(r, t); }); | ||
// We have to use a warning because fp is often in the global parameters | ||
if (_assumed_constant_cp && _fp) | ||
paramWarning( | ||
"fp", "No need to specify fluid properties if assuming the specific enthalpy is constant"); | ||
if (!_assumed_constant_cp && ((!_fp || !_pressure) && !_h)) | ||
paramError("fp", | ||
"Must specify both fluid properties and pressure or an enthalpy functor if not " | ||
"assuming the specific enthalpy is constant"); | ||
|
||
if (_assumed_constant_cp) | ||
{ | ||
const auto & rho_h = | ||
addFunctorProperty<ADReal>(NS::enthalpy_density, | ||
[this](const auto & r, const auto & t) | ||
{ return _rho(r, t) * _cp(r, t) * _temperature(r, t); }); | ||
|
||
const auto & h = addFunctorProperty<ADReal>(NS::specific_enthalpy, | ||
[this](const auto & r, const auto & t) | ||
{ return _cp(r, t) * _temperature(r, t); }); | ||
|
||
addFunctorProperty<ADReal>(NS::time_deriv(getParam<MooseFunctorName>(NS::specific_enthalpy)), | ||
[this](const auto & r, const auto & t) | ||
{ return _cp(r, t) * _temperature.dot(r, t); }); | ||
|
||
addFunctorProperty<ADReal>( | ||
"rho_cp_temp", [&rho_h](const auto & r, const auto & t) -> ADReal { return rho_h(r, t); }); | ||
|
||
const auto & h = addFunctorProperty<ADReal>(NS::specific_enthalpy, | ||
[this](const auto & r, const auto & t) | ||
{ return _cp(r, t) * _temperature(r, t); }); | ||
addFunctorProperty<ADReal>("cp_temp", | ||
[&h](const auto & r, const auto & t) -> ADReal { return h(r, t); }); | ||
} | ||
else if (_h) | ||
{ | ||
addFunctorProperty<ADReal>(NS::enthalpy_density, | ||
[this](const auto & r, const auto & t) | ||
{ return _rho(r, t) * (*_h)(r, t); }); | ||
|
||
addFunctorProperty<ADReal>(NS::time_deriv(getParam<MooseFunctorName>(NS::specific_enthalpy)), | ||
[this](const auto & r, const auto & t) | ||
{ return _cp(r, t) * _temperature.dot(r, t); }); | ||
addFunctorProperty<ADReal>(NS::time_deriv(getParam<MooseFunctorName>(NS::specific_enthalpy)), | ||
[this](const auto & r, const auto & t) { return _h->dot(r, t); }); | ||
} | ||
else | ||
{ | ||
addFunctorProperty<ADReal>( | ||
NS::enthalpy_density, | ||
[this](const auto & r, const auto & t) | ||
{ return _rho(r, t) * _fp->h_from_p_T((*_pressure)(r, t), _temperature(r, t)); }); | ||
|
||
addFunctorProperty<ADReal>( | ||
"rho_cp_temp", [&rho_h](const auto & r, const auto & t) -> ADReal { return rho_h(r, t); }); | ||
addFunctorProperty<ADReal>(NS::specific_enthalpy, | ||
[this](const auto & r, const auto & t) | ||
{ return _fp->h_from_p_T((*_pressure)(r, t), _temperature(r, t)); }); | ||
|
||
addFunctorProperty<ADReal>("cp_temp", | ||
[&h](const auto & r, const auto & t) -> ADReal { return h(r, t); }); | ||
addFunctorProperty<ADReal>( | ||
NS::time_deriv(getParam<MooseFunctorName>(NS::specific_enthalpy)), | ||
[this](const auto & r, const auto & t) | ||
{ | ||
Real h, dh_dp, dh_dT; | ||
_fp->h_from_p_T((*_pressure)(r, t).value(), _temperature(r, t).value(), h, dh_dp, dh_dT); | ||
return dh_dT * _temperature.dot(r, t) + dh_dp * _pressure->dot(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.
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