CASM  1.1.0
A Clusters Approach to Statistical Mechanics
ConfigMapping.cc
Go to the documentation of this file.
2 
3 #include <vector>
4 
14 #include "casm/clex/PrimClex.hh"
16 #include "casm/clex/Supercell.hh"
30 
31 namespace CASM {
32 
33 namespace Local {
34 static int _permute_dist(MappingNode::MoleculeMap const &_perm,
35  MappingNode const &_node) {
36  int result(0);
37  for (int i = 0; i < _perm.size(); ++i) {
38  result += std::abs(int(_node.atom_permutation[*(_perm[i].begin())]) - i);
39  }
40  return result;
41 }
42 
43 //*******************************************************************************************
44 
51 
52 template <typename IterType>
53 static IterType _strictest_equivalent(IterType begin, IterType end,
54  MappingNode const &_node) {
55  SymOp op(_node.isometry(), _node.translation(), false, _node.cost_tol());
56  SymOp t_op;
57  IterType best_it = begin;
58 
59  double tchar, tdist;
60  int tdet, tpdist;
61  double best_char = op.matrix().trace();
62  double best_dist = op.tau().norm();
63  int best_det = sgn(round(op.matrix().determinant()));
64  int best_pdist = _permute_dist(_node.mol_map, _node);
65 
67  while (begin != end) {
68  t_op = begin->sym_op() * op;
69  tdet = sgn(round(t_op.matrix().determinant()));
70  bool skip_fg = false;
71  if (tdet > best_det) {
72  best_det = tdet;
73  best_char = tdet * t_op.matrix().trace();
74  best_pdist =
75  _permute_dist(begin->combined_permute() * _node.mol_map, _node);
76  tau.cart() = t_op.tau();
77  tau.voronoi_within();
78  best_dist = tau.const_cart().norm();
79  best_it = begin;
80  } else if (tdet == best_det) {
81  tchar = tdet * t_op.matrix().trace();
82  if (almost_equal(tchar, best_char)) {
83  tpdist =
84  _permute_dist(begin->combined_permute() * _node.mol_map, _node);
85  if (tpdist > best_pdist) {
86  best_det = tdet;
87  best_char = tchar;
88  best_pdist = tpdist;
89  tau.cart() = t_op.tau();
90  tau.voronoi_within();
91  best_dist = tau.const_cart().norm();
92  best_it = begin;
93  } else if (tpdist == best_pdist) {
94  tau.voronoi_within();
95  tdist = tau.const_cart().norm();
96  if (tdist < best_dist) {
97  best_det = tdet;
98  best_char = tchar;
99  best_pdist = tpdist;
100  best_dist = tdist;
101  best_it = begin;
102  }
103  }
104  } else if (tchar > best_char) {
105  best_det = tdet;
106  best_char = tchar;
107  best_pdist =
108  _permute_dist(begin->combined_permute() * _node.mol_map, _node);
109  tau.cart() = t_op.tau();
110  tau.voronoi_within();
111  best_dist = tau.const_cart().norm();
112  best_it = begin;
113  } else {
114  skip_fg = true;
115  }
116  } else {
117  skip_fg = true;
118  }
119 
120  if (skip_fg) {
121  begin = begin_next_fg_op(begin, end);
122  } else {
123  ++begin;
124  }
125  }
126  return best_it;
127 }
128 } // namespace Local
129 
130 //*******************************************************************************************
131 Index ConfigMapperResult::n_optimal(double tol /*=TOL*/) const {
132  Index result = 0;
133  auto it = maps.begin();
134  while (it != maps.end() &&
135  almost_equal((it->first).cost, (maps.begin()->first).cost, tol)) {
136  ++result;
137  ++it;
138  }
139  return result;
140 }
141 
142 //*******************************************************************************************
143 namespace ConfigMapping {
144 
146  BasicStructure const &_prim, SimpleStructure::SpeciesMode _species_mode =
147  SimpleStructure::SpeciesMode::ATOM) {
148  xtal::StrucMapping::AllowedSpecies result(_prim.basis().size());
149  Index i = 0;
150  for (Site const &site : _prim.basis()) {
151  for (Molecule const &mol : site.occupant_dof()) {
152  if (_species_mode == SimpleStructure::SpeciesMode::MOL) {
153  result[i].push_back(mol.name());
154  } else if (_species_mode == SimpleStructure::SpeciesMode::ATOM) {
155  if (mol.size() != 1) {
156  throw std::runtime_error(
157  "ConfigMapping::_allowed_species may only be called on "
158  "structures with single-atom species.");
159  }
160  result[i].push_back(mol.atom(0).name());
161  }
162  }
163  ++i;
164  }
165 
166  return result;
167 }
168 } // namespace ConfigMapping
169 
170 //*******************************************************************************************
171 
175  bool transform_cost_mat) {
176  MappingNode result(_node);
177  SymOp op = _it.sym_op();
178 
179  // Apply symmetry to LatticeNode:
180  // lattice_node.parent and lattice_node.child remain unchanged, but isometry
181  // and stretch tensors are augmented
182  // parent superlattice Lp and child superlattice Lc are related via
183  // Lp = U * R * Lc (where R is isometry and U is right stretch tensor of
184  // _node)
185  // 'op' must be in point group of Lp, and invariance relation for Lp is
186  // op.matrix() * Lp * N = Lp (where 'N' is integer fractional symop
187  // matrix)
188  // Substituting above expression and inserting Identity =
189  // op.matrix().transpose() * op.matrix() yields:
190  // Lp = (op.matrix() * U * op.matrix().transpose()) * (op.matrix() * R) *
191  // Lc * N
192  // where terms are grouped to reveal the transformation rules for matrices
193  // 'U' and 'R' for the symmetry-related mapping The fractional matrix 'N' is
194  // not used in this routine, since _node records the child lattice in its
195  // undeformed state and all atomic coordinates are recorded in undeformed
196  // cartesian coordinates
197  result.lattice_node.isometry = op.matrix() * _node.isometry();
198  result.lattice_node.stretch =
199  op.matrix() * _node.stretch() * op.matrix().transpose();
200 
201  // Apply symmetry to HungarianNode:
202  // parent coordinates Cp (3xN) and child coordinates Cc (3xN) are related via
203  // the mapping relation
204  // Cp = U * R * Cc * P.transpose() - D + T)]
205  // where R is isometry, U is right stretch tensor, P is site permutation,
206  // D is displacement field (3xN) and T is mapping translation (3x1 repeated
207  // for N columns) 'op' must be in space group of Cp, and invariance relation
208  // for Cp is
209  // Cp = op.matrix() * Cp * Ps.transpose() + op.tau()
210  // where Ps = _it.combined_permute().matrix() and op.tau() is added col-wise.
211  // The invariance is only valid to within a lattice translation of the basis
212  // sites (which does not affect mapping score) Inserting the mapping relation
213  // for Cp into the invariance relation yields
214  // Cp = [op.matrix() * U * op.matrix.transpose()] * [op.matrix * R] * Cc *
215  // [P.transpose() * Ps.transpose()] - [op.matrix() * D * Ps] + [op.matrix()
216  // * T + op.tau()]
217  // where terms are grouped to reveal the transformation rules for mapping
218  // permutation 'P', displacement field 'D', and mapping translation 'T' The
219  // transormation rules for 'U' and 'R' are identical to those above and are
220  // recorded in _node.lattice_node. These five translation rules specify all
221  // considerations necessary to describe how a symop in the space group of the
222  // parent crystal relates a mapping of the child crystal onto the parent
223  // crystal to an equivalent mapping
224  result.atomic_node.translation = op.matrix() * _node.translation() + op.tau();
225  result.atom_displacement = op.matrix() * result.atom_displacement;
226  for (Index i = 0; i < result.mol_map.size(); ++i) {
227  result.mol_map[i] = _node.mol_map[_it.permute_ind(i)];
228  result.mol_labels[i] = _node.mol_labels[_it.permute_ind(i)];
229  // result.atom_displacement.col(i) = td.col(_it.permute_ind(i));
230  }
231 
232  // Attempt to transfrom the constrained mapping problem and cost matrix
233  // This is distinct from the relations described above, as the asignments are
234  // not yet all known Instead of permuting the child indices, we will permute
235  // the parent indices by the inverse permutation, which should have the same
236  // effect in the end
237  if (false) { // Disabled due to changes related to molecule
238  PermuteIterator inv_it = _it.inverse();
239  for (Index i = 0; i < result.atomic_node.irow.size(); ++i)
240  result.atomic_node.irow[i] =
241  inv_it.permute_ind(_node.atomic_node.irow[i]);
242 
243  result.atomic_node.forced_on.clear();
244  for (auto const &el : _node.atomic_node.forced_on)
245  result.atomic_node.forced_on.emplace(inv_it.permute_ind(el.first),
246  el.second);
247  // No need to transform assignment vector or cost_mat, which are in terms of
248  // the nominal indexing
249  }
250  return result;
251 }
252 
253 //*******************************************************************************************
254 
260 std::pair<ConfigDoF, std::set<std::string> > to_configdof(
261  SimpleStructure const &_child_struc, Supercell const &_scel) {
262  SimpleStructure::Info const &c_info(_child_struc.mol_info);
263  std::pair<ConfigDoF, std::set<std::string> > result(
264  make_configdof(_scel, TOL), {});
265  PrimClex::PrimType const &prim(_scel.prim());
266  Index i = 0;
267  for (Index b = 0; b < prim.basis().size(); ++b) {
268  for (Index l = 0; l < _scel.volume(); ++l, ++i) {
269  Index j = 0;
270  for (; j < prim.basis()[b].occupant_dof().size(); ++j) {
271  if (c_info.names[i] == prim.basis()[b].occupant_dof()[j]) {
272  result.first.occ(i) = j;
273  break;
274  }
275  }
276  if (j == prim.structure().basis()[b].occupant_dof().size())
277  throw std::runtime_error(
278  "Attempting to initialize ConfigDoF from SimpleStructure. Species "
279  "'" +
280  c_info.names[i] + "' is not allowed on sublattice " +
281  std::to_string(b));
282  }
283  }
284 
285  for (auto const &dof : result.first.global_dofs()) {
286  auto val = DoFType::traits(dof.first).find_values(_child_struc.properties);
287  result.first.global_dof(dof.first).from_standard_values(val.first);
288  result.second.insert(val.second.begin(), val.second.end());
289  }
290 
291  for (auto const &dof : result.first.local_dofs()) {
292  auto val = DoFType::traits(dof.first).find_values(c_info.properties);
293  result.first.local_dof(dof.first).from_standard_values(val.first);
294  result.second.insert(val.second.begin(), val.second.end());
295  }
296 
297  return result;
298 }
299 //*******************************************************************************************
300 
302  BasicStructure const &_prim, std::vector<xtal::SymOp> const &_symgroup,
303  SimpleStructure::SpeciesMode _species_mode /*=StrucMapping::ATOM*/)
305  make_simple_structure(_prim),
306  _symgroup.empty() ? xtal::make_factor_group(_prim) : _symgroup,
307  _species_mode, ConfigMapping::_allowed_species(_prim)),
308  m_prim(_prim) {}
309 
310 //*******************************************************************************************
311 
313  std::vector<std::string> const &_lattice_names) {
314  for (std::string const &_name : _lattice_names) {
315  auto it = primclex().template db<Supercell>().find(_name);
316  if (it == primclex().template db<Supercell>().end())
317  throw std::runtime_error(
318  "Could not add mapping lattice constraint " + _name +
319  " because no supercell having that name exists in database.\n");
320  m_struc_mapper.add_allowed_lattice(it->lattice());
321  }
322 }
323 
324 //*******************************************************************************************
325 
328 }
329 
330 //*******************************************************************************************
331 
333  ConfigMapping::Settings const &_settings,
334  double _tol /*=-1.*/)
335  : m_pclex(&_pclex),
336  m_struc_mapper(
338  _pclex.prim(), adapter::Adapter<xtal::SymOpVector, SymGroup>()(
339  _pclex.prim().factor_group())),
340  _settings.lattice_weight, _settings.max_vol_change,
341  _settings.options(), _tol > 0. ? _tol : _pclex.crystallography_tol(),
342  _settings.min_va_frac, _settings.max_va_frac),
343  m_settings(_settings) {
344  if (!settings().filter.empty()) {
347  DataFormatter<Supercell> formatter =
348  _pclex.settings().query_handler<Supercell>().dict().parse(
349  settings().filter);
350  auto filter = [formatter, &_pclex](Lattice const &parent,
351  Lattice const &child) -> bool {
352  ValueDataStream<bool> check_stream;
353  check_stream << formatter(Supercell(&_pclex, parent));
354  return check_stream.value();
355  };
356 
357  m_struc_mapper.set_filter(filter);
358  }
359 
360  for (std::string const &scel : settings().forced_lattices) {
361  auto it = _pclex.db<Supercell>().find(scel);
362  if (it == _pclex.db<Supercell>().end())
363  throw std::runtime_error("Cannot restrict mapping to lattice " + scel +
364  ". Superlattice does not exist in project.");
365  m_struc_mapper.add_allowed_lattice(it->lattice());
366  }
367 }
368 
369 //*******************************************************************************************
371  SimpleStructure const &_child_struc, Configuration const *hint_ptr,
372  std::vector<DoFKey> const &_hint_dofs) const {
373  return import_structure(_child_struc, settings().k_best, hint_ptr,
374  _hint_dofs);
375 }
376 
377 //*******************************************************************************************
378 
380  SimpleStructure const &child_struc, Index k, Configuration const *hint_ptr,
381  std::vector<DoFKey> const &_hint_dofs) const {
382  ConfigMapperResult result;
383  double best_cost = xtal::StrucMapping::big_inf();
384 
385  // bool is_new_config(true);
386  double hint_cost;
387  if (hint_ptr != nullptr) {
388  StrucMapper tmapper(
389  *struc_mapper().calculator().quasi_clone(
390  make_simple_structure(*hint_ptr, _hint_dofs),
392  hint_ptr->point_group(),
393  hint_ptr->supercell().sym_info().supercell_lattice()),
394  SimpleStructure::SpeciesMode::ATOM),
395  struc_mapper().lattice_weight(), 0., struc_mapper().options(),
396  struc_mapper().cost_tol());
397 
398  /*
399  auto config_maps = tmapper.map_deformed_struc_impose_lattice(child_struc,
400  hint_ptr->ideal_lattice(),
401  1);
402  */
403  auto config_maps = tmapper.map_deformed_struc_impose_lattice_node(
404  child_struc,
405  xtal::LatticeNode(hint_ptr->ideal_lattice(), hint_ptr->ideal_lattice(),
406  Lattice(child_struc.lat_column_mat),
407  Lattice(child_struc.lat_column_mat),
408  child_struc.atom_info.size()),
409  k);
410 
411  // Refactor into external routine A. This is too annoying with the current
412  // way that supercells are managed
413  if (!config_maps.empty()) {
414  hint_cost = best_cost = config_maps.rbegin()->cost;
415  }
416  //\End routine A
417  // TODO: Check equivalence with hint_ptr
418  }
419 
420  std::set<MappingNode> struc_maps;
421 
422  if (hint_ptr && settings().ideal) {
423  xtal::LatticeNode lattice_node(
424  hint_ptr->prim().lattice(), hint_ptr->ideal_lattice(),
425  Lattice(child_struc.lat_column_mat),
426  Lattice(child_struc.lat_column_mat), child_struc.atom_info.size());
428  child_struc, lattice_node, k);
429  } else if (hint_ptr && settings().fix_lattice) {
431  child_struc, hint_ptr->ideal_lattice(), k,
432  best_cost + struc_mapper().cost_tol());
433  if (struc_maps.empty())
434  result.fail_msg = "Unable to map structure using same lattice as " +
435  hint_ptr->name() +
436  ". Try setting \"fix_lattice\" : false.";
437 
438  } else if (hint_ptr && settings().fix_volume) {
439  Index vol = hint_ptr->supercell().volume();
441  child_struc, vol, vol, k, best_cost + struc_mapper().cost_tol());
442  if (struc_maps.empty())
443  result.fail_msg =
444  "Unable to map structure assuming volume = " + std::to_string(vol) +
445  ". Try setting \"fix_volume\" : false.";
446 
447  } else if (settings().ideal) {
448  struc_maps = struc_mapper().map_ideal_struc(child_struc, k);
449  if (struc_maps.empty())
450  result.fail_msg =
451  "Imported structure has lattice vectors that are not a perfect "
452  "supercell of PRIM. Try setting \"ideal\" : false.";
453  } else {
454  struc_maps = struc_mapper().map_deformed_struc(
455  child_struc, k, best_cost + struc_mapper().cost_tol());
456  if (struc_maps.empty())
457  result.fail_msg =
458  "Unable to map structure to prim. May be incompatible structure, or "
459  "provided settings may be too restrictive.";
460  }
461 
462  // Refactor into external routine A. This is too annoying with the current way
463  // that supercells are managed
464  for (auto const &map : struc_maps) {
465  std::shared_ptr<Supercell> shared_scel = std::make_shared<Supercell>(
466  &primclex(), map.lattice_node.parent.superlattice());
467  SimpleStructure resolved_struc =
468  struc_mapper().calculator().resolve_setting(map, child_struc);
469  std::pair<ConfigDoF, std::set<std::string> > tdof =
470  to_configdof(resolved_struc, *shared_scel);
471  Configuration tconfig(shared_scel, tdof.first);
472  PermuteIterator perm_it = shared_scel->sym_info().permute_begin();
473  if (settings().strict) {
474  // Strictness transformation reduces permutation swaps, translation
475  // magnitude, and isometry character
477  shared_scel->sym_info().permute_begin(),
478  shared_scel->sym_info().permute_end(), map);
479  } else {
480  perm_it = tconfig.to_canonical();
481  }
482  tconfig.apply_sym(perm_it);
483  MappingNode resolved_node = copy_apply(perm_it, map);
484  resolved_struc =
485  struc_mapper().calculator().resolve_setting(resolved_node, child_struc);
486  result.maps.emplace(
487  resolved_node, ConfigMapperResult::Individual(std::move(tconfig),
488  std::move(resolved_struc),
489  std::move(tdof.second)));
490  }
491  //\End routine A
492 
493  if (hint_ptr != nullptr) {
494  ConfigIsEquivalent all_equiv(*hint_ptr);
495 
496  ConfigIsEquivalent occ_equiv(*hint_ptr, {"occ"});
497 
498  for (auto &map : result.maps) {
499  map.second.hint_cost = hint_cost;
500 
501  if (map.second.config.supercell() != hint_ptr->supercell()) {
502  map.second.hint_status = HintStatus::NewScel;
503  continue;
504  }
505  if (all_equiv(map.second.config)) {
506  map.second.hint_status = HintStatus::Identical;
507  continue;
508  }
509  PermuteIterator perm_begin =
510  map.second.config.supercell().sym_info().permute_begin();
511  PermuteIterator perm_end =
512  map.second.config.supercell().sym_info().permute_end();
513  for (PermuteIterator it = perm_begin; it != perm_end; ++it) {
514  if (all_equiv(it, map.second.config)) {
515  map.second.hint_status = HintStatus::Equivalent;
516  break;
517  }
518  }
519  if (map.second.hint_status == HintStatus::Equivalent) continue;
520  map.second.hint_status = HintStatus::NewOcc;
521  for (PermuteIterator it = perm_begin; it != perm_end; ++it) {
522  if (occ_equiv(it, map.second.config)) {
523  map.second.hint_status = HintStatus::Derivative;
524  break;
525  }
526  }
527  }
528  }
529 
530  return result;
531 }
532 } // namespace CASM
PermuteIterator to_canonical() const
Class for comparison of Configurations (with the same Supercell)
ConfigMapper(PrimClex const &_pclex, ConfigMapping::Settings const &_settings, double _tol=-1.)
Construct and initialize a ConfigMapper.
StrucMapper const & struc_mapper() const
ConfigMapperResult import_structure(SimpleStructure const &_struc, Configuration const *hint_ptr=nullptr, std::vector< DoFKey > const &_hint_dofs={ "occ"}) const
imports structure specified by '_struc' into primclex()
const PrimClex & primclex() const
ConfigMapping::Settings const & settings() const
StrucMapper m_struc_mapper
Maps the supercell volume to a vector of Lattices with that volume.
void add_allowed_lattices(std::vector< std::string > const &_lattice_names)
Configuration & apply_sym(const PermuteIterator &it)
Transform Configuration from PermuteIterator via *this = permute_iterator * *this.
const Lattice & ideal_lattice() const
std::vector< PermuteIterator > point_group() const
Returns the point group that leaves the Configuration unchanged.
const Supercell & supercell() const
Get the Supercell for this Configuration.
Extract data from objects of 'DataObject' class.
virtual std::pair< Eigen::MatrixXd, std::set< std::string > > find_values(std::map< std::string, Eigen::MatrixXd > const &values) const
Retrieve the standard values for a DoF from dictionary of properties from properties....
Definition: DoFTraits.cc:58
SupercellSymInfo const & sym_info() const
Reference the SupercellSymInfo containing the operations being pointed at.
PermuteIterator inverse() const
Index permute_ind(Index i) const
PrimClex is the top-level data structure for a CASM project.
Definition: PrimClex.hh:55
PrimStrucMapCalculator(BasicStructure const &_prim, std::vector< xtal::SymOp > const &symgroup={}, SimpleStructure::SpeciesMode _species_mode=SimpleStructure::SpeciesMode::ATOM)
QueryHandler< DataObject > & query_handler()
Structure specifies the lattice and atomic basis of a crystal.
Definition: Structure.hh:30
Represents a supercell of the primitive parent crystal structure.
Definition: Supercell.hh:51
Index volume() const
Return number of primitive cells that fit inside of *this.
Definition: Supercell.cc:227
const Structure & prim() const
Definition: Supercell.cc:113
const SupercellSymInfo & sym_info() const
Definition: Supercell.cc:265
permute_const_iterator permute_end() const
const xtal::Lattice & supercell_lattice() const
const reference to supercell lattice
permute_const_iterator permute_begin() const
SymGroup is a collection of symmetry operations that satisfy the group property The symmetry operatio...
Definition: SymGroup.hh:42
SymOp is the Coordinate representation of a symmetry operation it keeps fraction (FRAC) and Cartesian...
Definition: SymOp.hh:28
const matrix_type & matrix() const
Const access of entire cartesian symmetry matrix.
Definition: SymOp.hh:60
const vector_type & tau() const
Const access of the cartesian translation vector, 'tau'.
Definition: SymOp.hh:63
const T & value() const
Definition: DataStream.hh:256
BasicStructure specifies the lattice and atomic basis of a crystal.
const std::vector< Site > & basis() const
Represents cartesian and fractional coordinates.
Definition: Coordinate.hh:34
Coordinate_impl::CartCoordinate cart()
Set Cartesian coordinate vector and update fractional coordinate vector.
Definition: Coordinate.hh:562
bool voronoi_within()
Map coordinate into the voronoi cell using a lattice translation.
Definition: Coordinate.cc:274
const vector_type & const_cart() const
user override to force const Access the Cartesian coordinate vector
Definition: Coordinate.hh:90
Class representing a Molecule.
Definition: Molecule.hh:93
Representation of a crystal of molecular and/or atomic occupants, and any additional properties....
std::map< std::string, Eigen::MatrixXd > properties
virtual SimpleStructure resolve_setting(MappingNode const &_node, SimpleStructure const &_child_struc) const =0
Creates copy of _child_struc by applying isometry, lattice transformation, translation,...
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...
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...
StrucMapCalculatorInterface const & calculator() const
void add_allowed_lattice(Lattice const &_lat)
specify a superlattice of the parent to be searched during mapping
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...
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...
void clear_allowed_lattices() const
clear the list of allowed parent superlattices; all superlattices will be generated automatically,...
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...
const Lattice & superlattice() const
Definition: Superlattice.hh:18
std::string to_string(ENUM val)
Return string representation of enum class.
Definition: io_traits.hh:172
Eigen::CwiseUnaryOp< decltype(Local::round_l< typename Derived::Scalar >), const Derived > round(const Eigen::MatrixBase< Derived > &val)
Round Eigen::MatrixXd.
DB::Database< T > & db() const
Definition: PrimClex.cc:302
ProjectSettings & settings()
Definition: PrimClex.cc:224
xtal::StrucMapping::AllowedSpecies _allowed_species(BasicStructure const &_prim, SimpleStructure::SpeciesMode _species_mode=SimpleStructure::SpeciesMode::ATOM)
Traits const & traits(std::string const &dof_key)
Lookup DoFType::Traits in the global dictionary.
Definition: DoFTraits.cc:46
static int _permute_dist(MappingNode::MoleculeMap const &_perm, MappingNode const &_node)
static IterType _strictest_equivalent(IterType begin, IterType end, MappingNode const &_node)
Find symop (as PermuteIterator) that gives the most 'faithful' equivalent mapping This means that (1)...
SharedPrimFormatter< jsonParser > factor_group()
SpeciesMode
enum to refer to a particular representation of the occupants (atomic or molecular)
double big_inf()
Very large value used to denote invalid or impossible mapping.
Definition: StrucMapping.hh:35
std::vector< std::vector< std::string > > AllowedSpecies
std::vector< SymOp > make_factor_group(const BasicStructure &struc, double tol=TOL)
std::vector< SymOp > SymOpVector
Main CASM namespace.
Definition: APICommand.hh:8
bool almost_equal(ClusterInvariants const &A, ClusterInvariants const &B, double tol)
Check if ClusterInvariants are equal.
IterType begin_next_fg_op(IterType it, IterType end)
xtal::SimpleStructure make_simple_structure(Supercell const &_scel, ConfigDoF const &_dof, std::vector< DoFKey > const &_which_dofs={})
Construct from ConfigDoF _dof belonging to provided Supercell _scel.
MappingNode copy_apply(PermuteIterator const &_it, MappingNode const &_node, bool transform_cost_mat=true)
Reorders the permutation and compounds the spatial isometry (rotation.
std::pair< ConfigDoF, std::set< std::string > > to_configdof(SimpleStructure const &_child_struc, Supercell const &_scel)
Initializes configdof of Supercell '_scel' corresponding to an idealized child structure (encoded by ...
int sgn(T val)
Definition: CASM_math.hh:180
const double TOL
Definition: definitions.hh:30
Iterator find(Iterator begin, Iterator end, const T &value, BinaryCompare q)
Equivalent to std::find(begin, end, value), but with custom comparison.
Definition: algorithm.hh:16
ConfigDoF make_configdof(Structure const &prim, Index volume)
Construct zero-valued ConfigDoF.
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
SymGroup make_point_group(const PermuteIteratorContainer &container, const Lattice &supercell_lattice)
Returns a SymGroup generated from a container of PermuteIterator.
Data structure holding results of ConfigMapper algorithm.
std::string fail_msg
Failure message if could not map to prim.
std::map< MappingNode, Individual > maps
The configurations that the input structure mapped onto.
Index n_optimal(double tol=TOL) const
Struct with optional parameters for Config Mapping Specifies default parameters for all values,...
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....
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...
Class describing the lattice-mapping portion of a particular mapping A general map for child_struc on...
Definition: StrucMapping.hh:82
Superlattice parent
PrimGrid for supercell of parent structure The parent structure defines the ideal strain state,...
Eigen::Matrix3d stretch
stretch tensor that takes child superlattice from its de-rotated, deformed state to its ideal,...
Definition: StrucMapping.hh:87
Eigen::Matrix3d isometry
cartesian rotation/reflection/rotoreflection that rotates the child superlattice to its de-rotated,...
Definition: StrucMapping.hh:91
AssignmentNode atomic_node
Eigen::Vector3d const & translation() const
convenience method to access MappingNode::atomic_node.translation
std::vector< AtomIndexSet > MoleculeMap
std::vector< Index > atom_permutation
Eigen::Matrix3d const & stretch() const
convenience method to access MappingNode::lattice_node.stretch
Eigen::MatrixXd atom_displacement
3xN matrix of displacements for all sites in parent supercell (Va are included, but set to Zero)
std::vector< MoleculeLabel > mol_labels
list of assigned molecule names
double cost_tol() const
Eigen::Matrix3d const & isometry() const
convenience method to access MappingNode::lattice_node.isometry
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'
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...