1 #ifndef CASM_StrucMapping
2 #define CASM_StrucMapping
4 #include <unordered_set>
12 #include "casm/external/Eigen/Core"
22 class SimpleStructure;
23 class StrucMapCalculatorInterface;
27 struct AssignmentNode;
31 namespace StrucMapping {
70 const std::vector<Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic,
71 Index>> &permutation_group,
238 result[pair.first] = pair.second;
350 throw std::runtime_error(
"MappingNode::clear() not implemented");
469 double _lattice_weight = 0.5,
double _max_volume_change = 0.5,
472 double _cost_tol =
TOL,
double _min_va_frac = 0.,
473 double _max_va_frac = 1.);
516 const std::vector<Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic,
517 Index>> &permutation_group) {
519 m_calc_ptr->set_sym_invariant_displacement_modes(
577 std::function<
bool(
Lattice const &,
Lattice const &)> _filter_f) {
606 bool keep_invalid =
false)
const;
625 bool keep_invalid =
false,
646 double min_cost = -
TOL,
bool keep_invalid =
false,
667 const SimpleStructure &child_struc,
const Lattice &imposed_lat,
669 double min_cost = -
TOL,
bool keep_invalid =
false,
692 const SimpleStructure &child_struc,
const LatticeNode &imposed_node,
694 double min_cost = -
TOL,
bool keep_invalid =
false)
const;
732 std::set<MappingNode> &queue,
Index k = 1,
734 double min_cost = -
TOL,
735 bool keep_invalid =
false,
736 bool keep_tail =
false,
737 bool no_partiton =
false)
const;
753 std::vector<Lattice>
const &_parent_scels,
754 std::vector<Lattice>
const &_child_scels,
Index k,
double max_strain_cost,
755 double min_strain_cost,
763 double max_strain_cost,
double min_strain_cost,
773 Lattice const &_child_lat)
const {
Representation of a crystal of molecular and/or atomic occupants, and any additional properties....
bool lattices_constrained() const
returns true if the search of parent superlattices is constrained to a pre-specified list
double atomic_weight() const
double max_va_frac() const
Returns the maximum fraction of sites allowed to be vacant in the mapping relation Vacancy fraction i...
std::set< MappingNode > _seed_from_vol_range(SimpleStructure const &child_struc, Index k, Index min_vol, Index max_vol, double max_strain_cost, double min_strain_cost, SymOpVector const &child_factor_group={SymOp::identity()}) const
construct partial mapping nodes (with uninitialized atomic_node) based on current settings considers ...
bool symmetrize_atomic_cost() const
notstd::cloneable_ptr< StrucMapCalculatorInterface > m_calc_ptr
void set_max_va_frac(double _max_va)
Sets the maximum fraction of sites allowed to be vacant in the mapping relation Vacancy fraction is u...
std::set< MappingNode > map_ideal_struc(const SimpleStructure &child_struc, Index k=1, double max_cost=StrucMapping::big_inf(), double min_cost=-TOL, bool keep_invalid=false) const
k-best mappings of ideal child structure onto parent structure Assumes that child_struc and parent_st...
Index lattice_transformation_range() const
Max element considered for integer unimodular matrix transformations (which define orientation relati...
std::set< MappingNode > map_deformed_struc_impose_lattice(const SimpleStructure &child_struc, const Lattice &imposed_lat, Index k=1, double max_cost=StrucMapping::big_inf(), double min_cost=-TOL, bool keep_invalid=false, SymOpVector const &child_factor_group={SymOp::identity()}) const
k-best mappings of arbitrary child structure onto parent structure imposes simplifying assumption tha...
bool symmetrize_lattice_cost() const
Index m_lattice_transformation_range
bool m_symmetrize_lattice_cost
bool _filter_lat(Lattice const &_parent_lat, Lattice const &_child_lat) const
StrucMapCalculatorInterface const & calculator() const
std::pair< Index, Index > _vol_range(const SimpleStructure &child_struc) const
int options() const
returns bit flag of selected options for this StrucMapper
LatMapType m_allowed_superlat_map
LatMapType m_superlat_map
Maps the supercell volume to a vector of Lattices with that volume.
void add_allowed_lattice(Lattice const &_lat)
specify a superlattice of the parent to be searched during mapping
void set_symmetrize_lattice_cost(bool _sym_lat_cost)
Flag that enables the calculation of a symmetrized lattice cost when performing the lattice maps....
std::function< bool(Lattice const &, Lattice const &)> m_filter_f
std::set< MappingNode > _seed_k_best_from_super_lats(SimpleStructure const &child_struc, std::vector< Lattice > const &_parent_scels, std::vector< Lattice > const &_child_scels, Index k, double max_strain_cost, double min_strain_cost, SymOpVector const &child_factor_group={SymOp::identity()}) const
generate list of partial mapping seeds (i.e., LatticeNode only) from a list of supercells of the pare...
std::set< MappingNode > map_deformed_struc_impose_lattice_vols(const SimpleStructure &child_struc, Index min_vol, Index max_vol, Index k=1, double max_cost=StrucMapping::big_inf(), double min_cost=-TOL, bool keep_invalid=false, SymOpVector const &child_factor_group={SymOp::identity()}) const
k-best mappings of arbitrary child structure onto parent structure imposes simplifying assumption tha...
double xtal_tol() const
Tolerance for initializing lattices. For now it is initialized to CASM::TOL.
Index _n_species(SimpleStructure const &sstruc) const
returns number of species in a SimpleStructure given the current calculator settings....
std::map< Index, std::vector< Lattice > > LatMapType
bool m_symmetrize_atomic_cost
void set_lattice_weight(double _lw)
std::set< MappingNode > map_deformed_struc(const SimpleStructure &child_struc, Index k=1, double max_cost=StrucMapping::big_inf(), double min_cost=-TOL, bool keep_invalid=false, SymOpVector const &child_factor_group={SymOp::identity()}) const
k-best mappings of arbitrary child structure onto parent structure, without simplifying assumptions I...
double min_va_frac() const
Returns the minimum fraction of sites allowed to be vacant in the mapping relation Vacancy fraction i...
void set_min_va_frac(double _min_va)
Sets the minimum fraction of sites allowed to be vacant in the mapping relation Vacancy fraction is u...
StrucMapper(StrucMapCalculatorInterface const &_calculator, double _lattice_weight=0.5, double _max_volume_change=0.5, int _options=0, double _cost_tol=TOL, double _min_va_frac=0., double _max_va_frac=1.)
Construct and initialize a StrucMapper.
void set_symmetrize_atomic_cost(bool _sym_atomic_cost, const SymOpVector &factor_group, const std::vector< Eigen::PermutationMatrix< Eigen::Dynamic, Eigen::Dynamic, Index >> &permutation_group)
Flag that enables the calculation of a symmetrized atomic cost when performing the atomic maps....
double m_max_volume_change
SimpleStructure const & parent() const
returns reference to parent structure
void clear_allowed_lattices() const
clear the list of allowed parent superlattices; all superlattices will be generated automatically,...
void set_lattice_transformation_range(Index _new_range)
Max element considered for integer unimodular matrix transformations (which define orientation relati...
void set_filter(std::function< bool(Lattice const &, Lattice const &)> _filter_f)
specify to use filtered lattices for mapping. The filter function is of the form bool filter(parent_l...
std::set< MappingNode > map_deformed_struc_impose_lattice_node(const SimpleStructure &child_struc, const LatticeNode &imposed_node, Index k=1, double max_cost=StrucMapping::big_inf(), double min_cost=-TOL, bool keep_invalid=false) const
k-best mappings of arbitrary child structure onto parent structure imposes simplifying assumption tha...
double lattice_weight() const
double cost_tol() const
Tolerance for determining if two mapping-cost values are identical.
Index k_best_maps_better_than(SimpleStructure const &child_struc, std::set< MappingNode > &queue, Index k=1, double max_cost=StrucMapping::big_inf(), double min_cost=-TOL, bool keep_invalid=false, bool keep_tail=false, bool no_partiton=false) const
low-level function. Takes a queue of mappings and use it to seed a search for k-best total mappings....
std::vector< Lattice > _lattices_of_vol(Index prim_vol) const
Eigen::MatrixXd m_strain_gram_mat
void unset_filter()
specify not to use filtered lattice for mapping
A 'cloneable_ptr' can be used in place of 'unique_ptr'.
double volume(const Lattice &lat)
Returns the volume of a Lattice.
Eigen::CwiseUnaryOp< decltype(Local::round_l< typename Derived::Scalar >), const Derived > round(const Eigen::MatrixBase< Derived > &val)
Round Eigen::MatrixXd.
double big_inf()
Very large value used to denote invalid or impossible mapping.
double atomic_cost_child(const MappingNode &mapped_result, Index Nsites)
Calculate the basis cost function of a MappingNode as the normalized mean-square displacement of its ...
double atomic_cost_parent(const MappingNode &mapped_result, Index Nsites)
Calculate the basis cost function of a MappingNode as the normalized mean-square displacement of its ...
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...
std::vector< std::vector< Index > > PermuteOpVector
double small_inf()
use as default value to initialize mapping costs. Does not indicate ivalidity
bool identical(LatticeNode const &A, LatticeNode const &B, double cost_tol)
returns true if cost values and parent/child supercell transformations are same for A and B
std::vector< Eigen::MatrixXd > generate_invariant_shuffle_modes(const std::vector< xtal::SymOp > &factor_group, const std::vector< Eigen::PermutationMatrix< Eigen::Dynamic, Eigen::Dynamic, Index >> &permute_group)
Eigen::Vector3d const & get_translation(MappingNode const &_node)
External accessor for translation, to provide xtal::SymOp adaptability.
bool get_time_reversal(MappingNode const &_node)
External accessor for time_reversal, to provide xtal::SymOp adaptability.
Eigen::Matrix3d const & get_matrix(MappingNode const &_node)
External accessor for isometry, to provide xtal::SymOp adaptability.
bool less(LatticeNode const &A, LatticeNode const &B, double cost_tol)
Compare two LatticeMap objects, based on their mapping cost first, followed by PrimGrid transformatio...
std::vector< SymOp > SymOpVector
T min(const T &A, const T &B)
INDEX_TYPE Index
For long integer indexing:
T max(const T &A, const T &B)
Structure to encode the solution of a constrained atomic assignmnet problem This describes the permut...
std::vector< Index > irow
'real' indices of rows in the reduced 'cost_mat' When a site assignment {i,j} is added to forced_on,...
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...
bool empty() const
True if cost matrix and assignment vector are uninitialized.
bool operator<(AssignmentNode const &other) const
Compares time_reversal and translation for time_reversal, false is less than true for translation,...
std::vector< Index > assignment
Solution of the assignment problem for the reduced 'cost_mat' An assignment {k,l} in the reduced prob...
Eigen::MatrixXd cost_mat
Cost matrix for an assignment problem, which may be a reduced assignment problem if forced_on....
std::vector< Index > icol
'real' indices of columns in the reduced 'cost_mat' When a site assignment {i,j} is added to forced_o...
std::set< std::pair< Index, Index > > forced_on
parent->child site assignments that have been forced on at this node for element 'el' such that force...
bool time_reversal
time_reversal relationship between child and parent
AssignmentNode(double _cost_tol=1e-6)
Class describing the lattice-mapping portion of a particular mapping A general map for child_struc on...
LatticeNode(Lattice const &parent_prim, Lattice const &parent_scel, Lattice const &child_prim, Lattice const &child_scel, Index child_N_atom, double _cost=StrucMapping::big_inf())
Construct with ideal parent_scel and deformed child_scel, which are related by a deformation tensor.
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,...
ConstDisplacement disp(Index i) const
const access i'th atomic displacement of mapped structure
Eigen::MatrixXd DisplacementMatrix
void calc()
non-const calc method solves the assignment problem via hungarian_method sets is_viable -> false if n...
bool operator<(MappingNode const &other) const
static MappingNode invalid()
Static constructor to build an invalid MappingNode, can be used as return value when no valid mapping...
DisplacementMatrix::ConstColXpr ConstDisplacement
MappingNode(LatticeNode _lattice_node, double _lattice_weight)
construct with lattice node and lattice_weight. Cost is initialized assuming zero atomic_node cost
AssignmentNode atomic_node
Eigen::Vector3d const & translation() const
convenience method to access MappingNode::atomic_node.translation
std::vector< AtomIndexSet > MoleculeMap
Displacement disp(Index i)
non-const access of i'th atomic displacement of mapped structure
std::vector< Index > atom_permutation
std::pair< Index, Index > vol_pair() const
Return pair of integer volumes {Vp, Vc}, where Vp is parent supercell volume and Vc is child supercel...
bool time_reversal() const
convenience method to access MappingNode::atomic_node.time_reveral
Eigen::Matrix3d const & stretch() const
convenience method to access MappingNode::lattice_node.stretch
bool is_partitioned
true if node has been partitioned into sub-nodes for generalized k-best assignment problem – default ...
Eigen::MatrixXd atom_displacement
3xN matrix of displacements for all sites in parent supercell (Va are included, but set to Zero)
DisplacementMatrix::ColXpr Displacement
bool is_viable
true if assignment problem is not yet known to be insoluable – default true
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...
std::pair< std::string, Index > MoleculeLabel
bool is_valid
true if assignment has been checked for physical validity and passes – default false
Eigen::Matrix3d const & isometry() const
convenience method to access MappingNode::lattice_node.isometry
void set_lattice_weight(double _lw)
set the lattice_weight. Cost is calculated as cost = lattice_weight*lattice_node.cost + atomic_weight...