CASM  1.1.0
A Clusters Approach to Statistical Mechanics
ConfigIOHull.hh
Go to the documentation of this file.
1 #ifndef CONFIGIOHULL_HH
2 #define CONFIGIOHULL_HH
3 
5 #include "casm/clex/PrimClex.hh"
7 #include "casm/hull/Hull.hh"
8 
9 namespace CASM {
10 
11 class Configuration;
12 
13 namespace ConfigIO {
14 
17 
20 
22 std::string default_hull_calculator();
23 
28 template <typename ValueType>
29 class BaseHull : public BaseValueFormatter<ValueType, Configuration> {
30  public:
32  BaseHull(
33  const std::string &_name, const std::string &_desc,
34  const std::string &_default_selection = "MASTER",
35  const std::string &_default_composition_type = default_hull_calculator(),
36  const Hull::CalculatorOptions &_calculator_map =
38  double _singular_value_tol = 1e-8, double _bottom_facet_tol = 1e-8);
39 
41  bool init(const Configuration &_tmplt) const override;
42 
44  std::string short_header(const Configuration &_config) const override;
45 
47  bool parse_args(const std::string &args) override;
48 
49  protected:
51  const Hull &_hull() const;
52 
53  // for parse_args: determine energy type based on composition type
55 
56  // detect and avoid printing -0.0
57  constexpr static double m_dist_to_hull_tol = 1e-14;
58 
59  private:
60  // tol used to detect zero singular values during principal component analysis
61  // preprocessing before hull calculation
63 
64  // tol used to detect which facets are on the bottom of the convex hull
66 
67  // the hull object
68  mutable std::shared_ptr<Hull> m_hull;
69 
70  // Parsed arguments
71  // -- what selection to use for constructing the hull
72  std::string m_selection;
73 
74  // Parsed arguments
75  // -- what composition to use for constructing the hull
76  // -- determines comp calculator and energy calculator, via m_calculator_map
77  std::string m_composition_type;
78 
79  // Prevent re-parsing args
81 };
82 
101 class OnHull : public BaseHull<bool> {
102  public:
103  static const std::string Name;
104  static const std::string Desc;
105 
107  OnHull();
108 
110  std::unique_ptr<OnHull> clone() const {
111  return std::unique_ptr<OnHull>(this->_clone());
112  }
113 
115  bool validate(const Configuration &_config) const override;
116 
118  bool evaluate(const Configuration &_config) const override;
119 
120  private:
122  OnHull *_clone() const override { return new OnHull(*this); }
123 };
124 
139 class HullDist : public BaseHull<double> {
140  public:
141  static const std::string Name;
142  static const std::string Desc;
143 
145  HullDist();
146 
148  std::unique_ptr<HullDist> clone() const {
149  return std::unique_ptr<HullDist>(this->_clone());
150  }
151 
153  bool validate(const Configuration &_config) const override;
154 
156  double evaluate(const Configuration &_config) const override;
157 
158  private:
160  HullDist *_clone() const override { return new HullDist(*this); }
161 };
162 
182 class OnClexHull : public BaseHull<bool> {
183  public:
184  static const std::string Name;
185  static const std::string Desc;
186 
188  OnClexHull();
189 
191  std::unique_ptr<OnClexHull> clone() const {
192  return std::unique_ptr<OnClexHull>(this->_clone());
193  }
194 
197  virtual bool validate(const Configuration &_config) const override;
198 
200  virtual bool evaluate(const Configuration &_config) const override;
201 
202  private:
204  OnClexHull *_clone() const override { return new OnClexHull(*this); }
205 };
206 
221 class ClexHullDist : public BaseHull<double> {
222  public:
223  static const std::string Name;
224  static const std::string Desc;
225 
227  ClexHullDist();
228 
230  std::unique_ptr<ClexHullDist> clone() const {
231  return std::unique_ptr<ClexHullDist>(this->_clone());
232  }
233 
236  virtual bool validate(const Configuration &_config) const override;
237 
239  virtual double evaluate(const Configuration &_config) const override;
240 
241  private:
243  ClexHullDist *_clone() const override { return new ClexHullDist(*this); }
244 };
245 
246 } // namespace ConfigIO
247 } // namespace CASM
248 
249 #endif
Base class for creating scalar DatumFormatter.
Base class for hull info formatters.
Definition: ConfigIOHull.hh:29
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
Definition: ConfigIOHull.hh:57
std::string short_header(const Configuration &_config) const override
column header to use
std::shared_ptr< Hull > m_hull
Definition: ConfigIOHull.hh:68
std::string m_composition_type
Definition: ConfigIOHull.hh:77
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.
Definition: ConfigIOHull.cc:56
const Hull & _hull() const
const Access the Hull object
Hull::CalculatorOptions m_calculator_map
Definition: ConfigIOHull.hh:54
bool init(const Configuration &_tmplt) const override
Calculates the convex hull.
Definition: ConfigIOHull.cc:79
Returns the distance, in eV, of a configuration's clex(formation_energy_per_atom) above the predicted...
virtual double evaluate(const Configuration &_config) const override
Return the distance to the hull.
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
std::unique_ptr< ClexHullDist > clone() const
Clone.
ClexHullDist * _clone() const override
Clone.
Returns the distance, in eV, of a configuration's formation_energy_per_atom above the convex hull.
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.
HullDist * _clone() const override
Clone.
std::unique_ptr< HullDist > clone() const
Clone.
Returns a boolean indicating if a Configuration is a predicted convex hull vertex.
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
std::unique_ptr< OnClexHull > clone() const
Clone.
OnClexHull * _clone() const override
Clone.
static const std::string Name
Returns a boolean indicating if a Configuration is a convex hull vertex.
OnHull * _clone() const override
Clone.
std::unique_ptr< OnHull > clone() const
Clone.
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.
Definition: Hull.hh:17
std::map< std::string, CalculatorPair > CalculatorOptions
Definition: Hull.hh:24
Hull::CalculatorOptions hull_calculator_options()
Returns a map containing default hull calculators.
Definition: ConfigIOHull.cc:15
std::string default_hull_calculator()
Returns "atom_frac".
Definition: ConfigIOHull.cc:36
Hull::CalculatorOptions clex_hull_calculator_options()
Returns a map containing default clex hull calculators.
Definition: ConfigIOHull.cc:25
Main CASM namespace.
Definition: APICommand.hh:8