https://mooseframework.inl.gov
ShaftConnectedMotor.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 "ShaftConnectedMotor.h"
11 #include "Shaft.h"
12 
13 registerMooseObject("ThermalHydraulicsApp", ShaftConnectedMotor);
14 
17 {
20  params.addRequiredParam<FunctionName>("torque", "Driving torque supplied by the motor [kg-m^2]");
21  params.addRequiredParam<FunctionName>("inertia", "Moment of inertia from the motor [N-m]");
22  params.addParam<bool>("ad", true, "Use AD version or not");
23  params.declareControllable("torque inertia");
24  params.addClassDescription("Motor to drive a shaft component");
25  return params;
26 }
27 
29  : Component(parameters),
30  ShaftConnectable(this),
31  _torque_fn_name(getParam<FunctionName>("torque")),
32  _inertia_fn_name(getParam<FunctionName>("inertia"))
33 {
34 }
35 
36 void
38 {
40 }
41 
42 void
44 {
45 }
46 
47 void
49 {
52 
53  const Shaft & shaft = getComponentByName<Shaft>(_shaft_name);
54  const VariableName shaft_speed_var_name = shaft.getOmegaVariableName();
55 
56  const UserObjectName & uo_name = getShaftConnectedUserObjectName();
57  if (getParam<bool>("ad"))
58  {
59  std::string class_name = "ADShaftConnectedMotorUserObject";
60  InputParameters params = _factory.getValidParams(class_name);
61  params.set<FunctionName>("torque") = _torque_fn_name;
62  params.set<FunctionName>("inertia") = _inertia_fn_name;
63  params.set<std::vector<VariableName>>("shaft_speed") = {shaft_speed_var_name};
64  getTHMProblem().addUserObject(class_name, uo_name, params);
65  }
66  else
67  {
68  std::string class_name = "ShaftConnectedMotorUserObject";
69  InputParameters params = _factory.getValidParams(class_name);
70  params.set<FunctionName>("torque") = _torque_fn_name;
71  params.set<FunctionName>("inertia") = _inertia_fn_name;
72  params.set<std::vector<VariableName>>("shaft_speed") = {shaft_speed_var_name};
73  getTHMProblem().addUserObject(class_name, uo_name, params);
74  }
75 }
std::string _shaft_name
Name of the shaft component.
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
ShaftConnectedMotor(const InputParameters &params)
THMProblem & getTHMProblem() const
Gets the THM problem.
Definition: Component.C:135
Motor to drive a shaft component.
T & set(const std::string &name, bool quiet_mode=false)
InputParameters getValidParams(const std::string &name) const
void makeFunctionControllableIfConstant(const FunctionName &fn_name, const std::string &control_name, const std::string &param="value") const
Makes a function controllable if it is constant.
Definition: Component.C:141
static InputParameters validParams()
virtual void checkShaftConnection(const Component *const component) const
static InputParameters validParams()
Definition: Component.C:18
void addRequiredParam(const std::string &name, const std::string &doc_string)
registerMooseObject("ThermalHydraulicsApp", ShaftConnectedMotor)
Component that connects torque of turbomachinery components.
Definition: Shaft.h:17
static InputParameters validParams()
virtual void addMooseObjects() override
Base class for THM components.
Definition: Component.h:27
const FunctionName & _torque_fn_name
Torque function name.
virtual void addVariables() override
const FunctionName & _inertia_fn_name
Moment of inertia function name.
virtual UserObjectName getShaftConnectedUserObjectName() const
virtual VariableName getOmegaVariableName() const
Definition: Shaft.C:129
Factory & _factory
The Factory associated with the MooseApp.
Definition: Component.h:446
Interface class for components that connect to a shaft.
virtual std::vector< std::shared_ptr< UserObject > > addUserObject(const std::string &user_object_name, const std::string &name, InputParameters &parameters)
virtual void check() const override
Check the component integrity.
void addClassDescription(const std::string &doc_string)
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})