LCOV - code coverage report
Current view: top level - src/materials - RosenthalTemperatureSource.C (source / functions) Hit Total Coverage
Test: idaholab/malamute: 0e4c8a Lines: 43 45 95.6 %
Date: 2025-08-02 07:01:39 Functions: 3 6 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /****************************************************************************/
       2             : /*                        DO NOT MODIFY THIS HEADER                         */
       3             : /*                                                                          */
       4             : /* MALAMUTE: MOOSE Application Library for Advanced Manufacturing UTilitiEs */
       5             : /*                                                                          */
       6             : /*           Copyright 2021 - 2024, Battelle Energy Alliance, LLC           */
       7             : /*                           ALL RIGHTS RESERVED                            */
       8             : /****************************************************************************/
       9             : 
      10             : #include "RosenthalTemperatureSource.h"
      11             : 
      12             : registerMooseObject("MalamuteApp", RosenthalTemperatureSource);
      13             : registerMooseObject("MalamuteApp", ADRosenthalTemperatureSource);
      14             : 
      15             : template <bool is_ad>
      16             : InputParameters
      17           8 : RosenthalTemperatureSourceTempl<is_ad>::validParams()
      18             : {
      19           8 :   InputParameters params = Material::validParams();
      20           8 :   params.addClassDescription("Computes the thermal profile following the Rosenthal equation");
      21          16 :   params.addParam<MaterialPropertyName>(
      22             :       "thermal_conductivity", "thermal_conductivity", "Property name of the thermal conductivity");
      23          16 :   params.addParam<MaterialPropertyName>(
      24             :       "specific_heat", "specific_heat", "Property name of the specific heat");
      25          16 :   params.addParam<MaterialPropertyName>("density", "density", "Property name of the density");
      26          16 :   params.addParam<MaterialPropertyName>(
      27             :       "absorptivity", "absorptivity", "Property name of the power absorption coefficient");
      28          16 :   params.addRequiredParam<Real>("power", "Laser power");
      29          16 :   params.addRequiredParam<Real>("velocity", "Scanning velocity");
      30          16 :   params.addParam<Real>(
      31          16 :       "ambient_temperature", 300, "Ambient temparature far away from the surface");
      32          16 :   params.addRequiredParam<Real>("melting_temperature", "Melting temparature of the material");
      33          16 :   params.addParam<Real>("initial_position", 0.0, "Initial coordiate of the heat source");
      34           8 :   return params;
      35           0 : }
      36             : template <bool is_ad>
      37           6 : RosenthalTemperatureSourceTempl<is_ad>::RosenthalTemperatureSourceTempl(
      38             :     const InputParameters & parameters)
      39             :   : Material(parameters),
      40           6 :     _P(getParam<Real>("power")),
      41          12 :     _V(getParam<Real>("velocity")),
      42          12 :     _T0(getParam<Real>("ambient_temperature")),
      43          12 :     _Tm(getParam<Real>("melting_temperature")),
      44          12 :     _x0(getParam<Real>("initial_position")),
      45           6 :     _thermal_conductivity(getGenericMaterialProperty<Real, is_ad>("thermal_conductivity")),
      46           6 :     _specific_heat(getGenericMaterialProperty<Real, is_ad>("specific_heat")),
      47           6 :     _density(getGenericMaterialProperty<Real, is_ad>("density")),
      48           6 :     _absorptivity(getGenericMaterialProperty<Real, is_ad>("absorptivity")),
      49          12 :     _thermal_diffusivity(declareGenericProperty<Real, is_ad>("thermal_diffusivity")),
      50          12 :     _temp_source(declareGenericProperty<Real, is_ad>("temp_source")),
      51          12 :     _meltpool_depth(declareGenericProperty<Real, is_ad>("meltpool_depth")),
      52          18 :     _meltpool_width(declareGenericProperty<Real, is_ad>("meltpool_width"))
      53             : {
      54           6 : }
      55             : 
      56             : template <bool is_ad>
      57             : void
      58         384 : RosenthalTemperatureSourceTempl<is_ad>::computeQpProperties()
      59             : {
      60         384 :   const Real & x = _q_point[_qp](0);
      61             :   const Real & y = _q_point[_qp](1);
      62             :   const Real & z = _q_point[_qp](2);
      63             : 
      64             :   // Moving heat source and distance
      65         384 :   Real x_t = x - _x0 - _V * _t;
      66         384 :   Real r = std::sqrt(x_t * x_t + y * y + z * z);
      67             : 
      68        1152 :   _thermal_diffusivity[_qp] = _thermal_conductivity[_qp] / (_specific_heat[_qp] * _density[_qp]);
      69             : 
      70        1536 :   _temp_source[_qp] = _T0 + (_absorptivity[_qp] * _P) /
      71         384 :                                 (2.0 * libMesh::pi * _thermal_conductivity[_qp] * r) *
      72        1152 :                                 std::exp(-_V / (2.0 * _thermal_diffusivity[_qp]) * (r + x_t));
      73         384 :   if (_temp_source[_qp] > _Tm)
      74           0 :     _temp_source[_qp] = _Tm;
      75             : 
      76         384 :   _meltpool_depth[_qp] =
      77         768 :       std::sqrt((2.0 * _absorptivity[_qp] * _P) / (std::exp(1.0) * libMesh::pi * _density[_qp] *
      78         384 :                                                    _specific_heat[_qp] * (_Tm - _T0) * _V));
      79             : 
      80         768 :   _meltpool_width[_qp] = 2.0 * _meltpool_depth[_qp];
      81         384 : }
      82             : 
      83             : template class RosenthalTemperatureSourceTempl<false>;
      84             : template class RosenthalTemperatureSourceTempl<true>;

Generated by: LCOV version 1.14