22 UnitCell ijk = index_to_ijk_f(ijk_ix);
33 std::vector<Eigen::Vector3d> result;
38 for (
Index i = 0; i < c_info.
size() && n_best > 1; ++i) {
41 if (it->second < n_best) {
51 std::string sp = c_info.
names[i_trans];
53 result.reserve(n_best);
59 Eigen::Vector3d best_equiv_trans;
62 Eigen::Vector3d translation =
64 best_equiv_trans = translation;
65 bool unique_trans =
true;
68 double best_dist = 1e20;
71 equiv_trans.
cart() = itrans + translation;
75 for (
auto const &rtrans : result) {
76 t_trans.
cart() = rtrans;
83 if (!unique_trans)
break;
87 double tdist = equiv_trans.
const_cart().norm();
88 if (tdist < best_dist) {
96 result.push_back(best_equiv_trans);
125 result.
lat_column_mat = U * pgrid.superlattice().lat_column_mat();
132 mol_displacement.setZero(3, _node.
mol_map.size());
135 pgrid.transformation_matrix_to_super());
141 std::set<Index>
const &mol = _node.
mol_map[i];
143 for (
Index j : mol) {
145 mol_displacement.col(i) +=
151 }
else if (mol.size() > 1)
152 throw std::runtime_error(
153 "SimpleStrucMapCalculator found multi-atom molecule with "
154 "vacancy. This should not occur");
159 parent_index_to_unitcell)
161 mol_displacement.col(i));
168 for (
auto const &el : _child_struc.
properties) {
172 result.
properties.emplace(el.first, trans * el.second);
184 .emplace(el.first, Eigen::MatrixXd::Zero(el.second.rows(),
190 if (k < (csize * cgrid.size())) {
191 (it->second).col(i) += tprop.col(k / cgrid.size());
196 (it->second).col(i) / double(_node.
mol_map[i].size());
213 Uvec << U(0, 0), U(1, 1), U(2, 2), sqrt(2.) * U(1, 2), sqrt(2.) * U(0, 2),
222 result.
properties[ttraits.
name()] = Eigen::Map<const Eigen::VectorXd>(
233 bool const &symmetrize_atomic_cost)
const {
236 if (!symmetrize_atomic_cost ||
243 (node.
lattice_node).parent.transformation_matrix_to_super().cast<
int>(),
246 std::vector<Eigen::MatrixXd> supercell_sym_invariant_modes(
248 Eigen::MatrixXd::Zero(3, basis_idx.size()));
253 for (
int sym_idx = 0;
255 for (
int scel_idx = 0; scel_idx < basis_idx.size(); ++scel_idx)
256 supercell_sym_invariant_modes[sym_idx].col(scel_idx) =
258 basis_idx[scel_idx]);
259 supercell_sym_invariant_modes[sym_idx] =
260 supercell_sym_invariant_modes[sym_idx] /
261 supercell_sym_invariant_modes[sym_idx].norm();
264 supercell_sym_invariant_modes[sym_idx].data(),
265 supercell_sym_invariant_modes[sym_idx].size());
266 double projected_comp = disp_map.dot(unrolled_sym_mode);
269 projected_comp * supercell_sym_invariant_modes[sym_idx];
293 cgrid.transformation_matrix_to_super());
295 pgrid.transformation_matrix_to_super());
320 child_index_to_unitcell)
322 pgrid.superlattice(),
CART);
328 i % pgrid.size(), pgrid, parent_index_to_unitcell);
332 disp_coord -= parent_coord;
339 Eigen::Vector3d avg_disp =
373 cgrid.transformation_matrix_to_super());
375 pgrid.transformation_matrix_to_super());
390 Index residual = pN - cN;
391 if (residual > this->
max_n_va() * pgrid.size()) {
402 Coordinate shifted_parent_coord(pgrid.superlattice());
403 Coordinate shifted_child_coord(pgrid.superlattice());
407 for (; bc < c_info.
size(); bc++) {
410 (it->second * pgrid.size()) < cgrid.size()) {
420 for (
Index lc = 0; lc < cgrid.size(); ++lc, ++ac) {
423 lc, cgrid, child_index_to_unitcell)
429 for (
Index bp = 0; bp < p_info.
size(); ++bp) {
435 for (
Index lp = 0; lp < pgrid.size(); ++lp, ++ap) {
436 shifted_parent_coord.
cart() =
438 lp, pgrid, parent_index_to_unitcell)
440 cost_matrix(ap, ac) =
441 shifted_parent_coord.
min_dist2(shifted_child_coord, metric);
456 cost_matrix.block(bp * pgrid.size(), ac, pgrid.size(), residual)
483 Index bc = i / cgrid.size();
484 std::string sp =
"Va";
489 this->_allowed_species()[j / pgrid.size()].end(), sp);
Specifies traits of (possibly) anisotropic crystal properties.
bool extensive() const
Returns true if type is extensive.
std::string const & name() const
Const access of name.
Eigen::MatrixXd symop_to_matrix(Eigen::Ref< const Eigen::Matrix3d > const &_matrix, Eigen::Ref< const Eigen::Vector3d > const &_tau, bool time_reversal) const
Generate a symmetry representation for the supporting vector space.
Index dim() const
Conventional dimensionality of this type, returns -1 if always variable.
Represents cartesian and fractional coordinates.
double min_dist2(const Coordinate &neighbor, const Eigen::Ref< const Eigen::Matrix3d > &metric) const
Coordinate_impl::CartCoordinate cart()
Set Cartesian coordinate vector and update fractional coordinate vector.
bool voronoi_within()
Map coordinate into the voronoi cell using a lattice translation.
double min_dist(const Coordinate &neighbor) const
Returns distance (in Angstr) to nearest periodic image of neighbor.
const vector_type & const_cart() const
user override to force const Access the Cartesian coordinate vector
bool populate_cost_mat(MappingNode &_node, SimpleStructure const &child_struc) const override
virtual bool _assign_molecules(MappingNode &_node, SimpleStructure const &child_struc) const
Initializes child_struc.mol_info based on child_struc.atom_info and _node. Default behavior simply co...
void populate_displacement(MappingNode &_node, SimpleStructure const &child_struc) const
void finalize(MappingNode &_node, SimpleStructure const &child_struc, bool const &symmetrize_atomic_cost=false) const override
Calculates final mapping score and sets _node.is_valid.
std::vector< Eigen::Vector3d > translations(MappingNode const &_node, SimpleStructure const &child_struc) const override
construct list of prospective mapping translations
virtual SimpleStructure resolve_setting(MappingNode const &_node, SimpleStructure const &_child_struc) const override
Creates copy of _child_struc by applying isometry, lattice transformation, translation,...
Representation of a crystal of molecular and/or atomic occupants, and any additional properties....
std::map< std::string, Eigen::MatrixXd > properties
void within(double tol=TOL)
Map all coordinates within the unit cell.
Eigen::Matrix3d lat_column_mat
std::map< std::string, Index > const & _max_n_species() const
maximum allowed number of each species
Index max_n_va() const
Return maximum possible number of vacancies in underlying primitive structure.
const std::vector< Eigen::MatrixXd > & sym_invariant_displacement_modes() const
SimpleStructure const & parent() const
StrucMapping::AllowedSpecies const & _allowed_species() const
SimpleStructure::Info const & struc_info(SimpleStructure const &_struc) const
std::vector< Eigen::Vector3d > const & internal_translations() const
List of internal translations that map parent onto itself.
double xtal_tol() const
Crystallographic tolerance, for now just return CASM::TOL.
std::unordered_set< Index > const & va_allowed() const
const Lattice & superlattice() const
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.
IdentitySymRepBuilder Identity()
static Coordinate _make_superlattice_coordinate(Index ijk_ix, const Superlattice &superlattice, impl::OrderedLatticePointGenerator index_to_ijk_f)
double atomic_cost(const MappingNode &mapped_config, Index Nsites)
Calculate the basis cost function of a MappingNode as the average of atomic_cost_child and atomic_cos...
double small_inf()
use as default value to initialize mapping costs. Does not indicate ivalidity
std::vector< Index > superstructure_basis_idx(Eigen::Ref< const Eigen::Matrix3i > const &_T, SimpleStructure const &_sstruc)
Constructs a vector containing the basis index of the ith site in the supercell.
Coordinate make_superlattice_coordinate(const UnitCell &ijk, const Superlattice &superlattice)
Iterator find(Iterator begin, Iterator end, const T &value, BinaryCompare q)
Equivalent to std::find(begin, end, value), but with custom comparison.
bool contains(const Container &container, const T &value)
Equivalent to container.end() != std::find(container.begin(), container.end(), value)
INDEX_TYPE Index
For long integer indexing:
Eigen::Vector3d translation
Mapping translation from child to parent Defined such that translation=parent_coord....
double cost
Total cost of best solution to the constrained assignment problem having some forced_on assignments.
std::vector< Index > permutation() const
Combines constrained vector HungarianNode::assignment and HungarianNode::forced_on to obtain total pe...
Eigen::MatrixXd cost_mat
Cost matrix for an assignment problem, which may be a reduced assignment problem if forced_on....
bool time_reversal
time_reversal relationship between child and parent
double cost
strain_cost of the LatticeNode
Superlattice parent
PrimGrid for supercell of parent structure The parent structure defines the ideal strain state,...
Superlattice child
PrimGrid for supercell of child structure The child lattice is recorded in its idealized state (de-ro...
Eigen::Matrix3d stretch
stretch tensor that takes child superlattice from its de-rotated, deformed state to its ideal,...
Eigen::Matrix3d isometry
cartesian rotation/reflection/rotoreflection that rotates the child superlattice to its de-rotated,...
AssignmentNode atomic_node
std::vector< Index > atom_permutation
Eigen::MatrixXd atom_displacement
3xN matrix of displacements for all sites in parent supercell (Va are included, but set to Zero)
std::set< Index > AtomIndexSet
std::vector< MoleculeLabel > mol_labels
list of assigned molecule names
double cost
total, finalized cost, populated by a StrucMapCalculator. Not guaranteed to be a linear function of l...
bool is_valid
true if assignment has been checked for physical validity and passes – default false
Struct to encode all information about the crystal basis Info may describe the basis in a atomic cont...
std::vector< std::string > names
names[i] is name of species that occupies sites 'i'
Coord cart_coord(Index i)
Access coordinate of site 'i'.
Index size() const
Number of sites is defined as names.size()
std::map< std::string, Eigen::MatrixXd > properties
map of [property name, (m x names.size()) matrix] for all numerical site properties properties are as...
void resize(Index N)
Resize to hold N sites. All coordinates set to zero, all occupants set to "Va".