LCOV - code coverage report
Current view: top level - src/materials - ADWallHeatTransferCoefficientGnielinskiMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 35 36 97.2 %
Date: 2025-07-30 13:02:48 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : #include "ADWallHeatTransferCoefficientGnielinskiMaterial.h"
      11             : #include "SinglePhaseFluidProperties.h"
      12             : #include "FlowModelSinglePhase.h"
      13             : #include "Numerics.h"
      14             : 
      15             : registerMooseObject("ThermalHydraulicsApp", ADWallHeatTransferCoefficientGnielinskiMaterial);
      16             : 
      17             : InputParameters
      18         192 : ADWallHeatTransferCoefficientGnielinskiMaterial::validParams()
      19             : {
      20         192 :   InputParameters params = Material::validParams();
      21         384 :   params.addParam<MaterialPropertyName>("Hw",
      22             :                                         FlowModelSinglePhase::HEAT_TRANSFER_COEFFICIENT_WALL,
      23             :                                         "Heat transfer coefficient material property");
      24         384 :   params.addParam<MaterialPropertyName>(
      25             :       "rho", FlowModelSinglePhase::DENSITY, "Density of the fluid");
      26         384 :   params.addParam<MaterialPropertyName>("vel", FlowModelSinglePhase::VELOCITY, "Fluid velocity");
      27         384 :   params.addParam<MaterialPropertyName>(
      28             :       "D_h", FlowModelSinglePhase::HYDRAULIC_DIAMETER, "Hydraulic diameter");
      29         384 :   params.addParam<MaterialPropertyName>(
      30             :       "cp", FlowModelSinglePhase::SPECIFIC_HEAT_CONSTANT_PRESSURE, "Specific heat of the fluid");
      31         384 :   params.addParam<MaterialPropertyName>(
      32             :       "mu", FlowModelSinglePhase::DYNAMIC_VISCOSITY, "Dynamic viscosity of the fluid");
      33         384 :   params.addParam<MaterialPropertyName>(
      34             :       "k", FlowModelSinglePhase::THERMAL_CONDUCTIVITY, "Heat conductivity of the fluid");
      35         384 :   params.addParam<MaterialPropertyName>(
      36             :       "T", FlowModelSinglePhase::TEMPERATURE, "Fluid temperature");
      37         384 :   params.addParam<MaterialPropertyName>("T_wall", FlowModel::TEMPERATURE_WALL, "Wall temperature");
      38         192 :   params.addClassDescription("Computes wall heat transfer coefficient for gases and water using "
      39             :                              "the Gnielinski correlation");
      40         192 :   return params;
      41           0 : }
      42             : 
      43         150 : ADWallHeatTransferCoefficientGnielinskiMaterial::ADWallHeatTransferCoefficientGnielinskiMaterial(
      44         150 :     const InputParameters & parameters)
      45             :   : Material(parameters),
      46         150 :     _Hw(declareADProperty<Real>("Hw")),
      47         300 :     _rho(getADMaterialProperty<Real>("rho")),
      48         300 :     _vel(getADMaterialProperty<Real>("vel")),
      49         300 :     _D_h(getADMaterialProperty<Real>("D_h")),
      50         300 :     _k(getADMaterialProperty<Real>("k")),
      51         300 :     _mu(getADMaterialProperty<Real>("mu")),
      52         300 :     _cp(getADMaterialProperty<Real>("cp")),
      53         300 :     _T(getADMaterialProperty<Real>("T")),
      54         450 :     _T_wall(getADMaterialProperty<Real>("T_wall"))
      55             : {
      56         150 : }
      57             : 
      58             : void
      59        4293 : ADWallHeatTransferCoefficientGnielinskiMaterial::computeQpProperties()
      60             : {
      61        4293 :   ADReal Pr = THM::Prandtl(_cp[_qp], _mu[_qp], _k[_qp]);
      62        4293 :   ADReal Re = std::max(1.0, THM::Reynolds(1., _rho[_qp], _vel[_qp], _D_h[_qp], _mu[_qp]));
      63             : 
      64        4293 :   if (Re < 2300 || Re > 5E+6 || Pr < 0.5 || Pr > 2000)
      65             :   {
      66           4 :     mooseDoOnce(mooseWarning(
      67             :         "The Gnielinski correlation is valid when Pr is between 0.5 and 2000, and Re is "
      68             :         "between 2300 and 5000000.  Be aware that using values out of this range may lead to "
      69             :         "significant errors in your results!"));
      70             :   }
      71             : 
      72        8578 :   ADReal f = std::pow(1.82 * std::log10(Re) - 1.64, -2.0);
      73        4289 :   ADReal Nu = ((f / 8.0) * std::max(0.0, Re - 1000.0) * Pr) /
      74       17156 :               (1.0 + 12.7 * std::sqrt(f / 8.0) * (std::pow(Pr, 2.0 / 3.0) - 1.0));
      75        4289 :   _Hw[_qp] = THM::wallHeatTransferCoefficient(Nu, _k[_qp], _D_h[_qp]);
      76        4289 : }

Generated by: LCOV version 1.14