LCOV - code coverage report
Current view: top level - src/userobjects - GasLiquidMassTransfer.C (source / functions) Hit Total Coverage
Test: idaholab/moose scalar_transport: #32971 (54bef8) with base c6cf66 Lines: 49 51 96.1 %
Date: 2026-05-29 20:39:31 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 "GasLiquidMassTransfer.h"
      11             : #include "MathUtils.h"
      12             : #include "SinglePhaseFluidProperties.h"
      13             : 
      14             : registerMooseObject("ScalarTransportApp", GasLiquidMassTransfer);
      15             : 
      16             : InputParameters
      17           4 : GasLiquidMassTransfer::validParams()
      18             : {
      19           4 :   InputParameters params = GeneralUserObject::validParams();
      20             :   // Required params
      21           8 :   params.addRequiredParam<Real>("d", "Pipe diameter [m]");
      22           8 :   params.addRequiredParam<UserObjectName>(
      23             :       "fp", "The name of the user object for liquid side fluid properties");
      24           8 :   MooseEnum equation_list("StokesEinstein WilkeChang");
      25           8 :   params.addRequiredParam<MooseEnum>(
      26             :       "equation", equation_list, "The equation to use for mass transfer calculation");
      27             :   // Required for Stokes-Einstein
      28           8 :   params.addParam<Real>("radius", "Particle radius [m]");
      29             :   // Required for Wilke-Chang
      30           8 :   params.addParam<Real>("molar_weight", "molar weight solvent [kg/mol]");
      31             :   // Optional
      32             :   // Wilke-Change gives a phi value of 1.0 for nonassociated solvents and 2.6 for water.
      33           8 :   params.addParam<Real>("phi", 1.0, "The association parameter for the solute (see Wilke-Chang)");
      34           8 :   params.addParam<Real>("wc", 7.4e-8, "WilkeChang constant");
      35           8 :   params.addParam<Real>("db", 0.023, "Dittus-Boelter equation constant");
      36           4 :   params.addClassDescription("Calculates overall liquid mass transfer coefficient `[m/s]`.");
      37           4 :   return params;
      38           4 : }
      39             : 
      40           2 : GasLiquidMassTransfer::GasLiquidMassTransfer(const InputParameters & parameters)
      41             :   : GeneralUserObject(parameters),
      42           2 :     _diameter(getParam<Real>("d")),
      43           2 :     _fp(getUserObject<SinglePhaseFluidProperties>("fp")),
      44           4 :     _equation_list(getParam<MooseEnum>("equation").getEnum<Equationlist>()),
      45           6 :     _radius(isParamValid("radius") ? getParam<Real>("radius") : 0.0),
      46           6 :     _mw(isParamValid("molar_weight") ? getParam<Real>("molar_weight") : 0.0),
      47           4 :     _phi(getParam<Real>("phi")),
      48           4 :     _wc(getParam<Real>("wc")),
      49           6 :     _db(getParam<Real>("db"))
      50             : {
      51           2 :   switch (_equation_list)
      52             :   {
      53           1 :     case Equationlist::WILKECHANG:
      54             :     {
      55           2 :       if (!isParamSetByUser("molar_weight"))
      56           0 :         paramError("molar_weight",
      57             :                    "Must set the molecular weight of the gas when using WilkeChang");
      58             :       break;
      59             :     }
      60           1 :     case Equationlist::STOKESEINSTEIN:
      61             :     {
      62           2 :       if (!isParamSetByUser("radius"))
      63           0 :         paramError("radius", "Must set particle radius when using StokesEinstein");
      64             :       break;
      65             :     }
      66             :   }
      67           2 : }
      68             : 
      69             : Real
      70           2 : GasLiquidMassTransfer::mtc(Real pressure, Real temperature, Real fluid_velocity) const
      71             : {
      72           2 :   Real mu = _fp.mu_from_p_T(pressure, temperature);
      73           2 :   Real rho = _fp.rho_from_p_T(pressure, temperature);
      74             :   Real Diffusivity = 0.0;
      75           2 :   switch (_equation_list)
      76             :   {
      77           1 :     case Equationlist::STOKESEINSTEIN:
      78           1 :       Diffusivity = _kB * temperature / (6.0 * libMesh::pi * mu * _radius);
      79           1 :       break;
      80             : 
      81           1 :     case Equationlist::WILKECHANG:
      82             :       // Equation 5 of:
      83             :       // C.R. Wilke, P. Chang, Correlation of diffusion coefficients in dilute solutions, AICHE J.,
      84             :       // 1955, 1(2) 264-270 Units of Wilke Chang are g-cm-s
      85             :       Real kg_to_g = 1000.0;
      86             :       Real m_to_cm = 100.0;
      87             :       Real cm_to_m = 1. / m_to_cm;
      88           1 :       Real mu_cgs = mu * kg_to_g / m_to_cm; // g/cm/s = Poise
      89             :       Real poise_to_centipoise = 100;
      90           1 :       mu_cgs = mu_cgs * poise_to_centipoise;                    // cP
      91           1 :       Real molar_volume = _mw / rho * Utility::pow<3>(m_to_cm); // cm3/mol
      92           1 :       Real molar_weight = _mw * kg_to_g;                        // g/mol
      93           1 :       Diffusivity = _wc * temperature * std::sqrt(_phi * molar_weight) /
      94           1 :                     (mu_cgs * std::pow(molar_volume, 0.6));
      95           1 :       Diffusivity = Diffusivity * Utility::pow<2>(cm_to_m);
      96           1 :       break;
      97             :   }
      98             : 
      99           2 :   Real re = rho * abs(fluid_velocity) * _diameter / mu;
     100           2 :   Real sc = mu / (rho * Diffusivity);
     101           2 :   Real mtc = _db * std::pow(re, 0.8) * std::pow(sc, 0.4) * Diffusivity / _diameter;
     102           2 :   return mtc;
     103             : }

Generated by: LCOV version 1.14