15 nA(&n.lattice == &(bc.A) ? n
16 : bc.getReciprocalLatticeDirectionInA(
17 -1 * n.reciprocalLatticeVector()))
19 nB(&n.lattice == &(bc.B) ? n
20 : bc.getReciprocalLatticeDirectionInB(
21 -1 * n.reciprocalLatticeVector()))
23 basisT(getBasisT(bc, n))
25 T(
Lattice<dim>(bc.dscl.latticeBasis *
26 getBasisT(bc, n).template cast<double>())) {
28 throw std::runtime_error(
29 "The normal does not belong to the reciprocal lattices of A and B \n");
31 catch(std::runtime_error& e)
33 std::cout << e.what() << std::endl;
34 throw(std::runtime_error(
"GB construction failed. "));
67 const double& orthogonality,
68 const int& dsclFactor,
72 for (
auto iter= std::next(boxVectors.begin()); iter < boxVectors.end(); iter++)
73 assert((*iter).dot(bc.getReciprocalLatticeDirectionInC(nA.reciprocalLatticeVector())) == 0 &&
74 "Box vectors not parallel to the grain boundary.");
76 auto config= bc.box(boxVectors,orthogonality,dsclFactor);
77 std::vector<LatticeVector<dim>> configuration;
80 if (&(latticeVector.lattice) == &bc.A && latticeVector.dot(nA)<=0)
81 configuration.push_back(latticeVector);
82 if (&(latticeVector.lattice) == &bc.B && latticeVector.dot(nB)<=0)
83 configuration.push_back(latticeVector);
84 if (&(latticeVector.lattice) == &bc.csl || &(latticeVector.lattice) == &bc.dscl)
85 configuration.push_back(latticeVector);
89 MatrixDimD rotation= Eigen::Matrix<double,dim,dim>::Identity();;
90 Eigen::Matrix<double,dim,dim-1> orthogonalVectors;
93 orthogonalVectors.col(0) = boxVectors[1].cartesian().normalized();
94 orthogonalVectors.col(1) = boxVectors[2].cartesian().normalized();
97 orthogonalVectors.col(0)= boxVectors[1].cartesian().normalized();
102 assert((rotation*rotation.transpose()).isApprox(Eigen::Matrix<double,dim,dim>::Identity())
103 &&
"Cannot orient the grain boundary. The GB plane box vectors are not orthogonal.");
105 if(!filename.empty()) {
108 if (!file) std::cerr <<
"Unable to open file";
109 file << configuration.size() << std::endl;
110 file <<
"Lattice=\"";
114 file << (rotation * 2 * boxVectors[0].cartesian()).transpose() <<
" 0 ";
115 file << (rotation * boxVectors[1].cartesian()).transpose() <<
" 0 ";
117 file <<
"\" Properties=atom_types:I:1:pos:R:3:radius:R:1 PBC=\"F T T\" origin=\"";
118 file << (rotation * origin.
cartesian()).transpose() <<
" 0.0\"" << std::endl;
119 for (
const auto &vector: configuration)
120 if (&(vector.lattice) == &bc.A)
121 file << 1 <<
" " << (rotation * vector.cartesian()).transpose() <<
" " << 0.0 <<
" "
122 << 0.05 << std::endl;
123 else if (&(vector.lattice) == &bc.B)
124 file << 2 <<
" " << (rotation * vector.cartesian()).transpose() <<
" " << 0.0 <<
" "
125 << 0.05 << std::endl;
126 else if (&(vector.lattice) == &bc.csl)
127 file << 3 <<
" " << (rotation * vector.cartesian()).transpose() <<
" " << 0.0 <<
" " << 0.2
130 file << 4 <<
" " << (rotation * vector.cartesian()).transpose() <<
" " << 0.0 <<
" "
131 << 0.01 << std::endl;
132 }
else if (dim == 3) {
133 file << (rotation * 2 * boxVectors[0].cartesian()).transpose() <<
" ";
134 file << (rotation * boxVectors[1].cartesian()).transpose() <<
" ";
135 file << (rotation * boxVectors[2].cartesian()).transpose() <<
" ";
136 file <<
"\" Properties=atom_types:I:1:pos:R:3:radius:R:1 PBC=\"F T T\" origin=\"";
137 file << (rotation * origin.
cartesian()).transpose() <<
"\"" << std::endl;
139 for (
const auto &vector: configuration)
140 if (&(vector.lattice) == &bc.A)
141 file << 1 <<
" " << (rotation * vector.cartesian()).transpose() <<
" " << 0.05
143 else if (&(vector.lattice) == &bc.B)
144 file << 2 <<
" " << (rotation * vector.cartesian()).transpose() <<
" " << 0.05
146 else if (&(vector.lattice) == &bc.csl)
147 file << 3 <<
" " << (rotation * vector.cartesian()).transpose() <<
" " << 0.2 << std::endl;
149 file << 4 <<
" " << (rotation * vector.cartesian()).transpose() <<
" " << 0.01
154 return configuration;
186 IntScalarType detMN= (bc.
M*bc.
N).
template cast<double>().determinant();
187 Eigen::DiagonalMatrix<IntScalarType,dim> nCDiagonal(nC.reciprocalLatticeVector());
188 RationalMatrix<dim> temp(adjM*adjN*Q*nCDiagonal, Eigen::Matrix<IntScalarType,dim,dim>::Constant(2*detMN));
197 auto basis= bc.
dscl.planeParallelLatticeBasis(m,
false);
198 for(
int i=0; i<dim; ++i) {
199 output.col(i) = basis[i].latticeVector();
200 if (i==0) output.col(i)= beta*output.col(i);
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