https://mooseframework.inl.gov
ADSimpleTurbine1PhaseUserObject.C
Go to the documentation of this file.
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 
12 #include "VolumeJunction1Phase.h"
13 #include "THMIndicesVACE.h"
15 #include "Numerics.h"
16 
18 
21 {
23  params.addRequiredParam<bool>("on", "Flag determining if turbine is operating or not");
24  params.addRequiredParam<Real>("W_dot", "Power, [W]");
25 
26  params.addClassDescription("Computes and caches flux and residual vectors for a 1-phase turbine");
27 
28  params.declareControllable("W_dot on");
29 
30  return params;
31 }
32 
35  _on(getParam<bool>("on")),
36  _W_dot(getParam<Real>("W_dot"))
37 {
38 }
39 
40 void
42 {
44 
45  if ((c == 0) && _on)
46  {
50 
51  const Point di = _dir[0];
52  const ADRealVectorValue rhouV_vec(rhouV, rhovV, rhowV);
53 
54  // energy source
55  const ADReal S_E = _W_dot;
56 
57  // momentum source
58  const ADReal v_in = THM::v_from_rhoA_A(_rhoA[0], _A[0]);
59 
60  const ADReal rhouA2 = _rhouA[0] * _rhouA[0];
61  const ADReal e_in = _rhoEA[0] / _rhoA[0] - 0.5 * rhouA2 / (_rhoA[0] * _rhoA[0]);
62 
63  const ADReal cp = _fp.cp_from_v_e(v_in, e_in);
64  const ADReal cv = _fp.cv_from_v_e(v_in, e_in);
65  const ADReal gamma = cp / cv;
66  const ADReal p_in = _fp.p_from_v_e(v_in, e_in);
67  const ADReal T_in = _fp.T_from_v_e(v_in, e_in);
68  const ADReal h_in = _fp.h_from_p_T(p_in, T_in);
69  const ADReal delta_p =
70  p_in * (1 - std::pow((1 - _W_dot / _rhouA[0] / h_in), (gamma / (gamma - 1))));
71 
72  const ADRealVectorValue S_M = delta_p * _A[0] * di;
73 
78  }
79 }
const ADVariableValue & _rhoA
rho*A of the connected flow channels
static const std::string cv
Definition: NS.h:122
void v_from_rhoA_A(Real rhoA, Real A, Real &v, Real &dv_drhoA)
Computes specific volume and its derivatives from rho*A, and area.
Definition: Numerics.C:100
const SinglePhaseFluidProperties & _fp
Single-phase fluid properties user object.
Computes and caches flux and residual vectors for a 1-phase junction that connects flow channels that...
void addRequiredParam(const std::string &name, const std::string &doc_string)
std::vector< ADReal > _residual
Cached scalar residual vector.
virtual void computeFluxesAndResiduals(const unsigned int &c) override
Computes and stores the fluxes, the scalar residuals, and their Jacobians.
const MaterialProperty< RealVectorValue > & _dir
Direction of the element connected to the junction.
static const std::string cp
Definition: NS.h:121
Computes and caches flux and residual vectors for a 1-phase turbine.
const ADVariableValue & _rhoEA
rho*E*A of the connected flow channels
ADSimpleTurbine1PhaseUserObject(const InputParameters &params)
const ADVariableValue & _A
Cross-sectional area of connected flow channels.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void computeFluxesAndResiduals(const unsigned int &c) override
Computes and stores the fluxes, the scalar residuals, and their Jacobians.
void addClassDescription(const std::string &doc_string)
registerMooseObject("ThermalHydraulicsApp", ADSimpleTurbine1PhaseUserObject)
const ADVariableValue & _rhouA
rho*u*A of the connected flow channels
const bool & _on
Flag determining if turbine is operating or not.
MooseUnits pow(const MooseUnits &, int)
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})
const Real & _W_dot
Turbine power, [W].