17 #include "metaphysicl/parallel_numberarray.h" 18 #include "metaphysicl/parallel_dualnumber.h" 19 #include "metaphysicl/parallel_semidynamicsparsenumberarray.h" 20 #include "libmesh/parallel_algebra.h" 30 params.
addParam<BoundaryName>(
"inlet",
"Compressor inlet");
31 params.
addParam<BoundaryName>(
"outlet",
"Compressor outlet");
33 params.
addRequiredParam<
bool>(
"treat_as_turbine",
"Treat the compressor as a turbine?");
37 "Rated compressor inlet stagnation fluid density [kg/m^3]");
38 params.
addRequiredParam<
Real>(
"c0_rated",
"Rated compressor inlet stagnation sound speed [m/s]");
41 params.
addRequiredParam<std::vector<Real>>(
"tau_fr_coeff",
"Friction coefficients [N-m]");
45 "Compressor inertia coefficients [kg-m^2]");
48 "Relative corrected speeds. Order of speeds needs correspond to the " 49 "orders of `Rp_functions` and `eff_functions` [-]");
52 "Functions of pressure ratio versus relative corrected flow. Each function is for a " 53 "different, constant relative corrected speed. The order of function names should correspond " 54 "to the order of speeds in the `speeds` parameter [-]");
57 "Functions of adiabatic efficiency versus relative corrected flow. Each function is for a " 58 "different, constant relative corrected speed. The order of function names should correspond " 59 "to the order of speeds in the `speeds` parameter [-]");
63 "Name of the instance of this compressor component");
67 "compressor. Also computes compressor torque " 68 "and delta_p which is passed to the connected shaft");
78 _di_out(getParam<Point>(
"di_out")),
79 _treat_as_turbine(getParam<bool>(
"treat_as_turbine")),
80 _omega_rated(getParam<
Real>(
"omega_rated")),
81 _mdot_rated(getParam<
Real>(
"mdot_rated")),
82 _rho0_rated(getParam<
Real>(
"rho0_rated")),
83 _c0_rated(getParam<
Real>(
"c0_rated")),
84 _speed_cr_fr(getParam<
Real>(
"speed_cr_fr")),
85 _tau_fr_const(getParam<
Real>(
"tau_fr_const")),
86 _tau_fr_coeff(getParam<
std::vector<
Real>>(
"tau_fr_coeff")),
87 _speed_cr_I(getParam<
Real>(
"speed_cr_I")),
88 _inertia_const(getParam<
Real>(
"inertia_const")),
89 _inertia_coeff(getParam<
std::vector<
Real>>(
"inertia_coeff")),
90 _speeds(getParam<
std::vector<
Real>>(
"speeds")),
91 _Rp_function_names(getParam<
std::vector<FunctionName>>(
"Rp_functions")),
92 _eff_function_names(getParam<
std::vector<FunctionName>>(
"eff_functions")),
93 _n_speeds(_speeds.size()),
94 _Rp_functions(_n_speeds),
95 _eff_functions(_n_speeds),
96 _Rp_min(getParam<
Real>(
"min_pressure_ratio")),
97 _Rp_max(getParam<
Real>(
"max_pressure_ratio")),
98 _compressor_name(getParam<
std::string>(
"compressor_name")),
99 _omega(adCoupledScalarValue(
"omega"))
102 mooseError(
"The number of entries of speeds needs to equal the number of entries of " 103 "Rp_functions and eff_functions");
106 for (
unsigned int i = 0; i <
_n_speeds; i++)
109 mooseError(
name(),
": This function cannot use its own name in the 'functions' parameter.");
165 const ADReal v_in =
_A[0] / rhoA_in;
166 const ADReal p_in =
_fp.p_from_v_e(v_in, e_in);
167 const ADReal vel_in = rhouA_in / rhoA_in;
170 const ADReal s_in =
_fp.s_from_v_e(v_in, e_in);
171 const ADReal s_out = s_in;
175 const ADReal h0_in = e_in + p_in * v_in + 0.5 * vel_in * vel_in;
176 const ADReal p0_in =
_fp.p_from_h_s(h0_in, s_in);
177 const ADReal rho0_in =
_fp.rho_from_p_s(p0_in, s_in);
178 const ADReal v0_in = 1.0 / rho0_in;
179 const ADReal e0_in =
_fp.e_from_p_rho(p0_in, rho0_in);
180 const ADReal c0_in =
_fp.c_from_v_e(v0_in, e0_in);
216 x1 = (x1_iter -
_speeds.begin()) - 1;
217 x2 = (x2_iter -
_speeds.begin());
225 const ADReal Rp_m = (y2_Rp - y1_Rp) / (x2_spd - x1_spd);
230 const ADReal eff_m = (y2_eff - y1_eff) / (x2_spd - x1_spd);
242 eff_comp = 1.0 /
_eff;
250 const ADReal p0_out = p0_in * Rp_comp;
251 const ADReal rho0_out_isen =
_fp.rho_from_p_s(p0_out, s_out);
253 const ADReal e0_out_isen =
_fp.e_from_p_rho(p0_out, rho0_out_isen);
267 const ADReal g_x = h0_out_isen - h0_in + h0_in * eff_comp;
268 const ADReal h0_out = g_x / eff_comp;
ADReal _Rp
Pressure ratio.
const ADVariableValue & _rhoA
rho*A of the connected flow channels
virtual void initialize()
const Real & _omega_rated
Rated compressor speed.
ADShaftConnectedCompressor1PhaseUserObject(const InputParameters ¶ms)
const std::vector< Real > & _speeds
Compressor speeds which correspond to Rp and eff function order.
std::vector< std::vector< dof_id_type > > _flow_channel_dofs
Degrees of freedom for flow channel variables, for each connection.
void e_from_arhoA_arhouA_arhoEA(Real arhoA, Real arhouA, Real arhoEA, Real &e, Real &de_darhoA, Real &de_darhouA, Real &de_darhoEA)
Computes specific internal energy and its derivatives from alpha*rho*A, alpha*rho*u*A, and alpha*rho*E*A.
const bool _treat_as_turbine
Treat the compressor as a turbine?
ADReal _delta_p
Compressor delta p.
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
std::vector< const Function * > _Rp_functions
Pressure ratio functions.
ADReal getDissipationTorque() const
Dissipation torque computed in the 1-phase shaft-connected compressor.
unsigned int getBoundaryIDIndex()
Gets the index of the currently executing boundary within the vector of boundary IDs given to this Si...
ADReal _isentropic_torque
Compressor isentropic torque.
const Real & _c0_rated
Rated compressor inlet stagnation sound speed.
static InputParameters validParams()
const SinglePhaseFluidProperties & _fp
Single-phase fluid properties user object.
ADReal _friction_torque
Compressor friction torque.
const std::vector< FunctionName > & _eff_function_names
Names of the adiabatic efficiency functions.
const std::vector< FunctionName > & _Rp_function_names
Names of the pressure ratio functions.
virtual void initialize() override
const Parallel::Communicator & comm() const
virtual void computeFluxesAndResiduals(const unsigned int &c) override
Computes and stores the fluxes, the scalar residuals, and their Jacobians.
const Real & _tau_fr_const
Compressor friction constant.
unsigned int _n_flux_eq
Number of flow channel flux components.
registerMooseObject("ThermalHydraulicsApp", ADShaftConnectedCompressor1PhaseUserObject)
const unsigned int _n_connections
Number of connected flow channels.
DualNumber< Real, DNDerivativeType, true > ADReal
virtual void initialize() override
virtual const std::string & name() const
std::vector< const Function * > _eff_functions
Adiabatic efficiency functions.
static InputParameters validParams()
std::vector< ADReal > _residual
Cached scalar residual vector.
ADReal _flow_rel_corr
relative corrected mass flow rate
virtual void setOmegaDofs(const MooseVariableScalar *omega_var)
virtual void initialSetup() override
ADReal getFrictionTorque() const
Friction torque computed in the 1-phase shaft-connected compressor.
const std::vector< Real > & _inertia_coeff
Compressor inertia coefficients.
virtual void threadJoin(const UserObject &uo) override
ADReal getIsentropicTorque() const
Isentropic torque computed in the 1-phase shaft-connected compressor.
const Real & _Rp_min
Minimum pressure ratio.
const Real & _A_ref
Reference area.
virtual void storeConnectionData()
Stores data (connection index, face shape functions, DoFs associated with flow channel variables) rel...
const std::vector< Real > & _tau_fr_coeff
Compressor friction coefficients.
const Real & _inertia_const
Compressor inertia constant.
const ADVariableValue & _rhoEA
rho*E*A of the connected flow channels
const MooseVariableScalar * getScalarVar(const std::string &var_name, unsigned int comp) const
Point _di_out
Direction of the compressor outlet.
virtual void setupJunctionData(std::vector< dof_id_type > &scalar_dofs)
Stores data associated with a junction component.
virtual void initialSetup() override
ADReal getRelativeCorrectedSpeed() const
Gets the elative corrected shaft speed.
const Real & _Rp_max
Maximum pressure ratio.
Computes and caches flux and residual vectors for a 1-phase volume junction.
const Real & _speed_cr_I
Compressor speed threshold for inertia.
ADReal getRelativeCorrectedMassFlowRate() const
Gets the relative corrected mass flow rate.
virtual void threadJoin(const UserObject &uo)
const unsigned int _n_speeds
Size of vector _speeds.
virtual void threadJoin(const UserObject &uo) override
virtual void finalize() override
const Real & _rho0_rated
Rated compressor inlet stagnation fluid density.
virtual void execute() override
std::vector< dof_id_type > _scalar_dofs
Degrees of freedom for scalar variables.
ADReal _moment_of_inertia
Moment of inertia.
Interface class for user objects that are connected to a shaft.
const ADVariableValue & _A
Cross-sectional area of connected flow channels.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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.
const Function & getFunctionByName(const FunctionName &name) const
ADReal getEfficiency() const
Gets the efficiency.
static const std::string alpha
const Real & _mdot_rated
Rated compressor mass flow rate.
Computes and caches flux and residual vectors for a 1-phase compressor.
ADReal _dissipation_torque
Compressor dissipation torque.
ADReal _speed_rel_corr
relative corrected shaft speed
void mooseError(Args &&... args) const
virtual void finalize() override
const ADVariableValue & _omega
ADReal getPressureRatio() const
Gets the pressure ratio.
ADReal getCompressorDeltaP() const
Compressor head computed in the 1-phase shaft-connected compressor.
virtual void setupConnections(unsigned int n_connections, unsigned int n_flow_eq)
ADReal _torque
Total torque.
static InputParameters validParams()
void h_from_e_p_rho(Real e, Real p, Real rho, Real &h, Real &dh_de, Real &dh_dp, Real &dh_drho)
Computes specific enthalpy and its derivatives from specific internal energy, pressure, and density.
const Real & _speed_cr_fr
Compressor speed threshold for friction.
const ADVariableValue & _rhouA
rho*u*A of the connected flow channels
virtual void computeFluxesAndResiduals(const unsigned int &c) override
Computes and stores the fluxes, the scalar residuals, and their Jacobians.