This example demonstrates the generation of strained moire superlattices from a 2D homostructure and calculation of the translational invariance of a moire
#include "../../include/IO/TextFileParser.h"
#include "../../include/Lattices/BiCrystal.h"
#include "../../include/Lattices/LatticeModule.h"
#include <chrono>
#include <numbers>
auto start = std::chrono::system_clock::now();
std::time_t startTime = std::chrono::system_clock::to_time_t(start);
std::cout << "Time stamp: " << std::ctime(&startTime) << std::endl;
const auto A(
TextFileParser(
"bicrystal_2d.txt").readMatrix<double, 2, 2>(
"A",
true));
const auto &coincidentLattices =
lattice.generateCoincidentLattices(1e-2, 30, 15);
for (const auto &deformationGradient : coincidentLattices) {
try {
Lattice<2>(lattice.latticeBasis, deformationGradient),
false);
continue;
std::cout << std::endl;
std::cout << "--------------------------------- SNF "
"-------------------------------------"
<< std::endl;
std::cout <<
"sigmaA = " << bc.
sigmaA <<
"; sigmaB = " << bc.
sigmaB
<< std::endl;
std::cout << "Ap= " << std::endl;
std::cout << std::setprecision(12) << bc.
Ap.latticeBasis << std::endl;
std::cout << "Bp= " << std::endl;
std::cout << std::setprecision(12) << bc.
Bp.latticeBasis << std::endl;
std::cout << "CSL= " << std::endl;
std::cout << std::setprecision(12) << bc.
csl.latticeBasis << std::endl;
std::cout << "DCSL= " << std::endl;
std::cout << std::setprecision(12) << bc.
dscl.latticeBasis << std::endl;
std::cout << endl;
std::cout << "------Hetero-deformation -------" << std::endl;
Eigen::Matrix2d F = deformationGradient;
std::cout << "Deformation gradient, F=" << std::endl;
std::cout << std::setprecision(12) << F << std::endl;
Eigen::Matrix2d C = F.transpose() * F;
Eigen::Matrix2d E = (C - Eigen::Matrix2d::Identity()) / 2.0;
std::cout << endl;
std::cout << "Polar decomposition of F:" << std::endl;
double s = sqrt(C(0, 0) * C(1, 1) - pow(C(0, 1), 2));
double t = sqrt(C(0, 0) + C(1, 1) + 2 * s);
Eigen::Matrix2d U = (C + s * Eigen::Matrix2d::Identity()) / t;
Eigen::Matrix2d R = F * U.inverse();
std::cout << "R(" << std::setprecision(12)
<< atan2(R(1, 0), R(0, 0)) * 180 / std::numbers::pi
<< ")= " << std::endl;
std::cout << R << std::endl;
std::cout << "U= " << std::endl;
std::cout << std::setprecision(12) << U << std::endl;
std::cout << endl;
std::cout << "Elastic strain:" << std::endl;
std::cout << std::setprecision(12) << E << std::endl;
std::cout << endl;
std::cout << "------Invariance of the moire -------" << std::endl;
auto reducedDsclBasis =
RLLL(bc.
dscl.latticeBasis, 0.75);
auto U_Dscl = reducedDsclBasis.unimodularMatrix();
std::cout << "Reduced DSCL basis vectors:" << std::endl;
std::cout << "d1 = ";
std::cout << std::setprecision(20)
<< reducedDsclBasis.reducedBasis().col(0).transpose()
<< std::endl;
std::cout << "Integer coordinates of d1:";
d1 << U_Dscl.col(0).template cast<IntScalarType>();
std::cout << std::setprecision(20) << d1.transpose() << std::endl;
std::cout << std::endl;
std::cout << "d2 = ";
std::cout << std::setprecision(20)
<< reducedDsclBasis.reducedBasis().col(1).transpose()
<< std::endl;
std::cout << "Integer coordinates of d2:";
d2 << U_Dscl.col(1).template cast<IntScalarType>();
std::cout << std::setprecision(20) << d2.transpose() << std::endl;
std::cout << std::endl;
std::cout << "Reduced shift vectors: " << std::endl;
Eigen::Vector2d s1_coordinates_in_reduced_csl =
Eigen::Vector2d s2_coordinates_in_reduced_csl =
Eigen::Vector2d s1_coordinates_modulo =
s1_coordinates_in_reduced_csl.array() -
s1_coordinates_in_reduced_csl.array().round();
Eigen::Vector2d s2_coordinates_modulo =
s2_coordinates_in_reduced_csl.array() -
s2_coordinates_in_reduced_csl.array().round();
std::cout << "s1 = ";
std::cout << std::setprecision(20)
<< (reducedCsl.
latticeBasis * s1_coordinates_modulo).transpose()
<< std::endl;
std::cout << "s2 = ";
std::cout << std::setprecision(20)
<< (reducedCsl.
latticeBasis * s2_coordinates_modulo).transpose()
<< std::endl;
std::cout << "-----------------------------------------------------------"
"----------------"
<< std::endl;
} catch (std::runtime_error &e) {
std::cout << e.what() << "Moving on ..." << std::endl;
}
}
auto end = std::chrono::system_clock::now();
std::time_t endTime = std::chrono::system_clock::to_time_t(end);
std::chrono::duration<double> elapsedSeconds(end - start);
std::cout << "Elapsed time: " << elapsedSeconds.count() << " seconds"
<< std::endl;
std::cout << "End of simulation" << std::endl;
return 0;
}
const MatrixDimI LambdaA
Shift tensor describes the shift in the CSL when lattice is shifted by a DSCL vector.
const Lattice< dim > Bp
Lattice with basis .
const IntScalarType sigmaA
Signed ratio of the unit cell volume of to that of . .
const Lattice< dim > csl
CSL lattice .
const Lattice< dim > dscl
DCSL lattice .
const IntScalarType sigmaB
Signed ratio of the unit cell volume of to that of : .
const Lattice< dim > Ap
Lattice with basis .
const MatrixDimD latticeBasis
VectorDimD cartesian() const
const MatrixType & reducedBasis() const
int main(int argc, char **argv)
Eigen::Matrix< IntScalarType, dim, 1 > VectorDimI
long long int IntScalarType