LCOV - code coverage report
Current view: top level - src/materials - FluidProperties3EqnMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 83 84 98.8 %
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 "FluidProperties3EqnMaterial.h"
      11             : #include "SinglePhaseFluidProperties.h"
      12             : #include "Numerics.h"
      13             : 
      14             : registerMooseObject("ThermalHydraulicsApp", FluidProperties3EqnMaterial);
      15             : 
      16             : InputParameters
      17         200 : FluidProperties3EqnMaterial::validParams()
      18             : {
      19         200 :   InputParameters params = Material::validParams();
      20             : 
      21         400 :   params.addRequiredCoupledVar("A", "Cross-sectional area");
      22         400 :   params.addRequiredCoupledVar("rhoA", "Conserved density");
      23         400 :   params.addRequiredCoupledVar("rhouA", "Conserved momentum");
      24         400 :   params.addRequiredCoupledVar("rhoEA", "Conserved total energy");
      25             : 
      26         400 :   params.addRequiredParam<UserObjectName>("fp", "The name of the user object for fluid properties");
      27         200 :   params.addClassDescription(
      28             :       "Defines material properties from fluid properties to serve in the 3-equation model");
      29             : 
      30         200 :   return params;
      31           0 : }
      32             : 
      33         150 : FluidProperties3EqnMaterial::FluidProperties3EqnMaterial(const InputParameters & parameters)
      34             :   : DerivativeMaterialInterfaceTHM<Material>(parameters),
      35         150 :     _area(coupledValue("A")),
      36         150 :     _rhoA(coupledValue("rhoA")),
      37         150 :     _rhouA(coupledValue("rhouA")),
      38         150 :     _rhoEA(coupledValue("rhoEA")),
      39             : 
      40         150 :     _rho(declareProperty<Real>("rho")),
      41         150 :     _drho_drhoA(declarePropertyDerivativeTHM<Real>("rho", "rhoA")),
      42             : 
      43         150 :     _v(declareProperty<Real>("v")),
      44         150 :     _dv_drhoA(declarePropertyDerivativeTHM<Real>("v", "rhoA")),
      45             : 
      46         150 :     _vel(declareProperty<Real>("vel")),
      47         150 :     _dvel_drhoA(declarePropertyDerivativeTHM<Real>("vel", "rhoA")),
      48         150 :     _dvel_drhouA(declarePropertyDerivativeTHM<Real>("vel", "rhouA")),
      49             : 
      50         150 :     _e(declareProperty<Real>("e")),
      51         150 :     _de_drhoA(declarePropertyDerivativeTHM<Real>("e", "rhoA")),
      52         150 :     _de_drhouA(declarePropertyDerivativeTHM<Real>("e", "rhouA")),
      53         150 :     _de_drhoEA(declarePropertyDerivativeTHM<Real>("e", "rhoEA")),
      54             : 
      55         150 :     _p(declareProperty<Real>("p")),
      56         150 :     _dp_drhoA(declarePropertyDerivativeTHM<Real>("p", "rhoA")),
      57         150 :     _dp_drhouA(declarePropertyDerivativeTHM<Real>("p", "rhouA")),
      58         150 :     _dp_drhoEA(declarePropertyDerivativeTHM<Real>("p", "rhoEA")),
      59             : 
      60         150 :     _T(declareProperty<Real>("T")),
      61         150 :     _dT_drhoA(declarePropertyDerivativeTHM<Real>("T", "rhoA")),
      62         150 :     _dT_drhouA(declarePropertyDerivativeTHM<Real>("T", "rhouA")),
      63         150 :     _dT_drhoEA(declarePropertyDerivativeTHM<Real>("T", "rhoEA")),
      64             : 
      65         150 :     _h(declareProperty<Real>("h")),
      66         150 :     _dh_drhoA(declarePropertyDerivativeTHM<Real>("h", "rhoA")),
      67         150 :     _dh_drhouA(declarePropertyDerivativeTHM<Real>("h", "rhouA")),
      68         150 :     _dh_drhoEA(declarePropertyDerivativeTHM<Real>("h", "rhoEA")),
      69             : 
      70         150 :     _H(declareProperty<Real>("H")),
      71         150 :     _dH_drhoA(declarePropertyDerivativeTHM<Real>("H", "rhoA")),
      72         150 :     _dH_drhouA(declarePropertyDerivativeTHM<Real>("H", "rhouA")),
      73         150 :     _dH_drhoEA(declarePropertyDerivativeTHM<Real>("H", "rhoEA")),
      74             : 
      75         150 :     _c(declareProperty<Real>("c")),
      76             : 
      77         150 :     _cp(declareProperty<Real>("cp")),
      78             : 
      79         150 :     _cv(declareProperty<Real>("cv")),
      80             : 
      81         150 :     _k(declareProperty<Real>("k")),
      82             : 
      83         300 :     _fp(getUserObject<SinglePhaseFluidProperties>("fp"))
      84             : {
      85         150 : }
      86             : 
      87             : void
      88         990 : FluidProperties3EqnMaterial::computeQpProperties()
      89             : {
      90         990 :   _rho[_qp] = _rhoA[_qp] / _area[_qp];
      91         990 :   _drho_drhoA[_qp] = 1.0 / _area[_qp];
      92             : 
      93         990 :   _v[_qp] = 1.0 / _rho[_qp];
      94         990 :   _dv_drhoA[_qp] = THM::dv_darhoA(_area[_qp], _rhoA[_qp]);
      95             : 
      96         990 :   THM::vel_from_arhoA_arhouA(
      97         990 :       _rhoA[_qp], _rhouA[_qp], _vel[_qp], _dvel_drhoA[_qp], _dvel_drhouA[_qp]);
      98             : 
      99         990 :   _e[_qp] = (_rhoEA[_qp] - 0.5 * _rhouA[_qp] * _rhouA[_qp] / _rhoA[_qp]) / _rhoA[_qp];
     100         990 :   _de_drhoA[_qp] = THM::de_darhoA(_rhoA[_qp], _rhouA[_qp], _rhoEA[_qp]);
     101         990 :   _de_drhouA[_qp] = THM::de_darhouA(_rhoA[_qp], _rhouA[_qp]);
     102         990 :   _de_drhoEA[_qp] = THM::de_darhoEA(_rhoA[_qp]);
     103             : 
     104         990 :   _p[_qp] = _fp.p_from_v_e(_v[_qp], _e[_qp]);
     105             :   Real p, dp_dv, dp_de;
     106         990 :   _fp.p_from_v_e(_v[_qp], _e[_qp], p, dp_dv, dp_de);
     107             : 
     108         990 :   _T[_qp] = _fp.T_from_v_e(_v[_qp], _e[_qp]);
     109             :   Real T, dT_dv, dT_de;
     110         990 :   _fp.T_from_v_e(_v[_qp], _e[_qp], T, dT_dv, dT_de);
     111             : 
     112         990 :   _dp_drhoA[_qp] = dp_dv * _dv_drhoA[_qp] + dp_de * _de_drhoA[_qp];
     113         990 :   _dp_drhouA[_qp] = dp_de * _de_drhouA[_qp];
     114             : 
     115         990 :   _dT_drhoA[_qp] = dT_dv * _dv_drhoA[_qp] + dT_de * _de_drhoA[_qp];
     116         990 :   _dT_drhouA[_qp] = dT_de * _de_drhouA[_qp];
     117             : 
     118         990 :   _dp_drhoEA[_qp] = dp_de * _de_drhoEA[_qp];
     119         990 :   _dT_drhoEA[_qp] = dT_de * _de_drhoEA[_qp];
     120             : 
     121         990 :   _h[_qp] = _e[_qp] + _p[_qp] / _rho[_qp];
     122             :   const Real dh_de = 1;
     123         990 :   const Real dh_dp = 1.0 / _rho[_qp];
     124         990 :   const Real dh_drho = -_p[_qp] / _rho[_qp] / _rho[_qp];
     125         990 :   _dh_drhoA[_qp] = dh_de * _de_drhoA[_qp] + dh_dp * _dp_drhoA[_qp] + dh_drho * _drho_drhoA[_qp];
     126         990 :   _dh_drhouA[_qp] = dh_de * _de_drhouA[_qp] + dh_dp * _dp_drhouA[_qp];
     127         990 :   _dh_drhoEA[_qp] = dh_de * _de_drhoEA[_qp] + dh_dp * _dp_drhoEA[_qp];
     128             : 
     129         990 :   _H[_qp] = _h[_qp] + 0.5 * _vel[_qp] * _vel[_qp];
     130         990 :   _dH_drhoA[_qp] = _dh_drhoA[_qp] + _vel[_qp] * _dvel_drhoA[_qp];
     131         990 :   _dH_drhouA[_qp] = _dh_drhouA[_qp] + _vel[_qp] * _dvel_drhouA[_qp];
     132         990 :   _dH_drhoEA[_qp] = _dh_drhoEA[_qp];
     133             : 
     134         990 :   _c[_qp] = _fp.c_from_v_e(_v[_qp], _e[_qp]);
     135         990 :   _cp[_qp] = _fp.cp_from_v_e(_v[_qp], _e[_qp]);
     136         990 :   _cv[_qp] = _fp.cv_from_v_e(_v[_qp], _e[_qp]);
     137         990 :   _k[_qp] = _fp.k_from_v_e(_v[_qp], _e[_qp]);
     138         990 : }

Generated by: LCOV version 1.14