CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
Hull.hh
Go to the documentation of this file.
1 #ifndef CASM_Hull
2 #define CASM_Hull
3 
4 #include "casm/external/qhull/libqhullcpp/PointCoordinates.h"
5 #include "casm/external/qhull/libqhullcpp/Qhull.h"
6 
9 
10 namespace CASM {
11 
15  class Hull {
16 
17  public:
18 
21  typedef std::pair<notstd::cloneable_ptr<CompCalculator>,
23  typedef std::map<std::string, CalculatorPair> CalculatorOptions;
24 
26  Hull(const ConstConfigSelection &_selection,
27  const CompCalculator &_comp_calculator = ConfigIO::SpeciesFrac(),
28  const EnergyCalculator &_energy_calculator = ConfigIO::formation_energy_per_species(),
29  double _singular_value_tol = 1e-14,
30  double _bottom_facet_tol = 1e-14);
31 
33  const orgQhull::Qhull &data() const;
34 
36  const Eigen::MatrixXd &reduce() const;
37 
39  const Eigen::Transpose<const Eigen::MatrixXd> expand() const;
40 
42  const Configuration &configuration(const orgQhull::QhullPoint &point) const;
43 
45  const Configuration &configuration(const orgQhull::QhullVertex &vertex) const;
46 
48  Eigen::VectorXd mu(const orgQhull::QhullFacet facet) const;
49 
51  const Configuration &groundstate(const Eigen::VectorXd &mu) const;
52 
54  double energy(const Configuration &config) const;
55 
57  Eigen::VectorXd composition(const Configuration &config) const;
58 
60  Eigen::VectorXd point(const Configuration &config) const;
61 
63  Eigen::VectorXd reduced_point(const Configuration &config) const;
64 
66  double dist_to_hull(const Configuration &config) const;
67 
69  double dist_to_hull(Eigen::VectorXd _reduced_point) const;
70 
71 
72  private:
73 
74  struct CompareVertex {
76 
77  bool operator()(orgQhull::QhullVertex A, orgQhull::QhullVertex B) const {
78  return A.id() < B.id();
79  }
80  };
81 
82  // the hull object
83  orgQhull::Qhull m_hull;
84 
85  // the selection of Configurations used to generate the hull
87 
88  // get composition coordinates for Configuration
90 
91  // get energy for a Configuration
93 
94  // transform full dimension comp/energy vector onto subspace range(comp)/energy
96 
97  // all 'bottom' facets, along with projection of 'm_bottom' along the unit outward normal
98  std::vector< std::pair<orgQhull::QhullFacet, double> > m_bottom_facets;
99 
100  // the vertices on the bottom hull
101  std::set<orgQhull::QhullVertex, CompareVertex> m_bottom_vertices;
102 
103  };
104 
105 }
106 
107 #endif
Eigen::MatrixXd MatrixXd
Generate and inspect the convex hull generated from a selection of Configurations.
Definition: Hull.hh:15
Returns fraction of all species that are a particular species, excluding vacancies.
Definition: ConfigIO.hh:202
double dist_to_hull(const Configuration &config) const
The distance a Configuration is above the hull along the energy axis.
Definition: Hull.cc:223
Abstract base class for creating 1D DatumFormatter.
Eigen::VectorXd composition(const Configuration &config) const
Use the CompCalculator to return the composition of a Configuration.
Definition: Hull.cc:204
const orgQhull::Qhull & data() const
const Access the hull object directly
Definition: Hull.cc:116
ScalarAttribute< Configuration > EnergyCalculator
Definition: Hull.hh:20
notstd::cloneable_ptr< CompCalculator > m_comp_calculator
Definition: Hull.hh:89
VectorXdAttribute< Configuration > CompCalculator
Definition: Hull.hh:19
std::vector< std::pair< orgQhull::QhullFacet, double > > m_bottom_facets
Definition: Hull.hh:98
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
Base class for creating scalar DatumFormatter.
Eigen::MatrixXd m_reduce
Definition: Hull.hh:95
Eigen::VectorXd mu(const orgQhull::QhullFacet facet) const
Return the chemical potential corresponding to a facet.
Definition: Hull.cc:149
bool operator()(orgQhull::QhullVertex A, orgQhull::QhullVertex B) const
Definition: Hull.hh:77
Hull(const ConstConfigSelection &_selection, const CompCalculator &_comp_calculator=ConfigIO::SpeciesFrac(), const EnergyCalculator &_energy_calculator=ConfigIO::formation_energy_per_species(), double _singular_value_tol=1e-14, double _bottom_facet_tol=1e-14)
Constructor for convex hull in composition/energy space.
Definition: Hull.cc:25
std::set< orgQhull::QhullVertex, CompareVertex > m_bottom_vertices
Definition: Hull.hh:101
double energy(const Configuration &config) const
Use the EnergyCalculator to return the energy of a Configuration.
Definition: Hull.cc:199
Eigen::VectorXd VectorXd
orgQhull::Qhull m_hull
Definition: Hull.hh:83
const Eigen::MatrixXd & reduce() const
Orthogonal transformation matrix from a point in full comp/energy space to dimension-reduced comp/ene...
Definition: Hull.cc:125
const Eigen::Transpose< const Eigen::MatrixXd > expand() const
Orthogonal transformation matrix from a point in the dimension-reduced comp/energy space to the full ...
Definition: Hull.cc:130
Eigen::VectorXd reduced_point(const Configuration &config) const
Return a vector corresponding to the coordinate of a given configuration in the reduced composition/e...
Definition: Hull.cc:218
Eigen::VectorXd point(const Configuration &config) const
Return a vector corresponding to the coordinate of a given configuration in full composition/energy s...
Definition: Hull.cc:210
std::pair< notstd::cloneable_ptr< CompCalculator >, notstd::cloneable_ptr< EnergyCalculator > > CalculatorPair
Definition: Hull.hh:22
A 'cloneable_ptr' can be used in place of 'unique_ptr'.
notstd::cloneable_ptr< EnergyCalculator > m_energy_calculator
Definition: Hull.hh:92
ConstConfigSelection m_selection
Definition: Hull.hh:86
const Configuration & groundstate(const Eigen::VectorXd &mu) const
Return the 0K ground state corresponding to the input chemical potential.
Definition: Hull.cc:165
A Configuration represents the values of all degrees of freedom in a Supercell.
ConfigIO::GenericConfigFormatter< double > formation_energy_per_species()
Definition: ConfigIO.cc:448