https://mooseframework.inl.gov
ElectrochemicalDefectMaterial.C
Go to the documentation of this file.
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 
11 #include "libmesh/quadrature.h"
12 #include "libmesh/utility.h"
13 
15 
18 {
20  params.addClassDescription(
21  "Calculates density, susceptibility, and derivatives for a defect species in the grand "
22  "potential sintering model coupled with electrochemistry");
24  "etas", "var_name_base", "op_num", "Array of order parameters that describe solid phase");
25  params.addRequiredCoupledVar("chemical_potential", "The name of the chemical potential variable");
26  params.addRequiredCoupledVar("void_op", "The name of the void phase order parameter");
27  params.addRequiredCoupledVar("Temperature", "Name of the temperature variable with units of K");
28  params.addRequiredCoupledVar("electric_potential",
29  "Name of the electric potential variable with units of V");
30  params.addParam<MaterialPropertyName>(
31  "void_density_name",
32  "nv",
33  "Name of material property to be created for defect number density in the void phase.");
34  params.addParam<MaterialPropertyName>(
35  "solid_density_name",
36  "ns",
37  "Name of material property to be created for defect number density in the solid phase.");
38  params.addParam<MaterialPropertyName>(
39  "chi_name", "chi", "Name of material property to be created defect susceptibility.");
40  params.addParam<MaterialPropertyName>("solid_energy_coefficient",
41  1.0,
42  "Parabolic solid energy coefficient (energy*volume) for "
43  "defect species. Only used for parabolic energy.");
44  params.addRequiredParam<MaterialPropertyName>(
45  "void_energy_coefficient",
46  "Parabolic void energy coefficient (energy*volume) for defect species.");
47  params.addRequiredParam<MaterialPropertyName>(
48  "min_vacancy_concentration_solid",
49  "Name of material that determines the minimum in energy wrt defect concentration in the "
50  "solid phase");
51  params.addRequiredParam<Real>("min_vacancy_concentration_void",
52  "Minimum in energy wrt defect concentration in the void phase");
53  MooseEnum solid_energy_model("PARABOLIC DILUTE IDEAL", "PARABOLIC");
54  params.addParam<MooseEnum>("solid_energy_model",
55  solid_energy_model,
56  "Type of energy function to use for the solid phase.");
57  params.addRequiredParam<int>("defect_charge", "Effective charge of defect species");
58  params.addRequiredParam<Real>("solid_relative_permittivity",
59  "Solid phase relative permittivity (dimensionless)");
60  params.addParam<Real>("voltage_scale", 1, "Voltage scale (default is for voltage in V)");
61  return params;
62 }
63 
66  _neta(coupledComponents("etas")),
67  _eta(_neta),
68  _eta_name(_neta),
69  _w(coupledValue("chemical_potential")),
70  _w_name(coupledName("chemical_potential", 0)),
71  _phi(coupledValue("void_op")),
72  _phi_name(coupledName("void_op", 0)),
73  _ns_min_name(getParam<MaterialPropertyName>("min_vacancy_concentration_solid")),
74  _ns_min(getMaterialProperty<Real>(_ns_min_name)),
75  _dns_min(_neta),
76  _d2ns_min(_neta),
77  _temp(coupledValue("Temperature")),
78  _v(coupledValue("electric_potential")),
79  _grad_V(coupledGradient("electric_potential")),
80  _kv(getMaterialProperty<Real>("void_energy_coefficient")),
81  _ks(getMaterialProperty<Real>("solid_energy_coefficient")),
82  _hv(getMaterialPropertyByName<Real>("hv")),
83  _dhv(getMaterialPropertyDerivativeByName<Real>("hv", _phi_name)),
84  _d2hv(getMaterialPropertyDerivativeByName<Real>("hv", _phi_name, _phi_name)),
85  _hs(getMaterialPropertyByName<Real>("hs")),
86  _dhs(getMaterialPropertyDerivativeByName<Real>("hs", _phi_name)),
87  _d2hs(getMaterialPropertyDerivativeByName<Real>("hs", _phi_name, _phi_name)),
88  _chi_name(getParam<MaterialPropertyName>("chi_name")),
89  _chi(declareProperty<Real>(_chi_name)),
90  _dchidphi(declarePropertyDerivative<Real>(_chi_name, _phi_name)),
91  _dchidw(declarePropertyDerivative<Real>(_chi_name, _w_name)),
92  _d2chidphi2(declarePropertyDerivative<Real>(_chi_name, _phi_name, _phi_name)),
93  _d2chidw2(declarePropertyDerivative<Real>(_chi_name, _w_name, _w_name)),
94  _d2chidphidw(declarePropertyDerivative<Real>(_chi_name, _phi_name, _w_name)),
95  _nv_name(getParam<MaterialPropertyName>("void_density_name")),
96  _nv(declareProperty<Real>(_nv_name)),
97  _dnvdw(declarePropertyDerivative<Real>(_nv_name, _w_name)),
98  _ns_name(getParam<MaterialPropertyName>("solid_density_name")),
99  _ns(declareProperty<Real>(_ns_name)),
100  _dnsdw(declarePropertyDerivative<Real>(_ns_name, _w_name)),
101  _d2nsdw2(declarePropertyDerivative<Real>(_ns_name, _w_name, _w_name)),
102  _dns(_neta),
103  _d2nsdwdeta(_neta),
104  _d2ns(_neta),
105  _solid_energy(getParam<MooseEnum>("solid_energy_model")),
106  _kB(8.617343e-5), // eV/K
107  _e(1.0), // to put energy units in eV
108  _z(getParam<int>("defect_charge")),
109  _v_scale(getParam<Real>("voltage_scale")),
110  _eps_r(getParam<Real>("solid_relative_permittivity")),
111  _nv_min(getParam<Real>("min_vacancy_concentration_void"))
112 {
113 
114  for (unsigned int i = 0; i < _neta; ++i)
115  {
116  _eta[i] = &coupledValue("etas", i);
117  _eta_name[i] = coupledName("etas", i);
118  _dns_min[i] = &getMaterialPropertyDerivativeByName<Real>(_ns_min_name, _eta_name[i]);
119  _d2ns_min[i].resize(_neta);
120  _dns[i] = &declarePropertyDerivative<Real>(_ns_name, _eta_name[i]);
121  _d2ns[i].resize(_neta);
122  _d2nsdwdeta[i] = &declarePropertyDerivative<Real>(_ns_name, _w_name, _eta_name[i]);
123 
124  for (unsigned int j = 0; j <= i; ++j)
125  {
126  _d2ns_min[j][i] =
127  &getMaterialPropertyDerivativeByName<Real>(_ns_min_name, _eta_name[j], _eta_name[i]);
128  _d2ns[j][i] = &declarePropertyDerivative<Real>(_ns_name, _eta_name[j], _eta_name[i]);
129  }
130  }
131 }
132 
133 void
135 {
136  // Calculate the void phase density and derivatives
137  _nv[_qp] = (_w[_qp] - _z * _e * _v[_qp] * _v_scale) / _kv[_qp] + _nv_min;
138  _dnvdw[_qp] = 1.0 / _kv[_qp]; // susceptibility
139 
140  // Calculate solid phase density and derivatives
141  Real d3nsdw3 = 0.0;
142  switch (_solid_energy)
143  {
144  case 0: // PARABOLIC
145  {
146  _ns[_qp] = (_w[_qp] - _z * _e * _v[_qp] * _v_scale) / _ks[_qp] + _ns_min[_qp];
147  _dnsdw[_qp] = 1.0 / _ks[_qp];
148  _d2nsdw2[_qp] = 0.0;
149  d3nsdw3 = 0.0;
150 
151  for (unsigned int i = 0; i < _neta; ++i)
152  {
153  (*_dns[i])[_qp] = (*_dns_min[i])[_qp];
154  (*_d2nsdwdeta[i])[_qp] = 0.0;
155  for (unsigned int j = i; j < _neta; ++j)
156  {
157  (*_d2ns[i][j])[_qp] = (*_d2ns_min[i][j])[_qp];
158  }
159  }
160  break;
161  } // case 0; // PARABOLIC
162  case 1: // DILUTE
163  {
164  Real n_exp = std::exp((_w[_qp] - _z * _e * _v[_qp] * _v_scale) / _kB / _temp[_qp]);
165  _ns[_qp] = _ns_min[_qp] * n_exp;
166  _dnsdw[_qp] = _ns[_qp] / _kB / _temp[_qp];
167  _d2nsdw2[_qp] = _dnsdw[_qp] / _kB / _temp[_qp];
168  d3nsdw3 = _d2nsdw2[_qp] / _kB / _temp[_qp];
169 
170  for (unsigned int i = 0; i < _neta; ++i)
171  {
172  (*_dns[i])[_qp] = (*_dns_min[i])[_qp] * n_exp;
173  (*_d2nsdwdeta[i])[_qp] = (*_dns_min[i])[_qp] * n_exp / _kB / _temp[_qp];
174  for (unsigned int j = i; j < _neta; ++j)
175  {
176  (*_d2ns[i][j])[_qp] = (*_d2ns_min[i][j])[_qp] * n_exp;
177  }
178  }
179  break;
180  } // case 1: // DILUTE
181  case 2: // IDEAL
182  {
183  mooseError("Ideal solution in solid is not yet supported in ElectrochemicalDefectMaterial");
184  break;
185  } // case 2: // IDEAL
186  } // switch (_solid_energy)
187 
188  // Calculate the susceptibilities
189  _chi[_qp] = _hs[_qp] * _dnsdw[_qp] + _hv[_qp] * _dnvdw[_qp];
190  _dchidphi[_qp] = _dhs[_qp] * _dnsdw[_qp] + _dhv[_qp] * _dnvdw[_qp];
191  _dchidw[_qp] = _hs[_qp] * _d2nsdw2[_qp];
193  _d2chidw2[_qp] = _hs[_qp] * d3nsdw3;
195 } // void ElectrochemicalDefectMaterial::computeQpProperties()
const MooseEnum _solid_energy
Type of energy function to use for the solid phase.
const VariableValue & _v
electric potential
const Real _kB
Boltzmann constant.
const MaterialProperty< Real > & _hv
void phase switching function
VariableName coupledName(const std::string &var_name, unsigned int comp=0) const
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const Real _nv_min
minimum in energy wrt vacancy concentration in void
const MaterialProperty< Real > & _dhs
void addRequiredParam(const std::string &name, const std::string &doc_string)
const MaterialProperty< Real > & _d2hs
std::vector< std::vector< MaterialProperty< Real > * > > _d2ns
const int _z
Defect species charge.
std::vector< MaterialProperty< Real > * > _dns
virtual const VariableValue & coupledValue(const std::string &var_name, unsigned int comp=0) const
const MaterialProperty< Real > & _ns_min
registerMooseObject("PhaseFieldApp", ElectrochemicalDefectMaterial)
const MaterialProperty< Real > & _ks
solid energy coefficient
MaterialPropertyName _ns_name
solid phase vacancy density
static InputParameters validParams()
const VariableValue & _temp
temperature
const unsigned int _neta
number of solid phase order paramters
const MaterialProperty< Real > & _kv
void energy coefficient
const MaterialProperty< Real > & _hs
solid phase switching function
std::vector< std::vector< const MaterialProperty< Real > * > > _d2ns_min
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addRequiredCoupledVarWithAutoBuild(const std::string &name, const std::string &base_name, const std::string &num_name, const std::string &doc_string)
ElectrochemicalDefectMaterial(const InputParameters &parameters)
std::vector< MaterialProperty< Real > * > _d2nsdwdeta
void mooseError(Args &&... args) const
const MaterialProperty< Real > & _d2hv
void addClassDescription(const std::string &doc_string)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
std::vector< const MaterialProperty< Real > * > _dns_min
This material calculates defect-specific parameters for the grand potential sintering model with mult...
std::vector< const VariableValue * > _eta
solid phase order parameters
const MaterialProperty< Real > & _dhv
void ErrorVector unsigned int
const MaterialPropertyName _ns_min_name
minimum in energy wrt vacancy concentration in solid
const VariableValue & _w
chemical potential