LCOV - code coverage report
Current view: top level - src/userobjects - HenryGasConstant.C (source / functions) Hit Total Coverage
Test: idaholab/moose chemical_reactions: #32971 (54bef8) with base c6cf66 Lines: 49 54 90.7 %
Date: 2026-05-29 20:35:47 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 "HenryGasConstant.h"
      11             : #include "MathUtils.h"
      12             : 
      13             : registerMooseObject("ChemicalReactionsApp", HenryGasConstant);
      14             : 
      15             : InputParameters
      16          10 : HenryGasConstant::validParams()
      17             : {
      18          10 :   InputParameters params = GeneralUserObject::validParams();
      19          20 :   params.addRequiredParam<Real>("radius", "Van der Waals radius [m]");
      20          20 :   MooseEnum salt_list("FLIBE FLINAK CUSTOM");
      21          20 :   params.addRequiredParam<MooseEnum>("salt", salt_list, "Salt");
      22          20 :   params.addParam<Real>("alpha", "alpha fit parameter in Henry model, if defining custom fluid");
      23          20 :   params.addParam<Real>("beta", "beta fit parameter in Henry model, if defining custom fluid");
      24          20 :   params.addParam<Real>("gamma_0",
      25             :                         "gamma_0 fit parameter in Henry model, if defining custom fluidl");
      26          20 :   params.addParam<Real>("dgamma_dT",
      27             :                         "gamma derivative fit parameter in Henry model, if defining custom fluid");
      28          20 :   params.addParam<Real>(
      29             :       "KH0", "Reference Henry parameter in Henry model, if defining custom fluid [mol/m3/Pa]");
      30          10 :   params.addClassDescription("Calculates Henry gas constant of a noble gas `[mol/m3/Pa]`");
      31          10 :   return params;
      32          10 : }
      33             : 
      34           5 : HenryGasConstant::HenryGasConstant(const InputParameters & parameters)
      35             :   : GeneralUserObject(parameters),
      36           5 :     _radius(getParam<Real>("radius")),
      37          10 :     _salt_list(getParam<MooseEnum>("salt").getEnum<Saltlist>()),
      38          12 :     _alpha(isParamSetByUser("alpha") ? getParam<Real>("alpha") : 0.0),
      39          12 :     _beta(isParamSetByUser("beta") ? getParam<Real>("beta") : 0.0),
      40          12 :     _gamma_0(isParamSetByUser("gamma_0") ? getParam<Real>("gamma_0") : 0.0),
      41          12 :     _dgamma_dT(isParamSetByUser("dgamma_dT") ? getParam<Real>("dgamma_dT") : 0.0),
      42          17 :     _KH0(isParamSetByUser("KH0") ? getParam<Real>("KH0") : 0.0)
      43             : {
      44           5 :   switch (_salt_list)
      45             :   {
      46           2 :     case Saltlist::FLIBE:
      47           2 :       _alpha = _alpha_FLiBe;
      48           2 :       _beta = _beta_FLiBe;
      49           2 :       _KH0 = _KH0_FLiBe;
      50           2 :       _gamma_0 = _gamma_0_FLiBe;
      51           2 :       _dgamma_dT = _dgamma_dT_FLiBe;
      52           2 :       break;
      53             : 
      54           2 :     case Saltlist::FLINAK:
      55           2 :       _alpha = _alpha_FLiNaK;
      56           2 :       _beta = _beta_FLiNaK;
      57           2 :       _KH0 = _KH0_FLiNaK;
      58           2 :       _gamma_0 = _gamma_0_FLiNaK;
      59           2 :       _dgamma_dT = _dgamma_dT_FLiNaK;
      60           2 :       break;
      61             : 
      62           1 :     case Saltlist::CUSTOM:
      63             :       // Ensure that all parameters were set by user
      64           2 :       if (!isParamSetByUser("alpha"))
      65           0 :         mooseError("Must include alpha parameter when using custom salt Henry gas model");
      66           2 :       if (!isParamSetByUser("beta"))
      67           0 :         mooseError("Must include beta parameter when using custom salt Henry gas model");
      68           2 :       if (!isParamSetByUser("gamma_0"))
      69           0 :         mooseError("Must include gamma_0 parameter when using custom salt Henry gas model");
      70           2 :       if (!isParamSetByUser("dgamma_dT"))
      71           0 :         mooseError("Must include dgamma_dT parameter when using custom salt Henry gas model");
      72           2 :       if (!isParamSetByUser("KH0"))
      73           0 :         mooseError("Must include KH0 parameter when using custom salt Henry gas model");
      74             :       break;
      75             :   }
      76           5 : }
      77             : 
      78             : Real
      79          30 : HenryGasConstant::henry(Real temperature) const
      80             : {
      81             : 
      82             :   const Real m_to_ang = 1e10;
      83             : 
      84             :   // Equations result in units of mol/cm^3/atm, so convert to mol/m^3/atm
      85             :   Real value =
      86          30 :       _alpha * 4. * libMesh::pi * Utility::pow<2>(_radius * m_to_ang) *
      87          30 :           (_gamma_0 + _dgamma_dT * (temperature - 273.15)) +
      88          30 :       _beta * 4. / 3. * libMesh::pi * std::pow(_radius * m_to_ang, 3) * _Rgas * temperature;
      89          30 :   value = exp(value / (_Rgas * temperature)) * _KH0;
      90          30 :   return value;
      91             : }

Generated by: LCOV version 1.14