LCOV - code coverage report
Current view: top level - src/userobjects - ADShaftConnectedMotorUserObject.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #32971 (54bef8) with base c6cf66 Lines: 30 31 96.8 %
Date: 2026-05-29 20:41:18 Functions: 7 7 100.0 %
Legend: Lines: hit not hit

          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 "ADShaftConnectedMotorUserObject.h"
      11             : #include "Function.h"
      12             : 
      13             : registerMooseObject("ThermalHydraulicsApp", ADShaftConnectedMotorUserObject);
      14             : 
      15             : InputParameters
      16         256 : ADShaftConnectedMotorUserObject::validParams()
      17             : {
      18         256 :   InputParameters params = GeneralUserObject::validParams();
      19         256 :   params += ADShaftConnectableUserObjectInterface::validParams();
      20         512 :   params.addRequiredParam<FunctionName>("torque", "Torque as a function of shaft speed");
      21         512 :   params.addRequiredParam<FunctionName>("inertia",
      22             :                                         "Moment of inertia as a function of shaft speed");
      23         512 :   params.addRequiredCoupledVar("shaft_speed", "Shaft speed");
      24         256 :   params.addClassDescription(
      25             :       "Computes the torque and moment of inertia of a shaft connected motor");
      26         256 :   return params;
      27           0 : }
      28             : 
      29         128 : ADShaftConnectedMotorUserObject::ADShaftConnectedMotorUserObject(const InputParameters & params)
      30             :   : GeneralUserObject(params),
      31             :     ADShaftConnectableUserObjectInterface(this),
      32         128 :     _torque_fn(getFunction("torque")),
      33         128 :     _inertia_fn(getFunction("inertia")),
      34         256 :     _shaft_speed(adCoupledScalarValue("shaft_speed"))
      35             : {
      36         128 : }
      37             : 
      38             : ADReal
      39        3097 : ADShaftConnectedMotorUserObject::getTorque() const
      40             : {
      41        3097 :   const ADReal & shaft_speed = _shaft_speed[0];
      42        3097 :   ADReal torque = _torque_fn.value(MetaPhysicL::raw_value(shaft_speed), Point());
      43        3097 :   torque.derivatives() = _torque_fn.timeDerivative(MetaPhysicL::raw_value(shaft_speed), Point()) *
      44             :                          shaft_speed.derivatives();
      45        3097 :   return torque;
      46             : }
      47             : 
      48             : ADReal
      49        2999 : ADShaftConnectedMotorUserObject::getMomentOfInertia() const
      50             : {
      51        2999 :   const ADReal & shaft_speed = _shaft_speed[0];
      52        2999 :   ADReal inertia = _inertia_fn.value(MetaPhysicL::raw_value(shaft_speed), Point());
      53        2999 :   inertia.derivatives() = _inertia_fn.timeDerivative(MetaPhysicL::raw_value(shaft_speed), Point()) *
      54             :                           shaft_speed.derivatives();
      55        2999 :   return inertia;
      56             : }
      57             : 
      58             : void
      59         497 : ADShaftConnectedMotorUserObject::initialize()
      60             : {
      61         497 : }
      62             : 
      63             : void
      64         497 : ADShaftConnectedMotorUserObject::execute()
      65             : {
      66         497 : }
      67             : 
      68             : void
      69         497 : ADShaftConnectedMotorUserObject::finalize()
      70             : {
      71         497 :   ADShaftConnectableUserObjectInterface::finalize();
      72         497 : }

Generated by: LCOV version 1.14