7#ifndef model_BiCrystal_cpp_
8#define model_BiCrystal_cpp_
10#include <LatticeModule.h>
22 const auto& dii(sd.matrixD()(
i,
i));
35 const auto& dii=sd.matrixD()(
i,
i);
42 typename BiCrystal<dim>::MatrixDimD BiCrystal<dim>::getCSLBasis(
const Lattice<dim>&
A,
45 const typename BiCrystal<dim>::MatrixDimI&
M,
46 const typename BiCrystal<dim>::MatrixDimI&
N,
73 const auto C1(
A.latticeBasis*(sd.matrixX()*
M).template cast<double>());
74 const auto C2(
B.latticeBasis*(sd.matrixV()*
N).template cast<double>());
75 if ((
C1-
C2).norm()>FLT_EPSILON)
77 throw std::runtime_error(
"CSL calculation failed.\n");
91 typename BiCrystal<dim>::MatrixDimD BiCrystal<dim>::getDSCLBasis(
const Lattice<dim>&
A,
94 const typename BiCrystal<dim>::MatrixDimI&
M,
95 const typename BiCrystal<dim>::MatrixDimI&
N,
99 const auto D1(
A.latticeBasis*sd.matrixX().template cast<double>()*
N.template cast<double>().inverse());
100 const auto D2(
B.latticeBasis*sd.matrixV().template cast<double>()*
M.template cast<double>().inverse());
101 if ((D1-D2).norm()>FLT_EPSILON)
103 throw std::runtime_error(
"DSCL calculation failed.\n");
119 const bool& useRLLL) :
120 RationalMatrix<dim>(A_in.reciprocalBasis.transpose()*B_in.latticeBasis)
124 ,
M(getM(*this,*this))
125 ,
N(getN(*this,*this))
129 ,
csl(getCSLBasis (
A,
B,*this,
M,
N,useRLLL),MatrixDimD::Identity())
130 ,
dscl(getDSCLBasis(
A,
B,*this,
M,
N,useRLLL),MatrixDimD::Identity())
131 ,
Ap(
A.latticeBasis*this->
matrixX().template cast<double>())
132 ,
Bp(
B.latticeBasis*this->
matrixV().template cast<double>())
138 const MatrixDimD tempA(
A.reciprocalBasis.transpose()*
csl.latticeBasis);
139 if ((tempA-tempA.array().round().matrix()).norm()>FLT_EPSILON)
141 throw std::runtime_error(
"CSL is not a multiple of lattice A\n");
144 const MatrixDimD tempB(
B.reciprocalBasis.transpose()*
csl.latticeBasis);
145 if ((tempB-tempB.array().round().matrix()).norm()>FLT_EPSILON)
147 throw std::runtime_error(
"CSL is not a multiple of lattice B\n");
154 const MatrixDimD tempA(
dscl.reciprocalBasis.transpose()*
A.latticeBasis);
155 if ((tempA-tempA.array().round().matrix()).norm()>FLT_EPSILON)
157 throw std::runtime_error(
"Lattice A is not a multiple of the DSCL\n");
160 const MatrixDimD tempB(
dscl.reciprocalBasis.transpose()*
B.latticeBasis);
161 if ((tempB-tempB.array().round().matrix()).norm()>FLT_EPSILON)
163 throw std::runtime_error(
"Lattice B is not a multiple of the DSCL\n");
const Lattice< dim > dscl
BiCrystal(const Lattice< dim > &A, const Lattice< dim > &B, const bool &useRLLL=true)
const MatrixType & reducedBasis() const
RationalMatrix(const MatrixDimD &R)
const MatrixInt & integerMatrix
const MatrixNi & matrixV() const
SmithDecomposition(const MatrixNi &A)
const MatrixNi & matrixX() const
initial point of the source segment B
function infiniteDisplacement syms Ax Ay Az Bx By Bz qx qy qz u L x y z real A
static IntScalarType gcd(const IntScalarType &a, const IntScalarType &b)