oILAB
Loading...
Searching...
No Matches
testGb3d.cpp

This examples demonstrates the construction of a grain boundary in a 3D bicrystal. We will construct a [111] tilt \(\Sigma 273\) - STGB (5 6 -11) and an ATGB (17 23 -40)(145 136 -281).

  1. Initialize the first lattice L1
    Eigen::Matrix3d A;
    A << 0.0, 0.5, 0.5,
    0.5, 0.0, 0.5,
    0.5, 0.5, 0.0;
    Lattice<dim> L1(A);
  2. Define the tilt axis \([1\,1\,1]\) as a reciprocal vector in L1
    Eigen::Vector3d axis;
    axis << 1,1,1;
    ReciprocalLatticeVector<dim> rv(L1.reciprocalLatticeDirection(axis).reciprocalLatticeVector());
  3. Form the second lattice L2 by rotating L1 about the tilt axis
    double angle= 6.0089831977661480877*M_PI/180;
    Eigen::AngleAxisd rotation(angle,axis.normalized());
    Lattice<dim> L2(A,rotation.matrix());
  4. Define the grain boundary normal (w.r.t lattice 1) and form the GB
    ReciprocalLatticeVector<dim> normal(L1);
    normal << 17,23,-40;
    //normal << 5,6,-11;
    Gb<dim> gb(bc,normal);
  5. To print, construct a grain boundary bounded by a box formed by three CSL vectors - period vector and vectors along the tilt axis and the grain boundary normal. Period vector is the shortest CSL vector normal to the tilt axis and the grain boundary normal.
    1. Calculate the period vector (periodC). glideA is a vector in lattice L1, and periodC is the shortest CSL vector along glideA.
      LatticeVector<dim> glideA(rv.cross(gb.nA.reciprocalLatticeVector()).latticeVector());
      LatticeVector<dim> periodC(bc.getLatticeDirectionInC(glideA).latticeVector());
    2. Calculate the CSL vector along the normal (normalC). normalA is a vector in lattice L1, and normalC is the shortest CSL vector along normalA.
      auto basis= bc.csl.planeParallelLatticeBasis(gb.bc.getReciprocalLatticeDirectionInC(gb.nA.reciprocalLatticeVector()),true);
      LatticeVector<dim> nonParallelC(basis[0].latticeVector());
    3. Calculate the CSL vector along the tilt axis (vectorAlongAxisC). vectorAlongAxisA is a vector in lattice L1, and vectorAlongAxisC is the shortest CSL vector along vectorAlongAxisA.
      LatticeVector<dim> vectorAlongAxisA(bc.A.latticeDirection(rv.cartesian()).latticeVector());
      LatticeVector<dim> vectorAlongAxisC(bc.getLatticeDirectionInC(vectorAlongAxisA).latticeVector());
  6. Form the box vectors and output the grain boundary to a file
    std::vector<LatticeVector<dim>> boxVectors;
    boxVectors.push_back(nonParallelC);
    boxVectors.push_back(periodC);
    boxVectors.push_back(vectorAlongAxisC);
    std::cout << "Input box vectors = " << std::endl;
    std::cout << boxVectors[0].cartesian().transpose() << std::endl;
    std::cout << boxVectors[1].cartesian().transpose() << std::endl;
    std::cout << boxVectors[2].cartesian().transpose() << std::endl;
    gb.box(boxVectors,0.5,2,"gb.txt",true);
    std::cout << "Output box vectors = " << std::endl;
    std::cout << boxVectors[0].cartesian().transpose() << std::endl;
    std::cout << boxVectors[1].cartesian().transpose() << std::endl;
    std::cout << boxVectors[2].cartesian().transpose() << std::endl;
    Full code:
