https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
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
40void
42{
44
45 using std::pow;
46
47 if ((c == 0) && _on)
48 {
52
53 const Point di = _dir[0];
54 const ADRealVectorValue rhouV_vec(rhouV, rhovV, rhowV);
55
56 // energy source
57 const ADReal S_E = _W_dot;
58
59 // momentum source
60 const ADReal v_in = THM::v_from_rhoA_A(_rhoA[0], _A[0]);
61
62 const ADReal rhouA2 = _rhouA[0] * _rhouA[0];
63 const ADReal e_in = _rhoEA[0] / _rhoA[0] - 0.5 * rhouA2 / (_rhoA[0] * _rhoA[0]);
64
65 const ADReal cp = _fp.cp_from_v_e(v_in, e_in);
66 const ADReal cv = _fp.cv_from_v_e(v_in, e_in);
67 const ADReal gamma = cp / cv;
68 const ADReal p_in = _fp.p_from_v_e(v_in, e_in);
69 const ADReal T_in = _fp.T_from_v_e(v_in, e_in);
70 const ADReal h_in = _fp.h_from_p_T(p_in, T_in);
71 const ADReal delta_p = p_in * (1 - pow((1 - _W_dot / _rhouA[0] / h_in), (gamma / (gamma - 1))));
72
73 const ADRealVectorValue S_M = delta_p * _A[0] * di;
74
79 }
80}
DualNumber< Real, DNDerivativeType, true > ADReal
registerMooseObject("ThermalHydraulicsApp", ADSimpleTurbine1PhaseUserObject)
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const MaterialProperty< RealVectorValue > & _dir
Direction of the element connected to the junction.
Computes and caches flux and residual vectors for a 1-phase junction that connects flow channels that...
virtual void computeFluxesAndResiduals(const unsigned int &c) override
Computes and stores the fluxes, the scalar residuals, and their Jacobians.
Computes and caches flux and residual vectors for a 1-phase turbine.
const bool & _on
Flag determining if turbine is operating or not.
ADSimpleTurbine1PhaseUserObject(const InputParameters &params)
virtual void computeFluxesAndResiduals(const unsigned int &c) override
Computes and stores the fluxes, the scalar residuals, and their Jacobians.
const SinglePhaseFluidProperties & _fp
Single-phase fluid properties user object.
const ADVariableValue & _rhoEA
rho*E*A of the connected flow channels
const ADVariableValue & _rhouA
rho*u*A of the connected flow channels
const ADVariableValue & _rhoA
rho*A of the connected flow channels
const ADVariableValue & _A
Cross-sectional area of connected flow channels.
std::vector< ADReal > _residual
Cached scalar residual vector.
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
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