4 #include "casm/external/Eigen/Dense"
18 : m_super_updated(false),
22 throw std::runtime_error(
23 "The beginning volume of the SuperlatticeEnumerator cannot be greater "
24 "than the end volume!");
28 throw std::runtime_error(
29 "Dimensions to count over must be greater than 0!");
88 if (last_determinant !=
m_current->determinant()) {
101 Eigen::Matrix3i expanded =
115 m_point_group(point_grp),
116 m_begin_volume(enum_props.begin_volume()),
117 m_end_volume(enum_props.end_volume()),
118 m_gen_mat(enum_props.generating_matrix()),
119 m_dims(enum_props.dims()) {
121 throw std::runtime_error(
122 "The transformation matrix to expand into a 3x3 matrix must have a "
123 "positive determinant!");
178 const Eigen::Matrix3i &T,
182 auto init_vol = T.determinant();
184 while (m * m * m * init_vol <
volume) {
190 auto init_vol = T.determinant();
192 while (m * init_vol <
volume) {
196 auto compactness = [](
const Lattice &lat) {
198 return (L.transpose() * L).trace();
202 return compactness(A) < compactness(B);
207 return best_it.matrix();
221 Eigen::Matrix3i H_best;
224 for (
const auto &op : effective_pg) {
225 Eigen::Matrix3i transformed =
231 H_best = H_transformed;
Eigen::VectorXi::Scalar value_type
const Eigen::Matrix3d & lat_column_mat() const
3x3 matrix with lattice vectors as its columne
Data structure for holding supercell enumeration properties.
A fake container of supercell matrices.
Iterators used with SuperlatticeEnumerator.
bool operator!=(const SuperlatticeIterator &B) const
Iterator comparison.
const_iterator end() const
A const iterator to the past-the-last volume.
SuperlatticeIterator const_iterator
const_iterator cend() const
A const iterator to the past-the-last volume.
Lattice m_super
A supercell, stored here so that iterator dereferencing will be OK. Only used when requested.
const Eigen::Matrix3i & gen_mat() const
Get the transformation matrix that's being applied to the unit vectors.
SuperlatticeIterator & operator=(const SuperlatticeIterator &B)
const SuperlatticeEnumerator & enumerator() const
const reference to the SuperlatticeEnumerator this is iterating with
void end_volume(size_type _end_volume)
Set the end volume.
Eigen::Matrix3i matrix() const
constructed supercell matrix
const Lattice m_unit
The unit cell of the supercells.
int dimension() const
Get the dimensions of the enumerator (1D, 2D or 3D)
const int m_dims
The number of lattice directions the enumeration is being done in.
bool operator==(const SuperlatticeIterator &B) const
Iterator comparison.
size_type begin_volume() const
Get the beginning volume.
Eigen::Matrix3i canonical_hnf(const Eigen::Matrix3i &T, const SymOpVector &effective_pg, const Lattice &ref_lattice)
Return canonical hermite normal form of the supercell matrix.
HermiteCounter::value_type volume() const
current volume
const Eigen::Matrix3i m_gen_mat
This matrix (G) specifies new lattice vectors to enumerate over column-wise, such that the resulting ...
std::vector< Eigen::Matrix3i > m_canon_hist
Keep track of the HNF matrices for the current determinant value.
pointer operator->() const
Access the supercell.
Eigen::Matrix3i enforce_min_volume(const Lattice &unit, const Eigen::Matrix3i &T, const SymOpVector &point_grp, Index volume, bool fix_shape=false)
Return a transformation matrix that ensures a supercell of at least some volume.
const int m_end_volume
The past-the-last volume supercells to be iterated over (what cend uses)
const_iterator citerator(size_type volume) const
A const iterator to a specified volume.
const Lattice & unit() const
Access the unit the is being made into superlattices.
const_iterator cbegin() const
A const iterator to the beginning volume.
SuperlatticeIterator & operator++()
Prefix increment operator. Increment to next unique supercell.
bool m_super_updated
Indicates if m_super reflects the current m_current supercell matrix.
SuperlatticeEnumerator(const Lattice &unit, const SymOpVector &point_grp, const ScelEnumProps &enum_props)
Construct a SuperlatticeEnumerator using custom point group operations.
const_iterator begin() const
A const iterator to the beginning volume, specify here how the iterator should jump through the enume...
reference operator*() const
Access the supercell.
size_type end_volume() const
Get the end volume.
const int m_begin_volume
The first volume supercells to be iterated over (what cbegin uses)
notstd::cloneable_ptr< HermiteCounter > m_current
Current supercell matrix in HermitCounter form.
void begin_volume(size_type _begin_volume)
Set the beginning volume.
const SuperlatticeEnumerator * m_enum
Pointer to SuperlatticeEnumerator which holds the unit cell and point group.
SymOpVector m_point_group
The lattice of the unit cell.
const SymOpVector & point_group() const
Access the unit point group.
void _increment()
Postfix increment operator. Increment to next unique supercell.
double volume(const Lattice &lat)
Returns the volume of a Lattice.
Lattice make_superlattice(const Lattice &lat, const Eigen::Matrix< IntegralType, 3, 3, Options > &transf_mat)
Returns a super Lattice. Transformation matrix must be integer.
std::pair< Eigen::MatrixXi, Eigen::MatrixXi > hermite_normal_form(const Eigen::MatrixXi &M)
Return the hermite normal form, M == H*V.
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::MatrixXi _expand_dims(const Eigen::MatrixXi &H, const Eigen::MatrixXi &G)
Expand a n x n Hermite normal matrix (H) into a m x m one through a m x m generating matrix (G) (e....
bool _canonical_compare(const Eigen::MatrixXi &H0, const Eigen::MatrixXi &H1)
Compare two integer matrices and see which one is lexicographically greatest. Returns true if H0<H1.
Eigen::Matrix3d const & get_matrix(MappingNode const &_node)
External accessor for isometry, to provide xtal::SymOp adaptability.
std::vector< SymOp > SymOpVector
bool compare(ClusterInvariants const &A, ClusterInvariants const &B, double tol)
Compare ClusterInvariants.
Iterator find(Iterator begin, Iterator end, const T &value, BinaryCompare q)
Equivalent to std::find(begin, end, value), but with custom comparison.
INDEX_TYPE Index
For long integer indexing:
Non-std smart pointer classes and functions.
cloneable_ptr< T > make_cloneable(Args &&... args)
make a cloneable_ptr<T> via T(Args... args)