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.addClassDescription("Motor to drive a shaft component");
24  return params;
25 }
26 
28  : Component(parameters),
29  ShaftConnectable(this),
30  _torque_fn_name(getParam<FunctionName>("torque")),
31  _inertia_fn_name(getParam<FunctionName>("inertia"))
32 {
33 }
34 
35 void
37 {
39 }
40 
41 void
43 {
44 }
45 
46 void
48 {
49  const Shaft & shaft = getComponentByName<Shaft>(_shaft_name);
50  const VariableName shaft_speed_var_name = shaft.getOmegaVariableName();
51 
52  const UserObjectName & uo_name = getShaftConnectedUserObjectName();
53  if (getParam<bool>("ad"))
54  {
55  std::string class_name = "ADShaftConnectedMotorUserObject";
56  InputParameters params = _factory.getValidParams(class_name);
57  params.set<FunctionName>("torque") = _torque_fn_name;
58  params.set<FunctionName>("inertia") = _inertia_fn_name;
59  params.set<std::vector<VariableName>>("shaft_speed") = {shaft_speed_var_name};
60  getTHMProblem().addUserObject(class_name, uo_name, params);
61  }
62  else
63  {
64  std::string class_name = "ShaftConnectedMotorUserObject";
65  InputParameters params = _factory.getValidParams(class_name);
66  params.set<FunctionName>("torque") = _torque_fn_name;
67  params.set<FunctionName>("inertia") = _inertia_fn_name;
68  params.set<std::vector<VariableName>>("shaft_speed") = {shaft_speed_var_name};
69  getTHMProblem().addUserObject(class_name, uo_name, params);
70  }
71 }
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
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:28
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:497
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)