LCOV - code coverage report
Current view: top level - src/userobjects - ADShaftConnectedMotorUserObject.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 30 31 96.8 %
Date: 2025-07-30 13:02:48 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         512 : ADShaftConnectedMotorUserObject::validParams()
      17             : {
      18         512 :   InputParameters params = GeneralUserObject::validParams();
      19         512 :   params += ADShaftConnectableUserObjectInterface::validParams();
      20        1024 :   params.addRequiredParam<FunctionName>("torque", "Torque as a function of shaft speed");
      21        1024 :   params.addRequiredParam<FunctionName>("inertia",
      22             :                                         "Moment of inertia as a function of shaft speed");
      23        1024 :   params.addRequiredCoupledVar("shaft_speed", "Shaft speed");
      24         512 :   params.addClassDescription(
      25             :       "Computes the torque and moment of inertia of a shaft connected motor");
      26         512 :   return params;
      27           0 : }
      28             : 
      29         256 : ADShaftConnectedMotorUserObject::ADShaftConnectedMotorUserObject(const InputParameters & params)
      30             :   : GeneralUserObject(params),
      31             :     ADShaftConnectableUserObjectInterface(this),
      32         256 :     _torque_fn(getFunction("torque")),
      33         256 :     _inertia_fn(getFunction("inertia")),
      34         512 :     _shaft_speed(adCoupledScalarValue("shaft_speed"))
      35             : {
      36         256 : }
      37             : 
      38             : ADReal
      39       13592 : ADShaftConnectedMotorUserObject::getTorque() const
      40             : {
      41       13592 :   const ADReal & shaft_speed = _shaft_speed[0];
      42       13592 :   ADReal torque = _torque_fn.value(MetaPhysicL::raw_value(shaft_speed), Point());
      43       13592 :   torque.derivatives() = _torque_fn.timeDerivative(MetaPhysicL::raw_value(shaft_speed), Point()) *
      44             :                          shaft_speed.derivatives();
      45       13592 :   return torque;
      46             : }
      47             : 
      48             : ADReal
      49       13096 : ADShaftConnectedMotorUserObject::getMomentOfInertia() const
      50             : {
      51       13096 :   const ADReal & shaft_speed = _shaft_speed[0];
      52       13096 :   ADReal inertia = _inertia_fn.value(MetaPhysicL::raw_value(shaft_speed), Point());
      53       13096 :   inertia.derivatives() = _inertia_fn.timeDerivative(MetaPhysicL::raw_value(shaft_speed), Point()) *
      54             :                           shaft_speed.derivatives();
      55       13096 :   return inertia;
      56             : }
      57             : 
      58             : void
      59        1714 : ADShaftConnectedMotorUserObject::initialize()
      60             : {
      61        1714 : }
      62             : 
      63             : void
      64        1714 : ADShaftConnectedMotorUserObject::execute()
      65             : {
      66        1714 : }
      67             : 
      68             : void
      69        1714 : ADShaftConnectedMotorUserObject::finalize()
      70             : {
      71        1714 :   ADShaftConnectableUserObjectInterface::finalize();
      72        1714 : }

Generated by: LCOV version 1.14