www.mooseframework.org
PolynomialFreeEnergy.C
Go to the documentation of this file.
1 #include "PolynomialFreeEnergy.h"
2 
3 template <>
4 InputParameters
6 {
7  InputParameters params = validParams<DerivativeParsedMaterialHelper>();
8  params.addClassDescription("Polynomial free energy for single component systems");
9  MooseEnum poly_order("4 6 8");
10  params.addRequiredParam<MooseEnum>(
11  "polynomial_order", poly_order, "Order of polynomial free energy");
12  params.addParam<MaterialPropertyName>(
13  "c_eq_name", "c_eq", "Name of material property storing the equilibrium concentration");
14  params.addParam<MaterialPropertyName>(
15  "W_name", "barr_height", "Name of the material property storing the barrier height");
16  params.addRequiredCoupledVar("c", "Concentration");
17  return params;
18 }
19 
20 PolynomialFreeEnergy::PolynomialFreeEnergy(const InputParameters & parameters)
21  : DerivativeParsedMaterialHelper(parameters),
22  _c("c"),
23  _a("c_eq_name"),
24  _W("W_name"),
25  _order(getParam<MooseEnum>("polynomial_order"))
26 {
27  EBFunction free_energy;
28 
29  // Free energy
30  switch (_order)
31  {
32  case 0: // 4th order
33  free_energy(_c, _W, _a) = pow(2.0, 4.0) * _W * pow(_c - _a, 2) * pow(1 - _c - _a, 2);
34  break;
35  case 1: // 6th order
36  free_energy(_c, _W, _a) =
37  pow(2.0, 6.0) * _W * (2.0 * pow(_c, 6) - 6.0 * pow(_c, 5) +
38  (3.0 * _a + 27.0 / 4.0 - 3.0 * _a * _a) * pow(_c, 4) +
39  (-6.0 * _a - 7.0 / 2.0 + 6.0 * _a * _a) * pow(_c, 3) +
40  (9.0 / 2.0 * _a - 9.0 / 2.0 * _a * _a + 3.0 / 4.0) * pow(_c, 2) +
41  (3.0 / 2.0 * _a * _a - 3.0 / 2.0 * _a) * _c);
42  break;
43  case 2: // 8th order
44  free_energy(_c, _W, _a) =
45  pow(2.0, 8.0) * _W *
46  (3.0 * pow(_c, 8) - 12.0 * pow(_c, 7) + (-4.0 * _a * _a + 4.0 * _a + 20.0) * pow(_c, 6) +
47  (12.0 * _a * _a - 12.0 * _a - 18.0) * pow(_c, 5) +
48  (15.0 * _a + 75.0 / 8.0 - 15.0 * _a * _a) * pow(_c, 4) +
49  (-10.0 * _a - 11.0 / 4.0 + 10.0 * _a * _a) * pow(_c, 3) +
50  (15.0 / 4.0 * _a - 15.0 / 4.0 * _a * _a + 3.0 / 8.0) * pow(_c, 2) +
51  (3.0 / 4.0 * _a * _a - 3.0 / 4.0 * _a) * _c);
52  break;
53  default:
54  mooseError("Error in PolynomialFreeEnergy: incorrect polynomial order");
55  }
56 
57  // Parse function
58  functionParse(free_energy, {}, {}, {"W_name", "c_eq_name"}, {}, {});
59 }
Helper class to perform the auto derivative taking.
EBTerm _W
Barrier height.
InputParameters validParams< PolynomialFreeEnergy >()
InputParameters validParams< DerivativeParsedMaterialHelper >()
PolynomialFreeEnergy(const InputParameters &parameters)
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
EBTerm _a
Equilibrium concentration.
EBTerm _c
Concentration variable used in the free energy expression.
User facing host object for a function. This combines a term with an argument list.
MooseEnum _order
Polynomial order.
void functionParse(const std::string &function_expression)