https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SimpleTurbine1Phase.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
10#include "SimpleTurbine1Phase.h"
12
14
17{
19
20 params.addRequiredParam<Real>("power", "Turbine power [W]");
21 params.addRequiredParam<bool>("on", "Flag determining if turbine is operating or not [-]");
22
23 params.declareControllable("power on");
24
26 "Simple turbine model that extracts prescribed power from the working fluid");
27
28 return params;
29}
30
33 _on(getParam<bool>("on")),
34 _power(getParam<Real>("power")),
35 _W_dot_var_name(junctionVariableName("W_dot"))
36{
37}
38
39void
46
47void
49{
52
53 {
54 const std::string class_name = "ADSimpleTurbine1PhaseUserObject";
55 InputParameters params = _factory.getValidParams(class_name);
56 params.set<bool>("use_scalar_variables") = false;
57 params.set<subdomain_id_type>("junction_subdomain_id") = _junction_subdomain_id;
58 params.set<std::vector<BoundaryName>>("boundary") = _boundary_names;
59 params.set<std::vector<Real>>("normals") = _normals;
60 params.set<std::vector<processor_id_type>>("processor_ids") = getConnectedProcessorIDs();
61 params.set<std::vector<UserObjectName>>("numerical_flux_names") = _numerical_flux_names;
62 params.set<Real>("volume") = _volume;
63 params.set<std::string>("component_name") = name();
64 params.set<std::vector<VariableName>>("A") = {FlowModel::AREA};
65 params.set<std::vector<VariableName>>("rhoA") = {FlowModelSinglePhase::RHOA};
66 params.set<std::vector<VariableName>>("rhouA") = {FlowModelSinglePhase::RHOUA};
67 params.set<std::vector<VariableName>>("rhoEA") = {FlowModelSinglePhase::RHOEA};
68 params.set<std::vector<VariableName>>("rhoV") = {_rhoV_var_name};
69 params.set<std::vector<VariableName>>("rhouV") = {_rhouV_var_name};
70 params.set<std::vector<VariableName>>("rhovV") = {_rhovV_var_name};
71 params.set<std::vector<VariableName>>("rhowV") = {_rhowV_var_name};
72 params.set<std::vector<VariableName>>("rhoEV") = {_rhoEV_var_name};
73 params.set<RealVectorValue>("dir_c0") = _directions[0];
74 params.set<Real>("K") = _K;
75 params.set<Real>("A_ref") = _A_ref;
76 params.set<bool>("on") = _on;
77 params.set<Real>("W_dot") = _power;
78 params.set<UserObjectName>("fp") = _fp_name;
79 params.set<ExecFlagEnum>("execute_on") = execute_on;
80 getTHMProblem().addUserObject(class_name, _junction_uo_name, params);
81 connectObject(params, _junction_uo_name, "power", "W_dot");
82 connectObject(params, _junction_uo_name, "on");
83 connectObject(params, _junction_uo_name, "K");
84 }
85}
86
87void
89{
91
92 {
93 const std::string nm = genName(name(), "W_dot_aux");
94 const std::string class_name = "SimpleTurbinePowerFieldAux";
95 InputParameters params = _factory.getValidParams(class_name);
96 params.set<AuxVariableName>("variable") = _W_dot_var_name;
97 params.set<Real>("value") = _power;
98 params.set<bool>("on") = _on;
99 params.set<std::vector<SubdomainName>>("block") = getSubdomainNames();
100 getTHMProblem().addAuxKernel(class_name, nm, params);
101 connectObject(params, nm, "power", "value");
102 connectObject(params, nm, "on");
103 }
104}
const ExecFlagType EXEC_INITIAL
const ExecFlagType EXEC_LINEAR
const ExecFlagType EXEC_NONLINEAR
const std::string name
Definition Setup.h:21
registerMooseObject("ThermalHydraulicsApp", SimpleTurbine1Phase)
std::vector< Real > _normals
Outward normals associated with connected components.
std::vector< RealVectorValue > _directions
Directions of connected components.
std::vector< BoundaryName > _boundary_names
Boundary names of connected components.
const std::vector< processor_id_type > & getConnectedProcessorIDs()
Gets the processor IDs of the connected 1D components.
subdomain_id_type _junction_subdomain_id
Junction subdomain ID.
virtual void addMooseObjects()
Definition Component.h:115
virtual const std::vector< SubdomainName > & getSubdomainNames() const
Gets the subdomain names for this component.
Definition Component.C:345
THMProblem & getTHMProblem() const
Gets the THM problem.
Definition Component.C:135
Factory & _factory
The Factory associated with the MooseApp.
Definition Component.h:497
virtual void addVariables()
Definition Component.h:113
void connectObject(const InputParameters &obj_params, const std::string &obj_name, const std::string &param) const
Connects a controllable parameter of the component to a controllable parameter of a constituent objec...
Definition Component.C:98
virtual std::vector< std::shared_ptr< UserObject > > addUserObject(const std::string &user_object_name, const std::string &name, InputParameters &parameters)
virtual void addAuxKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
InputParameters getValidParams(const std::string &name) const
std::vector< UserObjectName > _numerical_flux_names
const std::string _junction_uo_name
Name of junction user object name, if any.
UserObjectName _fp_name
Fluid property user object name.
static const std::string RHOUA
static const std::string RHOA
static const std::string RHOEA
static const std::string AREA
Definition FlowModel.h:102
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)
T & set(const std::string &name, bool quiet_mode=false)
Junction between 1-phase flow channels that are parallel.
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.
Simple turbine model that extracts prescribed power from the working fluid.
const bool & _on
Flag that specifies if the turbine is operating or not.
SimpleTurbine1Phase(const InputParameters &params)
VariableName _W_dot_var_name
Variable name that holds power.
static InputParameters validParams()
const Real & _power
Turbine power [W].
virtual void addVariables() override
virtual void buildVolumeJunctionUserObject() override
Builds user object for computing and storing the fluxes.
virtual void addMooseObjects() override
const VariableName _rhovV_var_name
rho*v*V variable name for junction
const Real _volume
Volume of the junction.
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 Real & _K
Form loss coefficient.
const VariableName _rhoEV_var_name
rho*E*V variable name for junction
const VariableName _rhoV_var_name
rho*V variable name for junction
const VariableName _rhowV_var_name
rho*w*V variable name for junction
const VariableName _rhouV_var_name
rho*u*V variable name for junction
const Real & _A_ref
Reference area.
ExecFlagEnum getDefaultExecFlagEnum()