www.mooseframework.org
RegularSolutionFreeEnergy.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
8 
9 template <>
10 InputParameters
12 {
13  InputParameters params = validParams<DerivativeParsedMaterialHelper>();
14  params.addClassDescription("Material that implements the free energy of a regular solution");
15  params.addRequiredCoupledVar("c", "Concentration variable");
16  params.addCoupledVar("T", 300, "Temperature variable");
17  params.addParam<Real>("omega", 0.1, "Regular solution parameter");
18  params.addParam<Real>("kB", 8.6173324e-5, "Boltzmann constant");
19  params.addParam<Real>(
20  "log_tol", "If specified logarithms are evaluated using a Taylor expansion below this value");
21  return params;
22 }
23 
24 RegularSolutionFreeEnergy::RegularSolutionFreeEnergy(const InputParameters & parameters)
25  : DerivativeParsedMaterialHelper(parameters),
26  _c("c"),
27  _T("T"),
28  _omega(getParam<Real>("omega")),
29  _kB(getParam<Real>("kB"))
30 {
31  EBFunction free_energy;
32  // Definition of the free energy for the expression builder
33  free_energy(_c) =
34  _omega * _c * (1.0 - _c) + _kB * _T * (_c * log(_c) + (1.0 - _c) * log(1.0 - _c));
35 
36  // Use Taylor expanded logarithm?
37  if (isParamValid("log_tol"))
38  free_energy.substitute(EBLogPlogSubstitution(getParam<Real>("log_tol")));
39 
40  // Parse function for automatic differentiation
41  functionParse(free_energy);
42 }
Helper class to perform the auto derivative taking.
unsigned int substitute(const EBSubstitutionRule &rule)
InputParameters validParams< RegularSolutionFreeEnergy >()
EBTerm _c
Coupled variable value for the concentration .
EBTerm _T
Coupled temperature variable .
InputParameters validParams< DerivativeParsedMaterialHelper >()
RegularSolutionFreeEnergy(const InputParameters &parameters)
const Real _kB
Boltzmann constant.
Substitution rule to replace all occurences of log(x) with plog(x, epsilon) with a user defined term ...
User facing host object for a function. This combines a term with an argument list.
void functionParse(const std::string &function_expression)