CASM  1.1.0
A Clusters Approach to Statistical Mechanics
ParamComposition.hh
Go to the documentation of this file.
1 #ifndef PARAMCOMPOSITION_HH
2 #define PARAMCOMPOSITION_HH
3 
4 #include <vector>
5 
8 #include "casm/global/eigen.hh"
9 
10 namespace CASM {
11 // defines the enum type used in composition.
13 
15  public:
16  using AllowedOccupants = std::vector<std::vector<std::string> >;
17 
18  static std::vector<std::string> string_components(
19  ParamComposition::AllowedOccupants const &_allowed_occs);
20  //*************************************************************
21  // CONSTRUCTORS
23  std::cerr << "WARNING in ParamComposition, you have not initialized a "
24  "PrimClex. Things could go horribly wrong if you dont. I hope "
25  "you know what you are doing."
26  << std::endl;
27  m_comp.resize(2);
28  m_rank_of_space = -1;
29  m_comp[0].resize(0, 0);
30  m_comp[1].resize(0, 0);
31  m_origin.resize(0);
32  return;
33  }
34 
35  ParamComposition(AllowedOccupants _allowed_occs);
36 
37  ParamComposition(AllowedOccupants _allowed_occs,
39  const Eigen::VectorXd &_origin, const int &_rank_of_space,
40  const int &COMP_TYPE);
41 
42  //*************************************************************
43  // GENERATE Routines
46  void generate_composition_space(bool verbose = false);
47 
48  //*************************************************************
49  // CALC Routines
51  const Eigen::VectorXd &torigin,
52  const std::vector<Eigen::VectorXd> tspanning);
53  Eigen::VectorXd calc(const Eigen::VectorXd &tcomp, const int &MODE);
54  // ptree calc_composition_ptree() const; //returns a ptree object with all
55  // the data from this composition object
58 
60  const Eigen::VectorXd &num_atoms_per_prim) const;
62  const Eigen::VectorXd &param_composition) const;
63 
64  //*************************************************************
65  // PRINT Routines
66  void print_prim_end_members(std::ostream &stream) const {
67  stream << "Number of end members: " << m_prim_end_members.rows()
68  << std::endl;
69  stream << m_components << std::endl << "------" << std::endl;
70  stream << m_prim_end_members << std::endl;
71  }
72  void print_components(std::ostream &stream) const {
73  stream << "Components: " << m_components << std::endl;
74  }
75 
76  void print_composition_axes(std::ostream &stream) const;
77  void print_curr_composition_axes(std::ostream &stream) const;
78  void print_end_member_formula(const int &end_member_index,
79  std::ostream &stream,
80  const int &stream_width) const;
81  void print_member_formula(const Eigen::VectorXd &member, std::ostream &stream,
82  const int &stream_width) const;
83  void print_origin_formula(std::ostream &stream,
84  const int &stream_width) const;
85  void print_composition_formula(std::ostream &stream,
86  const int &stream_width) const;
87 
88  void print_composition_matrices(std::ostream &stream) const {
89  stream << "components: ";
90  print_components(stream);
91  stream << "comp[PARAM_COMP] " << m_comp[PARAM_COMP] << std::endl;
92  stream << "comp[NUMBER_ATOMS] " << m_comp[NUMBER_ATOMS] << std::endl;
93  stream << "origin: " << m_origin << std::endl;
94  }
95 
96  //*************************************************************
97  // READ
98  // void read(const std::string &comp_filename);
99  // void read(std::istream &stream);
100  // void read(ptree comp_ptree);
101 
102  //*************************************************************
103  // MISCELLANEOUS
104  void select_composition_axes(const Index &choice);
105 
106  //*************************************************************
107  // ACCESSORS
108 
109  const std::vector<Eigen::VectorXd> &spanning_end_members() const {
110  return m_spanning_end_members;
111  }
112 
115 
116  const std::vector<Eigen::MatrixXd> &comp() const { return m_comp; }
117 
118  const Eigen::VectorXd &origin() const { return m_origin; }
119 
120  const int &rank_of_space() const { return m_rank_of_space; }
121 
122  const int &number_of_references() const { return m_rank_of_space; }
123 
125  const std::vector<std::vector<std::string> > &allowed_occs() const {
126  return m_allowed_occs;
127  }
128 
130  const std::vector<std::string> &components() const { return m_components; }
131 
132  std::string composition_formula() const;
133 
134  const std::vector<ParamComposition> &allowed_list() const {
135  return m_allowed_list;
136  }
137 
138  //*************************************************************
139  // TEST FUNCTIONS
140 
141  // A ParamComposition is defined as 'set' if origin is non-empty, the
142  // prim pointer does not point to nullptr, rank_of_space is greater
143  // than 0, the comp matrices are non-empty and have their matrices
144  // such that they are square
145  bool is_set() const {
146  if (m_rank_of_space <= 0 || m_components.size() == 0 ||
147  m_origin.size() != m_components.size()) {
148  return false;
149  }
150  if (m_comp.size() == 2) {
151  return (m_comp[0].rows() == m_components.size() &&
152  m_comp[0].cols() == m_components.size() &&
153  m_comp[1].rows() == m_components.size() &&
154  m_comp[1].cols() == m_components.size());
155  } else {
156  return false;
157  }
158  return true;
159  }
160 
161  private:
164 
166  std::vector<std::string> m_components;
167 
170  std::vector<Eigen::MatrixXd> m_comp;
171 
174 
178 
181  std::vector<Eigen::VectorXd> m_spanning_end_members;
182 
186 
189  std::vector<ParamComposition> m_allowed_list;
190 };
191 
192 } // namespace CASM
193 #endif
void print_prim_end_members(std::ostream &stream) const
const std::vector< Eigen::MatrixXd > & comp() const
Eigen::VectorXd calc_num_atoms(const Eigen::VectorXd &param_composition) const
void print_origin_formula(std::ostream &stream, const int &stream_width) const
void select_composition_axes(const Index &choice)
Eigen::MatrixXd prim_end_members() const
Return all possible end members as row matrix.
static std::vector< std::string > string_components(ParamComposition::AllowedOccupants const &_allowed_occs)
AllowedOccupants m_allowed_occs
m_allowed_occs[b] is list of occupants allowed at site [b]
Eigen::VectorXd m_origin
The origin of the composition space.
void print_end_member_formula(const int &end_member_index, std::ostream &stream, const int &stream_width) const
void print_composition_matrices(std::ostream &stream) const
const std::vector< ParamComposition > & allowed_list() const
std::vector< Eigen::VectorXd > m_spanning_end_members
std::vector< std::string > m_components
The list of all allowed components, based on allowed_occs()
void print_composition_formula(std::ostream &stream, const int &stream_width) const
std::string composition_formula() const
Eigen::MatrixXd m_prim_end_members
void print_components(std::ostream &stream) const
std::vector< std::vector< std::string > > AllowedOccupants
const std::vector< std::vector< std::string > > & allowed_occs() const
For each sublattice, a list of occupants allowed on that sublattice.
std::vector< Eigen::MatrixXd > m_comp
const Eigen::VectorXd & origin() const
void print_member_formula(const Eigen::VectorXd &member, std::ostream &stream, const int &stream_width) const
void print_composition_axes(std::ostream &stream) const
void generate_composition_transf()
const int & rank_of_space() const
Eigen::VectorXd calc_param_composition(const Eigen::VectorXd &num_atoms_per_prim) const
void generate_composition_space(bool verbose=false)
Eigen::VectorXd calc(const Eigen::VectorXd &tcomp, const int &MODE)
std::vector< ParamComposition > m_allowed_list
void print_curr_composition_axes(std::ostream &stream) const
const std::vector< std::string > & components() const
Components are in order of appearance precedence in allowed_occs()
const std::vector< Eigen::VectorXd > & spanning_end_members() const
const int & number_of_references() const
ParamComposition calc_composition_object(const Eigen::VectorXd &torigin, const std::vector< Eigen::VectorXd > tspanning)
Eigen::Matrix3l transf_mat(const Lattice &prim_lat, const Lattice &super_lat)
Main CASM namespace.
Definition: APICommand.hh:8
Eigen::MatrixXd MatrixXd
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
Eigen::VectorXd VectorXd