LCOV - code coverage report
Current view: top level - src/materials - RegularSolutionFreeEnergy.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 21 22 95.5 %
Date: 2025-09-04 07:55:36 Functions: 2 2 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 "RegularSolutionFreeEnergy.h"
      11             : 
      12             : registerMooseObject("PhaseFieldApp", RegularSolutionFreeEnergy);
      13             : 
      14             : InputParameters
      15         188 : RegularSolutionFreeEnergy::validParams()
      16             : {
      17         188 :   InputParameters params = DerivativeParsedMaterialHelper::validParams();
      18         188 :   params.addClassDescription("Material that implements the free energy of a regular solution");
      19         376 :   params.addRequiredCoupledVar("c", "Concentration variable");
      20         376 :   params.addCoupledVar("T", 300, "Temperature variable");
      21         376 :   params.addParam<Real>("omega", 0.1, "Regular solution parameter");
      22         376 :   params.addParam<Real>("kB", 8.6173324e-5, "Boltzmann constant");
      23         376 :   params.addParam<Real>(
      24             :       "log_tol", "If specified logarithms are evaluated using a Taylor expansion below this value");
      25         188 :   return params;
      26           0 : }
      27             : 
      28         144 : RegularSolutionFreeEnergy::RegularSolutionFreeEnergy(const InputParameters & parameters)
      29             :   : DerivativeParsedMaterialHelper(parameters),
      30         144 :     _c("c"),
      31         144 :     _T("T"),
      32         288 :     _omega(getParam<Real>("omega")),
      33         576 :     _kB(getParam<Real>("kB"))
      34             : {
      35         144 :   EBFunction free_energy;
      36             :   // Definition of the free energy for the expression builder
      37         144 :   free_energy(_c) =
      38         288 :       _omega * _c * (1.0 - _c) + _kB * _T * (_c * log(_c) + (1.0 - _c) * log(1.0 - _c));
      39             : 
      40             :   // Use Taylor expanded logarithm?
      41         288 :   if (isParamValid("log_tol"))
      42         144 :     free_energy.substitute(EBLogPlogSubstitution(getParam<Real>("log_tol")));
      43             : 
      44             :   // Parse function for automatic differentiation
      45         144 :   functionParse(free_energy);
      46         144 : }

Generated by: LCOV version 1.14