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