LCOV - code coverage report
Current view: top level - src/kernels - SoretDiffusion.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #32971 (54bef8) with base c6cf66 Lines: 34 35 97.1 %
Date: 2026-05-29 20:38:39 Functions: 6 6 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 "SoretDiffusion.h"
      11             : 
      12             : // MOOSE includes
      13             : #include "MooseVariable.h"
      14             : 
      15             : registerMooseObject("PhaseFieldApp", SoretDiffusion);
      16             : 
      17             : InputParameters
      18          60 : SoretDiffusion::validParams()
      19             : {
      20          60 :   InputParameters params = Kernel::validParams();
      21          60 :   params.addClassDescription("Add Soret effect to Split formulation Cahn-Hilliard Kernel");
      22         120 :   params.addRequiredCoupledVar("T", "Temperature");
      23         120 :   params.addCoupledVar("c", "Concentration");
      24         120 :   params.addRequiredParam<MaterialPropertyName>("diff_name",
      25             :                                                 "The diffusivity used with the kernel");
      26         120 :   params.addParam<MaterialPropertyName>(
      27             :       "Q_name", "Qheat", "The material name for the heat of transport");
      28          60 :   return params;
      29           0 : }
      30             : 
      31          32 : SoretDiffusion::SoretDiffusion(const InputParameters & parameters)
      32             :   : Kernel(parameters),
      33          32 :     _T_var(coupled("T")),
      34          32 :     _T(coupledValue("T")),
      35          32 :     _grad_T(coupledGradient("T")),
      36          32 :     _is_coupled(isCoupled("c")),
      37          32 :     _c_var(_is_coupled ? coupled("c") : _var.number()),
      38          32 :     _c(_is_coupled ? coupledValue("c") : _u),
      39          64 :     _D(getMaterialProperty<Real>("diff_name")),
      40          64 :     _Q(getMaterialProperty<Real>("Q_name")),
      41          32 :     _kB(8.617343e-5) // Boltzmann constant in eV/K
      42             : {
      43          32 : }
      44             : 
      45             : Real
      46     5526240 : SoretDiffusion::computeQpResidual()
      47             : {
      48     5526240 :   const Real T_term = _D[_qp] * _Q[_qp] * _c[_qp] / (_kB * _T[_qp] * _T[_qp]);
      49     5526240 :   return T_term * _grad_T[_qp] * _grad_test[_i][_qp];
      50             : }
      51             : 
      52             : Real
      53     8078960 : SoretDiffusion::computeQpJacobian()
      54             : {
      55     8078960 :   return (_is_coupled && _c_var != _var.number()) ? 0.0 : computeQpCJacobian();
      56             : }
      57             : 
      58             : Real
      59     2058000 : SoretDiffusion::computeQpOffDiagJacobian(unsigned int jvar)
      60             : {
      61             :   // c Off-Diagonal Jacobian
      62     2058000 :   if (_c_var == jvar)
      63      690480 :     return computeQpCJacobian();
      64             : 
      65             :   // T Off-Diagonal Jacobian
      66     1367520 :   if (_T_var == jvar)
      67     1367520 :     return _D[_qp] * _Q[_qp] * _c[_qp] * _grad_test[_i][_qp] *
      68     1367520 :            (_grad_phi[_j][_qp] - 2.0 * _grad_T[_qp] * _phi[_j][_qp] / _T[_qp]) /
      69     1367520 :            (_kB * _T[_qp] * _T[_qp]);
      70             : 
      71             :   return 0.0;
      72             : }
      73             : 
      74             : Real
      75     8078960 : SoretDiffusion::computeQpCJacobian()
      76             : {
      77             :   // Calculate the Jacobian for the c variable
      78     8078960 :   return _D[_qp] * _Q[_qp] * _phi[_j][_qp] * _grad_T[_qp] / (_kB * _T[_qp] * _T[_qp]) *
      79     8078960 :          _grad_test[_i][_qp];
      80             : }

Generated by: LCOV version 1.14