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 support for T_from_p_h in a few fluid properties #29621

Merged
merged 7 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class HelmholtzFluidProperties : public SinglePhaseFluidProperties
virtual Real h_from_p_T(Real pressure, Real temperature) const override;
virtual void h_from_p_T(Real p, Real T, Real & h, Real & dh_dp, Real & dh_dT) const override;

virtual Real T_from_p_h(Real pressure, Real enthalpy) const override;

/**
* Pressure as a function of density and temperature
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,6 @@ class LeadBismuthFluidProperties : public SinglePhaseFluidProperties

private:
/// Melting temperature of 2LiF-BeF2
const Real _T_mo;
static constexpr Real _T_mo = 398.;
};
#pragma GCC diagnostic pop
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,6 @@ class LeadFluidProperties : public SinglePhaseFluidProperties

private:
/// Melting temperature of Lead
const Real _T_mo;
static constexpr Real _T_mo = 600.6;
};
#pragma GCC diagnostic pop
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class StiffenedGasFluidProperties : public SinglePhaseFluidProperties, public Na
propfuncWithDefinitionOverride(s, p, T);
propfuncWithDefinitionOverride(T, v, e);
propfuncWithDefinitionOverride(p, v, e);
propfuncWithDefinitionOverride(T, p, h);
virtual Real e_from_T_v(Real T, Real v) const override;
virtual void e_from_T_v(Real T, Real v, Real & e, Real & de_dT, Real & de_dv) const override;
virtual Real p_from_T_v(Real T, Real v) const override;
Expand Down Expand Up @@ -174,6 +175,23 @@ StiffenedGasFluidProperties::T_from_v_e_template(
dT_de = 1.0 / _cv;
}

template <typename CppType>
CppType
StiffenedGasFluidProperties::T_from_p_h_template(const CppType & /*p*/, const CppType & h) const
{
return (1.0 / _cv) * (h - _q) / _gamma;
}

template <typename CppType>
void
StiffenedGasFluidProperties::T_from_p_h_template(
const CppType & p, const CppType & h, CppType & T, CppType & dT_dp, CppType & dT_dh) const
{
T = T_from_p_h_template(p, h);
dT_dp = 0;
dT_dh = 1.0 / _cv / _gamma;
}

template <typename CppType>
CppType
StiffenedGasFluidProperties::p_from_v_e_template(const CppType & v, const CppType & e) const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ class TabulatedFluidProperties : public SinglePhaseFluidProperties
virtual Real T_from_h_s(Real h, Real s) const;
virtual Real T_from_p_s(Real p, Real s) const;
virtual void T_from_p_s(Real p, Real s, Real & T, Real & dT_dp, Real & dT_ds) const;
virtual Real T_from_h_p(Real h, Real pressure) const override;
virtual Real s_from_v_e(Real v, Real e) const override;
virtual Real s_from_h_p(Real h, Real pressure) const override;
virtual void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,24 @@ HelmholtzFluidProperties::h_from_p_T(
molarMass();
}

Real
HelmholtzFluidProperties::T_from_p_h(Real pressure, Real enthalpy) const
{
auto lambda = [&](Real pressure, Real current_T, Real & new_h, Real & dh_dp, Real & dh_dT)
{ h_from_p_T(pressure, current_T, new_h, dh_dp, dh_dT); };
Real T = FluidPropertiesUtils::NewtonSolve(
pressure, enthalpy, _T_initial_guess, _tolerance, lambda, name() + "::T_from_p_h")
.first;
// check for nans
if (std::isnan(T))
mooseError("Conversion from enthalpy (h = ",
enthalpy,
") and pressure (p = ",
pressure,
") to temperature failed to converge.");
return T;
}

Real
HelmholtzFluidProperties::p_from_rho_T(Real density, Real temperature) const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ InputParameters
LeadBismuthFluidProperties::validParams()
{
InputParameters params = SinglePhaseFluidProperties::validParams();
params.addParam<Real>("T_mo", 398, "Melting Point (K)");
params.addClassDescription("Fluid properties for Lead Bismuth eutectic 2LiF-BeF2");

return params;
}

LeadBismuthFluidProperties::LeadBismuthFluidProperties(const InputParameters & parameters)
: SinglePhaseFluidProperties(parameters), _T_mo(getParam<Real>("T_mo"))
: SinglePhaseFluidProperties(parameters)
{
}

Expand Down Expand Up @@ -329,21 +328,99 @@ LeadBismuthFluidProperties::T_from_p_rho(
}

