https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
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
35void
40
41void
45
46void
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}
registerMooseObject("ThermalHydraulicsApp", ShaftConnectedMotor)
Base class for THM components.
Definition Component.h:32
THMProblem & getTHMProblem() const
Gets the THM problem.
Definition Component.C:135
Factory & _factory
The Factory associated with the MooseApp.
Definition Component.h:497
static InputParameters validParams()
Definition Component.C:18
virtual std::vector< std::shared_ptr< UserObject > > addUserObject(const std::string &user_object_name, const std::string &name, InputParameters &parameters)
InputParameters getValidParams(const std::string &name) const
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
Interface class for components that connect to a shaft.
std::string _shaft_name
Name of the shaft component.
virtual void checkShaftConnection(const Component *const component) const
virtual UserObjectName getShaftConnectedUserObjectName() const
static InputParameters validParams()
Motor to drive a shaft component.
const FunctionName & _torque_fn_name
Torque function name.
virtual void addMooseObjects() override
virtual void check() const override
Check the component integrity.
static InputParameters validParams()
ShaftConnectedMotor(const InputParameters &params)
virtual void addVariables() override
const FunctionName & _inertia_fn_name
Moment of inertia function name.
Component that connects torque of turbomachinery components.
Definition Shaft.h:18
virtual VariableName getOmegaVariableName() const
Definition Shaft.C:129