LCOV - code coverage report
Current view: top level - include/fluidproperties - SodiumProperties.h (source / functions) Hit Total Coverage
Test: idaholab/moose fluid_properties: #31405 (292dce) with base fef103 Lines: 26 26 100.0 %
Date: 2025-09-04 07:53:14 Functions: 5 5 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             : #pragma once
      11             : 
      12             : #include "FluidProperties.h"
      13             : 
      14             : /**
      15             :  * Properties of liquid sodium from ANL/RE-95/2 report "Thermodynamic and Transport Properties of
      16             :  * Sodium Liquid and Vapor" from ANL Reactor Engineering Division.
      17             :  */
      18             : class SodiumProperties : public FluidProperties
      19             : {
      20             : 
      21             : public:
      22             :   static InputParameters validParams();
      23             : 
      24             :   SodiumProperties(const InputParameters & parameters);
      25             : 
      26             :   /**
      27             :    * Thermal conductivity as a function of temperature. From page 181. Valid from 371 to 1500 K.
      28             :    * @param T temperature in K
      29             :    * @return Thermal conductivity of liquid sodium in W/m/K
      30             :    */
      31             :   template <typename T>
      32         127 :   T k(T temperature) const
      33             :   {
      34         127 :     if (_k)
      35             :       return _k;
      36             : 
      37         100 :     const T temperature2 = temperature * temperature;
      38         100 :     const T temperature3 = temperature2 * temperature;
      39         100 :     return 124.67 - 0.11381 * temperature + 5.5226e-5 * temperature2 - 1.1842e-8 * temperature3;
      40             :   }
      41             : 
      42             :   /**
      43             :    * Enthalpy of liquid Na (relative to solid Na at STP) in J/kg as a function of temperature
      44             :    * From page 4. Valid from 371 to 2000 K, and relative to enthalpy of solid Na at 298.15.
      45             :    * @param T temperature in K
      46             :    * @return enthalpy of liquid sodium in J/kg
      47             :    */
      48             :   template <typename T>
      49             :   T h(T temperature) const
      50             :   {
      51        1500 :     const T temperature2 = temperature * temperature;
      52        1500 :     const T temperature3 = temperature2 * temperature;
      53             : 
      54             :     // Converted from kJ/kg to J/kg.
      55        1500 :     return -365.77e3 + 1.6582e3 * temperature - 4.2395e-1 * temperature2 +
      56         132 :            1.4847e-4 * temperature3 + 2992.6e3 / temperature;
      57             :   }
      58             : 
      59             :   /**
      60             :    * Heat capacity of liquid Na in J/kg-K as a function of temperature. From page 29 (or by
      61             :    * differentiating enthalpy). Valid from 371 to 2000 K.
      62             :    * @param T temperature in K
      63             :    * @ return Heat capacity of liquid sodium in J/kg/K
      64             :    */
      65             :   template <typename T>
      66             :   T heatCapacity(T temperature) const
      67             :   {
      68         254 :     if (_cp)
      69             :       return _cp;
      70             : 
      71         199 :     const T temperature2 = temperature * temperature;
      72             : 
      73             :     // Converted from kJ/kg-K to J/kg-K.
      74        1034 :     return 1.6582e3 - 8.4790e-1 * temperature + 4.4541e-4 * temperature2 - 2992.6e3 / temperature2;
      75             :   }
      76             : 
      77             :   /**
      78             :    * Inverse solve for temperature from enthalpy
      79             :    * @param h enthalpy in J/kg
      80             :    * @return temperature of liquid sodium in K
      81             :    */
      82             :   template <typename T>
      83         254 :   T temperature(T enthalpy) const
      84             :   {
      85             :     // Estimate initial guess from linear part of enthalpy.
      86         254 :     T temperature = (enthalpy + 365.77e3) / 1.6582e3;
      87             : 
      88             :     // Newton-Raphson for this equation: enthalpy(T) - enthalpy = 0 = residual. This is easy because
      89             :     // dResidual/dT is just dH/dT, which is heat capacity.
      90        1446 :     for (unsigned iteration = 0; iteration < 10; ++iteration)
      91             :     {
      92        1374 :       const T residual = h(temperature) - enthalpy;
      93        1374 :       temperature -= residual / heatCapacity(temperature);
      94        1374 :       if (std::abs(residual / enthalpy) < 1e-6)
      95             :         break;
      96             :     }
      97             :     // If we get here, enthalpy is probably out of bounds. However, due to the nature of the JFNK
      98             :     // calculation, we probably just want to ignore the error and spit out a bogus T so that the
      99             :     // solver keeps rolling.
     100         254 :     return temperature;
     101             :   }
     102             : 
     103             :   /**
     104             :    * Density as a function of temperature. Valid 371 K < T < 2503.7 K
     105             :    * @param T temperature in K
     106             :    * @return density of liquid sodium in kg/m^3
     107             :    */
     108             :   template <typename T>
     109         127 :   T rho(T temperature) const
     110             :   {
     111             :     const T rhoc = 219.0; // kg/m^3
     112             :     const T f = 275.32;
     113             :     const T g = 511.58;
     114             :     const T Tc = 2503.7; // critical temperature, K
     115             :     mooseAssert(temperature < Tc, "Temperature is greater than critical temperature 2503.7 K ");
     116             : 
     117         127 :     return rhoc + f * (1.0 - temperature / Tc) + g * std::sqrt(1.0 - temperature / Tc);
     118             :   }
     119             : 
     120             :   /**
     121             :    * Derivative of density w.r.t temperature. Valid 371 K < T < 2503.7 K
     122             :    * @param T temperature in K
     123             :    * @return derivative of density of liquid sodium with respect to temperature
     124             :    */
     125             :   template <typename T>
     126         254 :   T drho_dT(T temperature) const
     127             :   {
     128             :     const T f = 275.32;
     129             :     const T g = 511.58;
     130             :     const T Tc = 2503.7; // critical temperature, K
     131             :     mooseAssert(temperature < Tc, "Temperature is greater than critical temperature 2503.7 K ");
     132             : 
     133         254 :     return -(f + g * 0.5 / std::sqrt(1.0 - temperature / Tc)) / Tc;
     134             :   }
     135             : 
     136             :   /**
     137             :    * Derivative of density w.r.t enthalpy. Valid 371 K < T < 2503.7 K
     138             :    * @param T enthalpy in J/kg
     139             :    * @return derivative of density of liquid sodium with respect to enthalpy
     140             :    */
     141             :   template <typename T>
     142         127 :   T drho_dh(T enthalpy) const
     143             :   {
     144         127 :     const T temperature = this->temperature(enthalpy);
     145         127 :     return drho_dT(temperature) / heatCapacity(temperature);
     146             :   }
     147             : 
     148             : private:
     149             :   /// Optional thermal conductivity from input parameters.
     150             :   const Real _k;
     151             : 
     152             :   /// Optional specific heat from input parameters.
     153             :   const Real _cp;
     154             : };

Generated by: LCOV version 1.14