CASM  1.1.0
A Clusters Approach to Statistical Mechanics
ChemicalReference.hh
Go to the documentation of this file.
1 #ifndef CASM_ChemicalReference
2 #define CASM_ChemicalReference
3 
4 #include "casm/clex/Reference.hh"
5 
6 namespace CASM {
7 namespace xtal {
8 class BasicStructure;
9 class Site;
10 } // namespace xtal
11 using xtal::BasicStructure;
12 using xtal::Site;
13 
14 class PrimClex;
15 
26 
29  std::function<Eigen::VectorXd(Configuration)> n,
30  std::function<double(Configuration)> e);
31 
33  std::map<std::string, double> species_num;
34 
37 };
38 
40  public:
41  typedef std::vector<ChemicalReferenceState> RefStateVec;
42  typedef std::map<std::string, RefStateVec> RefStateMap;
43  typedef Index size_type;
44 
45  static const std::string Name;
46  static const std::string Desc;
47 
49  explicit ChemicalReference(const BasicStructure &prim,
50  const Eigen::VectorXd &_global_ref,
51  SpecializedRef _supercell_ref = SpecializedRef(),
52  SpecializedRef _config_ref = SpecializedRef());
53 
56  template <typename RefStateIterator>
57  explicit ChemicalReference(const BasicStructure &prim, RefStateIterator begin,
58  RefStateIterator end, double tol);
59 
61  std::unique_ptr<ChemicalReference> clone() const;
62 
64  const BasicStructure &prim() const;
65 
66  // --- Global reference ---
67 
70  const Eigen::VectorXd &global() const;
71 
73  void set_global(const Eigen::VectorXd &ref);
74 
76  template <typename RefStateIterator>
77  void set_global(RefStateIterator begin, RefStateIterator end, double tol);
78 
81  const RefStateVec &global_ref_states() const;
82 
83  // --- Supercell specialized references ---
84 
88  const std::map<std::string, Eigen::VectorXd> &supercell() const;
89 
91  void set_supercell(const std::string &scelname, const Eigen::VectorXd &ref);
92 
94  template <typename RefStateIterator>
95  void set_supercell(const std::string &scelname, RefStateIterator begin,
96  RefStateIterator end, double tol);
97 
99  size_type erase_supercell(const std::string &scelname);
100 
103  const RefStateMap &supercell_ref_states() const;
104 
105  // --- Configuration specialized references ---
106 
110  const std::map<std::string, Eigen::VectorXd> &config() const;
111 
113  void set_config(const std::string &configname, const Eigen::VectorXd &ref);
114 
116  template <typename RefStateIterator>
117  void set_config(const std::string &configname, RefStateIterator begin,
118  RefStateIterator end, double tol);
119 
121  size_type erase_config(const std::string &configname);
122 
125  const RefStateMap &config_ref_states() const;
126 
129  template <typename RefStateIterator>
131  RefStateIterator begin,
132  RefStateIterator end, double tol);
133 
134  private:
138 
142  std::map<std::string, Eigen::VectorXd> &_supercell();
143 
147  std::map<std::string, Eigen::VectorXd> &_config();
148 
149  // --- For use in hyperplane() ------
150 
154  const BasicStructure &prim,
155  const std::vector<std::string> &struc_mol_name, Eigen::MatrixXd N,
156  Eigen::VectorXd E, double tol);
157 
159  ChemicalReference *_clone() const;
160 
161  // \brief non-owning pointer to const primitive BasicStructure
163 
164  // --- Store ChemicalReferenceState if known ----
165 
169 };
170 
174  double lin_alg_tol);
175 
178  // -- constructor --
179  ChemicalReferencePrinter(std::ostream &_stream, const ChemicalReference &_ref,
180  int _indent = 0, int _indent_incr = 2);
181 
182  // -- data --
183  std::ostream &stream;
184  int indent;
187  std::vector<std::string> struc_mol_name;
188 
189  void incr();
190 
191  void decr();
192 
193  // print regular string
194  void print(const std::string &str);
195 
196  // print plane as '<indent>mol_i(1): energy_per_species\n', for each molecule
197  void print(const Eigen::VectorXd &plane);
198 
199  // print plane as:
200  // \code
201  // <indent>mol_i(N_i)mol_j(N_j)...: energy_per_species //for each ref state
202  // ...
203  // \endcode
204  void print(const std::vector<ChemicalReferenceState> &ref_state_vec);
205 
206  // print supercell/config specific plane as:
207  // \code
208  // <indent>name:
209  // <indent> mol_i: energy_per_species // for each molecule
210  // \endcode
211  void print(const std::pair<std::string, Eigen::VectorXd> &_pair);
212 
213  // print supercell/config specific ref states as:
214  // \code
215  // <indent>name:
216  // <indent> mol_i(N_i)mol_j(N_j)...: energy_per_species // for each ref state
217  // \endcode
218  void print(const std::pair<std::string, std::vector<ChemicalReferenceState> >
219  &_pair);
220 
221  void print_global();
222 
223  void print_supercell();
224 
225  void print_supercell(const std::string &name);
226 
227  void print_config();
228 
229  void print_config(const std::string &name);
230 
231  void print_all();
232 };
233 
235 } // namespace CASM
236 
237 #endif
const std::map< std::string, Eigen::VectorXd > & supercell() const
const Access a map of scelname to reference for Supercell specialized references
size_type erase_supercell(const std::string &scelname)
Erase hyperplane reference specialized for a Supercell.
std::map< std::string, Eigen::VectorXd > & _supercell()
const Access a map of scelname to reference for Supercell specialized references
const BasicStructure * m_prim
static Eigen::VectorXd _calc_hyperplane(const BasicStructure &prim, const std::vector< std::string > &struc_mol_name, Eigen::MatrixXd N, Eigen::VectorXd E, double tol)
Convert a set of ChemicalReferenceState to a hyperplane, including checks.
std::vector< ChemicalReferenceState > RefStateVec
void set_config(const std::string &configname, const Eigen::VectorXd &ref)
Set hyperplane reference specialized for a Configuration.
const RefStateVec & global_ref_states() const
const Access a map of configname to RefStateVec for Supercell specialized references
void set_global(const Eigen::VectorXd &ref)
Set global hyperplane reference.
const RefStateMap & config_ref_states() const
const Access a map of configname to RefStateVec for Configuration specialized references
static const std::string Desc
const std::map< std::string, Eigen::VectorXd > & config() const
const Access a map of configname to reference for Configuration specialized references
static Eigen::VectorXd hyperplane(const BasicStructure &prim, RefStateIterator begin, RefStateIterator end, double tol)
Convert a set of ChemicalReferenceState to a hyperplane, including checks.
size_type erase_config(const std::string &configname)
Erase hyperplane reference specialized for a Configuration.
void set_supercell(const std::string &scelname, const Eigen::VectorXd &ref)
Set hyperplane reference specialized for a Supercell.
const Eigen::VectorXd & global() const
const Access the global reference
std::map< std::string, Eigen::VectorXd > & _config()
const Access a map of configname to reference for Configuration specialized references
std::unique_ptr< ChemicalReference > clone() const
Clone.
ChemicalReference(const BasicStructure &prim, const Eigen::VectorXd &_global_ref, SpecializedRef _supercell_ref=SpecializedRef(), SpecializedRef _config_ref=SpecializedRef())
Constructor.
const RefStateMap & supercell_ref_states() const
const Access a map of configname to RefStateVec for Supercell specialized references
ChemicalReference * _clone() const
Clone.
const BasicStructure & prim() const
Get primitive BasicStructure.
static const std::string Name
std::map< std::string, RefStateVec > RefStateMap
Eigen::VectorXd & _global()
Access the global reference.
Maps a Configuration to a scalar value via a hyperplane.
Definition: Reference.hh:68
std::map< std::string, Eigen::VectorXd > SpecializedRef
Definition: Reference.hh:70
PrimClex is the top-level data structure for a CASM project.
Definition: PrimClex.hh:55
BasicStructure specifies the lattice and atomic basis of a crystal.
std::string scelname(const Structure &prim, const Lattice &superlat)
Make supercell name name [deprecated].
Definition: Supercell.cc:497
ConfigIO::GenericConfigFormatter< jsonParser > config()
Definition: ConfigIO.cc:777
ConfigIO::GenericConfigFormatter< std::string > configname()
Constructs DataFormmaterDictionary containing all Configuration DatumFormatters.
Definition: ConfigIO.cc:563
Main CASM namespace.
Definition: APICommand.hh:8
Eigen::MatrixXd MatrixXd
ChemicalReference auto_chemical_reference(const PrimClex &primclex, double lin_alg_tol)
Automatically set ChemicalReference using calculated Configurations with 'extreme' compositions.
GenericDatumFormatter< std::string, DataObject > name()
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
Eigen::VectorXd VectorXd
pair_type ref
Definition: settings.cc:144
PrimClex * primclex
Definition: settings.cc:135
BasicStructure to help print ChemicalReference.
std::vector< std::string > struc_mol_name
void print(const std::string &str)
ChemicalReferencePrinter(std::ostream &_stream, const ChemicalReference &_ref, int _indent=0, int _indent_incr=2)
const ChemicalReference & ref
Stores the composition and energy in a single reference state.
std::map< std::string, double > species_num
Map of Molecule name : number of each species in reference state.
double energy_per_species
Energy in this reference state.