CASM  1.1.0
A Clusters Approach to Statistical Mechanics
Hull.hh
Go to the documentation of this file.
1 #ifndef CASM_Hull
2 #define CASM_Hull
3 
4 #include "casm/clex/ConfigIO.hh"
7 #include "casm/external/qhull/libqhullcpp/PointCoordinates.h"
8 #include "casm/external/qhull/libqhullcpp/Qhull.h"
9 
10 namespace CASM {
11 
17 class Hull {
18  public:
21  typedef std::pair<notstd::cloneable_ptr<CompCalculator>,
24  typedef std::map<std::string, CalculatorPair> CalculatorOptions;
25 
27  Hull(const DB::Selection<Configuration> &_selection,
28  const CompCalculator &_comp_calculator = ConfigIO::SpeciesFrac(),
29  const EnergyCalculator &_energy_calculator =
31  double _singular_value_tol = 1e-14, double _bottom_facet_tol = 1e-14);
32 
34  const orgQhull::Qhull &data() const;
35 
38  const Eigen::MatrixXd &reduce() const;
39 
42  const Eigen::Transpose<const Eigen::MatrixXd> expand() const;
43 
45  const Configuration &configuration(const orgQhull::QhullPoint &point) const;
46 
48  const Configuration &configuration(const orgQhull::QhullVertex &vertex) const;
49 
51  Eigen::VectorXd mu(const orgQhull::QhullFacet facet) const;
52 
55  const Configuration &groundstate(const Eigen::VectorXd &mu) const;
56 
58  double energy(const Configuration &config) const;
59 
62 
66 
70 
73  double dist_to_hull(const Configuration &config) const;
74 
77  double dist_to_hull(Eigen::VectorXd _reduced_point) const;
78 
79  private:
80  struct CompareVertex {
82 
83  bool operator()(orgQhull::QhullVertex A, orgQhull::QhullVertex B) const {
84  return A.id() < B.id();
85  }
86  };
87 
88  // the hull object
89  orgQhull::Qhull m_hull;
90 
91  // the selection of Configurations used to generate the hull
93 
94  // get composition coordinates for Configuration
96 
97  // get energy for a Configuration
99 
100  // transform full dimension comp/energy vector onto subspace
101  // range(comp)/energy
103 
104  // all 'bottom' facets, along with projection of 'm_bottom' along the unit
105  // outward normal
106  std::vector<std::pair<orgQhull::QhullFacet, double> > m_bottom_facets;
107 
108  // the vertices on the bottom hull
109  std::set<orgQhull::QhullVertex, CompareVertex> m_bottom_vertices;
110 };
111 
112 } // namespace CASM
113 
114 #endif
Abstract base class for creating 1D DatumFormatter.
Base class for creating scalar DatumFormatter.
Returns fraction of all species that are a particular species, excluding vacancies.
Definition: ConfigIO.hh:167
Generate and inspect the convex hull generated from a selection of Configurations.
Definition: Hull.hh:17
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:132
const Configuration & configuration(const orgQhull::QhullPoint &point) const
Return the configuration corresponding to any point.
Definition: Hull.cc:137
std::set< orgQhull::QhullVertex, CompareVertex > m_bottom_vertices
Definition: Hull.hh:109
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:226
std::vector< std::pair< orgQhull::QhullFacet, double > > m_bottom_facets
Definition: Hull.hh:106
ScalarAttribute< Configuration > EnergyCalculator
Definition: Hull.hh:20
const Configuration & groundstate(const Eigen::VectorXd &mu) const
Return the 0K ground state corresponding to the input chemical potential.
Definition: Hull.cc:173
orgQhull::Qhull m_hull
Definition: Hull.hh:89
DB::Selection< Configuration > m_selection
Definition: Hull.hh:92
Hull(const DB::Selection< Configuration > &_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:27
std::pair< notstd::cloneable_ptr< CompCalculator >, notstd::cloneable_ptr< EnergyCalculator > > CalculatorPair
Definition: Hull.hh:23
const Eigen::MatrixXd & reduce() const
Orthogonal transformation matrix from a point in full comp/energy space to dimension-reduced comp/ene...
Definition: Hull.cc:128
notstd::cloneable_ptr< EnergyCalculator > m_energy_calculator
Definition: Hull.hh:98
Eigen::VectorXd mu(const orgQhull::QhullFacet facet) const
Return the chemical potential corresponding to a facet.
Definition: Hull.cc:154
std::map< std::string, CalculatorPair > CalculatorOptions
Definition: Hull.hh:24
Eigen::VectorXd composition(const Configuration &config) const
Use the CompCalculator to return the composition of a Configuration.
Definition: Hull.cc:211
VectorXdAttribute< Configuration > CompCalculator
Definition: Hull.hh:19
double dist_to_hull(const Configuration &config) const
The distance a Configuration is above the hull along the energy axis.
Definition: Hull.cc:231
double energy(const Configuration &config) const
Use the EnergyCalculator to return the energy of a Configuration.
Definition: Hull.cc:206
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:217
notstd::cloneable_ptr< CompCalculator > m_comp_calculator
Definition: Hull.hh:95
const orgQhull::Qhull & data() const
const Access the hull object directly
Definition: Hull.cc:119
Eigen::MatrixXd m_reduce
Definition: Hull.hh:102
A 'cloneable_ptr' can be used in place of 'unique_ptr'.
ConfigIO::GenericConfigFormatter< jsonParser > config()
Definition: ConfigIO.cc:777
ConfigIO::GenericConfigFormatter< double > formation_energy_per_species()
Definition: ConfigIO.cc:678
Main CASM namespace.
Definition: APICommand.hh:8
Eigen::MatrixXd MatrixXd
Eigen::VectorXd VectorXd
bool operator()(orgQhull::QhullVertex A, orgQhull::QhullVertex B) const
Definition: Hull.hh:83