https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ADShaftConnectedTurbine1PhaseUserObject.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
14#include "MooseVariableScalar.h"
15#include "THMIndicesVACE.h"
16#include "Function.h"
17#include "Numerics.h"
18#include "metaphysicl/parallel_numberarray.h"
19#include "metaphysicl/parallel_dualnumber.h"
20#include "metaphysicl/parallel_semidynamicsparsenumberarray.h"
21#include "libmesh/parallel_algebra.h"
22#include "libmesh/utility.h"
23
25
28{
31
32 params.addParam<BoundaryName>("inlet", "Turbine inlet");
33 params.addParam<BoundaryName>("outlet", "Turbine outlet");
34 params.addRequiredParam<Point>("di_out", "Direction of connected outlet");
35 params.addRequiredParam<Real>("omega_rated", "Rated turbine speed [rad/s]");
36 params.addRequiredParam<Real>("D_wheel", "Diameter of turbine wheel [m]");
37 params.addRequiredParam<Real>("speed_cr_fr", "Turbine speed threshold for friction [-]");
38 params.addRequiredParam<Real>("tau_fr_const", "Turbine friction constant [N-m]");
39 params.addRequiredParam<std::vector<Real>>("tau_fr_coeff", "Friction coefficients [N-m]");
40 params.addRequiredParam<Real>("speed_cr_I", "Turbine speed threshold for inertia [-]");
41 params.addRequiredParam<Real>("inertia_const", "Turbine inertia constant [kg-m^2]");
42 params.addRequiredParam<std::vector<Real>>("inertia_coeff",
43 "Turbine inertia coefficients [kg-m^2]");
44 params.addRequiredParam<FunctionName>("head_coefficient",
45 "Function to compute data for turbine head [-]");
46 params.addRequiredParam<FunctionName>("power_coefficient",
47 "Function to compute data for turbine power [-]");
48 params.addRequiredParam<std::string>("turbine_name",
49 "Name of the instance of this turbine component");
50 params.addRequiredCoupledVar("omega", "Shaft rotational speed [rad/s]");
51
52 params.addClassDescription("Computes and caches flux and residual vectors for a 1-phase "
53 "turbine. Also computes turbine torque "
54 "and delta_p which is passed to the connected shaft");
55
56 return params;
57}
58
60 const InputParameters & params)
63
64 _di_out(getParam<Point>("di_out")),
65 _omega_rated(getParam<Real>("omega_rated")),
66 _D_wheel(getParam<Real>("D_wheel")),
67 _speed_cr_fr(getParam<Real>("speed_cr_fr")),
68 _tau_fr_const(getParam<Real>("tau_fr_const")),
69 _tau_fr_coeff(getParam<std::vector<Real>>("tau_fr_coeff")),
70 _speed_cr_I(getParam<Real>("speed_cr_I")),
71 _inertia_const(getParam<Real>("inertia_const")),
72 _inertia_coeff(getParam<std::vector<Real>>("inertia_coeff")),
73 _head_coefficient(getFunction("head_coefficient")),
74 _power_coefficient(getFunction("power_coefficient")),
75 _turbine_name(getParam<std::string>("turbine_name")),
76
77 _omega(adCoupledScalarValue("omega"))
78{
79}
80
81void
89
90void
102
103void
114
115void
117{
119
120 using std::abs;
121
122 // inlet c=0 established in component
123 if (c == 0)
124 {
126
127 const ADReal Q_in = (_rhouA[0] / _rhoA[0]) * _A[0];
128
129 _flow_coeff = Q_in / (_omega[0] * _D_wheel * _D_wheel * _D_wheel);
130
131 const auto head_coeff = _head_coefficient.value(_flow_coeff, ADPoint());
132
133 const ADReal gH = head_coeff * _D_wheel * _D_wheel * _omega[0] * _omega[0];
134
135 const auto power_coeff = _power_coefficient.value(_flow_coeff, ADPoint());
136
137 // friction torque
138 ADReal alpha = _omega[0] / _omega_rated;
139 Real sign;
140 if (_omega[0] >= 0)
141 sign = -1;
142 else
143 sign = 1;
144 if (alpha < _speed_cr_fr)
145 {
147 }
148 else
149 {
151 sign * (_tau_fr_coeff[0] + _tau_fr_coeff[1] * abs(alpha) +
152 _tau_fr_coeff[2] * alpha * alpha + _tau_fr_coeff[3] * abs(alpha * alpha * alpha));
153 }
154
156 power_coeff * (rhoV / _volume) * _omega[0] * _omega[0] * Utility::pow<5>(_D_wheel);
157
159
160 if (alpha < _speed_cr_I)
161 {
163 }
164 else
165 {
166 _moment_of_inertia += _inertia_coeff[0] + _inertia_coeff[1] * abs(alpha) +
167 _inertia_coeff[2] * alpha * alpha +
168 _inertia_coeff[3] * abs(alpha * alpha * alpha);
169 }
170
171 // compute momentum and energy source terms
172 // a positive torque value results in a negative S_energy
173 _power = _torque * _omega[0];
174 const ADReal S_energy = -_power;
175
176 _delta_p = (rhoV / _volume) * gH;
177
178 const ADRealVectorValue S_momentum = -_delta_p * _A_ref * _di_out;
179
181
185 }
186}
187
188ADReal
193
194ADReal
199
200ADReal
205
206ADReal
211
212ADReal
217
218void
234
235void
237{
240
241 const auto & scpuo = static_cast<const ADShaftConnectedTurbine1PhaseUserObject &>(uo);
243 _friction_torque += scpuo._friction_torque;
244 _flow_coeff += scpuo._flow_coeff;
245 _delta_p += scpuo._delta_p;
246 _power += scpuo._power;
247}
DualNumber< Real, DNDerivativeType, true > ADReal
registerMooseObject("ThermalHydraulicsApp", ADShaftConnectedTurbine1PhaseUserObject)
unsigned int getBoundaryIDIndex()
Gets the index of the currently executing boundary within the vector of boundary IDs given to this Si...
const unsigned int _n_connections
Number of connected flow channels.
Interface class for user objects that are connected to a shaft.
virtual void setOmegaDofs(const MooseVariableScalar *omega_var)
virtual void setupJunctionData(std::vector< dof_id_type > &scalar_dofs)
Stores data associated with a junction component.
virtual void setConnectionData(const std::vector< std::vector< dof_id_type > > &flow_channel_dofs)
Stores data computed by a volume-junction-like object associated with the conection.
virtual void setupConnections(unsigned int n_connections, unsigned int n_flow_eq)
Computes and caches flux and residual vectors for a 1-phase turbine.
const std::vector< Real > & _inertia_coeff
Turbine inertia coefficients.
ADReal getTurbineDeltaP() const
Turbine head computed in the 1-phase shaft-connected turbine.
ADReal getFrictionTorque() const
Friction torque computed in the 1-phase shaft-connected turbine.
const ADVariableValue & _omega
Connected shaft speed.
virtual void computeFluxesAndResiduals(const unsigned int &c) override
Computes and stores the fluxes, the scalar residuals, and their Jacobians.
ADReal _flow_coeff
Turbine flow coefficient - independent variable in user supplied head and power functions.
const Function & _power_coefficient
Function to compute data for turbine power.
ADReal getDrivingTorque() const
Driving torque computed in the 1-phase shaft-connected turbine.
const Real & _speed_cr_I
Turbine speed threshold for inertia.
const Real & _speed_cr_fr
Turbine speed threshold for friction.
ADReal getFlowCoefficient() const
Flow coefficient computed in the 1-phase shaft-connected turbine.
ADReal getTurbinePower() const
Turbine power computed in the 1-phase shaft-connected turbine.
virtual void threadJoin(const UserObject &uo) override
const Function & _head_coefficient
Function to compute data for turbine head.
const std::vector< Real > & _tau_fr_coeff
Turbine friction coefficients.
Computes and caches flux and residual vectors for a 1-phase volume junction.
virtual void computeFluxesAndResiduals(const unsigned int &c) override
Computes and stores the fluxes, the scalar residuals, and their Jacobians.
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< std::vector< dof_id_type > > _flow_channel_dofs
Degrees of freedom for flow channel variables, for each connection.
virtual void storeConnectionData()
Stores data (connection index, face shape functions, DoFs associated with flow channel variables) rel...
std::vector< dof_id_type > _scalar_dofs
Degrees of freedom for scalar variables.
unsigned int _n_flux_eq
Number of flow channel flux components.
std::vector< ADReal > _residual
Cached scalar residual vector.
const Real & _volume
Volume of the junction.
virtual Real value(Real t, const Point &p) const
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
const MooseVariableScalar * getScalarVar(const std::string &var_name, unsigned int comp) const
virtual void initialSetup()
virtual void initialize()=0
virtual void threadJoin(const UserObject &uo)=0
const Parallel::Communicator & comm() const