LCOV - code coverage report
Current view: top level - src/fluidproperties - PBSodiumFluidProperties.C (source / functions) Hit Total Coverage
Test: idaholab/moose subchannel: #33187 (5aa0b2) with base d7c4bd Lines: 76 87 87.4 %
Date: 2026-06-30 12:24:57 Functions: 15 15 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 "PBSodiumFluidProperties.h"
      11             : 
      12             : registerMooseObject("SubChannelApp", PBSodiumFluidProperties);
      13             : 
      14             : // Use the array to initialize the const static vector
      15             : const Real sodium_T[] = {
      16             :     388.15,  398.15,  408.15,  418.15,  428.15,  438.15,  448.15,  458.15,  468.15,  478.15,
      17             :     488.15,  498.15,  508.15,  518.15,  528.15,  538.15,  548.15,  558.15,  568.15,  578.15,
      18             :     588.15,  598.15,  608.15,  618.15,  628.15,  638.15,  648.15,  658.15,  668.15,  678.15,
      19             :     688.15,  698.15,  708.15,  718.15,  728.15,  738.15,  748.15,  758.15,  768.15,  778.15,
      20             :     788.15,  798.15,  808.15,  818.15,  828.15,  838.15,  848.15,  858.15,  868.15,  878.15,
      21             :     888.15,  898.15,  908.15,  918.15,  928.15,  938.15,  948.15,  958.15,  968.15,  978.15,
      22             :     988.15,  998.15,  1008.15, 1018.15, 1028.15, 1038.15, 1048.15, 1058.15, 1068.15, 1078.15,
      23             :     1088.15, 1098.15, 1108.15, 1118.15, 1128.15, 1138.15, 1148.15};
      24             : // sodium temperature vector corresponding to _e_vec enthalpy vector
      25             : const std::vector<Real>
      26             :     PBSodiumFluidProperties::_temperature_vec(sodium_T,
      27             :                                               sodium_T + sizeof(sodium_T) / sizeof(sodium_T[0]));
      28             : 
      29             : const Real sodium_e[] = {
      30             :     492755,      505884,      518995,      532089,      545166,      558227,      571270,
      31             :     584298,      597309,      610305,      623286,      636252,      649203,      662139,
      32             :     675061,      687970,      700865,      713747,      726616,      739472,      752316,
      33             :     765148,      777969,      790778,      803576,      816363,      829140,      841907,
      34             :     854665,      867413,      880151,      892882,      905603,      918317,      931023,
      35             :     943721,      956412,      969097,      981775,      994447,      1.00711e+06, 1.01977e+06,
      36             :     1.03243e+06, 1.04508e+06, 1.05773e+06, 1.07037e+06, 1.08301e+06, 1.09565e+06, 1.10828e+06,
      37             :     1.12091e+06, 1.13354e+06, 1.14617e+06, 1.15879e+06, 1.17142e+06, 1.18404e+06, 1.19667e+06,
      38             :     1.20929e+06, 1.22191e+06, 1.23454e+06, 1.24717e+06, 1.25979e+06, 1.27243e+06, 1.28506e+06,
      39             :     1.29769e+06, 1.31033e+06, 1.32298e+06, 1.33562e+06, 1.34828e+06, 1.36093e+06, 1.3736e+06,
      40             :     1.38626e+06, 1.39894e+06, 1.41162e+06, 1.42431e+06, 1.43701e+06, 1.44971e+06, 1.46243e+06};
      41             : // sodium enthalpy vector corresponding to _temperature_vec temperature vector
      42             : const std::vector<Real>
      43             :     PBSodiumFluidProperties::_e_vec(sodium_e, sodium_e + sizeof(sodium_e) / sizeof(sodium_e[0]));
      44             : 
      45             : InputParameters
      46         247 : PBSodiumFluidProperties::validParams()
      47             : {
      48         247 :   InputParameters params = SinglePhaseFluidProperties::validParams();
      49         494 :   params.addParam<Real>("p_0", 1.e5, "Reference pressure");
      50         247 :   params.addClassDescription(
      51             :       "Class that provides the methods that realize the equations of state for Liquid Sodium");
      52         247 :   return params;
      53           0 : }
      54             : 
      55         131 : PBSodiumFluidProperties::PBSodiumFluidProperties(const InputParameters & parameters)
      56         262 :   : SinglePhaseFluidProperties(parameters), _p_0(getParam<Real>("p_0"))
      57             : {
      58         131 :   _H0 = cp_from_p_T(_p_0, _T0) * _T0;
      59             :   // Evaluate cp at the heat-capacity correlation bounds (cp_from_p_T clamps to this range), so the
      60             :   // precomputed boundary values do not raise spurious invalid-solution flags during construction.
      61         131 :   _Cp_Tmax = cp_from_p_T(_p_0, _Tmax_cp_k);
      62         131 :   _Cp_Tmin = cp_from_p_T(_p_0, _Tmin_cp_k);
      63         131 :   _H_Tmax = h_from_p_T(_p_0, _Tmax);
      64         131 :   _H_Tmin = h_from_p_T(_p_0, _Tmin);
      65         131 : }
      66             : 
      67             : Real
      68     2785873 : PBSodiumFluidProperties::rho_from_p_T(Real /*pressure*/, Real temperature) const
      69             : {
      70             :   Real A12 = 1.00423e3;
      71             :   Real A13 = -0.21390;
      72             :   Real A14 = -1.1046e-5;
      73     2785873 :   return (A12 + A13 * temperature + A14 * temperature * temperature);
      74             : }
      75             : 
      76             : void
      77           1 : PBSodiumFluidProperties::rho_from_p_T(
      78             :     Real pressure, Real temperature, Real & rho, Real & drho_dp, Real & drho_dT) const
      79             : {
      80           1 :   rho = rho_from_p_T(pressure, temperature);
      81           1 :   drho_dp = 0;
      82             :   Real A13 = -0.21390;
      83             :   Real A14 = -1.1046e-5;
      84           1 :   drho_dT = (A13 + 2.0 * A14 * temperature);
      85           1 : }
      86             : 
      87             : Real
      88      371729 : PBSodiumFluidProperties::h_from_p_T(Real /*pressure*/, Real temperature) const
      89             : {
      90      371729 :   if (temperature > _Tmax + 1.e-3)
      91             :   {
      92           0 :     flagInvalidSolution(
      93             :         "Temperature above the valid range for the sodium enthalpy computation; extrapolating");
      94           0 :     return _H_Tmax + _Cp_Tmax * (temperature - _Tmax);
      95             :   }
      96      371729 :   else if (temperature < _Tmin - 1.e-3)
      97             :   {
      98           0 :     flagInvalidSolution(
      99             :         "Temperature below the valid range for the sodium enthalpy computation; extrapolating");
     100           0 :     return _H_Tmin + _Cp_Tmin * (temperature - _Tmin);
     101             :   }
     102             :   else
     103      371729 :     return _H0 + F_enthalpy(temperature) - F_enthalpy(_T0);
     104             : }
     105             : 
     106             : Real
     107           1 : PBSodiumFluidProperties::beta_from_p_T(Real /*pressure*/, Real temperature) const
     108             : {
     109             :   Real A42 = 2.5156e-6;
     110             :   Real A43 = 0.79919;
     111             :   Real A44 = -6.9716e2;
     112             :   Real A45 = 3.3140e5;
     113             :   Real A46 = -7.0502e7;
     114             :   Real A47 = 5.4920e9;
     115           1 :   Real dt = 2503.3 - temperature;
     116           1 :   return (A42 + A43 / dt + A44 / dt / dt + A45 / (dt * dt * dt) + A46 / (dt * dt * dt * dt) +
     117           1 :           A47 / (dt * dt * dt * dt * dt));
     118             : }
     119             : 
     120             : Real
     121           1 : PBSodiumFluidProperties::cv_from_p_T(Real pressure, Real temperature) const
     122             : {
     123             :   // Consistent with SAM model cv is assumed to be equal to cp
     124             :   // cv is currentl not being used in subchannel algorithm.
     125           1 :   return cp_from_p_T(pressure, temperature);
     126             : }
     127             : 
     128             : Real
     129    23111894 : PBSodiumFluidProperties::cp_from_p_T(Real /*pressure*/, Real temperature) const
     130             : {
     131    23111894 :   if (temperature < _Tmin_cp_k)
     132             :   {
     133           0 :     temperature = _Tmin_cp_k;
     134           0 :     flagInvalidSolution(
     135             :         "Temperature below the valid range [388.15, 1148.15] K for the sodium heat capacity "
     136             :         "computation");
     137             :   }
     138    23111894 :   if (temperature > _Tmax_cp_k)
     139             :   {
     140      128664 :     temperature = _Tmax_cp_k;
     141      128667 :     flagInvalidSolution(
     142             :         "Temperature above the valid range [388.15, 1148.15] K for the sodium heat capacity "
     143             :         "computation");
     144             :   }
     145    23111894 :   temperature = temperature_correction(temperature);
     146             :   Real A28 = 7.3898e5;
     147             :   Real A29 = 3.154e5;
     148             :   Real A30 = 1.1340e3;
     149             :   Real A31 = -2.2153e-1;
     150             :   Real A32 = 1.1156e-4;
     151    23111894 :   Real dt = 2503.3 - temperature;
     152    23111894 :   return (A28 / dt / dt + A29 / dt + A30 + A31 * dt + A32 * dt * dt);
     153             : }
     154             : 
     155             : void
     156           1 : PBSodiumFluidProperties::cp_from_p_T(
     157             :     Real pressure, Real temperature, Real & cp, Real & dcp_dp, Real & dcp_dT) const
     158             : {
     159           1 :   cp = cp_from_p_T(pressure, temperature);
     160           1 :   dcp_dp = 0;
     161             :   Real A28 = 7.3898e5;
     162             :   Real A29 = 3.154e5;
     163             :   Real A31 = -2.2153e-1;
     164             :   Real A32 = 1.1156e-4;
     165           1 :   Real dt = 2503.3 - temperature;
     166           1 :   if (temperature < _Tmax && temperature > _Tmin)
     167           1 :     dcp_dT = (2 * A28 / dt / dt / dt + A29 / dt / dt - A31 - 2 * A32 * dt);
     168             :   else
     169           0 :     dcp_dT = 0.;
     170           1 : }
     171             : 
     172             : Real
     173     2785867 : PBSodiumFluidProperties::mu_from_p_T(Real /*pressure*/, Real temperature) const
     174             : {
     175             :   Real A52 = 3.6522e-5;
     176             :   Real A53 = 0.16626;
     177             :   Real A54 = -4.56877e1;
     178             :   Real A55 = 2.8733e4;
     179     2785867 :   return (A52 + A53 / temperature + A54 / temperature / temperature +
     180     2785867 :           A55 / (temperature * temperature * temperature));
     181             : }
     182             : 
     183             : Real
     184           1 : PBSodiumFluidProperties::mu_from_rho_T(Real /*rho*/, Real temperature) const
     185             : {
     186             :   Real A52 = 3.6522e-5;
     187             :   Real A53 = 0.16626;
     188             :   Real A54 = -4.56877e1;
     189             :   Real A55 = 2.8733e4;
     190           1 :   return (A52 + A53 / temperature + A54 / temperature / temperature +
     191           1 :           A55 / (temperature * temperature * temperature));
     192             : }
     193             : 
     194             : Real
     195    23140834 : PBSodiumFluidProperties::k_from_p_T(Real /*pressure*/, Real temperature) const
     196             : {
     197    23140834 :   if (temperature < _Tmin_cp_k)
     198             :   {
     199             :     temperature = _Tmin_cp_k;
     200           0 :     flagInvalidSolution(
     201             :         "Temperature below the valid range [388.15, 1148.15] K for the sodium thermal "
     202             :         "conductivity computation");
     203             :   }
     204    23140834 :   if (temperature > _Tmax_cp_k)
     205             :   {
     206             :     temperature = _Tmax_cp_k;
     207      128667 :     flagInvalidSolution(
     208             :         "Temperature above the valid range [388.15, 1148.15] K for the sodium thermal "
     209             :         "conductivity computation");
     210             :   }
     211             :   Real A48 = 1.1045e2;
     212             :   Real A49 = -6.5112e-2;
     213             :   Real A50 = 1.5430e-5;
     214             :   Real A51 = -2.4617e-9;
     215    23140834 :   return (A48 + A49 * temperature + A50 * temperature * temperature +
     216    23140834 :           A51 * temperature * temperature * temperature);
     217             : }
     218             : 
     219             : Real
     220      743458 : PBSodiumFluidProperties::F_enthalpy(Real temperature) const
     221             : {
     222             :   Real A28 = 7.3898e5;
     223             :   Real A29 = 3.154e5;
     224             :   Real A30 = 1.1340e3;
     225             :   Real A31 = -2.2153e-1;
     226             :   Real A32 = 1.1156e-4;
     227      743458 :   Real dt = 2503.3 - temperature;
     228             : 
     229      743458 :   return -(-A28 / dt + A29 * std::log(dt) + A30 * dt + 0.5 * A31 * dt * dt +
     230      743458 :            1.0 / 3 * A32 * dt * dt * dt);
     231             : }
     232             : 
     233             : Real
     234    23111894 : PBSodiumFluidProperties::temperature_correction(Real & temperature) const
     235             : {
     236    23111894 :   if (temperature > _Tmax)
     237             :     return _Tmax;
     238    23111894 :   else if (temperature < _Tmin)
     239             :     return _Tmin;
     240             :   else
     241    23111894 :     return temperature;
     242             : }
     243             : 
     244             : Real
     245     2396838 : PBSodiumFluidProperties::T_from_p_h(Real /*pressure*/, Real enthalpy) const
     246             : {
     247             :   // the algorithm were made fully compliant with the enthalpy correlations above.
     248             :   // Consistent with the approach in SAM, it ignores that sodium boiling.
     249             :   // This part will be revisited in future.
     250             :   Real temperature = 0;
     251     2396838 :   if (enthalpy > _H_Tmax)
     252             :   {
     253       22683 :     flagInvalidSolution(
     254             :         "Enthalpy above the valid range for the sodium temperature computation; extrapolating");
     255       22680 :     temperature = (enthalpy - _H_Tmax) / _Cp_Tmax + _Tmax;
     256             :   }
     257     2374158 :   else if (enthalpy < _H_Tmin)
     258             :   {
     259           0 :     flagInvalidSolution(
     260             :         "Enthalpy below the valid range for the sodium temperature computation; extrapolating");
     261           0 :     temperature = (enthalpy - _H_Tmin) / _Cp_Tmin + _Tmin;
     262             :   }
     263             :   else
     264             :   {
     265    73724355 :     for (unsigned int i = 0; i < _e_vec.size() - 1; i++)
     266             :     {
     267    73724355 :       if (enthalpy > _e_vec[i] && enthalpy <= _e_vec[i + 1])
     268             :       {
     269     2374158 :         temperature = _temperature_vec[i] + (enthalpy - _e_vec[i]) / (_e_vec[i + 1] - _e_vec[i]) *
     270     2374158 :                                                 (_temperature_vec[i + 1] - _temperature_vec[i]);
     271     2374158 :         break;
     272             :       }
     273             :     }
     274             :   }
     275     2396838 :   return temperature;
     276             : }

Generated by: LCOV version 1.14