Real
LeadBismuthFluidProperties::T_from_p_h(Real p, Real h) const
{
auto lambda = [&](Real p, Real current_T, Real & new_h, Real & dh_dp, Real & dh_dT)
{ h_from_p_T(p, current_T, new_h, dh_dp, dh_dT); };
Real T = FluidPropertiesUtils::NewtonSolve(
p, h, _T_initial_guess, _tolerance, lambda, name() + "::T_from_p_h")
.first;
// check for nans
if (std::isnan(T))
mooseError("Conversion from pressure (p = ",
p,
") and enthalpy (h = ",
h,
") to temperature failed to converge.");
return T;
LeadBismuthFluidProperties::T_from_p_h(Real /*p*/, Real h) const
{
// Obtained from sympy solving h(T) with T as a symbol
return -2279.2270619664 *
std::sqrt(
-5.00288972505329e-15 * (283680000.0 * h - 112351848202732.0) /
std::pow(
5.58786624617756e-6 * h +
MathUtils::pow(1.0 - 3.69464146080841e-6 * h, 2) +
std::sqrt(0.755198459604694 *
MathUtils::pow(2.52492508612867e-6 * h - 1.0, 3) +
MathUtils::pow(
-5.58786624617756e-6 * h -
MathUtils::pow(1.0 - 3.69464146080841e-6 * h, 2) +
0.0867667825136797,
2)) -
0.0867667825136797,
1. / 3.) +
0.617230605772255 *
std::pow(
5.58786624617756e-6 * h +
MathUtils::pow(1.0 - 3.69464146080841e-6 * h, 2) +
std::sqrt(0.755198459604694 *
MathUtils::pow(2.52492508612867e-6 * h - 1.0, 3) +
MathUtils::pow(
-5.58786624617756e-6 * h -
MathUtils::pow(1.0 - 3.69464146080841e-6 * h, 2) +
0.0867667825136797,
2)) -
0.0867667825136797,
1. / 3.) -
1.0) +
3223.31382276067 *
std::sqrt(
5.27858159332216e-12 * (129917883803.256 - 480000.0 * h) /
std::sqrt(
-5.00288972505329e-15 * (283680000.0 * h - 112351848202732.0) /
std::pow(
5.58786624617756e-6 * h +
MathUtils::pow(1.0 - 3.69464146080841e-6 * h, 2) +
std::sqrt(
0.755198459604694 *
MathUtils::pow(2.52492508612867e-6 * h - 1.0, 3) +
MathUtils::pow(
-5.58786624617756e-6 * h -
MathUtils::pow(1.0 - 3.69464146080841e-6 * h, 2) +
0.0867667825136797,
2)) -
0.0867667825136797,
1. / 3.) +
0.617230605772255 *
std::pow(
5.58786624617756e-6 * h +
MathUtils::pow(1.0 - 3.69464146080841e-6 * h, 2) +
std::sqrt(
0.755198459604694 *
MathUtils::pow(2.52492508612867e-6 * h - 1.0, 3) +
MathUtils::pow(
-5.58786624617756e-6 * h -
MathUtils::pow(1.0 - 3.69464146080841e-6 * h, 2) +
0.0867667825136797,
2)) -
0.0867667825136797,
1. / 3.) -
1.0) +
2.50144486252665e-15 * (283680000.0 * h - 112351848202732.0) /
std::pow(
5.58786624617756e-6 * h +
MathUtils::pow(1.0 - 3.69464146080841e-6 * h, 2) +
std::sqrt(0.755198459604694 *
MathUtils::pow(2.52492508612867e-6 * h - 1.0, 3) +
MathUtils::pow(
-5.58786624617756e-6 * h -
MathUtils::pow(1.0 - 3.69464146080841e-6 * h, 2) +
0.0867667825136797,
2)) -
0.0867667825136797,
1. / 3.) -
0.308615302886127 *
std::pow(
5.58786624617756e-6 * h +
MathUtils::pow(1.0 - 3.69464146080841e-6 * h, 2) +
std::sqrt(0.755198459604694 *
MathUtils::pow(2.52492508612867e-6 * h - 1.0, 3) +
MathUtils::pow(
-5.58786624617756e-6 * h -
MathUtils::pow(1.0 - 3.69464146080841e-6 * h, 2) +
0.0867667825136797,
2)) -
0.0867667825136797,
1. / 3.) -
1.0) +
1182.0;
}

void
Expand Down
111 changes: 94 additions & 17 deletions modules/fluid_properties/src/fluidproperties/LeadFluidProperties.C
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ InputParameters
LeadFluidProperties::validParams()
{
InputParameters params = SinglePhaseFluidProperties::validParams();
params.addParam<Real>("T_mo", 600.6, "Melting Point (K)");
params.addClassDescription("Fluid properties for Lead");

return params;
}

LeadFluidProperties::LeadFluidProperties(const InputParameters & parameters)
: SinglePhaseFluidProperties(parameters), _T_mo(getParam<Real>("T_mo"))
: SinglePhaseFluidProperties(parameters)
{
}

Expand Down Expand Up @@ -250,21 +249,99 @@ LeadFluidProperties::T_from_v_e(Real v, Real e, Real & T, Real & dT_dv, Real & d
}

Real
LeadFluidProperties::T_from_p_h(Real p, Real h) const
{
auto lambda = [&](Real p, Real current_T, Real & new_h, Real & dh_dp, Real & dh_dT)
{ h_from_p_T(p, current_T, new_h, dh_dp, dh_dT); };
Real T = FluidPropertiesUtils::NewtonSolve(
p, h, _T_initial_guess, _tolerance, lambda, name() + "::T_from_p_h")
.first;
// check for nans
if (std::isnan(T))
mooseError("Conversion from pressure (p = ",
p,
") and enthalpy (h = ",
h,
") to temperature failed to converge.");
return T;
LeadFluidProperties::T_from_p_h(Real /*p*/, Real h) const
{
// Obtained from sympy solving h(T) with T as a symbol
return -2067.9254113598 *
GiudGiud marked this conversation as resolved.
Show resolved Hide resolved
std::sqrt(
-7.36955226020901e-15 * (232320624.378877 * h - 74598764305248.3) /
std::pow(
6.71651186402396e-6 * h +
MathUtils::pow(1.0 - 3.99399123439419e-6 * h, 2) +
std::sqrt(0.702754599548161 *
MathUtils::pow(3.11426907057403e-6 * h - 1.0, 3) +
MathUtils::pow(
-6.71651186402396e-6 * h -
MathUtils::pow(1.0 - 3.99399123439419e-6 * h, 2) +
0.0419568962265043,
2)) -
0.0419568962265043,
1. / 3.) +
0.61835541884035 *
std::pow(
6.71651186402396e-6 * h +
MathUtils::pow(1.0 - 3.99399123439419e-6 * h, 2) +
std::sqrt(0.702754599548161 *
MathUtils::pow(3.11426907057403e-6 * h - 1.0, 3) +
MathUtils::pow(
-6.71651186402396e-6 * h -
MathUtils::pow(1.0 - 3.99399123439419e-6 * h, 2) +
0.0419568962265043,
2)) -
0.0419568962265043,
1. / 3.) -
1.0) +
2924.48816272099 *
std::sqrt(
7.0676560676229e-12 * (97296416908.1661 - 388601.036269178 * h) /
std::sqrt(
-7.36955226020901e-15 * (232320624.378877 * h - 74598764305248.3) /
std::pow(
6.71651186402396e-6 * h +
MathUtils::pow(1.0 - 3.99399123439419e-6 * h, 2) +
std::sqrt(
0.702754599548161 *
MathUtils::pow(3.11426907057403e-6 * h - 1.0, 3) +
MathUtils::pow(
-6.71651186402396e-6 * h -
MathUtils::pow(1.0 - 3.99399123439419e-6 * h, 2) +
0.0419568962265043,
2)) -
0.0419568962265043,
1. / 3.) +
0.61835541884035 *
std::pow(
6.71651186402396e-6 * h +
MathUtils::pow(1.0 - 3.99399123439419e-6 * h, 2) +
std::sqrt(
0.702754599548161 *
MathUtils::pow(3.11426907057403e-6 * h - 1.0, 3) +
MathUtils::pow(
-6.71651186402396e-6 * h -
MathUtils::pow(1.0 - 3.99399123439419e-6 * h, 2) +
0.0419568962265043,
2)) -
0.0419568962265043,
1. / 3.) -
1.0) +
3.6847761301045e-15 * (232320624.378877 * h - 74598764305248.3) /
std::pow(
6.71651186402396e-6 * h +
MathUtils::pow(1.0 - 3.99399123439419e-6 * h, 2) +
std::sqrt(0.702754599548161 *
MathUtils::pow(3.11426907057403e-6 * h - 1.0, 3) +
MathUtils::pow(
-6.71651186402396e-6 * h -
MathUtils::pow(1.0 - 3.99399123439419e-6 * h, 2) +
0.0419568962265043,
2)) -
0.0419568962265043,
1. / 3.) -
0.309177709420175 *
std::pow(
6.71651186402396e-6 * h +
MathUtils::pow(1.0 - 3.99399123439419e-6 * h, 2) +
std::sqrt(0.702754599548161 *
MathUtils::pow(3.11426907057403e-6 * h - 1.0, 3) +
MathUtils::pow(
-6.71651186402396e-6 * h -
MathUtils::pow(1.0 - 3.99399123439419e-6 * h, 2) +
0.0419568962265043,
2)) -
0.0419568962265043,
1. / 3.) -
1.0) +
1195.67681347073;
}

void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,31 @@ StiffenedGasFluidProperties::T_from_v_e(
T_from_v_e_template(v, e, p, dp_dv, dp_de);
}

Real
StiffenedGasFluidProperties::T_from_p_h(Real v, Real e) const
{
return T_from_p_h_template(v, e);
}

void
StiffenedGasFluidProperties::T_from_p_h(Real v, Real e, Real & T, Real & dT_dv, Real & dT_de) const
{
T_from_p_h_template(v, e, T, dT_dv, dT_de);
}

ADReal
StiffenedGasFluidProperties::T_from_p_h(const ADReal & v, const ADReal & e) const
{
return T_from_p_h_template(v, e);
}

void
StiffenedGasFluidProperties::T_from_p_h(
const ADReal & v, const ADReal & e, ADReal & p, ADReal & dp_dv, ADReal & dp_de) const
{
T_from_p_h_template(v, e, p, dp_dv, dp_de);
}

Real
StiffenedGasFluidProperties::c_from_v_e(Real v, Real e) const
{
Expand Down
Loading