CASM  1.1.0
A Clusters Approach to Statistical Mechanics
StrainConverter.cc
Go to the documentation of this file.
2 
8 
9 namespace CASM {
10 
11 // Calculates the metric tensor of the the deformation gradient as
12 // F^{T}F
13 Matrix3d StrainConverter::metric_tensor(const Eigen::Ref<const Matrix3d> &F) {
14  return strain::metric_tensor(F);
15 }
16 
17 //*******************************************************************************************
18 // calculates and returns the value of U where F = R*U
20  Matrix3d &C, const Eigen::Ref<const Matrix3d> &F) {
21  C = strain::metric_tensor(F);
23 }
24 
25 //*******************************************************************************************
26 // overloaded version of the above
28  const Eigen::Ref<const Matrix3d> &F) {
30 }
31 
32 //*******************************************************************************************
34 Matrix3d StrainConverter::green_lagrange(const Eigen::Ref<const Matrix3d> &F) {
35  return strain::deformation_tensor_to_metric<STRAIN_METRIC::GREEN_LAGRANGE>(F);
36 }
37 
38 //*******************************************************************************************
41  const Eigen::Ref<const Matrix3d> &E) {
42  return strain::metric_to_deformation_tensor<STRAIN_METRIC::GREEN_LAGRANGE>(E);
43 }
44 
45 //*******************************************************************************************
47 Matrix3d StrainConverter::biot(const Eigen::Ref<const Matrix3d> &F) {
48  return strain::deformation_tensor_to_metric<STRAIN_METRIC::BIOT>(F);
49 }
50 
51 //*******************************************************************************************
53 Matrix3d StrainConverter::biot_to_F(const Eigen::Ref<const Matrix3d> &B) {
54  return strain::metric_to_deformation_tensor<STRAIN_METRIC::BIOT>(B);
55 }
56 
57 //*******************************************************************************************
59 Matrix3d StrainConverter::hencky(const Eigen::Ref<const Matrix3d> &F) {
60  return strain::deformation_tensor_to_metric<STRAIN_METRIC::HENCKY>(F);
61 }
62 
63 //*******************************************************************************************
65 Matrix3d StrainConverter::hencky_to_F(const Eigen::Ref<const Matrix3d> &H) {
66  return strain::metric_to_deformation_tensor<STRAIN_METRIC::HENCKY>(H);
67 }
68 
69 //*******************************************************************************************
71 Matrix3d StrainConverter::euler_almansi(const Eigen::Ref<const Matrix3d> &F) {
72  return strain::deformation_tensor_to_metric<STRAIN_METRIC::EULER_ALMANSI>(F);
73 }
74 
75 //*******************************************************************************************
78  const Eigen::Ref<const Matrix3d> &A) {
79  return strain::metric_to_deformation_tensor<STRAIN_METRIC::EULER_ALMANSI>(A);
80 }
81 
82 //*******************************************************************************************
84 Matrix3d StrainConverter::disp_grad(Eigen::Ref<const Matrix3d> const &F) {
85  return F;
86 }
87 
88 //*******************************************************************************************
89 // Calculates the strain metric based on what mode is passed
90 // in. Allowed modes are listed in STRAIN_METRIC
91 Matrix3d StrainConverter::strain_metric(Eigen::Ref<const Matrix3d> const &F,
92  STRAIN_METRIC MODE) {
94  if (MODE == STRAIN_METRIC::GREEN_LAGRANGE) {
95  return green_lagrange(F);
96  }
98  else if (MODE == STRAIN_METRIC::BIOT) {
99  return biot(F);
100  }
102  else if (MODE == STRAIN_METRIC::HENCKY) {
103  return hencky(F);
104  }
106  else if (MODE == STRAIN_METRIC::EULER_ALMANSI) {
107  return euler_almansi(F);
108  }
110  else if (MODE == STRAIN_METRIC::STRETCH) {
111  return right_stretch_tensor(F);
112  }
114  else if (MODE == STRAIN_METRIC::DISP_GRAD) {
115  return disp_grad(F);
116  } else {
117  std::cerr << "CRITICAL ERROR: In StrainConverter::strain_metric. "
118  "Unrecognized strain metric"
119  << std::endl;
120  std::cerr << " Your only options are GREEN_LAGRANGE, BIOT, "
121  "HENCKY, EULER_ALMANSI,STRETCH and DISP_GRAD"
122  << std::endl;
123  std::cerr << " Exiting..." << std::endl;
124  exit(1);
125  }
126 }
127 
128 //*******************************************************************************************
129 // Calculates the strain metric based on what mode is passed
130 // in. Allowed modes are listed in STRAIN_METRIC
132  Eigen::Ref<const Matrix3d> const &F) const {
133  assert(curr_metric_func && "StrainConverter object improperly initialized!");
134  return (*curr_metric_func)(F);
135 }
136 
137 //*******************************************************************************************
138 // Calculates the strain metric based on what mode is passed
139 // in. Allowed modes are listed in STRAIN_METRIC
141  Eigen::Ref<const Matrix3d> const &E) const {
142  assert(curr_inv_metric_func &&
143  "StrainConverter object improperly initialized!");
144  return (*curr_inv_metric_func)(E);
145 }
146 
147 //*******************************************************************************************
148 // Returns the symmetrically unique elements of E (assuming your
149 // strain metric is symmetric) ordered in a manner decided by
150 // m_order_strain
151 VectorXd StrainConverter::unroll_E(Eigen::Ref<const Matrix3d> const &E) const {
152  VectorXd _unrolled_E(m_order_strain.size());
153  for (Index i = 0; i < m_order_strain.size(); i++) {
154  _unrolled_E(i) =
155  m_weight_strain[i] * E(m_order_strain[i][0], m_order_strain[i][1]);
156  }
157  return _unrolled_E;
158 }
159 
160 //*******************************************************************************************
161 // Returns the symmetrically unique elements of E (assuming your
162 // strain metric is symmetric) ordered in a manner decided by
163 // m_order_strain
165  Eigen::Ref<const VectorXd> const &_unrolled_E) const {
166  Matrix3d _rolled_E;
167  for (Index i = 0; i < m_order_strain.size(); i++) {
168  _rolled_E(m_order_strain[i][0], m_order_strain[i][1]) =
169  _unrolled_E(i) / m_weight_strain[i];
170  _rolled_E(m_order_strain[i][1], m_order_strain[i][0]) =
171  _unrolled_E(i) / m_weight_strain[i];
172  }
173  return _rolled_E;
174 }
175 
176 //*******************************************************************************************
178  Eigen::Ref<const Matrix3d> const &F) const {
179  return unroll_E(strain_metric(F));
180 }
181 
182 //*******************************************************************************************
184  Eigen::Ref<const VectorXd> const &E) const {
185  return strain_metric_to_F(rollup_E(E));
186 }
187 
188 //*******************************************************************************************
189 // Calculates a linear combination of the components of unroll_E
190 // using the sop_transf_mat
192  Eigen::Ref<const Matrix3d> const &F,
193  STRAIN_METRIC MODE) const {
194  U = right_stretch_tensor(C, F);
195  E = strain_metric(F, MODE);
196  VectorXd _unroll_E = unroll_E(E);
197  VectorXd _sop = m_sop_transf_mat * _unroll_E;
198  return _sop;
199 }
200 
201 //*******************************************************************************************
202 
204  Eigen::Ref<const Matrix3d> const &F) const {
205  return sop(E, C, U, F, STRAIN_METRIC_MODE);
206 }
207 
208 //************************************* SET routines
209 //****************************************
210 
211 void StrainConverter::set_mode(const std::string &mode_name) {
213  if (mode_name == "STRAIN_GL" || mode_name == "GL") {
214  STRAIN_METRIC_MODE = STRAIN_METRIC::GREEN_LAGRANGE;
218  }
220  else if (mode_name == "STRAIN_B" || mode_name == "B") {
221  STRAIN_METRIC_MODE = STRAIN_METRIC::BIOT;
225  }
227  else if (mode_name == "STRAIN_H" || mode_name == "H") {
228  STRAIN_METRIC_MODE = STRAIN_METRIC::HENCKY;
232  }
234  else if (mode_name == "STRAIN_EA" || mode_name == "EA") {
235  STRAIN_METRIC_MODE = STRAIN_METRIC::EULER_ALMANSI;
239  }
241  else if (mode_name == "STRAIN_U" || mode_name == "U") {
242  STRAIN_METRIC_MODE = STRAIN_METRIC::STRETCH;
246  }
248  else if (mode_name == "STRAIN_F" || mode_name == "F") {
249  STRAIN_METRIC_MODE = STRAIN_METRIC::DISP_GRAD;
253  } else {
254  std::cerr << "CRITICAL ERROR: In StrainConverter::set_mode(). Unrecognized "
255  "strain metric '"
256  << mode_name << "'" << std::endl;
257  std::cerr << " Your only options are STRAIN_GL, STRAIN_B, "
258  "STRAIN_H, STRAIN_EA, STRAIN_U, and STRAIN_F"
259  << std::endl;
260  std::cerr << " Exiting..." << std::endl;
261  exit(1);
262  }
263 }
264 
265 //*******************************************************************************************
266 
268  Eigen::VectorXd tvec(Eigen::VectorXd::Zero(m_order_strain.size()));
269  Eigen::Matrix3d tmat;
270  SymGroupRep strain_rep(pg);
271 
272  for (Index g = 0; g < pg.size(); g++) {
273  Eigen::MatrixXd trep(tvec.size(), tvec.size());
274  for (Index i = 0; i < tvec.size(); i++) {
275  tvec[i] = 1;
276  tmat = rollup_E(tvec);
277  tvec[i] = 0;
278  tmat = pg[g].matrix() * tmat * pg[g].matrix().transpose();
279  trep.col(i) = unroll_E(tmat);
280  }
281  strain_rep.set_rep(pg[g], SymMatrixXd(trep));
282  }
284  breathing.normalize();
285 
286  Eigen::MatrixXd bigmat(tvec.size(), tvec.size() + 1);
287  bigmat.col(0) = breathing;
288  bigmat.rightCols(tvec.size()) = irrep_trans_mat(strain_rep, pg).transpose();
289  // m_sop_transf_mat=irrep_trans_mat(strain_rep,pg).transpose();
290  Eigen::HouseholderQR<Eigen::MatrixXd> QR(bigmat);
291  m_sop_transf_mat = QR.householderQ();
293  coord_transformed_copy(strain_rep, m_sop_transf_mat.transpose()));
294 }
295 
296 //*******************************************************************************************
297 // Conventional strain order parameters:
298 // e1 = (E11+E22+E33) / sqrt(3)
299 // e2 = (E11-E22) / sqrt(2)
300 // e3 = (2E33-E11+E22) / sqrt(6)
301 // e4 = E12
302 // e5 = E23
303 // e6 = E13
305  m_sop_transf_mat.resize(6, 6);
306  m_sop_transf_mat << 1.0 / sqrt(3.0), 1.0 / sqrt(3.0), 1.0 / sqrt(3.0), 0, 0,
307  0, 1.0 / sqrt(2.0), -1.0 / sqrt(2.0), 0, 0, 0, 0, -1.0 / sqrt(6.0),
308  -1.0 / sqrt(6.0), 2.0 / sqrt(6.0), 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
309  1, 0, 0, 0, 0, 1, 0, 0;
310 }
311 
312 //*******************************************************************************************
313 // Conventional order_strain:
314 // unroll_E = (E11 E22 E33 E23 E13 E12)
316  m_order_strain.resize(6, {0, 0});
317 
318  m_order_strain[0][0] = 0;
319  m_order_strain[0][1] = 0;
320  m_order_strain[1][0] = 1;
321  m_order_strain[1][1] = 1;
322  m_order_strain[2][0] = 2;
323  m_order_strain[2][1] = 2;
324  m_order_strain[3][0] = 1;
325  m_order_strain[3][1] = 2;
326  m_order_strain[4][0] = 0;
327  m_order_strain[4][1] = 2;
328  m_order_strain[5][0] = 0;
329  m_order_strain[5][1] = 1;
330 
331  m_weight_strain.setOnes(6);
332  m_weight_strain.tail(3) *= sqrt(2.0);
333 }
334 
335 //*******************************************************************************************
336 // Conventional order_strain:
337 // unroll_E = (E11 E12 E13 E21 E22 E23 E31 E32 E33)
339  m_order_strain.resize(9, {0, 0});
340  m_weight_strain.setOnes(9);
341 
342  Index l = 0;
343  for (Index i = 0; i < 3; i++) {
344  for (Index j = 0; j < 3; j++) {
345  m_order_strain[l][0] = i;
346  m_order_strain[l][1] = j;
347  l++;
348  }
349  }
350 }
351 
352 } // namespace CASM
SymGroupRepID add_representation(const SymGroupRep &new_rep) const
Definition: SymGroup.cc:702
Matrix3d unrolled_strain_metric_to_F(Eigen::Ref< const VectorXd > const &E) const
std::vector< std::vector< Index > > m_order_strain
VectorXd unroll_E(Eigen::Ref< const Matrix3d > const &E) const
Unrolls the green-lagrange metric ( or any symmetric metric)
static Matrix3d right_stretch_tensor(Matrix3d &C, Eigen::Ref< const Matrix3d > const &F)
static Matrix3d euler_almansi_to_F(Eigen::Ref< const Matrix3d > const &A)
EULER_ALMANSI = (I-(F F^{T})^(-1))/2.
static Matrix3d hencky(Eigen::Ref< const Matrix3d > const &F)
HENCKY = log(C)/2.
static Matrix3d biot(Eigen::Ref< const Matrix3d > const &F)
BIOT = (U-I)
static Matrix3d strain_metric(Eigen::Ref< const Matrix3d > const &F, STRAIN_METRIC MODE)
static Matrix3d hencky_to_F(Eigen::Ref< const Matrix3d > const &H)
HENCKY = log(C)/2.
static Matrix3d euler_almansi(Eigen::Ref< const Matrix3d > const &F)
EULER_ALMANSI = (I-(F F^{T})^(-1))/2.
Matrix3d rollup_E(Eigen::Ref< const VectorXd > const &_unrolled_E) const
static Matrix3d metric_tensor(Eigen::Ref< const Matrix3d > const &F)
VectorXd unrolled_strain_metric(Eigen::Ref< const Matrix3d > const &F) const
void set_mode(const std::string &mode_name)
static Matrix3d disp_grad(Eigen::Ref< const Matrix3d > const &F)
DISP_GRAD = F.
STRAIN_METRIC STRAIN_METRIC_MODE
static Matrix3d green_lagrange_to_F(Eigen::Ref< const Matrix3d > const &E)
GREEN_LAGRANGE = 1/2 * (F^{T} F - I)
static Matrix3d biot_to_F(Eigen::Ref< const Matrix3d > const &B)
BIOT = (U-I)
static Matrix3d disp_grad_to_F(Eigen::Ref< const Matrix3d > const &F)
VectorXd sop(Matrix3d &E, Matrix3d &C, Matrix3d &U, Eigen::Ref< const Matrix3d > const &F) const
static Matrix3d green_lagrange(Eigen::Ref< const Matrix3d > const &F)
GREEN_LAGRANGE = (C-I)/2.
MetricFuncPtr curr_inv_metric_func
void set_symmetrized_sop(const SymGroup &pg)
MetricFuncPtr curr_metric_func
void set_conventional_order_unsymmetric()
Eigen::VectorXd m_weight_strain
Matrix3d strain_metric_to_F(Eigen::Ref< const Matrix3d > const &E) const
SymGroup is a collection of symmetry operations that satisfy the group property The symmetry operatio...
Definition: SymGroup.hh:42
const MasterSymGroup & master_group() const
Definition: SymGroup.hh:73
SymGroupRep is an alternative representation of a SymGroup for something other than real space....
Definition: SymGroupRep.hh:31
void set_rep(Index op_index, const SymOpRepresentation &new_rep)
Sets the representation of operation at entry 'op_index' of this group representation Throws if this ...
Definition: SymGroupRep.cc:114
Generalized symmetry matrix representation for arbitrary dimension Can be used to describe applicatio...
Definition: SymMatrixXd.hh:26
IdentitySymRepBuilder Identity()
Eigen::Matrix3d right_stretch_tensor(const Eigen::Ref< const Eigen::Matrix3d > &deformation_tensor)
Calculates and returns the value of U where F = R*U.
Definition: Strain.cc:104
Eigen::Matrix3d metric_tensor(const Eigen::Ref< const Eigen::Matrix3d > &deformation_tensor)
Definition: Strain.cc:98
Main CASM namespace.
Definition: APICommand.hh:8
Eigen::MatrixXd MatrixXd
Eigen::Matrix3d Matrix3d
SymGroupRep coord_transformed_copy(SymGroupRep const &_rep, const Eigen::MatrixXd &trans_mat)
Make a copy of representation on vector space 'V' that is transformed into a representation on vector...
Definition: SymGroupRep.cc:175
Eigen::MatrixXd irrep_trans_mat(SymGroupRep const &_rep, const SymGroup &head_group)
Finds the transformation matrix that block-diagonalizes this representation of head_group into irrep ...
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
Eigen::VectorXd VectorXd