#include <LatticeModule.h>
#include <TextFileParser.h>
/* This examples demonstrates the construction of a grain boundary in a 3D bicrystal.
* The following is a snippet from the output generated by testGenerateGBs. In this example,
* we will construct a [111] tilt Sigma 273 - STGB (5 6 -11) and an
* ATGB (17 23 -40)(145 136 -281).
Lattice A =
0 0.5 0.5
0.5 0 0.5
0.5 0.5 0
maxis=
1
1
1
Cartesian coordinates of axis =
1 1 1
###################################################
Misorientation angle = 6.0089831977661480877; Sigma = 273
Lattice B =
0.001831501831501824995 0.52930402930402931094 0.46886446886446891957
0.46886446886446891957 0.001831501831501824995 0.52930402930402931094
0.52930402930402931094 0.46886446886446891957 0.001831501831501824995
Parallel CSL basis Cp=
272.5 -7.5 -136.5
145 -8 -136.5
128.5 0.5 8.8817841970012523234e-16
Parallel DSCL basis Dp =
0.998168498168498175 -7.5 0.5
0.53113553113553113594 -8 0.5
0.47069597069597068906 0.5 -3.2534008047623634856e-18
Reduced DSCL basis vectors:
d1 = 0.001831501831501824995 -0.031135531135531135938 0.029304029304029310943
Integer coordinates of d1:-1 1 17
d2 = 0.02930402930402919992 0.001831501831501824995 -0.031135531135531024916
Integer coordinates of d2:-16 15 257
Reduced shift vectors:
s1 = 0.0018315018315023801065 0.4688644688644695302 0.52930402930402986605
s2 = 0.52930402930402831174 0.0018315018315036013519 0.46886446886445387605
GBs of varying inclination (measured with respect to the first grain boundary)
-----------------------------------------------------------------------------
-- CAUTION: The integer coordinates of GB normals are w.r.t the reciprocal --
-- basis of the primitive unit cell. --
-----------------------------------------------------------------------------
1) Inclination = 0
nA = 5 6 -11
nB = 6 5 -11
GB period = 11.68332144554794283
CSL plane distance (Height)= 3.3726843908079144896
Glide disconnection Burgers vector = 0.031135531135532801272 -0.02930402930402919992 -0.0018315018315027131734; norm = 0.042796049251092468935
Step height of glide disconnection = 0.40768712416676056165
Step height of non-glide disconnection 1= 0.22237479499852241815
Step height of non-glide disconnection 2= 0.18531232916825057799
-----------------------------------------------------------------------------
2) Inclination = 1.9451190845039707522
nA = 17 23 -40
nB = 145 136 -281
GB period = 99.36548696604899078
CSL plane distance (Height)= 0.39655776945623399943
Glide disconnection Burgers vector = 0.80769230769237765344 -0.7307692307690558664 -0.07692307692309441336; norm = 1.0919284281982737372
Step height of glide disconnection = 0.091513331645593942731
Step height of non-glide disconnection 1= -0.18593184794961481465
Step height of non-glide disconnection 2= 0.19755258845548662183
*/
using namespace gbLAB;
int main()
{
const int dim=3;
Eigen::Matrix3d A;
A << 0.0, 0.5, 0.5,
0.5, 0.0, 0.5,
0.5, 0.5, 0.0;
Lattice<dim> L1(A);
Eigen::Vector3d axis;
axis << 1,1,1;
ReciprocalLatticeVector<dim> rv(L1.reciprocalLatticeDirection(axis).reciprocalLatticeVector());
double angle= 6.0089831977661480877*M_PI/180;
Eigen::AngleAxisd rotation(angle,axis.normalized());
Lattice<dim> L2(A,rotation.matrix());
try
{
BiCrystal<dim> bc(L1,L2);
std::cout << "Sigma = " << bc.sigma << std::endl;
normal << 17,23,-40;
//normal << 5,6,-11;
Gb<dim> gb(bc,normal);
std::cout << "Miller indices w.r.t A: ";
std::cout << gb.nA << std::endl;
std::cout << "Miller indices w.r.t B: ";
std::cout << gb.nB << std::endl;
LatticeVector<dim> glideA(rv.cross(gb.nA.reciprocalLatticeVector()).latticeVector());
LatticeVector<dim> periodC(bc.getLatticeDirectionInC(glideA).latticeVector());
auto basis= bc.csl.planeParallelLatticeBasis(gb.bc.getReciprocalLatticeDirectionInC(gb.nA.reciprocalLatticeVector()),true);
LatticeVector<dim> nonParallelC(basis[0].latticeVector());
LatticeVector<dim> vectorAlongAxisA(bc.A.latticeDirection(rv.cartesian()).latticeVector());
LatticeVector<dim> vectorAlongAxisC(bc.getLatticeDirectionInC(vectorAlongAxisA).latticeVector());
std::vector<LatticeVector<dim>> boxVectors;
boxVectors.push_back(nonParallelC);
boxVectors.push_back(periodC);
boxVectors.push_back(vectorAlongAxisC);
std::cout << "Input box vectors = " << std::endl;
std::cout << boxVectors[0].cartesian().transpose() << std::endl;
std::cout << boxVectors[1].cartesian().transpose() << std::endl;
std::cout << boxVectors[2].cartesian().transpose() << std::endl;
gb.box(boxVectors,0.5,2,"gb.txt",true);
std::cout << "Output box vectors = " << std::endl;
std::cout << boxVectors[0].cartesian().transpose() << std::endl;
std::cout << boxVectors[1].cartesian().transpose() << std::endl;
std::cout << boxVectors[2].cartesian().transpose() << std::endl;
}
catch(std::runtime_error& e)
{
std::cout << e.what() << std::endl;
return -1;
}
return 0;
}
const Lattice< dim > & A
Definition BiCrystal.h:56
const int sigma
if , else
Definition BiCrystal.h:82
LatticeDirection< dim > getLatticeDirectionInC(const LatticeVector< dim > &v) const
const Lattice< dim > csl
CSL lattice .
Definition BiCrystal.h:86
Definition Gb.h:16
const ReciprocalLatticeDirection< dim > nA
Definition Gb.h:33
const BiCrystal< dim > & bc
Definition Gb.h:29
std::enable_if< dm==2||dm==3, std::vector< LatticeVector< dim > > >::type box(std::vector< LatticeVector< dim > > &boxVectors, const double &orthogonality, const int &dsclFactor, std::string filename="", bool orient=false) const
Definition Gb.cpp:49
const ReciprocalLatticeDirection< dim > nB
Definition Gb.h:37
Lattice class.
Definition Lattice.h:34
ReciprocalLatticeDirection< dim > reciprocalLatticeDirection(const VectorDimD &d, const double &tol=FLT_EPSILON) const
Returns the reciprocal lattice direction along a vector.
Definition Lattice.cpp:83
LatticeVector class.
std::enable_if< dm==2, LatticeDirection< dim > >::type cross(const ReciprocalLatticeVector< dim > &other) const
int main(int argc, char **argv)
Definition main.cpp:11