50 const double& orthogonality,
51 const int& dsclFactor,
55 for (
auto iter= std::next(boxVectors.begin()); iter < boxVectors.end(); iter++)
56 assert((*iter).dot(bc.getReciprocalLatticeDirectionInC(nA.reciprocalLatticeVector())) == 0 &&
57 "Box vectors not parallel to the grain boundary.");
59 auto config= bc.box(boxVectors,orthogonality,dsclFactor);
60 std::vector<LatticeVector<dim>> configuration;
63 if (&(latticeVector.lattice) == &bc.A && latticeVector.dot(nA)<=0)
64 configuration.push_back(latticeVector);
65 if (&(latticeVector.lattice) == &bc.B && latticeVector.dot(nB)<=0)
66 configuration.push_back(latticeVector);
67 if (&(latticeVector.lattice) == &bc.csl || &(latticeVector.lattice) == &bc.dscl)
68 configuration.push_back(latticeVector);
72 MatrixDimD rotation= Eigen::Matrix<double,dim,dim>::Identity();;
73 Eigen::Matrix<double,dim,dim-1> orthogonalVectors;
76 orthogonalVectors.col(0) = boxVectors[1].cartesian().normalized();
77 orthogonalVectors.col(1) = boxVectors[2].cartesian().normalized();
80 orthogonalVectors.col(0)= boxVectors[1].cartesian().normalized();
85 assert((rotation*rotation.transpose()).isApprox(Eigen::Matrix<double,dim,dim>::Identity())
86 &&
"Cannot orient the grain boundary. The GB plane box vectors are not orthogonal.");
88 if(!filename.empty()) {
91 if (!file) std::cerr <<
"Unable to open file";
92 file << configuration.size() << std::endl;
97 file << (rotation * 2 * boxVectors[0].cartesian()).transpose() <<
" 0 ";
98 file << (rotation * boxVectors[1].cartesian()).transpose() <<
" 0 ";
100 file <<
"\" Properties=atom_types:I:1:pos:R:3:radius:R:1 PBC=\"F T T\" origin=\"";
101 file << (rotation * origin.
cartesian()).transpose() <<
" 0.0\"" << std::endl;
102 for (
const auto &vector: configuration)
103 if (&(vector.lattice) == &bc.A)
104 file << 1 <<
" " << (rotation * vector.cartesian()).transpose() <<
" " << 0.0 <<
" "
105 << 0.05 << std::endl;
106 else if (&(vector.lattice) == &bc.B)
107 file << 2 <<
" " << (rotation * vector.cartesian()).transpose() <<
" " << 0.0 <<
" "
108 << 0.05 << std::endl;
109 else if (&(vector.lattice) == &bc.csl)
110 file << 3 <<
" " << (rotation * vector.cartesian()).transpose() <<
" " << 0.0 <<
" " << 0.2
113 file << 4 <<
" " << (rotation * vector.cartesian()).transpose() <<
" " << 0.0 <<
" "
114 << 0.01 << std::endl;
115 }
else if (dim == 3) {
116 file << (rotation * 2 * boxVectors[0].cartesian()).transpose() <<
" ";
117 file << (rotation * boxVectors[1].cartesian()).transpose() <<
" ";
118 file << (rotation * boxVectors[2].cartesian()).transpose() <<
" ";
119 file <<
"\" Properties=atom_types:I:1:pos:R:3:radius:R:1 PBC=\"F T T\" origin=\"";
120 file << (rotation * origin.
cartesian()).transpose() <<
"\"" << std::endl;
122 for (
const auto &vector: configuration)
123 if (&(vector.lattice) == &bc.A)
124 file << 1 <<
" " << (rotation * vector.cartesian()).transpose() <<
" " << 0.05
126 else if (&(vector.lattice) == &bc.B)
127 file << 2 <<
" " << (rotation * vector.cartesian()).transpose() <<
" " << 0.05
129 else if (&(vector.lattice) == &bc.csl)
130 file << 3 <<
" " << (rotation * vector.cartesian()).transpose() <<
" " << 0.2 << std::endl;
132 file << 4 <<
" " << (rotation * vector.cartesian()).transpose() <<
" " << 0.01
137 return configuration;
169 IntScalarType detMN= (bc.
M*bc.
N).
template cast<double>().determinant();
170 Eigen::DiagonalMatrix<IntScalarType,dim> nCDiagonal(nC.reciprocalLatticeVector());
171 RationalMatrix<dim> temp(adjM*adjN*Q*nCDiagonal, Eigen::Matrix<IntScalarType,dim,dim>::Constant(2*detMN));
180 auto basis= bc.
dscl.planeParallelLatticeBasis(m,
false);
181 for(
int i=0; i<dim; ++i) {
182 output.col(i) = basis[i].latticeVector();
183 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