Line data Source code
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 : 15 : InputParameters 16 532 : ShaftConnectedMotor::validParams() 17 : { 18 532 : InputParameters params = Component::validParams(); 19 532 : params += ShaftConnectable::validParams(); 20 1064 : params.addRequiredParam<FunctionName>("torque", "Driving torque supplied by the motor [kg-m^2]"); 21 1064 : params.addRequiredParam<FunctionName>("inertia", "Moment of inertia from the motor [N-m]"); 22 1064 : params.addParam<bool>("ad", true, "Use AD version or not"); 23 1064 : params.declareControllable("torque inertia"); 24 532 : params.addClassDescription("Motor to drive a shaft component"); 25 532 : return params; 26 0 : } 27 : 28 266 : ShaftConnectedMotor::ShaftConnectedMotor(const InputParameters & parameters) 29 : : Component(parameters), 30 : ShaftConnectable(this), 31 266 : _torque_fn_name(getParam<FunctionName>("torque")), 32 798 : _inertia_fn_name(getParam<FunctionName>("inertia")) 33 : { 34 266 : } 35 : 36 : void 37 266 : ShaftConnectedMotor::check() const 38 : { 39 266 : checkShaftConnection(this); 40 266 : } 41 : 42 : void 43 256 : ShaftConnectedMotor::addVariables() 44 : { 45 256 : } 46 : 47 : void 48 256 : ShaftConnectedMotor::addMooseObjects() 49 : { 50 512 : makeFunctionControllableIfConstant(_torque_fn_name, "torque"); 51 512 : makeFunctionControllableIfConstant(_inertia_fn_name, "inertia"); 52 : 53 256 : const Shaft & shaft = getComponentByName<Shaft>(_shaft_name); 54 256 : const VariableName shaft_speed_var_name = shaft.getOmegaVariableName(); 55 : 56 256 : const UserObjectName & uo_name = getShaftConnectedUserObjectName(); 57 512 : if (getParam<bool>("ad")) 58 : { 59 256 : std::string class_name = "ADShaftConnectedMotorUserObject"; 60 256 : InputParameters params = _factory.getValidParams(class_name); 61 256 : params.set<FunctionName>("torque") = _torque_fn_name; 62 512 : params.set<FunctionName>("inertia") = _inertia_fn_name; 63 768 : params.set<std::vector<VariableName>>("shaft_speed") = {shaft_speed_var_name}; 64 256 : getTHMProblem().addUserObject(class_name, uo_name, params); 65 256 : } 66 : else 67 : { 68 0 : std::string class_name = "ShaftConnectedMotorUserObject"; 69 0 : InputParameters params = _factory.getValidParams(class_name); 70 0 : params.set<FunctionName>("torque") = _torque_fn_name; 71 0 : params.set<FunctionName>("inertia") = _inertia_fn_name; 72 0 : params.set<std::vector<VariableName>>("shaft_speed") = {shaft_speed_var_name}; 73 0 : getTHMProblem().addUserObject(class_name, uo_name, params); 74 0 : } 75 256 : }