https://mooseframework.inl.gov
ADShaftConnectedMotorUserObject.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 
11 #include "Function.h"
12 
14 
17 {
20  params.addRequiredParam<FunctionName>("torque", "Torque as a function of shaft speed");
21  params.addRequiredParam<FunctionName>("inertia",
22  "Moment of inertia as a function of shaft speed");
23  params.addRequiredCoupledVar("shaft_speed", "Shaft speed");
24  params.addClassDescription(
25  "Computes the torque and moment of inertia of a shaft connected motor");
26  return params;
27 }
28 
30  : GeneralUserObject(params),
32  _torque_fn(getFunction("torque")),
33  _inertia_fn(getFunction("inertia")),
34  _shaft_speed(adCoupledScalarValue("shaft_speed"))
35 {
36 }
37 
38 ADReal
40 {
41  const ADReal & shaft_speed = _shaft_speed[0];
42  ADReal torque = _torque_fn.value(MetaPhysicL::raw_value(shaft_speed), Point());
43  torque.derivatives() = _torque_fn.timeDerivative(MetaPhysicL::raw_value(shaft_speed), Point()) *
44  shaft_speed.derivatives();
45  return torque;
46 }
47 
48 ADReal
50 {
51  const ADReal & shaft_speed = _shaft_speed[0];
52  ADReal inertia = _inertia_fn.value(MetaPhysicL::raw_value(shaft_speed), Point());
53  inertia.derivatives() = _inertia_fn.timeDerivative(MetaPhysicL::raw_value(shaft_speed), Point()) *
54  shaft_speed.derivatives();
55  return inertia;
56 }
57 
58 void
60 {
61 }
62 
63 void
65 {
66 }
67 
68 void
70 {
72 }
registerMooseObject("ThermalHydraulicsApp", ADShaftConnectedMotorUserObject)
const Function & _inertia_fn
Moment of inertia as a function of shaft speed.
virtual ADReal getTorque() const override
static InputParameters validParams()
const Function & _torque_fn
Torque as a function of shaft speed.
virtual Real timeDerivative(Real t, const Point &p) const
auto raw_value(const Eigen::Map< T > &in)
User object to provide data for a shaft-connected motor.
const ADVariableValue & _shaft_speed
Shaft speed.
DualNumber< Real, DNDerivativeType, true > ADReal
void addRequiredParam(const std::string &name, const std::string &doc_string)
ADShaftConnectedMotorUserObject(const InputParameters &params)
virtual ADReal getMomentOfInertia() const override
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
Interface class for user objects that are connected to a shaft.
void addClassDescription(const std::string &doc_string)
virtual Real value(Real t, const Point &p) const