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;
45 namespace ConfigIO_impl {
49 if (args.size() > 0) m_mol_names.push_back(args);
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]);
63 for (
Index n = 0; n < m_mol_names.size(); n++) {
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}));
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");
81 std::vector<std::string> MolDependent::col_header(
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] +
")");
95 const std::string Comp::Name =
"comp";
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.";
108 return config.primclex().has_composition_axes();
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 +
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]) +
")");
134 const std::string CompN::Name =
"comp_n";
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), "
148 const std::string SiteFrac::Name =
"site_frac";
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.";
162 const std::string AtomFrac::Name =
"atom_frac";
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.";
176 const std::string Corr::Name =
"corr";
178 const std::string Corr::Desc =
179 "Correlation values (evaluated basis functions, normalized per primitive "
181 "If no arguments, prints all correlations, using the basis set for the "
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)'.";
201 if (!m_clexulator.initialized()) {
216 std::vector<std::string> splt_vec;
217 boost::split(splt_vec, args, boost::is_any_of(
","), boost::token_compress_on);
219 if (!splt_vec.size()) {
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]);
226 m_clex_name = splt_vec[0];
228 }
else if (splt_vec.size() == 2) {
229 m_clex_name = splt_vec[0];
230 _parse_index_expression(splt_vec[1]);
232 std::stringstream ss;
233 ss <<
"Too many arguments for 'corr'. Received: " << args <<
"\n";
234 throw std::runtime_error(ss.str());
241 const std::string CorrContribution::Name =
"corr_contribution";
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)`.";
259 if (!m_clexulator.initialized()) {
278 std::vector<std::string> splt_vec;
279 boost::split(splt_vec, args, boost::is_any_of(
","), boost::token_compress_on);
281 if (!splt_vec.size()) {
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]);
292 m_clex_name = splt_vec[1];
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]);
299 std::stringstream ss;
300 ss <<
"Too many arguments for 'corr_contribution'. Received: " << args
302 throw std::runtime_error(ss.str());
309 const std::string PointCorr::Name =
"point_corr";
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, "
334 if (!m_clexulator.initialized()) {
354 std::vector<std::string> splt_vec;
355 boost::split(splt_vec, args, boost::is_any_of(
","), boost::token_compress_on);
357 if (splt_vec.size() < 2) {
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]);
370 m_clex_name = splt_vec[2];
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]);
378 std::stringstream ss;
379 ss <<
"Too many arguments for 'point_corr'. Received: " << args <<
"\n";
380 throw std::runtime_error(ss.str());
387 const std::string GradCorr::Name =
"gradcorr";
389 const std::string GradCorr::Desc =
390 "Gradiant of correlation values (evaluated basis functions), with respect "
392 "degree of freedom (DoF). For each configuration, output is a (D*N x C) "
394 "is DoF dimension, 'N' is either 1 (for global DoF) or number of sites in "
396 "(for site DoF), and 'C' is number of basis functions. Gradient components "
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)' "
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)'";
417 if (!m_clexulator.initialized()) {
433 std::vector<std::string> split_vec;
434 boost::split(split_vec, args, boost::is_any_of(
","),
435 boost::token_compress_on);
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.");
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());
448 boost::erase_all(split_vec[0],
"'");
450 m_key = split_vec[0];
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]);
458 m_clex_name = split_vec[i];
466 const std::string Clex::Name =
"clex";
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' "
481 m_clexulator(clexulator),
492 return std::unique_ptr<Clex>(this->
_clone());
501 ?
primclex.settings().default_clex()
510 throw std::runtime_error(
"Error: bset and eci mismatch");
519 std::vector<std::string> splt_vec;
520 boost::split(splt_vec, args, boost::is_any_of(
","), boost::token_compress_on);
523 if (splt_vec.size()) {
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>();
534 std::stringstream ss;
535 ss <<
"Error parsing second argument for 'clex'. Received: " << args
537 throw std::runtime_error(ss.str());
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());
565 "configname",
"Configuration name, in the form 'SCEL#_#_#_#_#_#_#/#'",
571 "scelname",
"Supercell name, in the form 'SCEL#_#_#_#_#_#_#'",
579 "calc_status",
"Status of calculation.",
581 return CASM::calc_status<Configuration>(
config);
584 return CASM::has_calc_status<Configuration>(
config);
590 "failure_type",
"Reason for calculation failure.",
592 return CASM::failure_type<Configuration>(
config);
595 return CASM::has_failure_type<Configuration>(
config);
602 "Supercell volume, given as the integer number of primitive cells",
611 "Symmetric multiplicity of the configuration, excluding translational "
614 return config.multiplicity();
620 "point_group_name",
"Name of the configuration's point group.",
622 return config.point_group_name();
630 "DFT energy, normalized per primitive cell (deprecated for `energy`)",
636 "energy",
"DFT energy, normalized per primitive cell",
CASM::energy,
643 "relaxed_energy_per_atom",
644 "DFT energy, normalized per atom (deprecated for `energy_per_atom`)",
650 "DFT energy, normalized per atom",
657 "reference energy, normalized per primitive cell, as determined by "
658 "current reference states",
664 "reference_energy_per_atom",
665 "reference energy, normalized per atom, as determined by current "
673 "DFT formation energy, normalized per primitive cell and measured "
674 "relative to current reference states",
680 "formation_energy_per_atom",
681 "DFT formation energy, normalized per atom and measured relative to "
682 "current reference states",
700 "True (1) if all current properties have been been calculated for the "
709 "True (1) if the configuration cannot be "
710 "described within a smaller supercell",
717 "True (1) if the configuration cannot be transformed by symmetry to a "
718 "configuration with higher lexicographic order",
725 "Root-mean-square forces of relaxed configurations, determined from DFT "
732 "atomic_deformation",
733 "Cost function that describes the degree to which basis sites have "
740 "lattice_deformation",
741 "Cost function that describes the degree to which lattice has relaxed.",
748 "Change in volume due to relaxation, expressed as the ratio V/V_0.",
755 "Relaxed magnetic moment, normalized per primative cell.",
761 "relaxed_magmom_per_atom",
762 "Relaxed magnetic moment, normalized per atom.",
769 "Structure resulting from application of DoF, formatted as JSON",
779 "config",
"All degrees of freedom (DoF), formatted as JSON",
787 "properties",
"All mapped properties, by calctype, formatted as JSON",
789 return jsonParser{configuration.calc_properties_map()};
796 "Structure resulting from application of DoF, formatted as VASP POSCAR",
798 std::stringstream ss;
808 StringAttributeDictionary<Configuration>
810 using namespace ConfigIO;
811 StringAttributeDictionary<Configuration> dict;
813 dict.insert(name<Configuration>(),
configname(), alias<Configuration>(),
821 BooleanAttributeDictionary<Configuration>
823 using namespace ConfigIO;
824 BooleanAttributeDictionary<Configuration> dict;
827 DB::Selected<Configuration>(), OnClexHull(), OnHull());
833 IntegerAttributeDictionary<Configuration>
835 using namespace ConfigIO;
836 IntegerAttributeDictionary<Configuration> dict;
844 ScalarAttributeDictionary<Configuration>
846 using namespace ConfigIO;
847 ScalarAttributeDictionary<Configuration> dict;
849 dict.insert(Clex(), HullDist(), ClexHullDist(), Novelty(),
relaxed_energy(),
860 VectorXiAttributeDictionary<Configuration>
862 using namespace ConfigIO;
863 VectorXiAttributeDictionary<Configuration> dict;
868 VectorXdAttributeDictionary<Configuration>
870 using namespace ConfigIO;
871 VectorXdAttributeDictionary<Configuration> dict;
873 dict.insert(AtomFrac(), Comp(), CompN(), Corr(), CorrContribution(),
874 PointCorr(), RelaxationStrain(), DoFStrain(), SiteFrac(),
881 MatrixXdAttributeDictionary<Configuration>
883 using namespace ConfigIO;
884 MatrixXdAttributeDictionary<Configuration> dict;
886 dict.insert(GradCorr());
892 DataFormatterDictionary<Configuration,
893 BaseValueFormatter<jsonParser, Configuration>>
895 using namespace ConfigIO;
896 DataFormatterDictionary<Configuration,
897 BaseValueFormatter<jsonParser, Configuration>>
size_type corr_size() const
Number of correlations.
bool initialized() const
Is runtime library loaded?
Returns predicted formation energy.
double evaluate(const Configuration &config) const override
Returns the atom fraction.
double _norm(const Configuration &config) const
Returns the normalization.
bool init(const Configuration &_tmplt) const override
If not yet initialized, use the global clexulator and eci from the PrimClex.
notstd::cloneable_ptr< Norm< Configuration > > m_norm
bool parse_args(const std::string &args) override
Expects 'clex', 'clex(formation_energy)', or 'clex(formation_energy_per_species)'.
Clex * _clone() const override
Clone using copy constructor.
std::unique_ptr< Clex > clone() const
Clone using copy constructor.
A sparse container of ECI values and their corresponding orbit indices.
const std::vector< size_type > & index() const
const Access orbit indices of ECI values
void error(const std::string &what)
static const int standard
PrimClex is the top-level data structure for a CASM project.
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.
MatrixXdAttributeDictionary< Configuration > make_matrixxd_dictionary< Configuration >()
IntegerAttributeDictionary< Configuration > make_integer_dictionary< Configuration >()
BooleanAttributeDictionary< Configuration > make_boolean_dictionary< Configuration >()
ScalarAttributeDictionary< Configuration > make_scalar_dictionary< Configuration >()
VectorXdAttributeDictionary< Configuration > make_vectorxd_dictionary< Configuration >()
StringAttributeDictionary< Configuration > make_string_dictionary< Configuration >()
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()
Clexulator clexulator(std::string const &basis_set_name) const
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)
ConfigIO::GenericConfigFormatter< std::string > poscar()
ConfigIO::GenericConfigFormatter< bool > is_canonical()
ConfigIO::GenericConfigFormatter< double > atomic_deformation()
ConfigIO::GenericConfigFormatter< double > energy_per_species()
ConfigIO::GenericConfigFormatter< double > lattice_deformation()
ConfigIO::GenericConfigFormatter< double > reference_energy()
ConfigIO::GenericConfigFormatter< std::string > point_group_name()
ConfigIO::GenericConfigFormatter< jsonParser > properties()
ConfigIO::GenericConfigFormatter< jsonParser > config()
ConfigIO::GenericConfigFormatter< double > formation_energy()
ConfigIO::GenericConfigFormatter< double > relaxed_magmom()
ConfigIO::GenericConfigFormatter< jsonParser > structure()
ConfigIO::GenericConfigFormatter< double > volume_relaxation()
ConfigIO::GenericConfigFormatter< std::string > failure_type()
ConfigIO::GenericConfigFormatter< double > formation_energy_per_species()
ConfigIO::GenericConfigFormatter< double > relaxed_energy()
ConfigIO::GenericConfigFormatter< bool > is_primitive()
ConfigIO::GenericConfigFormatter< Index > multiplicity()
ConfigIO::GenericConfigFormatter< bool > is_calculated()
ConfigIO::GenericConfigFormatter< Index > scel_size()
ConfigIO::GenericConfigFormatter< double > relaxed_energy_per_species()
ConfigIO::GenericConfigFormatter< std::string > scelname()
ConfigIO::GenericConfigFormatter< double > relaxed_magmom_per_species()
ConfigIO::GenericConfigFormatter< std::string > calc_status()
ConfigIO::GenericConfigFormatter< double > rms_force()
ConfigIO::GenericConfigFormatter< double > energy()
ConfigIO::GenericConfigFormatter< std::string > configname()
Constructs DataFormmaterDictionary containing all Configuration DatumFormatters.
ConfigIO::GenericConfigFormatter< double > reference_energy_per_species()
Validator validate(OccupationDoFSpecs const &occ_specs, const Structure &prim)
GenericScelFormatter< double > volume()
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.
VectorXiAttributeDictionary< Configuration > make_vectorxi_dictionary< Configuration >()
void parse_args(Completer::OptionHandlerBase &opt, std::string args)
GenericDatumFormatter< std::string, DataObject > name()
DataFormatterDictionary< Configuration, BaseValueFormatter< jsonParser, Configuration > > make_json_dictionary< Configuration >()
Iterator find(Iterator begin, Iterator end, const T &value, BinaryCompare q)
Equivalent to std::find(begin, end, value), but with custom comparison.
void print_poscar(Configuration const &configuration, std::ostream &sout)
INDEX_TYPE Index
For long integer indexing:
std::unique_ptr< T > clone(const T &obj)
Specifies a particular cluster expansion.
Clex(Clexulator const &_clexulator, ECIContainer const &_eci)