59 const double& orthogonality,
60 const int& dsclFactor,
64 for (
auto iter= std::next(boxVectors.begin()); iter < boxVectors.end(); iter++)
65 assert((*iter).dot(bc.getReciprocalLatticeDirectionInC(nA.reciprocalLatticeVector())) == 0 &&
66 "Box vectors not parallel to the grain boundary.");
68 auto config= bc.box(boxVectors,orthogonality,dsclFactor);
69 std::vector<LatticeVector<dim>> configuration;
72 if (&(latticeVector.lattice) == &bc.A && latticeVector.dot(nA)<=0)
73 configuration.push_back(latticeVector);
74 if (&(latticeVector.lattice) == &bc.B && latticeVector.dot(nB)<=0)
75 configuration.push_back(latticeVector);
76 if (&(latticeVector.lattice) == &bc.csl || &(latticeVector.lattice) == &bc.dscl)
77 configuration.push_back(latticeVector);
81 MatrixDimD rotation= Eigen::Matrix<double,dim,dim>::Identity();;
82 Eigen::Matrix<double,dim,dim-1> orthogonalVectors;
85 orthogonalVectors.col(0) = boxVectors[1].cartesian().normalized();
86 orthogonalVectors.col(1) = boxVectors[2].cartesian().normalized();
89 orthogonalVectors.col(0)= boxVectors[1].cartesian().normalized();
94 assert((rotation*rotation.transpose()).isApprox(Eigen::Matrix<double,dim,dim>::Identity())
95 &&
"Cannot orient the grain boundary. The GB plane box vectors are not orthogonal.");
97 if(!filename.empty()) {
100 if (!file) std::cerr <<
"Unable to open file";
101 file << configuration.size() << std::endl;
102 file <<
"Lattice=\"";
106 file << (rotation * 2 * boxVectors[0].cartesian()).transpose() <<
" 0 ";
107 file << (rotation * boxVectors[1].cartesian()).transpose() <<
" 0 ";
109 file <<
"\" Properties=atom_types:I:1:pos:R:3:radius:R:1 PBC=\"F T T\" origin=\"";
110 file << (rotation * origin.
cartesian()).transpose() <<
" 0.0\"" << std::endl;
111 for (
const auto &vector: configuration)
112 if (&(vector.lattice) == &bc.A)
113 file << 1 <<
" " << (rotation * vector.cartesian()).transpose() <<
" " << 0.0 <<
" "
114 << 0.05 << std::endl;
115 else if (&(vector.lattice) == &bc.B)
116 file << 2 <<
" " << (rotation * vector.cartesian()).transpose() <<
" " << 0.0 <<
" "
117 << 0.05 << std::endl;
118 else if (&(vector.lattice) == &bc.csl)
119 file << 3 <<
" " << (rotation * vector.cartesian()).transpose() <<
" " << 0.0 <<
" " << 0.2
122 file << 4 <<
" " << (rotation * vector.cartesian()).transpose() <<
" " << 0.0 <<
" "
123 << 0.01 << std::endl;
124 }
else if (dim == 3) {
125 file << (rotation * 2 * boxVectors[0].cartesian()).transpose() <<
" ";
126 file << (rotation * boxVectors[1].cartesian()).transpose() <<
" ";
127 file << (rotation * boxVectors[2].cartesian()).transpose() <<
" ";
128 file <<
"\" Properties=atom_types:I:1:pos:R:3:radius:R:1 PBC=\"F T T\" origin=\"";
129 file << (rotation * origin.
cartesian()).transpose() <<
"\"" << std::endl;
131 for (
const auto &vector: configuration)
132 if (&(vector.lattice) == &bc.A)
133 file << 1 <<
" " << (rotation * vector.cartesian()).transpose() <<
" " << 0.05
135 else if (&(vector.lattice) == &bc.B)
136 file << 2 <<
" " << (rotation * vector.cartesian()).transpose() <<
" " << 0.05
138 else if (&(vector.lattice) == &bc.csl)
139 file << 3 <<
" " << (rotation * vector.cartesian()).transpose() <<
" " << 0.2 << std::endl;
141 file << 4 <<
" " << (rotation * vector.cartesian()).transpose() <<
" " << 0.01
146 return configuration;
178 IntScalarType detMN= (bc.
M*bc.
N).
template cast<double>().determinant();
179 Eigen::DiagonalMatrix<IntScalarType,dim> nCDiagonal(nC.reciprocalLatticeVector());
180 RationalMatrix<dim> temp(adjM*adjN*Q*nCDiagonal, Eigen::Matrix<IntScalarType,dim,dim>::Constant(2*detMN));
189 auto basis= bc.
dscl.planeParallelLatticeBasis(m,
false);
190 for(
int i=0; i<dim; ++i) {
191 output.col(i) = basis[i].latticeVector();
192 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