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