LCOV - code coverage report
Current view: top level - src/userobjects - ADSimpleTurbine1PhaseUserObject.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #31706 (f8ed4a) with base bb0a08 Lines: 31 32 96.9 %
Date: 2025-11-03 17:29:56 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 "ADSimpleTurbine1PhaseUserObject.h"
      11             : #include "SinglePhaseFluidProperties.h"
      12             : #include "VolumeJunction1Phase.h"
      13             : #include "THMIndicesVACE.h"
      14             : #include "ADNumericalFlux3EqnBase.h"
      15             : #include "Numerics.h"
      16             : 
      17             : registerMooseObject("ThermalHydraulicsApp", ADSimpleTurbine1PhaseUserObject);
      18             : 
      19             : InputParameters
      20         146 : ADSimpleTurbine1PhaseUserObject::validParams()
      21             : {
      22         146 :   InputParameters params = ADJunctionParallelChannels1PhaseUserObject::validParams();
      23         292 :   params.addRequiredParam<bool>("on", "Flag determining if turbine is operating or not");
      24         292 :   params.addRequiredParam<Real>("W_dot", "Power, [W]");
      25             : 
      26         292 :   params.addClassDescription("Computes and caches flux and residual vectors for a 1-phase turbine");
      27             : 
      28         292 :   params.declareControllable("W_dot on");
      29             : 
      30         146 :   return params;
      31           0 : }
      32             : 
      33          79 : ADSimpleTurbine1PhaseUserObject::ADSimpleTurbine1PhaseUserObject(const InputParameters & params)
      34             :   : ADJunctionParallelChannels1PhaseUserObject(params),
      35          79 :     _on(getParam<bool>("on")),
      36         237 :     _W_dot(getParam<Real>("W_dot"))
      37             : {
      38          79 : }
      39             : 
      40             : void
      41        2898 : ADSimpleTurbine1PhaseUserObject::computeFluxesAndResiduals(const unsigned int & c)
      42             : {
      43        2898 :   ADJunctionParallelChannels1PhaseUserObject::computeFluxesAndResiduals(c);
      44             : 
      45             :   using std::pow;
      46             : 
      47        2898 :   if ((c == 0) && _on)
      48             :   {
      49             :     const auto & rhouV = _cached_junction_var_values[VolumeJunction1Phase::RHOUV_INDEX];
      50             :     const auto & rhovV = _cached_junction_var_values[VolumeJunction1Phase::RHOVV_INDEX];
      51             :     const auto & rhowV = _cached_junction_var_values[VolumeJunction1Phase::RHOWV_INDEX];
      52             : 
      53        1214 :     const Point di = _dir[0];
      54             :     const ADRealVectorValue rhouV_vec(rhouV, rhovV, rhowV);
      55             : 
      56             :     // energy source
      57        1214 :     const ADReal S_E = _W_dot;
      58             : 
      59             :     // momentum source
      60        1214 :     const ADReal v_in = THM::v_from_rhoA_A(_rhoA[0], _A[0]);
      61             : 
      62        1214 :     const ADReal rhouA2 = _rhouA[0] * _rhouA[0];
      63        3642 :     const ADReal e_in = _rhoEA[0] / _rhoA[0] - 0.5 * rhouA2 / (_rhoA[0] * _rhoA[0]);
      64             : 
      65        1214 :     const ADReal cp = _fp.cp_from_v_e(v_in, e_in);
      66        1214 :     const ADReal cv = _fp.cv_from_v_e(v_in, e_in);
      67             :     const ADReal gamma = cp / cv;
      68        1214 :     const ADReal p_in = _fp.p_from_v_e(v_in, e_in);
      69        1214 :     const ADReal T_in = _fp.T_from_v_e(v_in, e_in);
      70        1214 :     const ADReal h_in = _fp.h_from_p_T(p_in, T_in);
      71        3642 :     const ADReal delta_p = p_in * (1 - pow((1 - _W_dot / _rhouA[0] / h_in), (gamma / (gamma - 1))));
      72             : 
      73        2428 :     const ADRealVectorValue S_M = delta_p * _A[0] * di;
      74             : 
      75        1214 :     _residual[VolumeJunction1Phase::RHOUV_INDEX] += S_M(0);
      76        1214 :     _residual[VolumeJunction1Phase::RHOVV_INDEX] += S_M(1);
      77        1214 :     _residual[VolumeJunction1Phase::RHOWV_INDEX] += S_M(2);
      78        1214 :     _residual[VolumeJunction1Phase::RHOEV_INDEX] += S_E;
      79             :   }
      80        2898 : }

Generated by: LCOV version 1.14