https://mooseframework.inl.gov
ShaftConnectedCompressor1Phase.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 
11 #include "FlowModelSinglePhase.h"
12 #include "Numerics.h"
13 #include "Shaft.h"
15 #include "MooseVariableScalar.h"
16 #include "Assembly.h"
17 #include "ScalarKernel.h"
19 
21 
24 {
27  params.makeParamRequired<Real>("A_ref");
28  params.addRequiredParam<BoundaryName>("inlet", "Compressor inlet");
29  params.addRequiredParam<BoundaryName>("outlet", "Compressor outlet");
30  params.set<std::vector<BoundaryName>>("connections") = {};
31  params.suppressParameter<std::vector<BoundaryName>>("connections");
32  params.addParam<bool>("treat_as_turbine", false, "Treat the compressor as a turbine?");
33  params.addRequiredParam<Real>("omega_rated", "Rated compressor speed [rad/s]");
34  params.addRequiredParam<Real>("mdot_rated", "Rated compressor mass flow rate [kg/s]");
35  params.addRequiredParam<Real>("rho0_rated", "Rated compressor stagnation fluid density [kg/m^3]");
36  params.addRequiredParam<Real>("c0_rated", "Rated compressor stagnation sound speed [m/s]");
37  params.addRequiredParam<Real>("speed_cr_fr", "Compressor speed threshold for friction [-]");
38  params.addRequiredParam<Real>("tau_fr_const", "Compressor friction constant [N-m]");
39  params.addRequiredParam<std::vector<Real>>("tau_fr_coeff",
40  "Compressor friction coefficients [N-m]");
41  params.addRequiredParam<Real>("speed_cr_I", "Compressor speed threshold for inertia [-]");
42  params.addRequiredParam<Real>("inertia_const", "Compressor inertia constant [kg-m^2]");
43  params.addRequiredParam<std::vector<Real>>("inertia_coeff",
44  "Compressor inertia coefficients [kg-m^2]");
45  params.addRequiredParam<std::vector<Real>>(
46  "speeds",
47  "Relative corrected speeds. Order of speeds needs correspond to the "
48  "orders of `Rp_functions` and `eff_functions` [-]");
49  params.addRequiredParam<std::vector<FunctionName>>(
50  "Rp_functions",
51  "Functions of pressure ratio versus relative corrected flow. Each function is for a "
52  "different, constant relative corrected speed. The order of function names should correspond "
53  "to the order of speeds in the `speeds` parameter [-]");
54  params.addRequiredParam<std::vector<FunctionName>>(
55  "eff_functions",
56  "Functions of adiabatic efficiency versus relative corrected flow. Each function is for a "
57  "different, constant relative corrected speed. The order of function names should correspond "
58  "to the order of speeds in the `speeds` parameter [-]");
59  params.addParam<Real>("min_pressure_ratio", 0.0, "Minimum pressure ratio");
60  params.addParam<Real>("max_pressure_ratio", 50.0, "Maximum pressure ratio");
61 
62  params.addClassDescription(
63  "1-phase compressor that must be connected to a Shaft component. Compressor speed "
64  "is controlled by the connected shaft; Isentropic/Dissipation torque and delta_p are "
65  "computed by user input functions of inlet flow rate and shaft speed");
66 
67  return params;
68 }
69 
71  : VolumeJunction1Phase(parameters),
72  ShaftConnectable(this),
73  _inlet(getParam<BoundaryName>("inlet")),
74  _outlet(getParam<BoundaryName>("outlet")),
75  _omega_rated(getParam<Real>("omega_rated")),
76  _mdot_rated(getParam<Real>("mdot_rated")),
77  _rho0_rated(getParam<Real>("rho0_rated")),
78  _c0_rated(getParam<Real>("c0_rated")),
79  _speed_cr_fr(getParam<Real>("speed_cr_fr")),
80  _tau_fr_const(getParam<Real>("tau_fr_const")),
81  _tau_fr_coeff(getParam<std::vector<Real>>("tau_fr_coeff")),
82  _speed_cr_I(getParam<Real>("speed_cr_I")),
83  _inertia_const(getParam<Real>("inertia_const")),
84  _inertia_coeff(getParam<std::vector<Real>>("inertia_coeff")),
85  _speeds(getParam<std::vector<Real>>("speeds")),
86  _Rp_functions(getParam<std::vector<FunctionName>>("Rp_functions")),
87  _eff_functions(getParam<std::vector<FunctionName>>("eff_functions")),
88  _delta_p_var_name(junctionVariableName("delta_p")),
89  _isentropic_torque_var_name(junctionVariableName("isentropic_torque")),
90  _dissipation_torque_var_name(junctionVariableName("dissipation_torque")),
91  _friction_torque_var_name(junctionVariableName("friction_torque")),
92  _moi_var_name(junctionVariableName("moment_of_inertia"))
93 {
94  // this determines connection ordering
97 
98  checkSizeEqualsValue<Real>("tau_fr_coeff", 4);
99  checkSizeEqualsValue<Real>("inertia_coeff", 4);
100 }
101 
102 void
104 {
106  checkShaftConnection(this);
107 }
108 
109 void
111 {
112  const Component & c = getComponentByName<Component>(_shaft_name);
113  const Shaft & scc = dynamic_cast<const Shaft &>(c);
114  const VariableName omega_var_name = scc.getOmegaVariableName();
115 
117  execute_on = {EXEC_INITIAL, EXEC_LINEAR, EXEC_NONLINEAR};
118 
119  {
120  const std::string class_name = "ADShaftConnectedCompressor1PhaseUserObject";
121  InputParameters params = _factory.getValidParams(class_name);
122  params.set<bool>("use_scalar_variables") = false;
123  params.set<subdomain_id_type>("junction_subdomain_id") = _junction_subdomain_id;
124  params.set<std::vector<BoundaryName>>("boundary") = _boundary_names;
125  params.set<std::vector<Real>>("normals") = _normals;
126  params.set<std::vector<processor_id_type>>("processor_ids") = getConnectedProcessorIDs();
127  params.set<std::vector<UserObjectName>>("numerical_flux_names") = _numerical_flux_names;
128  params.set<Real>("volume") = _volume;
129  params.set<std::vector<VariableName>>("A") = {FlowModel::AREA};
130  params.set<std::vector<VariableName>>("rhoA") = {FlowModelSinglePhase::RHOA};
131  params.set<std::vector<VariableName>>("rhouA") = {FlowModelSinglePhase::RHOUA};
132  params.set<std::vector<VariableName>>("rhoEA") = {FlowModelSinglePhase::RHOEA};
133  params.set<std::vector<VariableName>>("rhoV") = {_rhoV_var_name};
134  params.set<std::vector<VariableName>>("rhouV") = {_rhouV_var_name};
135  params.set<std::vector<VariableName>>("rhovV") = {_rhovV_var_name};
136  params.set<std::vector<VariableName>>("rhowV") = {_rhowV_var_name};
137  params.set<std::vector<VariableName>>("rhoEV") = {_rhoEV_var_name};
138  // the direction of the outlet channel
139  params.set<Point>("di_out") = _directions[1].unit();
140  params.set<Real>("omega_rated") = _omega_rated;
141  params.set<bool>("treat_as_turbine") = getParam<bool>("treat_as_turbine");
142  params.set<Real>("mdot_rated") = _mdot_rated;
143  params.set<Real>("rho0_rated") = _rho0_rated;
144  params.set<Real>("c0_rated") = _c0_rated;
145  params.set<Real>("speed_cr_fr") = _speed_cr_fr;
146  params.set<Real>("tau_fr_const") = _tau_fr_const;
147  params.set<std::vector<Real>>("tau_fr_coeff") = _tau_fr_coeff;
148  params.set<Real>("speed_cr_I") = _speed_cr_I;
149  params.set<Real>("inertia_const") = _inertia_const;
150  params.set<std::vector<Real>>("inertia_coeff") = _inertia_coeff;
151  params.set<std::vector<Real>>("speeds") = _speeds;
152  params.set<std::vector<FunctionName>>("Rp_functions") = _Rp_functions;
153  params.set<std::vector<FunctionName>>("eff_functions") = _eff_functions;
154  params.set<Real>("min_pressure_ratio") = getParam<Real>("min_pressure_ratio");
155  params.set<Real>("max_pressure_ratio") = getParam<Real>("max_pressure_ratio");
156  params.set<std::vector<VariableName>>("omega") = {omega_var_name};
157  params.set<Real>("A_ref") = getParam<Real>("A_ref");
158  params.set<Real>("K") = getParam<Real>("K");
159  params.set<UserObjectName>("fp") = _fp_name;
160  params.set<std::string>("compressor_name") = cname();
161  params.set<bool>("apply_velocity_scaling") = getParam<bool>("apply_velocity_scaling");
162  params.set<ExecFlagEnum>("execute_on") = execute_on;
164  connectObject(params, _junction_uo_name, "K");
165  }
166 }
167 
168 void
170 {
172 
178 
179  if (!_app.isRestarting())
180  {
186  }
187 }
188 
189 void
191 {
193 
194  const std::vector<std::pair<std::string, VariableName>> quantities_aux = {
195  {"delta_p", _delta_p_var_name},
196  {"isentropic_torque", _isentropic_torque_var_name},
197  {"dissipation_torque", _dissipation_torque_var_name},
198  {"friction_torque", _friction_torque_var_name},
199  {"moment_of_inertia", _moment_of_inertia_var_name}};
200  for (const auto & quantity_and_name : quantities_aux)
201  {
202  const std::string class_name = "ShaftConnectedCompressor1PhaseAux";
203  InputParameters params = _factory.getValidParams(class_name);
204  params.set<AuxVariableName>("variable") = quantity_and_name.second;
205  params.set<MooseEnum>("quantity") = quantity_and_name.first;
206  params.set<UserObjectName>("compressor_uo") = getShaftConnectedUserObjectName();
207  const std::string obj_name = genName(name(), quantity_and_name.first + "_aux");
208  params.set<std::vector<SubdomainName>>("block") = getSubdomainNames();
209  getTHMProblem().addAuxKernel(class_name, obj_name, params);
210  }
211 
212  const std::vector<std::string> quantities_pp = {
213  "pressure_ratio", "efficiency", "rel_corrected_flow", "rel_corrected_speed"};
214  for (const auto & quantity : quantities_pp)
215  {
216  const std::string class_name = "ShaftConnectedCompressor1PhasePostprocessor";
217  InputParameters params = _factory.getValidParams(class_name);
218  params.set<MooseEnum>("quantity") = quantity;
219  params.set<UserObjectName>("compressor_uo") = getShaftConnectedUserObjectName();
220  params.set<ExecFlagEnum>("execute_on") = {EXEC_INITIAL, EXEC_TIMESTEP_END};
221  getTHMProblem().addPostprocessor(class_name, Component::genName(name(), quantity), params);
222  }
223 }
virtual void check() const override
Check the component integrity.
virtual UserObjectName getShaftConnectedUserObjectName() const override
const Real & _rho0_rated
Rated compressor inlet stagnation fluid density.
virtual void addVariables() override
std::string genName(const std::string &prefix, unsigned int id, const std::string &suffix="") const
Build a name from a prefix, number and possible suffix.
std::string _shaft_name
Name of the shaft component.
const VariableName _rhoV_var_name
rho*V variable name for junction
const std::vector< processor_id_type > & getConnectedProcessorIDs()
Gets the processor IDs of the connected 1D components.
static InputParameters validParams()
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
static const std::string AREA
Definition: FlowModel.h:102
const Real & _speed_cr_fr
Compressor speed threshold for friction.
THMProblem & getTHMProblem() const
Gets the THM problem.
Definition: Component.C:135
const std::vector< Real > & _speeds
Compressor speeds which correspond to Rp and eff function order.
const VariableName _dissipation_torque_var_name
Name of compressor dissipation torque variable.
const VariableName _rhovV_var_name
rho*v*V variable name for junction
T & set(const std::string &name, bool quiet_mode=false)
InputParameters getValidParams(const std::string &name) const
const std::string & cname() const
Get the component name.
Definition: Component.C:51
registerMooseObject("ThermalHydraulicsApp", ShaftConnectedCompressor1Phase)
const Real & _tau_fr_const
Compressor friction constant.
const Real & _mdot_rated
Rated compressor mass flow rate.
const Real & _c0_rated
Rated compressor inlet stagnation sound speed.
virtual void buildVolumeJunctionUserObject() override
Builds user object for computing and storing the fluxes.
const ExecFlagType EXEC_TIMESTEP_END
virtual void addAuxKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
const BoundaryName & _outlet
Compressor outlet.
const Real & _speed_cr_I
Compressor speed threshold for inertia.
static InputParameters validParams()
const VariableName _rhowV_var_name
rho*w*V variable name for junction
bool isRestarting() const
const VariableName _isentropic_torque_var_name
Name of compressor isentropic torque variable.
virtual void checkShaftConnection(const Component *const component) const
std::vector< BoundaryName > _boundary_names
Boundary names of connected components.
void addConnection(const BoundaryName &boundary_name)
Adds a connection for this component.
virtual const std::string & name() const
void addRequiredParam(const std::string &name, const std::string &doc_string)
const VariableName _delta_p_var_name
Name of compressor delta_p variable.
void suppressParameter(const std::string &name)
ExecFlagEnum getDefaultExecFlagEnum()
Component that connects torque of turbomachinery components.
Definition: Shaft.h:17
virtual void addPostprocessor(const std::string &pp_name, const std::string &name, InputParameters &parameters)
void addJunctionIC(const VariableName &var, Real value)
Adds a junction IC to the problem, as a scalar or field variable.
const BoundaryName & _inlet
Compressor inlet.
static const std::string RHOUA
std::vector< UserObjectName > _numerical_flux_names
virtual void check() const override
Check the component integrity.
static const std::string RHOA
virtual void addMooseObjects() override
Base class for THM components.
Definition: Component.h:27
const Real _volume
Volume of the junction.
VariableName _moment_of_inertia_var_name
Moment of inertia variable name.
1-phase compressor that must be connected to a Shaft component
void addJunctionVariable(bool is_nonlinear, const VariableName &var, Real scaling_factor=1.0)
Adds a junction variable to the problem, as a scalar or field variable.
const ExecFlagType EXEC_LINEAR
const std::vector< FunctionName > & _Rp_functions
Names of the pressure ratio functions.
ShaftConnectedCompressor1Phase(const InputParameters &params)
Junction between 1-phase flow channels that has a non-zero volume.
const ExecFlagType EXEC_NONLINEAR
const std::string _junction_uo_name
Name of junction user object name, if any.
Definition: FlowJunction.h:40
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
MooseApp & _app
virtual VariableName getOmegaVariableName() const
Definition: Shaft.C:129
Factory & _factory
The Factory associated with the MooseApp.
Definition: Component.h:446
void connectObject(const InputParameters &params, const std::string &mooseName, const std::string &name) const
Connect with control logic.
Definition: Component.C:98
Interface class for components that connect to a shaft.
UserObjectName _fp_name
Fluid property user object name.
Definition: FlowJunction.h:38
virtual std::vector< std::shared_ptr< UserObject > > addUserObject(const std::string &user_object_name, const std::string &name, InputParameters &parameters)
const std::vector< Real > & _inertia_coeff
Compressor inertia coefficients.
void makeParamRequired(const std::string &name)
const std::vector< FunctionName > & _eff_functions
Names of the adiabatic efficiency functions.
void addClassDescription(const std::string &doc_string)
static const std::string RHOEA
const VariableName _rhouV_var_name
rho*u*V variable name for junction
const std::vector< Real > & _tau_fr_coeff
Compressor friction coefficients.
virtual const std::vector< SubdomainName > & getSubdomainNames() const
Gets the subdomain names for this component.
Definition: Component.C:307
const Real & _inertia_const
Compressor inertia constant.
std::vector< Real > _normals
Outward normals associated with connected components.
std::vector< RealVectorValue > _directions
Directions of connected components.
const VariableName _rhoEV_var_name
rho*E*V variable name for junction
subdomain_id_type _junction_subdomain_id
Junction subdomain ID.
const Real & _omega_rated
Rated compressor speed.
const VariableName _friction_torque_var_name
Name of compressor friction torque variable.
const ExecFlagType EXEC_INITIAL