1 #ifndef CONFIGIOHULL_HH
2 #define CONFIGIOHULL_HH
29 template<
typename ValueType>
36 const std::string &_desc,
37 const std::string &_default_selection =
"MASTER",
40 double _singular_value_tol = 1e-8,
41 double _bottom_facet_tol = 1e-8);
50 bool parse_args(
const std::string &args)
override;
73 mutable std::shared_ptr<Hull>
m_hull;
116 std::unique_ptr<OnHull>
clone()
const {
117 return std::unique_ptr<OnHull>(this->
_clone());
157 std::unique_ptr<HullDist>
clone()
const {
158 return std::unique_ptr<HullDist>(this->
_clone());
203 std::unique_ptr<OnClexHull>
clone()
const {
204 return std::unique_ptr<OnClexHull>(this->
_clone());
245 std::unique_ptr<ClexHullDist>
clone()
const {
246 return std::unique_ptr<ClexHullDist>(this->
_clone());
280 template<
typename ValueType>
282 const std::string &_desc,
283 const std::string &_default_selection,
284 const std::string &_default_composition_type,
286 double _singular_value_tol,
287 double _bottom_facet_tol) :
289 m_calculator_map(_calculator_map),
290 m_singular_value_tol(_singular_value_tol),
291 m_bottom_facet_tol(_bottom_facet_tol),
292 m_selection(_default_selection),
293 m_composition_type(_default_composition_type),
294 m_initialized(false) {}
302 template<
typename ValueType>
308 if(m_selection ==
"ALL") {
314 else if(m_selection ==
"MASTER") {
317 else if(m_selection ==
"CALCULATED") {
325 if(!fs::exists(m_selection)) {
326 throw std::runtime_error(
327 std::string(
"ERROR in $selection argument for '") + short_header(_tmplt) +
"'." +
328 " Expected <filename>, 'ALL', 'CALCULATED', or 'MASTER' <--default" +
329 " No file named '" + m_selection +
"'.");
339 m_calculator_map.find(m_composition_type)->second.first->init(_tmplt);
340 m_calculator_map.find(m_composition_type)->second.second->init(_tmplt);
342 m_hull = std::make_shared<Hull>(selection,
343 *m_calculator_map.
find(m_composition_type)->second.first,
344 *m_calculator_map.find(m_composition_type)->second.second,
345 m_singular_value_tol,
356 template<
typename ValueType>
358 std::stringstream t_ss;
359 t_ss << this->name() <<
"(" << m_selection <<
"," << m_composition_type <<
")";
383 template<
typename ValueType>
390 std::vector<std::string> splt_vec;
391 boost::split(splt_vec, args, boost::is_any_of(
","), boost::token_compress_on);
393 if(splt_vec.size() > 4) {
394 throw std::runtime_error(
"Attempted to initialize format tag " + this->name()
396 + args +
"), but only up to 4 arguments allowed.\n");
400 while(splt_vec.size() < 4) {
401 splt_vec.push_back(
"");
404 m_selection = splt_vec[0].empty() ? m_selection : splt_vec[0];
405 m_composition_type = splt_vec[1].empty() ? m_composition_type : splt_vec[1];
406 m_singular_value_tol = splt_vec[2].empty() ? m_singular_value_tol : std::stod(splt_vec[2]);
407 m_bottom_facet_tol = splt_vec[3].empty() ? m_bottom_facet_tol : std::stod(splt_vec[3]);
408 m_initialized =
true;
410 auto it = m_calculator_map.find(m_composition_type);
411 if(it == m_calculator_map.end()) {
413 std::stringstream ss;
414 ss <<
"Composition type '" << m_composition_type <<
"' is not recognized. Options are: ";
415 for(
auto it = m_calculator_map.begin(); it != m_calculator_map.end(); ++it) {
416 std::cerr << it->first <<
" ";
417 if(it != m_calculator_map.begin()) {
420 ss <<
"'" << it->first <<
"'";
422 throw std::runtime_error(ss.str());
431 template<
typename ValueType>
Generate and inspect the convex hull generated from a selection of Configurations.
static const std::string Name
PrimClex & get_primclex() const
Get the PrimClex for this Configuration.
void init(const Configuration &_tmplt) const override
Calculates the convex hull.
static const std::string Name
Returns the distance, in eV, of a configuration's clex(formation_energy_per_atom) above the predicted...
iterator find(const std::string &configname)
std::unique_ptr< ClexHullDist > clone() const
Clone.
HullDist * _clone() const override
Clone.
virtual bool validate(const Configuration &_config) const override
Validate that the Configuration has a cluster expanded formation energy per species.
ClexHullDist * _clone() const override
Clone.
std::map< std::string, CalculatorPair > CalculatorOptions
Hull::CalculatorOptions clex_hull_calculator_options()
Returns a map containing default clex hull calculators.
std::string to_string(ENUM val)
Return string representation of enum class.
static const std::string Desc
bool parse_args(const std::string &args) override
Determine the selection to use to generate the hull.
double evaluate(const Configuration &_config) const override
Return the distance to the hull.
std::shared_ptr< Hull > m_hull
OnHull * _clone() const override
Clone.
static const std::string Desc
Returns the distance, in eV, of a configuration's formation_energy_per_atom above the convex hull...
std::unique_ptr< OnHull > clone() const
Clone.
void set_selected(const std::string &configname, bool is_selected)
static const std::string Name
bool validate(const Configuration &_config) const override
Validate that the Configuration has a formation energy per species.
OnClexHull * _clone() const override
Clone.
double m_bottom_facet_tol
config_const_iterator config_cend() const
const Configuration iterator: end
virtual bool validate(const Configuration &_config) const override
Validate that the Configuration has a cluster expanded formation energy per species.
bool evaluate(const Configuration &_config) const override
Check if the Configuration is a hull vertex.
PrimClex is the top-level data structure for a CASM project.
Returns a boolean indicating if a Configuration is a convex hull vertex.
config_const_iterator config_cbegin() const
const Configuration iterator: begin
std::string default_hull_calculator()
Returns "atom_frac".
static constexpr double m_dist_to_hull_tol
ConfigIO::GenericConfigFormatter< bool > is_calculated()
static const std::string Desc
double m_singular_value_tol
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.
std::unique_ptr< HullDist > clone() const
Clone.
const Hull & _hull() const
const Access the Hull object
static const std::string Name
bool validate(const Configuration &_config) const override
Validate that the Configuration has a formation energy per species.
Hull::CalculatorOptions hull_calculator_options()
Returns a map containing default hull calculators.
ConfigSelection< true > ConstConfigSelection
virtual double evaluate(const Configuration &_config) const override
Return the distance to the hull.
Hull::CalculatorOptions m_calculator_map
ClexHullDist()
Constructor.
std::string m_composition_type
Returns a boolean indicating if a Configuration is a predicted convex hull vertex.
static const std::string Desc
Base class for hull info formatters.
virtual bool evaluate(const Configuration &_config) const override
Check if the Configuration is a hull vertex.
std::string short_header(const Configuration &_config) const override
column header to use
A Configuration represents the values of all degrees of freedom in a Supercell.
std::unique_ptr< OnClexHull > clone() const
Clone.