Skip to content

Commit

Permalink
Address Mauricio's review
Browse files Browse the repository at this point in the history
- 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 <[email protected]>
  • Loading branch information
GiudGiud and tanoret committed Jan 12, 2025
1 parent c9faf9e commit b22431f
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Real
NaClFluidProperties::cp_from_p_T(Real pressure, Real temperature) const
{
// Correlation needs pressure in bar
Real pbar = pressure * 10.0e-5;
Real pbar = pressure * 1.0e-5;
// Correlation requires temperature in Celsius
Real Tc = temperature - _T_c2k;
// Triple point temperature of NaCl (in C)
Expand All @@ -155,7 +155,7 @@ NaClFluidProperties::cp_from_p_T(
Real pressure, Real temperature, Real & cp, Real & dcp_dp, Real & dcp_dT) const
{
// Correlation needs pressure in bar
Real pbar = pressure * 10.0e-5;
Real pbar = pressure * 1.0e-5;
// Correlation requires temperature in Celsius
Real Tc = temperature - _T_c2k;
// Triple point temperature of NaCl (in C)
Expand All @@ -169,7 +169,7 @@ NaClFluidProperties::cp_from_p_T(
// 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;
dcp_dp = r3 * 1.e-5 + 2 * r4 * pbar * 1.e-5;
dcp_dT = 0.551548 + 2 * 2.64309e-4 * (Tc - Tt) + dr3_dT * pbar + dr4_dT * pbar * pbar;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class INSFVEnthalpyFunctorMaterial : public FunctorMaterial

protected:
/// whether we can use a constant cp as a shortcut to compute enthalpy
bool _assume_constant_cp;
bool _assumed_constant_cp;

/// A fluid properties user object to compute enthalpy
const SinglePhaseFluidProperties * _fp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ INSFVEnthalpyFunctorMaterial::validParams()
NS::specific_enthalpy, NS::specific_enthalpy, "the name of the specific enthalpy");

// To handle non constant cp
params.addParam<bool>("assume_constant_cp", true, "Whether to assume cp is constant");
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>(
Expand All @@ -50,7 +50,7 @@ INSFVEnthalpyFunctorMaterial::validParams()

INSFVEnthalpyFunctorMaterial::INSFVEnthalpyFunctorMaterial(const InputParameters & parameters)
: FunctorMaterial(parameters),
_assume_constant_cp(getParam<bool>("assume_constant_cp")),
_assumed_constant_cp(getParam<bool>("assumed_constant_cp")),
_fp(isParamValid(NS::fluid)
? &UserObjectInterface::getUserObject<SinglePhaseFluidProperties>(NS::fluid)
: nullptr),
Expand All @@ -63,15 +63,15 @@ INSFVEnthalpyFunctorMaterial::INSFVEnthalpyFunctorMaterial(const InputParameters
: nullptr)
{
// We have to use a warning because fp is often in the global parameters
if (_assume_constant_cp && _fp)
if (_assumed_constant_cp && _fp)
paramWarning(
"fp", "No need to specify fluid properties if assuming the specific enthalpy is constant");
if (!_assume_constant_cp && ((!_fp || !_pressure) && !_h))
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 (_assume_constant_cp)
if (_assumed_constant_cp)
{
const auto & rho_h =
addFunctorProperty<ADReal>(NS::enthalpy_density,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ advected_interp_method = 'upwind'
rho = 'rho'
cp = 'cp'

assume_constant_cp = false
assumed_constant_cp = false
h_in = 'h'
# Alternative to providing 'h': set the fluid property and the pressure parameter
# fp = 'fp'
# pressure = 'pressure'
[]
Expand Down Expand Up @@ -215,14 +216,14 @@ advected_interp_method = 'upwind'
variable = T
boundary = 'right'
[]
[T_analytical]
[T_analytical_outlet]
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}
[]
[error_T]
type = ParsedPostprocessor
expression = 'T_out - T_analytical'
pp_names = 'T_out T_analytical'
expression = 'T_out - T_analytical_outlet'
pp_names = 'T_out T_analytical_outlet'
[]
[]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ advected_interp_method = 'upwind'
rho = 'rho'
cp = 'cp'

assume_constant_cp = false
assumed_constant_cp = false
h_in = 'h'
# fp = 'fp'
# pressure = 'pressure'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

[FluidProperties]
[fp]
type = Water97FluidProperties
type = LeadBismuthFluidProperties
[]
[]

Expand All @@ -62,7 +62,18 @@
[]
[]

T_mo = 398

[Postprocessors]
[min_T]
type = ElementExtremeFunctorValue
value_type = 'min'
functor = 'T_fluid'
[]
[max_T]
type = ElementExtremeFunctorValue
functor = 'T_fluid'
[]
[min_h]
type = ElementExtremeFunctorValue
value_type = 'min'
Expand All @@ -83,6 +94,22 @@
value_type = 'max'
functor = 'rho_h'
[]
[expected_min_h]
type = ParsedPostprocessor
expression = '164.8 * (min_T - T_mo) - 1.97e-2 * (min_T * min_T - T_mo * T_mo) +
(1.25e-5 / 3) * (min_T * min_T * min_T - T_mo * T_mo * T_mo) + 4.56e+5 * (1. / min_T - 1. / T_mo)'
pp_names = 'min_T'
constant_names = 'T_mo'
constant_expressions = '${T_mo}'
[]
[expected_max_h]
type = ParsedPostprocessor
expression = '164.8 * (max_T - T_mo) - 1.97e-2 * (max_T * max_T - T_mo * T_mo) +
(1.25e-5 / 3) * (max_T * max_T * max_T - T_mo * T_mo * T_mo) + 4.56e+5 * (1. / max_T - 1. / T_mo)'
pp_names = 'max_T'
constant_names = 'T_mo'
constant_expressions = '${T_mo}'
[]
[]


Expand All @@ -94,6 +121,7 @@

[Outputs]
csv = true
hide = 'min_T max_T'
[]

[Problem]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
time,H_in,H_out,Q,T_analytical,T_out,balance_in_percent,error_T
time,H_in,H_out,Q,T_analytical_outlet,T_out,balance_in_percent,error_T
0,0,0,1500000,899.2226858156,0,0,0
1,-24665522.4,26165522.540111,1500000,899.2226858156,899.22268943977,-5.6804577370916e-07,3.6241718817109e-06
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
time,max_h,max_rho_h,min_h,min_rho_h
0,0,0,0,0
0.1,2780642.3501412,404825244.74395,171177.11854132,1611602.983575
time,expected_max_h,expected_min_h,max_h,max_rho_h,min_h,min_rho_h
0,0,0,0,0,0,0
0.1,4144.0087586618,-12492.171943853,4144.0087586619,43570862.298165,-12492.171943853,-133154035.76519
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
time,max_h,max_rho_h,min_h,min_rho_h
0,0,0,0,0
0.1,1577428.5775996,1510770803.1975,786797.01942594,473293.31093746
time,expected_max_h,expected_min_h,max_h,max_rho_h,min_h,min_rho_h
0,0,0,0,0,0,0
0.1,4144.0087586618,-12492.171943853,62950.582764789,661873884.19505,46797.277600637,498812088.35063
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
[transient_using_h]
type = 'Exodiff'
input = 2d-transient.i
cli_args = 'FunctorMaterials/ins_fv/assume_constant_cp=false FunctorMaterials/ins_fv/fp=fp FunctorMaterials/ins_fv/pressure=pressure'
cli_args = 'FunctorMaterials/ins_fv/assumed_constant_cp=false FunctorMaterials/ins_fv/fp=fp FunctorMaterials/ins_fv/pressure=pressure'
exodiff = 2d-transient_out.e
method = "!dbg"
requirement = 'The system shall be able to use realistic fluid properties in a weakly compressible flow simulation'
Expand Down Expand Up @@ -52,7 +52,7 @@
custom_cmp = 'dynamic_pressure.cmp'
prereq = 'neglect_drho_dt_derivatives'
[]
[enthalpy_computation]
[enthalpy_computation_constant_cp]
type = 'CSVDiff'
input = enthalpy_computation.i
csvdiff = enthalpy_computation_out.csv
Expand All @@ -66,7 +66,7 @@
cli_args = "Outputs/file_base=enthalpy_computation_non_constant_cp_out
FunctorMaterials/compute_cp/fp=fp
FunctorMaterials/compute_cp/pressure=pressure
FunctorMaterials/compute_cp/assume_constant_cp=false"
FunctorMaterials/compute_cp/assumed_constant_cp=false"
requirement = 'The system shall be able to compute the specific enthalpy and the enthalpy with a non constant specific heat.'
recover = false
[]
Expand Down Expand Up @@ -97,7 +97,7 @@
[missing_fp]
type = RunException
input = '2d-transient.i'
cli_args = "FunctorMaterials/ins_fv/assume_constant_cp=false"
cli_args = "FunctorMaterials/ins_fv/assumed_constant_cp=false"
expect_err = "Must specify both fluid properties and pressure or an enthalpy functor "
detail = "not enough parameters are specified when defining the enthalpy functor."
[]
Expand Down

0 comments on commit b22431f

Please sign in to comment.