CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
ConfigIOHull.cc
Go to the documentation of this file.
1 #include <functional>
4 #include "casm/clex/PrimClex.hh"
5 #include "casm/clex/Norm.hh"
6 
7 namespace CASM {
8 
9  namespace ConfigIO {
10 
15  options["comp"] = Hull::CalculatorPair(Comp().clone(), formation_energy().clone());
16  return options;
17  }
18 
22  Clex clex;
23  options["comp"] = Hull::CalculatorPair(Comp().clone(), clex.clone());
24  clex.parse_args("formation_energy,per_species");
25  options["atom_frac"] = Hull::CalculatorPair(SpeciesFrac().clone(), clex.clone());
26  return options;
27  }
28 
29 
31  std::string default_hull_calculator() {
32  return "atom_frac";
33  }
34 
35  // --- OnHull Definitions -------------------
36 
37  const std::string OnHull::Name = "on_hull";
38 
39  const std::string OnHull::Desc =
40  "Whether configuration is a vertex on the formation_energy convex hull (i.e., is a groundstate)."
41  " Only one Configuration out of a set that have identical or almost identical points in"
42  " composition/energy space will return true."
43  " Accepts arguments ($selection,$composition,$dim_tol,$bottom_tol)."
44  " ($selection may be one of: <filename>, 'ALL', 'CALCULATED', 'MASTER' <--default)"
45  " ($composition may be one of: 'comp', 'atom_frac' <--default)"
46  " ($dim_tol: tolerance for detecting composition dimensionality, default=1e-8)"
47  " ($bottom_tol: tolerance for detecting which facets form the convex hull bottom, default=1e-8)"
48  " For 'comp', 'formation_energy' is used. For 'atom_frac', 'formation_energy_per_atom' is used."
49  " Ex: on_hull, on_hull(MASTER,comp).";
50 
53  BaseHull<bool>(Name, Desc) {}
54 
56  bool OnHull::validate(const Configuration &_config) const {
57  return has_formation_energy(_config);
58  }
59 
64  bool OnHull::evaluate(const Configuration &_config) const {
65  orgQhull::QhullVertexList vertices = _hull().data().vertexList();
66  for(auto it = vertices.begin(); it != vertices.end(); ++it) {
67  if(_hull().configuration(*it).name() == _config.name()) {
68  return true;
69  }
70  }
71  return false;
72  }
73 
74 
75  // --- HullDist Definitions -------------------
76 
77  const std::string HullDist::Name = "hull_dist";
78 
79  const std::string HullDist::Desc =
80  "Distance, in eV, of a configuration's formation_energy_per_atom above the convex hull."
81  " Accepts arguments ($selection,$composition,$dim_tol,$bottom_tol)."
82  " ($selection may be one of: <filename>, 'ALL', 'CALCULATED', 'MASTER' <--default)"
83  " ($composition may be one of: 'comp', 'atom_frac' <--default)."
84  " ($dim_tol: tolerance for detecting composition dimensionality, default=1e-8)"
85  " ($bottom_tol: tolerance for detecting which facets form the convex hull bottom, default=1e-8)"
86  " For 'comp', 'formation_energy' is used. For 'atom_frac', 'formation_energy_per_atom' is used."
87  " Ex: hull_dist, hull_dist(MASTER,comp).";
88 
91  BaseHull<double>(Name, Desc) {}
92 
94  bool HullDist::validate(const Configuration &_config) const {
95  return has_formation_energy(_config);
96  }
97 
99  double HullDist::evaluate(const Configuration &_config) const {
100  double d = _hull().dist_to_hull(_config);
101  d = (std::abs(d) < m_dist_to_hull_tol) ? 0.0 : d;
102  return d;
103  }
104 
105 
106  // --- OnClexHull Definitions -------------------
107 
108  const std::string OnClexHull::Name = "on_clex_hull";
109 
110  const std::string OnClexHull::Desc =
111  "Whether configuration is a vertex on the *cluster-expanded* formation_energy "
112  "convex hull (i.e., is a *predicted* groundstate)."
113  " Only one Configuration out of a set that have identical or almost identical points in"
114  " composition/energy space will return true."
115  " Accepts arguments ($selection,$composition,$dim_tol,$bottom_tol)."
116  " ($selection may be one of: <filename>, 'ALL', 'CALCULATED', 'MASTER' <--default)"
117  " ($composition may be one of: 'comp', 'atom_frac' <--default)"
118  " ($dim_tol: tolerance for detecting composition dimensionality, default=1e-8)"
119  " ($bottom_tol: tolerance for detecting which facets form the convex hull bottom, default=1e-8)"
120  " For 'comp', 'clex(formation_energy)' is used. For 'atom_frac', 'clex(formation_energy_per_atom)' is used."
121  " Ex: clex_hull_dist, clex_hull_dist(MASTER,comp).";
122 
125  BaseHull<bool>(Name, Desc, "MASTER", default_hull_calculator(), clex_hull_calculator_options()) {}
126 
127 
131  bool OnClexHull::validate(const Configuration &_config) const {
132  return true;
133  }
134 
139  bool OnClexHull::evaluate(const Configuration &_config) const {
140  orgQhull::QhullVertexList vertices = _hull().data().vertexList();
141  for(auto it = vertices.begin(); it != vertices.end(); ++it) {
142  if(_hull().configuration(*it).name() == _config.name()) {
143  return true;
144  }
145  }
146  return false;
147  }
148 
149 
150  // --- ClexHullDist Definitions -------------------
151 
152  const std::string ClexHullDist::Name = "clex_hull_dist";
153 
154  const std::string ClexHullDist::Desc =
155  "Distance, in eV, of a configuration's *cluster-expanded* "
156  "formation_energy_per_atom above the convex hull."
157  " Accepts arguments ($selection,$composition,$dim_tol,$bottom_tol)."
158  " ($selection may be one of: <filename>, 'ALL', 'CALCULATED', 'MASTER' <--default)"
159  " ($composition may be one of: 'comp', 'atom_frac' <--default)"
160  " ($dim_tol: tolerance for detecting composition dimensionality, default=1e-8)"
161  " ($bottom_tol: tolerance for detecting which facets form the convex hull bottom, default=1e-8)"
162  " For 'comp', 'clex(formation_energy)' is used. For 'atom_frac', 'clex(formation_energy_per_atom)' is used."
163  " Ex: clex_hull_dist, clex_hull_dist(MASTER,comp).";
164 
167  BaseHull<double>(Name, Desc, "MASTER", default_hull_calculator(), clex_hull_calculator_options()) {}
168 
172  bool ClexHullDist::validate(const Configuration &_config) const {
173  return true;
174  }
175 
177  double ClexHullDist::evaluate(const Configuration &_config) const {
178  double d = _hull().dist_to_hull(_config);
179  d = (std::abs(d) < m_dist_to_hull_tol) ? 0.0 : d;
180  return d;
181  }
182 
183  }
184 }
185 
AtomFrac SpeciesFrac
In the future, AtomFrac will actually be atoms only.
Definition: ConfigIO.hh:233
static const std::string Name
double dist_to_hull(const Configuration &config) const
The distance a Configuration is above the hull along the energy axis.
Definition: Hull.cc:223
static const std::string Name
bool has_formation_energy(const Configuration &_config)
const orgQhull::Qhull & data() const
const Access the hull object directly
Definition: Hull.cc:116
virtual bool validate(const Configuration &_config) const override
Validate that the Configuration has a cluster expanded formation energy per species.
const Configuration & configuration(const orgQhull::QhullPoint &point) const
Return the configuration corresponding to any point.
Definition: Hull.cc:135
Main CASM namespace.
Definition: complete.cpp:8
std::map< std::string, CalculatorPair > CalculatorOptions
Definition: Hull.hh:23
Hull::CalculatorOptions clex_hull_calculator_options()
Returns a map containing default clex hull calculators.
Definition: ConfigIOHull.cc:20
bool parse_args(const std::string &args) override
Expects 'clex', 'clex(formation_energy)', or 'clex(formation_energy_per_species)'.
Definition: ConfigIO.cc:276
static const std::string Desc
double evaluate(const Configuration &_config) const override
Return the distance to the hull.
Definition: ConfigIOHull.cc:99
Calculate param composition of a Configuration.
Definition: ConfigIO.hh:80
HullDist()
Constructor.
Definition: ConfigIOHull.cc:90
static const std::string Desc
static const std::string Name
bool validate(const Configuration &_config) const override
Validate that the Configuration has a formation energy per species.
Definition: ConfigIOHull.cc:56
std::unique_ptr< T > clone(const T &obj, typename std::enable_if< has_clone< T >::value, T >::type *=nullptr)
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.
Definition: ConfigIOHull.cc:64
ConfigIO::GenericConfigFormatter< double > formation_energy()
Definition: ConfigIO.cc:439
std::string name() const
SCELV_A_B_C_D_E_F/i.
std::string default_hull_calculator()
Returns "atom_frac".
Definition: ConfigIOHull.cc:31
static constexpr double m_dist_to_hull_tol
Definition: ConfigIOHull.hh:62
static const std::string Desc
Returns predicted formation energy.
Definition: ConfigIO.hh:334
const Hull & _hull() const
const Access the Hull object
static const std::string Name
std::pair< notstd::cloneable_ptr< CompCalculator >, notstd::cloneable_ptr< EnergyCalculator > > CalculatorPair
Definition: Hull.hh:22
bool validate(const Configuration &_config) const override
Validate that the Configuration has a formation energy per species.
Definition: ConfigIOHull.cc:94
Hull::CalculatorOptions hull_calculator_options()
Returns a map containing default hull calculators.
Definition: ConfigIOHull.cc:12
virtual double evaluate(const Configuration &_config) const override
Return the distance to the hull.
std::unique_ptr< Clex > clone() const
Clone using copy constructor.
Definition: ConfigIO.cc:253
static const std::string Desc
OnHull()
Constructor.
Definition: ConfigIOHull.cc:52
Base class for hull info formatters.
Definition: ConfigIOHull.hh:30
virtual bool evaluate(const Configuration &_config) const override
Check if the Configuration is a hull vertex.
A Configuration represents the values of all degrees of freedom in a Supercell.
ConfigIO::GenericConfigFormatter< double > formation_energy_per_species()
Definition: ConfigIO.cc:448