This example demonstrates the computation of plane-parallel lattice basis and direction-orthogonal reciprocal lattice basis for a random reciprocal lattice direction and a random lattice direction, respectively.
#include <random>
{
using IntScalarType= long long int;
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> distr(-10, 10);
const int dim= 5;
Eigen::Matrix<double,dim,dim> A;
A.setIdentity();
std::cout << "Testing in dimension = " << dim << std::endl;
Eigen::Vector<IntScalarType,dim> millerIndices;
for (auto& element : millerIndices)
element= distr(gen);
millerIndices<< -3, 10, 9, -1, -9;
Eigen::Vector<IntScalarType,dim> latticeCoordinates;
for (auto& element : latticeCoordinates)
element= distr(gen);
std::cout << "Input Miller index:" << rDir << std::endl;
std::cout << "Plane parallel lattice basis: " << std::endl;
for (auto it= directions.begin(); it!=directions.end(); ++it)
{
std::cout << it->latticeVector().transpose() << std::endl;
}
try {
for (auto it = directions.begin(); it != directions.end(); ++it) {
if (it == directions.begin())
{
throw std::runtime_error("The dot product of the input reciprocal vector and the first basis vector is not +1 or -1\n");
}
else
{
throw std::runtime_error(
"One of the plane-parallel basis vector is not perpendicular to the input reciprocal lattice direction\n");
}
}
}
catch (std::runtime_error& e){
std::cout << e.what() << std::endl;
return -1;
}
std::cout << "----------------------------------------------------" << std::endl;
std::cout <<
"Input lattice direction :" << lDir.
latticeVector().transpose() << std::endl;
std::cout << "Direction orthogonal reciprocal basis: " << std::endl;
for (auto it= reciprocalDirections.begin(); it!=reciprocalDirections.end(); ++it)
{
std::cout << *it << std::endl;
}
try {
for (auto it = reciprocalDirections.begin(); it != reciprocalDirections.end(); ++it) {
if (it == reciprocalDirections.begin())
{
throw std::runtime_error("The dot product of the input lattice direction and the first reciprocal basis vector is not +1 or -1\n");
}
else
{
throw std::runtime_error(
"One of the direction-orthogonal reciprocal basis vector is not perpendicular to the input lattice direction\n");
}
}
}
catch (std::runtime_error& e){
std::cout << e.what() << std::endl;
return -1;
}
return 0;
}
std::vector< ReciprocalLatticeDirection< dim > > directionOrthogonalReciprocalLatticeBasis(const LatticeDirection< dim > &l, const bool &useRLLL=false) const
Given a lattice direction , this function returns a direction-orthogonal reciprocal lattice basis ,...
std::vector< LatticeDirection< dim > > planeParallelLatticeBasis(const ReciprocalLatticeDirection< dim > &l, const bool &useRLLL=false) const
Given a reciprocal lattice direction , this function returns a plane-parallel lattice basis ,...
IntScalarType dot(const ReciprocalLatticeVector< dim > &other) const
IntScalarType dot(const LatticeVector< dim > &other) const
int main(int argc, char **argv)
const LatticeVector< dim > & latticeVector() const