oILAB
Loading...
Searching...
No Matches
testGb.cpp

This example demonstrates the computation of step heights and the use of Gb class

  1. Initialize two lattices
    const auto A(TextFileParser("bicrystal_2d.txt").readMatrix<double,2,2>("A",true));
    const auto B(TextFileParser("bicrystal_2d.txt").readMatrix<double,2,2>("B",true));
    const auto F(TextFileParser("bicrystal_2d.txt").readMatrix<double,2,2>("F",true));
    Lattice<2> L1(A);
    Lattice<2> L2(B,F);
  2. Form the bicrystal
    BiCrystal<2> bc(L1,L2);
  3. Define the grain boundary normal (w.r.t lattice 2) and form the GB
    ReciprocalLatticeVector<2> rvec(L2);
    rvec << 1,1;
    ReciprocalLatticeDirection<2> n(rvec);
    Gb<2> gb(bc,n);
  4. Define the Burgers vector \(b\) of a disconnection and compute the two step heights, \(h_{\mathcal A}\) and \(h_{\mathcal B}\).
    LatticeVector<2> b(bc.dscl);
    b << 1,1;
    std::cout << "Step height A: ";
    double stepHeightA= gb.stepHeightA(b);
    std::cout << stepHeightA << std::endl;
    std::cout << "Step height B: ";
    double stepHeightB= gb.stepHeightB(b);
    std::cout << stepHeightB << std::endl;
  5. Compute the CSL plane spacing \(H\) parallel to the grain boundary
    auto dir= gb.bc.getReciprocalLatticeDirectionInC(n.reciprocalLatticeVector());
    double cslPlaneSpacing= dir.planeSpacing();
  6. Check the conditions: \( \mod(h_{\mathcal A} - h_{\mathcal B} - \textbf{b} \cdot \hat{\textbf{n}}_{\mathcal A}, H) = 0 \), where \(\hat{\textbf{n}}_{\mathcal A}\) and \(\hat{\textbf{n}}_{\mathcal B}\) are the outward unit normals to lattices \(\mathcal A\) and \(\mathcal B\), respectively.
    double error= abs(stepHeightA-stepHeightB - b.cartesian().dot(gb.nA.cartesian().normalized()));
    error= std::remainder(error,cslPlaneSpacing);
    if((gb.nA.cartesian().normalized()+gb.nB.cartesian().normalized()).norm() > 1e-5)
    throw std::runtime_error("Cartesian coordinates of normalized nA and nB are not anti-parallel");
    if(error > 1e-6)
    throw std::runtime_error("Error in step height calculation");

Full code:

#include <LatticeModule.h>
#include <TextFileParser.h>
using namespace gbLAB;
int main()
{
const auto A(TextFileParser("bicrystal_2d.txt").readMatrix<double,2,2>("A",true));
const auto B(TextFileParser("bicrystal_2d.txt").readMatrix<double,2,2>("B",true));
const auto F(TextFileParser("bicrystal_2d.txt").readMatrix<double,2,2>("F",true));
Lattice<2> L1(A);
Lattice<2> L2(B,F);
try
{
BiCrystal<2> bc(L1,L2);
rvec << 1,1;
Gb<2> gb(bc,n);
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;
b << 1,1;
std::cout << "Step height A: ";
double stepHeightA= gb.stepHeightA(b);
std::cout << stepHeightA << std::endl;
std::cout << "Step height B: ";
double stepHeightB= gb.stepHeightB(b);
std::cout << stepHeightB << std::endl;
auto dir= gb.bc.getReciprocalLatticeDirectionInC(n.reciprocalLatticeVector());
double cslPlaneSpacing= dir.planeSpacing();
double error= abs(stepHeightA-stepHeightB - b.cartesian().dot(gb.nA.cartesian().normalized()));
error= std::remainder(error,cslPlaneSpacing);
if((gb.nA.cartesian().normalized()+gb.nB.cartesian().normalized()).norm() > 1e-5)
throw std::runtime_error("Cartesian coordinates of normalized nA and nB are not anti-parallel");
if(error > 1e-6)
throw std::runtime_error("Error in step height calculation");
auto nC= gb.bc.getReciprocalLatticeDirectionInC(gb.nA.reciprocalLatticeVector());
auto planeParallelBasis= bc.csl.planeParallelLatticeBasis(nC,true);
std::vector<LatticeVector<2>> boxVectors;
boxVectors.push_back(planeParallelBasis[0].latticeVector());
boxVectors.push_back(planeParallelBasis[1].latticeVector());
gb.box(boxVectors,0.9,1,"gb.txt", true);
}
catch(std::runtime_error& e)
{
std::cout << e.what() << std::endl;
return -1;
}
return 0;
}
const Lattice< dim > dscl
DCSL lattice .
Definition BiCrystal.h:90
const Lattice< dim > csl
CSL lattice .
Definition BiCrystal.h:86
Definition Gb.h:16
const ReciprocalLatticeDirection< dim > nA
Definition Gb.h:33
double stepHeightA(const LatticeVector< dim > &d) const
Computes the step height of a disconnection formed by displacing lattice by a Burgers vector .
Definition Gb.cpp:30
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
double stepHeightB(const LatticeVector< dim > &d) const
Computes the step height of a disconnection formed by displacing lattice by a Burgers vector .
Definition Gb.cpp:39
Lattice class.
Definition Lattice.h:34
LatticeVector class.
VectorDimD cartesian() const
int main(int argc, char **argv)
Definition main.cpp:11
const ReciprocalLatticeVector< dim > & reciprocalLatticeVector() const
Returns a constant reference to the base class (ReciprocalLatticeVector)