www.mooseframework.org
CrystalPlasticitySlipRateGSS.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 
12 #include <fstream>
13 
15 
17 
18 InputParameters
20 {
21  InputParameters params = CrystalPlasticitySlipRate::validParams();
22  params.addParam<std::string>("uo_state_var_name",
23  "Name of state variable property: Same as "
24  "state variable user object specified in input "
25  "file.");
26  params.addClassDescription("Phenomenological constitutive model slip rate class. Override the "
27  "virtual functions in your class");
28  return params;
29 }
30 
32  : CrystalPlasticitySlipRate(parameters),
33  _mat_prop_state_var(
34  getMaterialProperty<std::vector<Real>>(parameters.get<std::string>("uo_state_var_name"))),
35  _pk2(getMaterialPropertyByName<RankTwoTensor>("pk2")),
36  _a0(_variable_size),
37  _xm(_variable_size),
38  _flow_direction(getMaterialProperty<std::vector<RankTwoTensor>>(_name + "_flow_direction"))
39 {
40  if (_slip_sys_flow_prop_file_name.length() != 0)
42  else
44 }
45 
46 void
48 {
49  MooseUtils::checkFileReadable(_slip_sys_flow_prop_file_name);
50 
51  std::ifstream file;
52  file.open(_slip_sys_flow_prop_file_name.c_str());
53 
54  std::vector<Real> vec;
55  vec.resize(_num_slip_sys_flowrate_props);
56 
57  for (unsigned int i = 0; i < _variable_size; ++i)
58  {
59  for (unsigned int j = 0; j < _num_slip_sys_flowrate_props; ++j)
60  if (!(file >> vec[j]))
61  mooseError(
62  "Error CrystalPlasticitySlipRateGSS: Premature end of slip_sys_flow_rate_param file");
63 
64  _a0(i) = vec[0];
65  _xm(i) = vec[1];
66  }
67 
68  file.close();
69 }
70 
71 void
73 {
74  if (_flowprops.size() <= 0)
75  mooseError("CrystalPlasticitySlipRateGSS: Error in reading flow rate properties: Specify "
76  "input in .i file or a slip_sys_flow_prop_file_name");
77 
78  _a0.resize(_variable_size);
79  _xm.resize(_variable_size);
80 
81  unsigned int num_data_grp = 2 + _num_slip_sys_flowrate_props; // Number of data per group e.g.
82  // start_slip_sys, end_slip_sys,
83  // value1, value2, ..
84 
85  for (unsigned int i = 0; i < _flowprops.size() / num_data_grp; ++i)
86  {
87  Real vs, ve;
88  unsigned int is, ie;
89 
90  vs = _flowprops[i * num_data_grp];
91  ve = _flowprops[i * num_data_grp + 1];
92 
93  if (vs <= 0 || ve <= 0)
94  mooseError("CrystalPlasticitySlipRateGSS: Indices in flow rate parameter read must be "
95  "positive integers: is = ",
96  vs,
97  " ie = ",
98  ve);
99 
100  if (vs != std::floor(vs) || ve != std::floor(ve))
101  mooseError("CrystalPlasticitySlipRateGSS: Error in reading flow props: Values specifying "
102  "start and end number of slip system groups should be integer");
103 
104  is = static_cast<unsigned int>(vs);
105  ie = static_cast<unsigned int>(ve);
106 
107  if (is > ie)
108  mooseError("CrystalPlasticitySlipRateGSS: Start index is = ",
109  is,
110  " should be greater than end index ie = ",
111  ie,
112  " in flow rate parameter read");
113 
114  for (unsigned int j = is; j <= ie; ++j)
115  {
116  _a0(j - 1) = _flowprops[i * num_data_grp + 2];
117  _xm(j - 1) = _flowprops[i * num_data_grp + 3];
118  }
119  }
120 
121  for (unsigned int i = 0; i < _variable_size; ++i)
122  {
123  if (!(_a0(i) > 0.0 && _xm(i) > 0.0))
124  {
125  mooseWarning(
126  "CrystalPlasticitySlipRateGSS: Non-positive flow rate parameters ", _a0(i), ",", _xm(i));
127  break;
128  }
129  }
130 }
131 
132 void
134  std::vector<RankTwoTensor> & flow_direction) const
135 {
136  DenseVector<Real> mo(LIBMESH_DIM * _variable_size), no(LIBMESH_DIM * _variable_size);
137 
138  // Update slip direction and normal with crystal orientation
139  for (unsigned int i = 0; i < _variable_size; ++i)
140  {
141  for (unsigned int j = 0; j < LIBMESH_DIM; ++j)
142  {
143  mo(i * LIBMESH_DIM + j) = 0.0;
144  for (unsigned int k = 0; k < LIBMESH_DIM; ++k)
145  mo(i * LIBMESH_DIM + j) =
146  mo(i * LIBMESH_DIM + j) + _crysrot[qp](j, k) * _mo(i * LIBMESH_DIM + k);
147  }
148 
149  for (unsigned int j = 0; j < LIBMESH_DIM; ++j)
150  {
151  no(i * LIBMESH_DIM + j) = 0.0;
152  for (unsigned int k = 0; k < LIBMESH_DIM; ++k)
153  no(i * LIBMESH_DIM + j) =
154  no(i * LIBMESH_DIM + j) + _crysrot[qp](j, k) * _no(i * LIBMESH_DIM + k);
155  }
156  }
157 
158  // Calculate Schmid tensor and resolved shear stresses
159  for (unsigned int i = 0; i < _variable_size; ++i)
160  for (unsigned int j = 0; j < LIBMESH_DIM; ++j)
161  for (unsigned int k = 0; k < LIBMESH_DIM; ++k)
162  flow_direction[i](j, k) = mo(i * LIBMESH_DIM + j) * no(i * LIBMESH_DIM + k);
163 }
164 
165 bool
166 CrystalPlasticitySlipRateGSS::calcSlipRate(unsigned int qp, Real dt, std::vector<Real> & val) const
167 {
168  DenseVector<Real> tau(_variable_size);
169 
170  for (unsigned int i = 0; i < _variable_size; ++i)
171  tau(i) = _pk2[qp].doubleContraction(_flow_direction[qp][i]);
172 
173  for (unsigned int i = 0; i < _variable_size; ++i)
174  {
175  val[i] = _a0(i) * std::pow(std::abs(tau(i) / _mat_prop_state_var[qp][i]), 1.0 / _xm(i)) *
176  std::copysign(1.0, tau(i));
177  if (std::abs(val[i] * dt) > _slip_incr_tol)
178  {
179 #ifdef DEBUG
180  mooseWarning("Maximum allowable slip increment exceeded ", std::abs(val[i]) * dt);
181 #endif
182  return false;
183  }
184  }
185 
186  return true;
187 }
188 
189 bool
191  Real /*dt*/,
192  std::vector<Real> & val) const
193 {
194  DenseVector<Real> tau(_variable_size);
195 
196  for (unsigned int i = 0; i < _variable_size; ++i)
197  tau(i) = _pk2[qp].doubleContraction(_flow_direction[qp][i]);
198 
199  for (unsigned int i = 0; i < _variable_size; ++i)
200  val[i] = _a0(i) / _xm(i) *
201  std::pow(std::abs(tau(i) / _mat_prop_state_var[qp][i]), 1.0 / _xm(i) - 1.0) /
202  _mat_prop_state_var[qp][i];
203 
204  return true;
205 }
CrystalPlasticitySlipRate::_flowprops
std::vector< Real > _flowprops
Definition: CrystalPlasticitySlipRate.h:47
CrystalPlasticitySlipRateGSS::getFlowRateParams
virtual void getFlowRateParams()
Definition: CrystalPlasticitySlipRateGSS.C:72
registerMooseObject
registerMooseObject("TensorMechanicsApp", CrystalPlasticitySlipRateGSS)
CrystalPlasticitySlipRateGSS::_flow_direction
const MaterialProperty< std::vector< RankTwoTensor > > & _flow_direction
Definition: CrystalPlasticitySlipRateGSS.h:46
pow
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
Definition: ExpressionBuilder.h:673
CrystalPlasticitySlipRate
Crystal plasticity slip rate userobject class The virtual functions written below must be over-ridden...
Definition: CrystalPlasticitySlipRate.h:25
CrystalPlasticitySlipRate::_mo
DenseVector< Real > _mo
Definition: CrystalPlasticitySlipRate.h:66
CrystalPlasticitySlipRateGSS::_pk2
const MaterialProperty< RankTwoTensor > & _pk2
Definition: CrystalPlasticitySlipRateGSS.h:41
CrystalPlasticitySlipRate::_no
DenseVector< Real > _no
Definition: CrystalPlasticitySlipRate.h:67
CrystalPlasticitySlipRate::_slip_sys_flow_prop_file_name
std::string _slip_sys_flow_prop_file_name
File should contain values of the flow rate equation parameters.
Definition: CrystalPlasticitySlipRate.h:58
CrystalPlasticitySlipRate::validParams
static InputParameters validParams()
Definition: CrystalPlasticitySlipRate.C:18
CrystalPlasticitySlipRateGSS::readFileFlowRateParams
virtual void readFileFlowRateParams()
Definition: CrystalPlasticitySlipRateGSS.C:47
CrystalPlasticitySlipRateGSS.h
CrystalPlasticitySlipRateGSS::_xm
DenseVector< Real > _xm
Definition: CrystalPlasticitySlipRateGSS.h:44
CrystalPlasticitySlipRateGSS::_mat_prop_state_var
const MaterialProperty< std::vector< Real > > & _mat_prop_state_var
Definition: CrystalPlasticitySlipRateGSS.h:39
CrystalPlasticityUOBase::_variable_size
unsigned int _variable_size
Definition: CrystalPlasticityUOBase.h:33
CrystalPlasticitySlipRate::_crysrot
const MaterialProperty< RankTwoTensor > & _crysrot
Crystal rotation.
Definition: CrystalPlasticitySlipRate.h:70
CrystalPlasticitySlipRateGSS
Phenomenological constitutive model slip rate userobject class.
Definition: CrystalPlasticitySlipRateGSS.h:23
defineLegacyParams
defineLegacyParams(CrystalPlasticitySlipRateGSS)
CrystalPlasticitySlipRate::_slip_incr_tol
Real _slip_incr_tol
Slip increment tolerance.
Definition: CrystalPlasticitySlipRate.h:64
CrystalPlasticitySlipRateGSS::CrystalPlasticitySlipRateGSS
CrystalPlasticitySlipRateGSS(const InputParameters &parameters)
Definition: CrystalPlasticitySlipRateGSS.C:31
RankTwoTensorTempl
Definition: ACGrGrElasticDrivingForce.h:17
CrystalPlasticitySlipRateGSS::calcSlipRateDerivative
virtual bool calcSlipRateDerivative(unsigned int qp, Real, std::vector< Real > &val) const
Definition: CrystalPlasticitySlipRateGSS.C:190
CrystalPlasticitySlipRate::_num_slip_sys_flowrate_props
unsigned int _num_slip_sys_flowrate_props
Number of slip system flow rate parameters.
Definition: CrystalPlasticitySlipRate.h:61
CrystalPlasticitySlipRateGSS::calcFlowDirection
virtual void calcFlowDirection(unsigned int qp, std::vector< RankTwoTensor > &flow_direction) const
Definition: CrystalPlasticitySlipRateGSS.C:133
CrystalPlasticitySlipRateGSS::calcSlipRate
virtual bool calcSlipRate(unsigned int qp, Real dt, std::vector< Real > &val) const
Definition: CrystalPlasticitySlipRateGSS.C:166
CrystalPlasticitySlipRateGSS::_a0
DenseVector< Real > _a0
Definition: CrystalPlasticitySlipRateGSS.h:43
CrystalPlasticitySlipRateGSS::validParams
static InputParameters validParams()
Definition: CrystalPlasticitySlipRateGSS.C:19