Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
src
Lattices
LatticeTransitionMatrix.cpp
Go to the documentation of this file.
1
/* This file is part of PIL, the Particle Interaction Library.
2
*
3
*
4
* MODEL is distributed without any warranty under the
5
* GNU General Public License (GPL) v2 <http://www.gnu.org/licenses/>.
6
*/
7
8
#ifndef model_LatticeTransitionMatrix_cpp_
9
#define model_LatticeTransitionMatrix_cpp_
10
#include <LatticeModule.h>
11
#include <
LatticeTransitionMatrix.h
>
// FLT_EPSILON
12
13
namespace
model
14
{
20
/**********************************************************************/
21
template
<
int
dim>
22
typename
LatticeTransitionMatrix<dim>::IntValueType
LatticeTransitionMatrix<dim>::gcd
(
const
IntValueType
&
a
,
const
IntValueType
&
b
)
23
{
24
return
b
> 0 ?
gcd
(
b
,
a
%
b
) :
a
;
25
}
26
27
/**********************************************************************/
28
template
<
int
dim>
29
RationalMatrix<dim>
LatticeTransitionMatrix<dim>::getTransitionMatrix
(
const
LatticeType
&
A
,
30
const
LatticeType
&
B
)
31
{
32
const
MatrixDimD
R(
B
.latticeBasis *
A
.reciprocalBasis.transpose());
33
34
// Check that R is a proper rotation
35
const
MatrixDimD
RRT = R * R.transpose();
36
const
double
RRTmInorm = (RRT - Eigen::Matrix<double, dim, dim>::Identity()).norm() / Eigen::Matrix<double, dim, dim>::Identity().norm();
37
if
(RRTmInorm > FLT_EPSILON)
38
{
39
std::cout <<
"R="
<< std::endl
40
<< R << std::endl;
41
std::cout <<
"R*R^T="
<< std::endl
42
<< RRT << std::endl;
43
std::cout <<
"norm(R*R^T-I)/norm(I)="
<< RRTmInorm <<
", tol="
<< FLT_EPSILON << std::endl;
44
assert(0 &&
"R IS NOT ORTHOGONAL."
);
45
}
46
// make sure that C2G is proper
47
assert(std::fabs(R.determinant() - 1.0) < FLT_EPSILON &&
"R IS NOT PROPER."
);
48
49
// Compute the transition matrix T=inv(A)*B
50
const
MatrixDimD
T =
A
.reciprocalBasis.transpose() *
B
.latticeBasis;
51
52
// For the two lattices to have coincident sites, R must be a rational matrix
53
// Compute the integer matrix P and the integer sigma such that T=P/sigma
54
return
RationalMatrix<dim>
(T);
55
}
56
57
/**********************************************************************/
58
template
<
int
dim>
59
LatticeTransitionMatrix<dim>::LatticeTransitionMatrix
(
const
LatticeType
&A_in,
60
const
LatticeType
&B_in) :
/* init */
RationalMatrix
<dim>(
getTransitionMatrix
(A_in, B_in))
61
{
62
}
63
template
struct
LatticeTransitionMatrix<3>
;
64
65
}
// end namespace
66
#endif
67
68
LatticeTransitionMatrix.h
model::RationalMatrix::RationalMatrix
RationalMatrix(const MatrixDimD &R)
Definition
Lattices/RationalMatrix.cpp:78
B
initial point of the source segment B
Definition
infiniteDisplacement.m:5
A
function infiniteDisplacement syms Ax Ay Az Bx By Bz qx qy qz u L x y z real A
Definition
infiniteDisplacement.m:4
a
a
Definition
int_R.m:14
b
b
Definition
int_R.m:16
model
Definition
DD_converter.dox:2
model::LatticeTransitionMatrix
Definition
LatticeTransitionMatrix.h:28
model::LatticeTransitionMatrix::LatticeType
Lattice< dim > LatticeType
Definition
LatticeTransitionMatrix.h:34
model::LatticeTransitionMatrix::getTransitionMatrix
static RationalMatrix< dim > getTransitionMatrix(const LatticeType &A, const LatticeType &B)
Definition
LatticeTransitionMatrix.cpp:29
model::LatticeTransitionMatrix::MatrixDimD
Eigen::Matrix< double, dim, dim > MatrixDimD
Definition
LatticeTransitionMatrix.h:33
model::LatticeTransitionMatrix::IntValueType
long long int IntValueType
Definition
LatticeTransitionMatrix.h:35
model::LatticeTransitionMatrix::gcd
static IntValueType gcd(const IntValueType &a, const IntValueType &b)
Definition
LatticeTransitionMatrix.cpp:22
model::LatticeTransitionMatrix::LatticeTransitionMatrix
LatticeTransitionMatrix(const LatticeType &A_in, const LatticeType &B_in)
Definition
LatticeTransitionMatrix.cpp:59
Generated by
1.15.0