29 clex.
parse_args(
"formation_energy,per_species");
30 options[
"atom_frac"] =
55 template <
typename ValueType>
57 const std::string &_desc,
58 const std::string &_default_selection,
59 const std::string &_default_composition_type,
61 double _singular_value_tol,
62 double _bottom_facet_tol)
64 m_calculator_map(_calculator_map),
65 m_singular_value_tol(_singular_value_tol),
66 m_bottom_facet_tol(_bottom_facet_tol),
67 m_selection(_default_selection),
68 m_composition_type(_default_composition_type),
69 m_initialized(false) {}
78 template <
typename ValueType>
88 auto res = m_calculator_map.find(m_composition_type)->second;
89 res.first->init(_tmplt);
90 res.second->init(_tmplt);
92 m_hull = std::make_shared<Hull>(selection, *res.first, *res.second,
93 m_singular_value_tol, m_bottom_facet_tol);
104 template <
typename ValueType>
107 std::stringstream t_ss;
108 t_ss << this->
name() <<
"(" << m_selection <<
"," << m_composition_type
135 template <
typename ValueType>
141 std::vector<std::string> splt_vec;
142 boost::split(splt_vec, args, boost::is_any_of(
","), boost::token_compress_on);
144 if (splt_vec.size() > 4) {
145 throw std::runtime_error(
"Attempted to initialize format tag " +
146 this->
name() +
" with " +
148 args +
"), but only up to 4 arguments allowed.\n");
152 while (splt_vec.size() < 4) {
153 splt_vec.push_back(
"");
156 m_selection = splt_vec[0].empty() ? m_selection : splt_vec[0];
157 m_composition_type = splt_vec[1].empty() ? m_composition_type : splt_vec[1];
158 m_singular_value_tol =
159 splt_vec[2].empty() ? m_singular_value_tol : std::stod(splt_vec[2]);
161 splt_vec[3].empty() ? m_bottom_facet_tol : std::stod(splt_vec[3]);
162 m_initialized =
true;
164 auto it = m_calculator_map.find(m_composition_type);
165 if (it == m_calculator_map.end()) {
166 std::stringstream ss;
167 ss <<
"Composition type '" << m_composition_type
168 <<
"' is not recognized. Options are: ";
169 for (
auto it = m_calculator_map.begin(); it != m_calculator_map.end();
171 std::cerr << it->first <<
" ";
172 if (it != m_calculator_map.begin()) {
175 ss <<
"'" << it->first <<
"'";
177 throw std::runtime_error(ss.str());
185 template <
typename ValueType>
195 "Whether configuration is a vertex on the formation_energy convex hull "
196 "(i.e., is a groundstate)."
197 " Only one Configuration out of a set that have identical or almost "
198 "identical points in"
199 " composition/energy space will return true."
200 " Accepts arguments ($selection,$composition,$dim_tol,$bottom_tol)."
201 " ($selection may be one of: <filename>, 'ALL', 'CALCULATED', 'MASTER' "
203 " ($composition may be one of: 'comp', 'atom_frac' <--default)"
204 " ($dim_tol: tolerance for detecting composition dimensionality, "
206 " ($bottom_tol: tolerance for detecting which facets form the convex hull "
207 "bottom, default=1e-8)"
208 " For 'comp', 'formation_energy' is used. For 'atom_frac', "
209 "'formation_energy_per_atom' is used."
210 " Ex: on_hull, on_hull(MASTER,comp).";
226 orgQhull::QhullVertexList vertices =
_hull().
data().vertexList();
227 for (
auto it = vertices.begin(); it != vertices.end(); ++it) {
228 if (
_hull().configuration(*it).name() == _config.name()) {
240 "Distance, in eV, of a configuration's formation_energy_per_atom above the "
242 " Accepts arguments ($selection,$composition,$dim_tol,$bottom_tol)."
243 " ($selection may be one of: <filename>, 'ALL', 'CALCULATED', 'MASTER' "
245 " ($composition may be one of: 'comp', 'atom_frac' <--default)."
246 " ($dim_tol: tolerance for detecting composition dimensionality, "
248 " ($bottom_tol: tolerance for detecting which facets form the convex hull "
249 "bottom, default=1e-8)"
250 " For 'comp', 'formation_energy' is used. For 'atom_frac', "
251 "'formation_energy_per_atom' is used."
252 " Ex: hull_dist, hull_dist(MASTER,comp).";
274 "Whether configuration is a vertex on the *cluster-expanded* "
276 "convex hull (i.e., is a *predicted* groundstate)."
277 " Only one Configuration out of a set that have identical or almost "
278 "identical points in"
279 " composition/energy space will return true."
280 " Accepts arguments ($selection,$composition,$dim_tol,$bottom_tol)."
281 " ($selection may be one of: <filename>, 'ALL', 'CALCULATED', 'MASTER' "
283 " ($composition may be one of: 'comp', 'atom_frac' <--default)"
284 " ($dim_tol: tolerance for detecting composition dimensionality, "
286 " ($bottom_tol: tolerance for detecting which facets form the convex hull "
287 "bottom, default=1e-8)"
288 " For 'comp', 'clex(formation_energy)' is used. For 'atom_frac', "
289 "'clex(formation_energy_per_atom)' is used."
290 " Ex: clex_hull_dist, clex_hull_dist(MASTER,comp).";
309 orgQhull::QhullVertexList vertices =
_hull().
data().vertexList();
310 for (
auto it = vertices.begin(); it != vertices.end(); ++it) {
311 if (
_hull().configuration(*it).name() == _config.name()) {
323 "Distance, in eV, of a configuration's *cluster-expanded* "
324 "formation_energy_per_atom above the convex hull."
325 " Accepts arguments ($selection,$composition,$dim_tol,$bottom_tol)."
326 " ($selection may be one of: <filename>, 'ALL', 'CALCULATED', 'MASTER' "
328 " ($composition may be one of: 'comp', 'atom_frac' <--default)"
329 " ($dim_tol: tolerance for detecting composition dimensionality, "
331 " ($bottom_tol: tolerance for detecting which facets form the convex hull "
332 "bottom, default=1e-8)"
333 " For 'comp', 'clex(formation_energy)' is used. For 'atom_frac', "
334 "'clex(formation_energy_per_atom)' is used."
335 " Ex: clex_hull_dist, clex_hull_dist(MASTER,comp).";
Base class for hull info formatters.
bool parse_args(const std::string &args) override
Determine the selection to use to generate the hull.
constexpr static double m_dist_to_hull_tol
std::string short_header(const Configuration &_config) const override
column header to use
BaseHull(const std::string &_name, const std::string &_desc, const std::string &_default_selection="MASTER", const std::string &_default_composition_type=default_hull_calculator(), const Hull::CalculatorOptions &_calculator_map=hull_calculator_options(), double _singular_value_tol=1e-8, double _bottom_facet_tol=1e-8)
Constructor.
const Hull & _hull() const
const Access the Hull object
bool init(const Configuration &_tmplt) const override
Calculates the convex hull.
Returns predicted formation energy.
bool parse_args(const std::string &args) override
Expects 'clex', 'clex(formation_energy)', or 'clex(formation_energy_per_species)'.
std::unique_ptr< Clex > clone() const
Clone using copy constructor.
virtual double evaluate(const Configuration &_config) const override
Return the distance to the hull.
ClexHullDist()
Constructor.
virtual bool validate(const Configuration &_config) const override
Validate that the Configuration has a cluster expanded formation energy per species.
static const std::string Name
static const std::string Desc
Calculate param composition of a Configuration.
double evaluate(const Configuration &_config) const override
Return the distance to the hull.
static const std::string Name
static const std::string Desc
bool validate(const Configuration &_config) const override
Validate that the Configuration has a formation energy per species.
virtual bool validate(const Configuration &_config) const override
Validate that the Configuration has a cluster expanded formation energy per species.
virtual bool evaluate(const Configuration &_config) const override
Check if the Configuration is a hull vertex.
static const std::string Desc
static const std::string Name
static const std::string Desc
bool evaluate(const Configuration &_config) const override
Check if the Configuration is a hull vertex.
static const std::string Name
bool validate(const Configuration &_config) const override
Validate that the Configuration has a formation energy per species.
Generate and inspect the convex hull generated from a selection of Configurations.
std::pair< notstd::cloneable_ptr< CompCalculator >, notstd::cloneable_ptr< EnergyCalculator > > CalculatorPair
std::map< std::string, CalculatorPair > CalculatorOptions
double dist_to_hull(const Configuration &config) const
The distance a Configuration is above the hull along the energy axis.
const orgQhull::Qhull & data() const
const Access the hull object directly
bool has_formation_energy(const Configuration &_config)
std::string to_string(ENUM val)
Return string representation of enum class.
ConfigIO::GenericConfigFormatter< double > formation_energy()
ConfigIO::GenericConfigFormatter< double > formation_energy_per_species()
AtomFrac SpeciesFrac
In the future, AtomFrac will actually be atoms only.
Hull::CalculatorOptions hull_calculator_options()
Returns a map containing default hull calculators.
std::string default_hull_calculator()
Returns "atom_frac".
Hull::CalculatorOptions clex_hull_calculator_options()
Returns a map containing default clex hull calculators.
GenericDatumFormatter< std::string, DataObject > name()
std::unique_ptr< T > clone(const T &obj)