CASM  1.1.0
A Clusters Approach to Statistical Mechanics
ConfigIO.cc
Go to the documentation of this file.
1 #include "casm/clex/ConfigIO.hh"
2 
3 #include <functional>
4 
7 #include "casm/casm_io/Log.hh"
12 #include "casm/clex/Calculable.hh"
19 #include "casm/clex/Norm.hh"
20 #include "casm/clex/PrimClex.hh"
29 
30 namespace CASM {
31 
32 template class BaseDatumFormatter<Configuration>;
33 template class DataFormatterOperator<bool, std::string, Configuration>;
34 template class DataFormatterOperator<bool, bool, Configuration>;
35 template class DataFormatterOperator<bool, double, Configuration>;
36 template class DataFormatterOperator<double, double, Configuration>;
37 template class DataFormatterOperator<Index, double, Configuration>;
38 template class DataFormatter<Configuration>;
39 template bool DataFormatter<Configuration>::evaluate_as_scalar<bool>(
40  Configuration const &) const;
41 template double DataFormatter<Configuration>::evaluate_as_scalar<double>(
42  Configuration const &) const;
44 
45 namespace ConfigIO_impl {
46 
48 bool MolDependent::parse_args(const std::string &args) {
49  if (args.size() > 0) m_mol_names.push_back(args);
50  return true;
51 }
52 
54 bool MolDependent::init(const Configuration &_tmplt) const {
55  auto struc_mol = xtal::struc_molecule_name(_tmplt.primclex().prim());
56 
57  if (m_mol_names.size() == 0) {
58  for (Index i = 0; i < struc_mol.size(); i++) {
59  _add_rule(std::vector<Index>({i}));
60  m_mol_names.push_back(struc_mol[i]);
61  }
62  } else {
63  for (Index n = 0; n < m_mol_names.size(); n++) {
64  Index i = 0;
65  for (i = 0; i < struc_mol.size(); i++) {
66  if (struc_mol[i] == m_mol_names[n]) {
67  _add_rule(std::vector<Index>({i}));
68  break;
69  }
70  }
71  if (i == struc_mol.size())
72  throw std::runtime_error(
73  std::string("Format tag: '") + name() + "(" + m_mol_names[n] +
74  ")' does not correspond to a viable composition.\n");
75  }
76  }
77  return true;
78 }
79 
81 std::vector<std::string> MolDependent::col_header(
82  const Configuration &_tmplt) const {
83  std::vector<std::string> col;
84  for (Index c = 0; c < m_mol_names.size(); c++) {
85  col.push_back(name() + "(" + m_mol_names[c] + ")");
86  }
87  return col;
88 }
89 } // namespace ConfigIO_impl
90 
91 namespace ConfigIO {
92 
93 // --- Comp implementations -----------
94 
95 const std::string Comp::Name = "comp";
96 
97 const std::string Comp::Desc =
98  "Parametric composition parameters, individual label as argument. "
99  "Without argument, all values are printed. Ex: comp(a), comp(b), etc.";
100 
102 Eigen::VectorXd Comp::evaluate(const Configuration &config) const {
103  return comp(config);
104 }
105 
107 bool Comp::validate(const Configuration &config) const {
108  return config.primclex().has_composition_axes();
109 }
110 
112 bool Comp::parse_args(const std::string &args) {
113  if (args.size() == 1) {
114  _add_rule(std::vector<Index>({(Index)(args[0] - 'a')}));
115  } else if (args.size() > 1) {
116  throw std::runtime_error(std::string("Format tag: 'comp(") + args +
117  ") is invalid.\n");
118  return false;
119  }
120  return true;
121 }
122 
124 std::vector<std::string> Comp::col_header(const Configuration &_tmplt) const {
125  std::vector<std::string> col;
126  for (Index c = 0; c < _index_rules().size(); c++) {
127  col.push_back(name() + "(" + (char)('a' + _index_rules()[c][0]) + ")");
128  }
129  return col;
130 }
131 
132 // --- CompN implementations -----------
133 
134 const std::string CompN::Name = "comp_n";
135 
136 const std::string CompN::Desc =
137  "Number of each species per unit cell, including vacancies. "
138  "No argument prints all available values. Ex: comp_n, comp_n(Au), "
139  "comp_n(Pt), etc.";
140 
142 Eigen::VectorXd CompN::evaluate(const Configuration &config) const {
143  return comp_n(config);
144 }
145 
146 // --- SiteFrac implementations -----------
147 
148 const std::string SiteFrac::Name = "site_frac";
149 
150 const std::string SiteFrac::Desc =
151  "Fraction of sites occupied by a species, including vacancies. "
152  "No argument prints all available values. Ex: site_frac(Au), "
153  "site_frac(Pt), etc.";
154 
156 Eigen::VectorXd SiteFrac::evaluate(const Configuration &config) const {
157  return site_frac(config);
158 }
159 
160 // --- AtomFrac implementations -----------
161 
162 const std::string AtomFrac::Name = "atom_frac";
163 
164 const std::string AtomFrac::Desc =
165  "Fraction of atoms that are a particular species, excluding vacancies. "
166  "Without argument, all values are printed. Ex: atom_frac(Au), "
167  "atom_frac(Pt), etc.";
168 
170 Eigen::VectorXd AtomFrac::evaluate(const Configuration &config) const {
171  return species_frac(config);
172 }
173 
174 // --- Corr implementations -----------
175 
176 const std::string Corr::Name = "corr";
177 
178 const std::string Corr::Desc =
179  "Correlation values (evaluated basis functions, normalized per primitive "
180  "cell). "
181  "If no arguments, prints all correlations, using the basis set for the "
182  "default "
183  "cluster expansion as listed by 'casm settings -l'. "
184  "If one argument, accepts either: "
185  "1) a cluster expansion name, for example 'corr(formation_energy)', and "
186  "evaluates all basis functions, or "
187  "2) an integer index or range of indices of basis functions to evaluate, "
188  "for example 'corr(6)', or 'corr(0:6)'. "
189  "If two arguments, accepts cluster expansion name and an integer index or "
190  "range of basis functions to evaluate, for example "
191  "'corr(formation_energy,6)' "
192  "or 'corr(formation_energy,0:6)'.";
193 
195 Eigen::VectorXd Corr::evaluate(const Configuration &config) const {
196  return correlations(config, m_clexulator);
197 }
198 
200 bool Corr::init(const Configuration &_tmplt) const {
201  if (!m_clexulator.initialized()) {
202  const PrimClex &primclex = _tmplt.primclex();
203  ClexDescription desc = m_clex_name.empty()
205  : primclex.settings().clex(m_clex_name);
206  m_clexulator = primclex.clexulator(desc.bset);
207  }
208 
210  return true;
211 }
212 
215 bool Corr::parse_args(const std::string &args) {
216  std::vector<std::string> splt_vec;
217  boost::split(splt_vec, args, boost::is_any_of(","), boost::token_compress_on);
218 
219  if (!splt_vec.size()) {
220  return true;
221  } else if (splt_vec.size() == 1) {
222  if ((splt_vec[0].find_first_not_of("0123456789") == std::string::npos) ||
223  (splt_vec[0].find(':') != std::string::npos)) {
224  _parse_index_expression(splt_vec[0]);
225  } else {
226  m_clex_name = splt_vec[0];
227  }
228  } else if (splt_vec.size() == 2) {
229  m_clex_name = splt_vec[0];
230  _parse_index_expression(splt_vec[1]);
231  } else {
232  std::stringstream ss;
233  ss << "Too many arguments for 'corr'. Received: " << args << "\n";
234  throw std::runtime_error(ss.str());
235  }
236  return true;
237 }
238 
239 // --- CorrContribution implementations -----------
240 
241 const std::string CorrContribution::Name = "corr_contribution";
242 
243 const std::string CorrContribution::Desc =
244  "Correlation values (evaluated basis functions for a single unit cell, not "
245  " normalized). The first argument is the linear unit cell index [0, "
246  " scel_vol). The remaining arguments follow the same conventions as "
247  "`corr` accepting any of `corr_contribution(linear_unitcell_index)` or "
248  "`corr_contribution(linear_unitcell_index, clex_name)` or "
249  "`corr_contribution(linear_unitcell_index, indices)`, or "
250  "`corr_contribution(linear_unitcell_index, clex_name, indices)`.";
251 
253 Eigen::VectorXd CorrContribution::evaluate(const Configuration &config) const {
254  return corr_contribution(m_linear_unitcell_index, config, m_clexulator);
255 }
256 
258 bool CorrContribution::init(const Configuration &_tmplt) const {
259  if (!m_clexulator.initialized()) {
260  const PrimClex &primclex = _tmplt.primclex();
261  ClexDescription desc = m_clex_name.empty()
263  : primclex.settings().clex(m_clex_name);
264  m_clexulator = primclex.clexulator(desc.bset);
265  }
266 
268  return true;
269 }
270 
277 bool CorrContribution::parse_args(const std::string &args) {
278  std::vector<std::string> splt_vec;
279  boost::split(splt_vec, args, boost::is_any_of(","), boost::token_compress_on);
280 
281  if (!splt_vec.size()) {
282  return false;
283  }
284  if (splt_vec.size() == 1) {
285  m_linear_unitcell_index = std::stol(splt_vec[0]);
286  } else if (splt_vec.size() == 2) {
287  m_linear_unitcell_index = std::stol(splt_vec[0]);
288  if ((splt_vec[1].find_first_not_of("0123456789") == std::string::npos) ||
289  (splt_vec[1].find(':') != std::string::npos)) {
290  _parse_index_expression(splt_vec[1]);
291  } else {
292  m_clex_name = splt_vec[1];
293  }
294  } else if (splt_vec.size() == 3) {
295  m_linear_unitcell_index = std::stol(splt_vec[0]);
296  m_clex_name = splt_vec[1];
297  _parse_index_expression(splt_vec[2]);
298  } else {
299  std::stringstream ss;
300  ss << "Too many arguments for 'corr_contribution'. Received: " << args
301  << "\n";
302  throw std::runtime_error(ss.str());
303  }
304  return true;
305 }
306 
307 // --- PointCorr implementations -----------
308 
309 const std::string PointCorr::Name = "point_corr";
310 
311 const std::string PointCorr::Desc =
312  "Point correlation values (evaluated basis functions for a single site, "
313  "normalized by cluster orbit size). The first argument is the linear unit "
314  "cell index [0, scel_vol). The second argument is the index of the site in "
315  "the neighbor list. For periodic cluster functions this is the sublattice "
316  "index [0, basis_size). For local clusters this is the index of sites in "
317  "the local neighborhood [0, basis_size*neighborhood_size), where "
318  "neighborhood_size is the number of distinct unitcells with a site in any "
319  "cluster orbit. The remaining arguments follow the same conventions as "
320  "`corr` accepting any of "
321  "`corr_contribution(linear_unitcell_index, neighbor_index)` or "
322  "`corr_contribution(linear_unitcell_index, neighbor_index, clex_name)` or "
323  "`corr_contribution(linear_unitcell_index, neighbor_index, indices)`, or "
324  "`corr_contribution(linear_unitcell_index, neighbor_index, clex_name, "
325  "indices)`.";
326 
327 Eigen::VectorXd PointCorr::evaluate(const Configuration &config) const {
328  return point_corr(m_linear_unitcell_index, m_neighbor_index, config,
329  m_clexulator);
330 }
331 
333 bool PointCorr::init(const Configuration &_tmplt) const {
334  if (!m_clexulator.initialized()) {
335  const PrimClex &primclex = _tmplt.primclex();
336  ClexDescription desc = m_clex_name.empty()
338  : primclex.settings().clex(m_clex_name);
339  m_clexulator = primclex.clexulator(desc.bset);
340  }
341 
343  return true;
344 }
345 
353 bool PointCorr::parse_args(const std::string &args) {
354  std::vector<std::string> splt_vec;
355  boost::split(splt_vec, args, boost::is_any_of(","), boost::token_compress_on);
356 
357  if (splt_vec.size() < 2) {
358  return false;
359  }
360  if (splt_vec.size() == 2) {
361  m_linear_unitcell_index = std::stol(splt_vec[0]);
362  m_neighbor_index = std::stol(splt_vec[1]);
363  } else if (splt_vec.size() == 3) {
364  m_linear_unitcell_index = std::stol(splt_vec[0]);
365  m_neighbor_index = std::stol(splt_vec[1]);
366  if ((splt_vec[2].find_first_not_of("0123456789") == std::string::npos) ||
367  (splt_vec[2].find(':') != std::string::npos)) {
368  _parse_index_expression(splt_vec[2]);
369  } else {
370  m_clex_name = splt_vec[2];
371  }
372  } else if (splt_vec.size() == 4) {
373  m_linear_unitcell_index = std::stol(splt_vec[0]);
374  m_neighbor_index = std::stol(splt_vec[1]);
375  m_clex_name = splt_vec[2];
376  _parse_index_expression(splt_vec[3]);
377  } else {
378  std::stringstream ss;
379  ss << "Too many arguments for 'point_corr'. Received: " << args << "\n";
380  throw std::runtime_error(ss.str());
381  }
382  return true;
383 }
384 
385 // --- GradCorr implementations -----------
386 
387 const std::string GradCorr::Name = "gradcorr";
388 
389 const std::string GradCorr::Desc =
390  "Gradiant of correlation values (evaluated basis functions), with respect "
391  "to a specified "
392  "degree of freedom (DoF). For each configuration, output is a (D*N x C) "
393  "matrix, where 'D' "
394  "is DoF dimension, 'N' is either 1 (for global DoF) or number of sites in "
395  "the configuration "
396  "(for site DoF), and 'C' is number of basis functions. Gradient components "
397  "are ordered such "
398  "that components corresponding to particular site are listed in "
399  "consecutive rows. Requires "
400  "at least one argument, specifying the DoF with repect to which gradient "
401  "is taken [e.g., 'gradcorr(disp)']. "
402  "Basis functions are the basis set for the default cluster expansion, as "
403  "listed by 'casm settings -l', "
404  "unless otherwise specified. Accepts up to three additional arguments:\n"
405  "1) a cluster expansion name, e.g. 'gradcorr(disp,formation_energy)' "
406  "and/or\n"
407  "2) a pair of indices, or index ranges, e.g. 'gradcorr(disp,5,2)', "
408  "'gradcorr(disp,:,3:5)', 'gradcorr(disp,0:4,3)'";
409 
411 Eigen::MatrixXd GradCorr::evaluate(const Configuration &config) const {
412  return gradcorrelations(config, m_clexulator, m_key);
413 }
414 
416 bool GradCorr::init(const Configuration &_tmplt) const {
417  if (!m_clexulator.initialized()) {
418  const PrimClex &primclex = _tmplt.primclex();
419  ClexDescription desc = m_clex_name.empty()
421  : primclex.settings().clex(m_clex_name);
422  m_clexulator = primclex.clexulator(desc.bset);
423  }
424 
426  return true;
427 }
428 
431 bool GradCorr::parse_args(const std::string &args) {
432  // std::cout << "parsing args: " << args << "\n";
433  std::vector<std::string> split_vec;
434  boost::split(split_vec, args, boost::is_any_of(","),
435  boost::token_compress_on);
436  // std::cout << "after split: " << split_vec << "\n";
437  if (!split_vec.size()) {
438  throw std::runtime_error(
439  "'gradcorr' query requires at least one argument, corresponding to the "
440  "independent variable wrt which gradient is to be computed.");
441  return false;
442  } else if (split_vec.size() > 4) {
443  std::stringstream ss;
444  ss << "Too many arguments for 'gradcorr'. Received: " << args << "\n";
445  throw std::runtime_error(ss.str());
446  }
447 
448  boost::erase_all(split_vec[0], "'");
449  // std::cout << "Now split_vec[0] is " << split_vec[0] << "\n";
450  m_key = split_vec[0];
451 
452  for (Index i = 1; i < split_vec.size(); ++i) {
453  if ((split_vec[i].find_first_not_of("0123456789") == std::string::npos) ||
454  (split_vec[i].find(':') != std::string::npos)) {
455  _parse_index_expression(split_vec[i] + "," + split_vec[i + 1]);
456  ++i;
457  } else {
458  m_clex_name = split_vec[i];
459  }
460  }
461  return true;
462 }
463 
464 // --- Clex implementations -----------
465 
466 const std::string Clex::Name = "clex";
467 
468 const std::string Clex::Desc =
469  "Predicted property value."
470  " Accepts arguments ($clex_name,$norm)."
471  " ($clex_name is a cluster expansion name as listed by 'casm settings -l', "
472  "default=the default clex)"
473  " ($norm is the normalization, either 'per_species', or 'per_unitcell' "
474  "<--default)";
475 
477 
478 Clex::Clex(const Clexulator &clexulator, const ECIContainer &eci,
479  const Norm<Configuration> &norm)
480  : ScalarAttribute<Configuration>(Name, Desc),
481  m_clexulator(clexulator),
482  m_eci(eci),
483  m_norm(norm.clone()) {}
484 
486 double Clex::evaluate(const Configuration &config) const {
488 }
489 
491 std::unique_ptr<Clex> Clex::clone() const {
492  return std::unique_ptr<Clex>(this->_clone());
493 }
494 
497 bool Clex::init(const Configuration &_tmplt) const {
498  if (!m_clexulator.initialized()) {
499  const PrimClex &primclex = _tmplt.primclex();
501  ? primclex.settings().default_clex()
502  : primclex.settings().clex(m_clex_name);
503  m_clexulator = primclex.clexulator(desc.bset);
504  m_eci = primclex.eci(desc);
505  if (m_eci.index().back() >= m_clexulator.corr_size()) {
507  err_log.error<Log::standard>("bset and eci mismatch");
508  err_log << "basis set size: " << m_clexulator.corr_size() << std::endl;
509  err_log << "max eci index: " << m_eci.index().back() << std::endl;
510  throw std::runtime_error("Error: bset and eci mismatch");
511  }
512  }
513  return true;
514 }
515 
518 bool Clex::parse_args(const std::string &args) {
519  std::vector<std::string> splt_vec;
520  boost::split(splt_vec, args, boost::is_any_of(","), boost::token_compress_on);
521 
522  m_clex_name = "";
523  if (splt_vec.size()) {
524  m_clex_name = splt_vec[0];
525  }
526 
527  m_norm = notstd::make_cloneable<Norm<Configuration>>();
528  if (splt_vec.size() == 2) {
529  if (splt_vec[1] == "per_unitcell") {
530  m_norm = notstd::make_cloneable<Norm<Configuration>>();
531  } else if (splt_vec[1] == "per_species") {
532  m_norm = notstd::make_cloneable<NormPerSpecies>();
533  } else {
534  std::stringstream ss;
535  ss << "Error parsing second argument for 'clex'. Received: " << args
536  << "\n";
537  throw std::runtime_error(ss.str());
538  }
539  }
540 
541  if (splt_vec.size() > 2) {
542  std::stringstream ss;
543  ss << "Too many arguments for 'clex'. Received: " << args << "\n";
544  throw std::runtime_error(ss.str());
545  }
546 
547  return true;
548 }
549 
551 double Clex::_norm(const Configuration &config) const {
552  return (*m_norm)(config);
553 }
554 
556 Clex *Clex::_clone() const { return new Clex(*this); }
557 
558 /*End ConfigIO*/
559 } // namespace ConfigIO
560 
561 namespace ConfigIO {
562 
565  "configname", "Configuration name, in the form 'SCEL#_#_#_#_#_#_#/#'",
566  [](const Configuration &config) -> std::string { return config.name(); });
567 }
568 
571  "scelname", "Supercell name, in the form 'SCEL#_#_#_#_#_#_#'",
572  [](const Configuration &config) -> std::string {
573  return config.supercell().name();
574  });
575 }
576 
579  "calc_status", "Status of calculation.",
580  [](const Configuration &config) -> std::string {
581  return CASM::calc_status<Configuration>(config);
582  },
583  [](const Configuration &config) -> bool {
584  return CASM::has_calc_status<Configuration>(config);
585  });
586 }
587 
590  "failure_type", "Reason for calculation failure.",
591  [](const Configuration &config) -> std::string {
592  return CASM::failure_type<Configuration>(config);
593  },
594  [](const Configuration &config) -> bool {
595  return CASM::has_failure_type<Configuration>(config);
596  });
597 }
598 
601  "scel_size",
602  "Supercell volume, given as the integer number of primitive cells",
603  [](const Configuration &config) -> Index {
604  return config.supercell().volume();
605  });
606 }
607 
610  "multiplicity",
611  "Symmetric multiplicity of the configuration, excluding translational "
612  "equivalents.",
613  [](const Configuration &config) -> Index {
614  return config.multiplicity();
615  });
616 }
617 
620  "point_group_name", "Name of the configuration's point group.",
621  [](const Configuration &config) -> std::string {
622  return config.point_group_name();
623  });
624 }
625 
626 // deprecated for 'energy'
629  "relaxed_energy",
630  "DFT energy, normalized per primitive cell (deprecated for `energy`)",
632 }
633 
636  "energy", "DFT energy, normalized per primitive cell", CASM::energy,
637  has_energy);
638 }
639 
640 // deprecated for 'energy_per_species'
643  "relaxed_energy_per_atom",
644  "DFT energy, normalized per atom (deprecated for `energy_per_atom`)",
646 }
647 
649  return GenericConfigFormatter<double>("energy_per_atom",
650  "DFT energy, normalized per atom",
652 }
653 
656  "reference_energy",
657  "reference energy, normalized per primitive cell, as determined by "
658  "current reference states",
660 }
661 
664  "reference_energy_per_atom",
665  "reference energy, normalized per atom, as determined by current "
666  "reference states",
668 }
669 
672  "formation_energy",
673  "DFT formation energy, normalized per primitive cell and measured "
674  "relative to current reference states",
676 }
677 
680  "formation_energy_per_atom",
681  "DFT formation energy, normalized per atom and measured relative to "
682  "current reference states",
684 }
685 
686 /*Generic1DDatumFormatter<std::vector<double>, Configuration
687  >relaxation_strain() { return Generic1DDatumFormatter<std::vector<double>,
688  Configuration >("relaxation_strain", "Green-Lagrange strain of dft-relaxed
689  configuration, relative to the ideal crystal. Ordered as [E(0,0), E(1,1),
690  E(2,2), E(1,2), E(0,2), E(0,1)]. Accepts index as argument on interval
691  [0,5]", CASM::relaxation_strain, has_relaxation_strain,
692  [](const std::vector<double> &cont)->Index{
693  return 6;
694  });
695  }*/
696 
699  "is_calculated",
700  "True (1) if all current properties have been been calculated for the "
701  "configuration",
702  [](const Configuration &config) -> bool {
703  return CASM::is_calculated(config);
704  });
705 }
706 
708  return GenericConfigFormatter<bool>("is_primitive",
709  "True (1) if the configuration cannot be "
710  "described within a smaller supercell",
712 }
713 
716  "is_canonical",
717  "True (1) if the configuration cannot be transformed by symmetry to a "
718  "configuration with higher lexicographic order",
720 }
721 
724  "rms_force",
725  "Root-mean-square forces of relaxed configurations, determined from DFT "
726  "(eV/Angstr.)",
728 }
729 
732  "atomic_deformation",
733  "Cost function that describes the degree to which basis sites have "
734  "relaxed",
736 }
737 
740  "lattice_deformation",
741  "Cost function that describes the degree to which lattice has relaxed.",
743 }
744 
747  "volume_relaxation",
748  "Change in volume due to relaxation, expressed as the ratio V/V_0.",
750 }
751 
754  "relaxed_magmom",
755  "Relaxed magnetic moment, normalized per primative cell.",
757 }
758 
761  "relaxed_magmom_per_atom",
762  "Relaxed magnetic moment, normalized per atom.",
764 }
765 
768  "structure",
769  "Structure resulting from application of DoF, formatted as JSON",
770  [](Configuration const &configuration) {
772  to_json(make_simple_structure(configuration), json);
773  return json;
774  });
775 }
776 
779  "config", "All degrees of freedom (DoF), formatted as JSON",
780  [](Configuration const &configuration) {
781  return jsonParser{configuration};
782  });
783 }
784 
787  "properties", "All mapped properties, by calctype, formatted as JSON",
788  [](Configuration const &configuration) {
789  return jsonParser{configuration.calc_properties_map()};
790  });
791 }
792 
795  "poscar",
796  "Structure resulting from application of DoF, formatted as VASP POSCAR",
797  [](Configuration const &configuration) {
798  std::stringstream ss;
799  print_poscar(configuration, ss);
800  return ss.str();
801  });
802 }
803 
804 /*End ConfigIO*/
805 } // namespace ConfigIO
806 
807 template <>
808 StringAttributeDictionary<Configuration>
810  using namespace ConfigIO;
811  StringAttributeDictionary<Configuration> dict;
812 
813  dict.insert(name<Configuration>(), configname(), alias<Configuration>(),
814  alias_or_name<Configuration>(), scelname(), calc_status(),
816 
817  return dict;
818 }
819 
820 template <>
821 BooleanAttributeDictionary<Configuration>
823  using namespace ConfigIO;
824  BooleanAttributeDictionary<Configuration> dict;
825 
826  dict.insert(is_calculated(), is_canonical(), is_primitive(),
827  DB::Selected<Configuration>(), OnClexHull(), OnHull());
828 
829  return dict;
830 }
831 
832 template <>
833 IntegerAttributeDictionary<Configuration>
835  using namespace ConfigIO;
836  IntegerAttributeDictionary<Configuration> dict;
837 
838  dict.insert(scel_size(), multiplicity());
839 
840  return dict;
841 }
842 
843 template <>
844 ScalarAttributeDictionary<Configuration>
846  using namespace ConfigIO;
847  ScalarAttributeDictionary<Configuration> dict;
848 
849  dict.insert(Clex(), HullDist(), ClexHullDist(), Novelty(), relaxed_energy(),
855 
856  return dict;
857 }
858 
859 template <>
860 VectorXiAttributeDictionary<Configuration>
862  using namespace ConfigIO;
863  VectorXiAttributeDictionary<Configuration> dict;
864  return dict;
865 }
866 
867 template <>
868 VectorXdAttributeDictionary<Configuration>
870  using namespace ConfigIO;
871  VectorXdAttributeDictionary<Configuration> dict;
872 
873  dict.insert(AtomFrac(), Comp(), CompN(), Corr(), CorrContribution(),
874  PointCorr(), RelaxationStrain(), DoFStrain(), SiteFrac(),
875  StrucScore());
876 
877  return dict;
878 }
879 
880 template <>
881 MatrixXdAttributeDictionary<Configuration>
883  using namespace ConfigIO;
884  MatrixXdAttributeDictionary<Configuration> dict;
885 
886  dict.insert(GradCorr());
887 
888  return dict;
889 }
890 
891 template <>
892 DataFormatterDictionary<Configuration,
893  BaseValueFormatter<jsonParser, Configuration>>
895  using namespace ConfigIO;
896  DataFormatterDictionary<Configuration,
897  BaseValueFormatter<jsonParser, Configuration>>
898  dict;
899 
900  dict.insert(structure(), config(), properties());
901 
902  return dict;
903 }
904 
905 } // namespace CASM
virtual bool init(const DataObject &_template_obj) const override
Default initialization adds rules for each element.
virtual bool init(const DataObject &_template_obj) const override
Default initialization adds rules for each element.
Base class for creating scalar DatumFormatter.
Evaluates correlations.
Definition: Clexulator.hh:440
size_type corr_size() const
Number of correlations.
Definition: Clexulator.hh:480
bool initialized() const
Is runtime library loaded?
Definition: Clexulator.hh:471
Returns predicted formation energy.
Definition: ConfigIO.hh:385
double evaluate(const Configuration &config) const override
Returns the atom fraction.
Definition: ConfigIO.cc:486
std::string m_clex_name
Definition: ConfigIO.hh:432
double _norm(const Configuration &config) const
Returns the normalization.
Definition: ConfigIO.cc:551
bool init(const Configuration &_tmplt) const override
If not yet initialized, use the global clexulator and eci from the PrimClex.
Definition: ConfigIO.cc:497
notstd::cloneable_ptr< Norm< Configuration > > m_norm
Definition: ConfigIO.hh:435
ECIContainer m_eci
Definition: ConfigIO.hh:434
bool parse_args(const std::string &args) override
Expects 'clex', 'clex(formation_energy)', or 'clex(formation_energy_per_species)'.
Definition: ConfigIO.cc:518
Clex * _clone() const override
Clone using copy constructor.
Definition: ConfigIO.cc:556
Clexulator m_clexulator
Definition: ConfigIO.hh:433
std::unique_ptr< Clex > clone() const
Clone using copy constructor.
Definition: ConfigIO.cc:491
Parsing dictionary for constructing a DataFormatter<DataObject> object.
A sparse container of ECI values and their corresponding orbit indices.
Definition: ECIContainer.hh:12
const std::vector< size_type > & index() const
const Access orbit indices of ECI values
Definition: ECIContainer.hh:44
A DatumFormatter that returns a value of specified type, via functions that may be specified at runti...
Definition: Log.hh:48
void error(const std::string &what)
Definition: Log.hh:129
static const int standard
Definition: Log.hh:52
PrimClex is the top-level data structure for a CASM project.
Definition: PrimClex.hh:55
ClexDescription const & clex(std::string clex_name) const
Get a ClexDescription by name.
ClexDescription const & default_clex() const
Get default ClexDescription.
static jsonParser object()
Returns an empty json object.
Definition: jsonParser.hh:395
MatrixXdAttributeDictionary< Configuration > make_matrixxd_dictionary< Configuration >()
Definition: ConfigIO.cc:882
IntegerAttributeDictionary< Configuration > make_integer_dictionary< Configuration >()
Definition: ConfigIO.cc:834
BooleanAttributeDictionary< Configuration > make_boolean_dictionary< Configuration >()
Definition: ConfigIO.cc:822
ScalarAttributeDictionary< Configuration > make_scalar_dictionary< Configuration >()
Definition: ConfigIO.cc:845
VectorXdAttributeDictionary< Configuration > make_vectorxd_dictionary< Configuration >()
Definition: ConfigIO.cc:869
StringAttributeDictionary< Configuration > make_string_dictionary< Configuration >()
Definition: ConfigIO.cc:809
double reference_energy(const Configuration &config)
Returns the reference energy, normalized per unit cell.
bool has_relaxed_magmom(const Configuration &_config)
bool has_volume_relaxation(const Configuration &_config)
double formation_energy(const Configuration &config)
Returns the formation energy, normalized per unit cell.
bool has_reference_energy(const Configuration &_config)
double formation_energy_per_species(const Configuration &config)
Returns the formation energy, normalized per species.
double atomic_deformation(const Configuration &_config)
Cost function that describes the degree to which basis sites have relaxed.
Eigen::VectorXd correlations(const Configuration &config, Clexulator const &clexulator)
Returns correlations using 'clexulator'.
Eigen::VectorXd corr_contribution(Index linear_unitcell_index, const Configuration &config, Clexulator const &clexulator)
Returns correlation contribution from a single unit cell, not normalized.
Eigen::VectorXd comp(const Configuration &config)
Returns parametric composition, as calculated using PrimClex::param_comp.
double rms_force(const Configuration &_config)
Root-mean-square forces of relaxed configurations, determined from DFT (eV/Angstr....
bool has_lattice_deformation(const Configuration &_config)
bool has_rms_force(const Configuration &_config)
bool is_primitive(const Configuration &_config)
returns true if _config describes primitive cell of the configuration it describes
double volume_relaxation(const Configuration &_config)
Change in volume due to relaxation, expressed as the ratio V/V_0.
double reference_energy_per_species(const Configuration &config)
Returns the reference energy, normalized per species.
Eigen::MatrixXd gradcorrelations(const Configuration &config, Clexulator const &clexulator, DoFKey &key)
Returns gradient correlations using 'clexulator', with respect to DoF 'dof_type'.
Eigen::VectorXd comp_n(const Configuration &config)
Returns the composition, as number of each species per unit cell.
double relaxed_magmom(const Configuration &_config)
Returns the relaxed magnetic moment, normalized per unit cell.
Eigen::VectorXd site_frac(const Configuration &config)
Returns the composition as site fraction, in the order of Structure::get_struc_molecule.
double lattice_deformation(const Configuration &_config)
Cost function that describes the degree to which lattice has relaxed.
double energy(const Configuration &config)
Returns the energy, normalized per unit cell.
Eigen::VectorXd point_corr(Index linear_unitcell_index, Index neighbor_index, const Configuration &config, Clexulator const &clexulator)
Returns point correlations from a single site, normalized by cluster orbit size.
double energy_per_species(const Configuration &config)
Returns the energy, normalized per species.
bool has_formation_energy(const Configuration &_config)
Eigen::VectorXd species_frac(const Configuration &config)
Returns the composition as species fraction, with [Va] = 0.0, in the order of Structure::get_struc_mo...
bool has_atomic_deformation(const Configuration &_config)
bool is_canonical(const Configuration &_config)
returns true if no symmetry transformation applied to _config will increase its lexicographic order
double relaxed_magmom_per_species(const Configuration &_config)
Returns the relaxed magnetic moment, normalized per species.
bool has_energy(const Configuration &_config)
ProjectSettings & settings()
Definition: PrimClex.cc:224
Clexulator clexulator(std::string const &basis_set_name) const
Definition: PrimClex.cc:366
std::vector< std::string > struc_molecule_name(BasicStructure const &_struc)
Returns an Array of each possible Molecule in this Structure.
T norm(const Tensor< T > &ttens)
Definition: Tensor.hh:932
ConfigIO::GenericConfigFormatter< std::string > poscar()
Definition: ConfigIO.cc:793
ConfigIO::GenericConfigFormatter< bool > is_canonical()
Definition: ConfigIO.cc:714
ConfigIO::GenericConfigFormatter< double > atomic_deformation()
Definition: ConfigIO.cc:730
ConfigIO::GenericConfigFormatter< double > energy_per_species()
Definition: ConfigIO.cc:648
ConfigIO::GenericConfigFormatter< double > lattice_deformation()
Definition: ConfigIO.cc:738
ConfigIO::GenericConfigFormatter< double > reference_energy()
Definition: ConfigIO.cc:654
ConfigIO::GenericConfigFormatter< std::string > point_group_name()
Definition: ConfigIO.cc:618
ConfigIO::GenericConfigFormatter< jsonParser > properties()
Definition: ConfigIO.cc:785
ConfigIO::GenericConfigFormatter< jsonParser > config()
Definition: ConfigIO.cc:777
ConfigIO::GenericConfigFormatter< double > formation_energy()
Definition: ConfigIO.cc:670
ConfigIO::GenericConfigFormatter< double > relaxed_magmom()
Definition: ConfigIO.cc:752
ConfigIO::GenericConfigFormatter< jsonParser > structure()
Definition: ConfigIO.cc:766
ConfigIO::GenericConfigFormatter< double > volume_relaxation()
Definition: ConfigIO.cc:745
ConfigIO::GenericConfigFormatter< std::string > failure_type()
Definition: ConfigIO.cc:588
ConfigIO::GenericConfigFormatter< double > formation_energy_per_species()
Definition: ConfigIO.cc:678
ConfigIO::GenericConfigFormatter< double > relaxed_energy()
Definition: ConfigIO.cc:627
ConfigIO::GenericConfigFormatter< bool > is_primitive()
Definition: ConfigIO.cc:707
ConfigIO::GenericConfigFormatter< Index > multiplicity()
Definition: ConfigIO.cc:608
ConfigIO::GenericConfigFormatter< bool > is_calculated()
Definition: ConfigIO.cc:697
ConfigIO::GenericConfigFormatter< Index > scel_size()
Definition: ConfigIO.cc:599
ConfigIO::GenericConfigFormatter< double > relaxed_energy_per_species()
Definition: ConfigIO.cc:641
ConfigIO::GenericConfigFormatter< std::string > scelname()
Definition: ConfigIO.cc:569
ConfigIO::GenericConfigFormatter< double > relaxed_magmom_per_species()
Definition: ConfigIO.cc:759
ConfigIO::GenericConfigFormatter< std::string > calc_status()
Definition: ConfigIO.cc:577
ConfigIO::GenericConfigFormatter< double > rms_force()
Definition: ConfigIO.cc:722
ConfigIO::GenericConfigFormatter< double > energy()
Definition: ConfigIO.cc:634
ConfigIO::GenericConfigFormatter< std::string > configname()
Constructs DataFormmaterDictionary containing all Configuration DatumFormatters.
Definition: ConfigIO.cc:563
ConfigIO::GenericConfigFormatter< double > reference_energy_per_species()
Definition: ConfigIO.cc:662
Validator validate(OccupationDoFSpecs const &occ_specs, const Structure &prim)
GenericScelFormatter< double > volume()
Definition: SupercellIO.cc:258
Main CASM namespace.
Definition: APICommand.hh:8
Eigen::MatrixXd MatrixXd
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.
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
bool is_calculated(const ConfigType &config, std::string calctype="")
Return true if all required properties have been been calculated for the configuration.
Definition: Calculable.cc:137
VectorXiAttributeDictionary< Configuration > make_vectorxi_dictionary< Configuration >()
Definition: ConfigIO.cc:861
void parse_args(Completer::OptionHandlerBase &opt, std::string args)
Definition: CLIParse.cc:48
GenericDatumFormatter< std::string, DataObject > name()
DataFormatterDictionary< Configuration, BaseValueFormatter< jsonParser, Configuration > > make_json_dictionary< Configuration >()
Definition: ConfigIO.cc:894
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
void print_poscar(Configuration const &configuration, std::ostream &sout)
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
Eigen::VectorXd VectorXd
Log & err_log()
Definition: Log.hh:426
std::unique_ptr< T > clone(const T &obj)
pair_type eci
Definition: settings.cc:146
PrimClex * primclex
Definition: settings.cc:135
ClexDescription & desc
Definition: settings.cc:138
Specifies a particular cluster expansion.
Clex(Clexulator const &_clexulator, ECIContainer const &_eci)
Definition: Clex.hh:20