www.mooseframework.org
GBAnisotropyBase.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 
10 #include "GBAnisotropyBase.h"
11 #include "MooseMesh.h"
12 
13 #include <fstream>
14 
15 template <>
16 InputParameters
18 {
19  InputParameters params = validParams<Material>();
20  params.addCoupledVar("T", 300.0, "Temperature in Kelvin");
21  params.addParam<Real>("length_scale", 1.0e-9, "Length scale in m, where default is nm");
22  params.addParam<Real>("time_scale", 1.0e-9, "Time scale in s, where default is ns");
23  params.addParam<Real>("molar_volume_value",
24  7.11e-6,
25  "molar volume of material in m^3/mol, by default it's the value of copper");
26  params.addParam<Real>(
27  "delta_sigma", 0.1, "factor determining inclination dependence of GB energy");
28  params.addParam<Real>(
29  "delta_mob", 0.1, "factor determining inclination dependence of GB mobility");
30  params.addRequiredParam<FileName>("Anisotropic_GB_file_name",
31  "Name of the file containing: 1)GB mobility prefactor; 2) GB "
32  "migration activation energy; 3)GB energy");
33  params.addRequiredParam<bool>("inclination_anisotropy",
34  "The GB anisotropy inclination would be considered if true");
35  params.addRequiredCoupledVarWithAutoBuild(
36  "v", "var_name_base", "op_num", "Array of coupled variables");
37  return params;
38 }
39 
40 GBAnisotropyBase::GBAnisotropyBase(const InputParameters & parameters)
41  : Material(parameters),
42  _mesh_dimension(_mesh.dimension()),
43  _length_scale(getParam<Real>("length_scale")),
44  _time_scale(getParam<Real>("time_scale")),
45  _M_V(getParam<Real>("molar_volume_value")),
46  _delta_sigma(getParam<Real>("delta_sigma")),
47  _delta_mob(getParam<Real>("delta_mob")),
48  _Anisotropic_GB_file_name(getParam<FileName>("Anisotropic_GB_file_name")),
49  _inclination_anisotropy(getParam<bool>("inclination_anisotropy")),
50  _T(coupledValue("T")),
51  _kappa(declareProperty<Real>("kappa_op")),
52  _gamma(declareProperty<Real>("gamma_asymm")),
53  _L(declareProperty<Real>("L")),
54  _mu(declareProperty<Real>("mu")),
55  _molar_volume(declareProperty<Real>("molar_volume")),
56  _entropy_diff(declareProperty<Real>("entropy_diff")),
57  _act_wGB(declareProperty<Real>("act_wGB")),
58  _kb(8.617343e-5), // Boltzmann constant in eV/K
59  _JtoeV(6.24150974e18), // Joule to eV conversion
60  _mu_qp(0.0),
61  _op_num(coupledComponents("v")),
62  _vals(_op_num),
63  _grad_vals(_op_num)
64 {
65  // reshape vectors
66  _sigma.resize(_op_num);
67  _mob.resize(_op_num);
68  _Q.resize(_op_num);
69  _kappa_gamma.resize(_op_num);
70  _a_g2.resize(_op_num);
71 
72  for (unsigned int op = 0; op < _op_num; ++op)
73  {
74  // Initialize variables
75  _vals[op] = &coupledValue("v", op);
76  _grad_vals[op] = &coupledGradient("v", op);
77 
78  _sigma[op].resize(_op_num);
79  _mob[op].resize(_op_num);
80  _Q[op].resize(_op_num);
81  _kappa_gamma[op].resize(_op_num);
82  _a_g2[op].resize(_op_num);
83  }
84 
85  // Read in data from "Anisotropic_GB_file_name"
86  std::ifstream inFile(_Anisotropic_GB_file_name.c_str());
87 
88  if (!inFile)
89  paramError("Anisotropic_GB_file_name", "Can't open GB anisotropy input file");
90 
91  for (unsigned int i = 0; i < 2; ++i)
92  inFile.ignore(255, '\n'); // ignore line
93 
94  Real data;
95  for (unsigned int i = 0; i < 3 * _op_num; ++i)
96  {
97  std::vector<Real> row; // create an empty row of double values
98  for (unsigned int j = 0; j < _op_num; ++j)
99  {
100  inFile >> data;
101  row.push_back(data);
102  }
103 
104  if (i < _op_num)
105  _sigma[i] = row; // unit: J/m^2
106 
107  else if (i < 2 * _op_num)
108  _mob[i - _op_num] = row; // unit: m^4/(J*s)
109 
110  else
111  _Q[i - 2 * _op_num] = row; // unit: eV
112  }
113 
114  inFile.close();
115 }
116 
117 void
119 {
120  Real sum_kappa = 0.0;
121  Real sum_gamma = 0.0;
122  Real sum_L = 0.0;
123  Real Val = 0.0;
124  Real sum_val = 0.0;
125  Real f_sigma = 1.0;
126  Real f_mob = 1.0;
127  Real gamma_value = 0.0;
128 
129  for (unsigned int m = 0; m < _op_num - 1; ++m)
130  {
131  for (unsigned int n = m + 1; n < _op_num; ++n) // m<n
132  {
133  gamma_value = _kappa_gamma[n][m];
134 
136  {
137  if (_mesh_dimension == 3)
138  mooseError("This material doesn't support inclination dependence for 3D for now!");
139 
140  Real phi_ave = libMesh::pi * n / (2.0 * _op_num);
141  Real sin_phi = std::sin(2.0 * phi_ave);
142  Real cos_phi = std::cos(2.0 * phi_ave);
143 
144  Real a = (*_grad_vals[m])[_qp](0) - (*_grad_vals[n])[_qp](0);
145  Real b = (*_grad_vals[m])[_qp](1) - (*_grad_vals[n])[_qp](1);
146  Real ab = a * a + b * b + 1.0e-7; // for the sake of numerical convergence, the smaller the
147  // more accurate, but more difficult to converge
148 
149  Real cos_2phi = cos_phi * (a * a - b * b) / ab + sin_phi * 2.0 * a * b / ab;
150  Real cos_4phi = 2.0 * cos_2phi * cos_2phi - 1.0;
151 
152  f_sigma = 1.0 + _delta_sigma * cos_4phi;
153  f_mob = 1.0 + _delta_mob * cos_4phi;
154 
155  Real g2 = _a_g2[n][m] * f_sigma;
156  Real y = -5.288 * g2 * g2 * g2 * g2 - 0.09364 * g2 * g2 * g2 + 9.965 * g2 * g2 -
157  8.183 * g2 + 2.007;
158  gamma_value = 1.0 / y;
159  }
160 
161  Val = (100000.0 * ((*_vals[m])[_qp]) * ((*_vals[m])[_qp]) + 0.01) *
162  (100000.0 * ((*_vals[n])[_qp]) * ((*_vals[n])[_qp]) + 0.01);
163 
164  sum_val += Val;
165  sum_kappa += _kappa_gamma[m][n] * f_sigma * Val;
166  sum_gamma += gamma_value * Val;
167  // Following comes from substituting Eq. (36c) from the paper into (36b)
168  sum_L += Val * _mob[m][n] * std::exp(-_Q[m][n] / (_kb * _T[_qp])) * f_mob * _mu_qp *
169  _a_g2[n][m] / _sigma[m][n];
170  }
171  }
172 
173  _kappa[_qp] = sum_kappa / sum_val;
174  _gamma[_qp] = sum_gamma / sum_val;
175  _L[_qp] = sum_L / sum_val;
176  _mu[_qp] = _mu_qp;
177 
178  _molar_volume[_qp] =
179  _M_V / (_length_scale * _length_scale * _length_scale); // m^3/mol converted to ls^3/mol
180  _entropy_diff[_qp] = 9.5 * _JtoeV; // J/(K mol) converted to eV(K mol)
181  _act_wGB[_qp] = 0.5e-9 / _length_scale; // 0.5 nm
182 }
GBAnisotropyBase::_Anisotropic_GB_file_name
const FileName _Anisotropic_GB_file_name
Definition: GBAnisotropyBase.h:41
GBAnisotropyBase::_sigma
std::vector< std::vector< Real > > _sigma
Definition: GBAnisotropyBase.h:47
GBAnisotropyBase::_entropy_diff
MaterialProperty< Real > & _entropy_diff
Definition: GBAnisotropyBase.h:59
GBAnisotropyBase::_molar_volume
MaterialProperty< Real > & _molar_volume
Definition: GBAnisotropyBase.h:58
GBAnisotropyBase::_grad_vals
std::vector< const VariableGradient * > _grad_vals
Definition: GBAnisotropyBase.h:69
GBAnisotropyBase::GBAnisotropyBase
GBAnisotropyBase(const InputParameters &parameters)
Definition: GBAnisotropyBase.C:40
GBAnisotropyBase::_kb
const Real _kb
Definition: GBAnisotropyBase.h:62
GBAnisotropyBase::_gamma
MaterialProperty< Real > & _gamma
Definition: GBAnisotropyBase.h:54
GBAnisotropyBase::_mob
std::vector< std::vector< Real > > _mob
Definition: GBAnisotropyBase.h:48
GBAnisotropyBase::_kappa_gamma
std::vector< std::vector< Real > > _kappa_gamma
Definition: GBAnisotropyBase.h:50
GBAnisotropyBase::_mu
MaterialProperty< Real > & _mu
Definition: GBAnisotropyBase.h:56
GBAnisotropyBase::_M_V
const Real _M_V
Definition: GBAnisotropyBase.h:37
GBAnisotropyBase::_length_scale
const Real _length_scale
Definition: GBAnisotropyBase.h:35
GBAnisotropyBase::_JtoeV
const Real _JtoeV
Definition: GBAnisotropyBase.h:63
GBAnisotropyBase::_delta_sigma
const Real _delta_sigma
Definition: GBAnisotropyBase.h:38
GBAnisotropyBase::_vals
std::vector< const VariableValue * > _vals
Definition: GBAnisotropyBase.h:68
GBAnisotropyBase::_Q
std::vector< std::vector< Real > > _Q
Definition: GBAnisotropyBase.h:49
GBAnisotropyBase::_kappa
MaterialProperty< Real > & _kappa
Definition: GBAnisotropyBase.h:53
validParams< GBAnisotropyBase >
InputParameters validParams< GBAnisotropyBase >()
Definition: GBAnisotropyBase.C:17
GBAnisotropyBase::_op_num
const unsigned int _op_num
Definition: GBAnisotropyBase.h:66
GBAnisotropyBase::_delta_mob
const Real _delta_mob
Definition: GBAnisotropyBase.h:39
GBAnisotropyBase.h
GBAnisotropyBase::_a_g2
std::vector< std::vector< Real > > _a_g2
Definition: GBAnisotropyBase.h:51
GBAnisotropyBase::_mu_qp
Real _mu_qp
Definition: GBAnisotropyBase.h:64
GBAnisotropyBase::_L
MaterialProperty< Real > & _L
Definition: GBAnisotropyBase.h:55
GBAnisotropyBase::computeQpProperties
virtual void computeQpProperties()
Definition: GBAnisotropyBase.C:118
GBAnisotropyBase::_mesh_dimension
const unsigned int _mesh_dimension
Definition: GBAnisotropyBase.h:33
GBAnisotropyBase::_act_wGB
MaterialProperty< Real > & _act_wGB
Definition: GBAnisotropyBase.h:60
GBAnisotropyBase::_T
const VariableValue & _T
Definition: GBAnisotropyBase.h:45
GBAnisotropyBase::_inclination_anisotropy
const bool _inclination_anisotropy
Definition: GBAnisotropyBase.h:43