www.mooseframework.org
RegularSolutionFreeEnergy.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
11 
13 
14 template <>
15 InputParameters
17 {
18  InputParameters params = validParams<DerivativeParsedMaterialHelper>();
19  params.addClassDescription("Material that implements the free energy of a regular solution");
20  params.addRequiredCoupledVar("c", "Concentration variable");
21  params.addCoupledVar("T", 300, "Temperature variable");
22  params.addParam<Real>("omega", 0.1, "Regular solution parameter");
23  params.addParam<Real>("kB", 8.6173324e-5, "Boltzmann constant");
24  params.addParam<Real>(
25  "log_tol", "If specified logarithms are evaluated using a Taylor expansion below this value");
26  return params;
27 }
28 
29 RegularSolutionFreeEnergy::RegularSolutionFreeEnergy(const InputParameters & parameters)
30  : DerivativeParsedMaterialHelper(parameters),
31  _c("c"),
32  _T("T"),
33  _omega(getParam<Real>("omega")),
34  _kB(getParam<Real>("kB"))
35 {
36  EBFunction free_energy;
37  // Definition of the free energy for the expression builder
38  free_energy(_c) =
39  _omega * _c * (1.0 - _c) + _kB * _T * (_c * log(_c) + (1.0 - _c) * log(1.0 - _c));
40 
41  // Use Taylor expanded logarithm?
42  if (isParamValid("log_tol"))
43  free_energy.substitute(EBLogPlogSubstitution(getParam<Real>("log_tol")));
44 
45  // Parse function for automatic differentiation
46  functionParse(free_energy);
47 }
ExpressionBuilder::EBFunction
User facing host object for a function. This combines a term with an argument list.
Definition: ExpressionBuilder.h:520
RegularSolutionFreeEnergy::_omega
const Real _omega
Prefactor.
Definition: RegularSolutionFreeEnergy.h:39
RegularSolutionFreeEnergy
Material class that creates regular solution free energy with the expression builder and uses automat...
Definition: RegularSolutionFreeEnergy.h:26
RegularSolutionFreeEnergy::_c
EBTerm _c
Coupled variable value for the concentration .
Definition: RegularSolutionFreeEnergy.h:33
RegularSolutionFreeEnergy::RegularSolutionFreeEnergy
RegularSolutionFreeEnergy(const InputParameters &parameters)
Definition: RegularSolutionFreeEnergy.C:29
ExpressionBuilder::EBFunction::substitute
unsigned int substitute(const EBSubstitutionRule &rule)
Definition: ExpressionBuilder.C:231
RegularSolutionFreeEnergy::_T
EBTerm _T
Coupled temperature variable .
Definition: RegularSolutionFreeEnergy.h:36
RegularSolutionFreeEnergy.h
RegularSolutionFreeEnergy::_kB
const Real _kB
Boltzmann constant.
Definition: RegularSolutionFreeEnergy.h:42
ExpressionBuilder::EBLogPlogSubstitution
Substitution rule to replace all occurences of log(x) with plog(x, epsilon) with a user defined term ...
Definition: ExpressionBuilder.h:338
registerMooseObject
registerMooseObject("PhaseFieldApp", RegularSolutionFreeEnergy)
validParams< RegularSolutionFreeEnergy >
InputParameters validParams< RegularSolutionFreeEnergy >()
Definition: RegularSolutionFreeEnergy.C:16