10 #include "casm/external/Eigen/src/Core/Matrix.h"
15 Eigen::Ref<const Eigen::MatrixXd>
const
17 if (strain_gram_mat.size() == 0 || strain_gram_mat.isIdentity(1e-9)) {
22 if (strain_gram_mat.rows() == 6 && strain_gram_mat.cols() == 6) {
23 std::vector<Index> map({0, 5, 4, 1, 3, 2});
24 for (
Index i = 0; i < 6; ++i) {
25 for (
Index j = 0; j < 6; ++j) {
26 m_gram_mat(i, j) = strain_gram_mat(map[i], map[j]);
32 if (strain_gram_mat.rows() == 9 && strain_gram_mat.cols() == 9) {
34 for (
Index i = 0; i < 3; ++i) {
35 for (
Index j = i; j < 3; ++j, ++m) {
37 for (
Index k = 0; k < 3; ++k) {
38 for (
Index l = k; l < 3; ++l, ++n) {
39 m_gram_mat(m, n) = strain_gram_mat(i * 3 + j, k * 3 + l);
78 const Eigen::Matrix3d &_deformation_gradient,
double _vol_factor)
const {
85 for (
Index i = 0; i < 3; ++i) {
86 for (
Index j = i; j < 3; ++j, ++m) {
88 for (
Index k = 0; k < 3; ++k) {
89 for (
Index l = k; l < 3; ++l, ++n) {
119 for (
auto const &op : parent_point_group) {
120 stretch_aggregate += op.matrix * stretch * op.matrix.inverse();
122 stretch_aggregate = stretch_aggregate / double(parent_point_group.size());
130 Index num_atoms,
int _range,
133 Eigen::Ref<const Eigen::MatrixXd>
const &strain_gram_mat,
134 double _init_better_than ,
135 bool _symmetrize_strain_cost,
double _xtal_tol)
136 : m_calc(strain_gram_mat),
137 m_vol_factor(pow(
std::abs(
volume(_child) /
volume(_parent)), 1. / 3.)),
141 m_symmetrize_strain_cost(_symmetrize_strain_cost),
142 m_xtal_tol(_xtal_tol) {
154 else if (_range == 2)
156 else if (_range == 3)
158 else if (_range == 4)
161 throw std::runtime_error(
162 "LatticeMap cannot currently be invoked for range>4");
168 for (
auto const &op : _parent_point_group) {
169 if (!symcheck(op))
continue;
189 for (
auto const &op : _child_point_group) {
190 if (!symcheck(op))
continue;
203 reset(_init_better_than);
207 Eigen::Ref<const LatticeMap::DMatType>
const &_child,
208 Index _num_atoms,
int _range,
211 Eigen::Ref<const Eigen::MatrixXd>
const &strain_gram_mat,
212 double _init_better_than ,
213 bool _symmetrize_strain_cost,
double _xtal_tol)
215 _parent_point_group, _child_point_group, strain_gram_mat,
216 _init_better_than, _symmetrize_strain_cost, _xtal_tol) {}
318 double tcost = max_cost;
329 if (std::abs(tcost) < (std::abs(max_cost) + std::abs(
xtal_tol()))) {
344 if (!(std::abs(tcost) < (std::abs(max_cost) + std::abs(
xtal_tol())))) {
Checks if operations are point group operations.
const Eigen::Matrix3d & lat_column_mat() const
3x3 matrix with lattice vectors as its columne
Lattice reduced_cell() const
Find the lattice vectors which give most compact unit cell Compactness is measured by how close lat_c...
const Eigen::Matrix3d & inv_lat_column_mat() const
Inverse of Lattice::lat_column_mat() It is the transformation matrix 'C2F', such that f = C2F * c whe...
Eigen::Matrix< double, 3, 3, Eigen::DontAlign > DMatType
SymOpVector m_parent_point_group
double strain_cost() const
LatticeMap(Lattice const &_parent, Lattice const &_child, Index _num_atoms, int _range, SymOpVector const &_parent_point_group, SymOpVector const &_child_point_group, Eigen::Ref< const Eigen::MatrixXd > const &strain_gram_mat=Eigen::MatrixXd::Identity(9, 9), double _init_better_than=1e20, bool _symmetrize_strain_cost=false, double _xtal_tol=TOL)
Eigen::Matrix3i const & inv_mat() const
Returns the inverse of the current transformation matrix under consideration.
const DMatType & deformation_gradient() const
StrainCostCalculator m_calc
LatticeMap const & next_mapping_better_than(double max_cost) const
bool symmetrize_strain_cost() const
Index n_mat() const
Number of unimodular matrices.
double calc_strain_cost(const Eigen::Matrix3d &deformation_gradient) const
void reset(double _better_than=1e20)
LatticeMap const & best_strain_mapping() const
DMatType m_deformation_gradient
std::vector< Eigen::Matrix3i > const * m_mvec_ptr
std::vector< Eigen::Matrix3i > m_child_fsym_mats
LatticeMap const & _next_mapping_better_than(double max_cost) const
std::vector< Eigen::Matrix3i > m_parent_fsym_mats
bool _check_canonical() const
Returns true if current transformation is the canonical equivalent.
Eigen::MatrixXd m_gram_mat
Eigen::Matrix3d m_cache_inv
static double isotropic_strain_cost(Eigen::Matrix3d const &_deformation_gradient)
StrainCostCalculator(Eigen::Ref< const Eigen::MatrixXd > const &strain_gram_mat=Eigen::MatrixXd::Identity(9, 9))
double strain_cost(Eigen::Matrix3d const &_deformation_gradient) const
static double vol_factor(Eigen::Matrix3d const &_deformation_gradient)
double volume(const Lattice &lat)
Returns the volume of a Lattice.
Eigen::Matrix3d polar_decomposition(Eigen::Matrix3d const &mat)
Eigen::Matrix< typename Derived::Scalar, Derived::RowsAtCompileTime, Derived::ColsAtCompileTime > inverse(const Eigen::MatrixBase< Derived > &M)
Return the integer inverse matrix of an invertible integer matrix.
Eigen::CwiseUnaryOp< decltype(Local::iround_l< typename Derived::Scalar >), const Derived > iround(const Eigen::MatrixBase< Derived > &val)
Round Eigen::MatrixXd to Eigen::MatrixXi.
IdentitySymRepBuilder Identity()
Eigen::Matrix3d right_stretch_tensor(const Eigen::Ref< const Eigen::Matrix3d > &deformation_tensor)
Calculates and returns the value of U where F = R*U.
std::vector< SymOp > SymOpVector
INDEX_TYPE Index
For long integer indexing: