CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
PrimClex.hh
Go to the documentation of this file.
1 #ifndef PRIMCLEX_HH
2 #define PRIMCLEX_HH
3 
4 #include "casm/external/boost.hh"
5 
7 #include "casm/casm_io/Log.hh"
8 
10 #include "casm/clex/DoFManager.hh"
12 #include "casm/clex/Supercell.hh"
13 #include "casm/clex/Clexulator.hh"
17 
21 #include "casm/app/QueryHandler.hh"
22 
24 namespace CASM {
25 
26  class ECIContainer;
27 
28  template<typename T, typename U> class ConfigIterator;
29 
43  class PrimClex : public Logging {
53 
55 
58 
62 
64 
66  boost::container::stable_vector< Supercell > supercell_list;
67 
68 
71  bool m_has_composition_axes = false;
73 
77 
81 
82 
83  public:
84 
87 
88  // **** Constructors ****
89 
91  PrimClex(const Structure &_prim, const Logging &logging = Logging());
92 
95  PrimClex(const fs::path &_root, const Logging &logging = Logging());
96 
98  void refresh(bool read_settings = false,
99  bool read_composition = false,
100  bool read_chem_ref = false,
101  bool read_configs = false,
102  bool clear_clex = false);
103 
104  // **** Accessors ****
105 
107  std::string name() const;
108 
109 
110  // ** Directory path accessors **
111 
112  const DirectoryStructure &dir() const {
113  return m_dir;
114  }
115 
117  return m_settings;
118  }
119 
120  const ProjectSettings &settings() const {
121  return m_settings;
122  }
123 
124  double crystallography_tol() const {
125  return settings().crystallography_tol();
126  }
127 
128  double lin_alg_tol() const {
129  return settings().lin_alg_tol();
130  }
131 
133  fs::path get_path() const;
134 
136  fs::path get_path(const Index &scel_index) const;
137 
139  fs::path get_path(const Index &scel_index, const Index &config_index) const;
140 
143 
144 
145  // ** Composition accessors **
146 
148  bool has_composition_axes() const;
149 
151  const CompositionConverter &composition_axes() const;
152 
153  // ** Chemical reference **
154 
156  bool has_chemical_reference() const;
157 
159  const ChemicalReference &chemical_reference() const;
160 
161 
162  // ** Prim and Orbitree accessors **
163 
165  const Structure &get_prim() const;
166 
168  PrimNeighborList &nlist() const;
169 
171  bool vacancy_allowed() const;
172 
174  Index vacancy_index() const;
175 
176  // ** Supercell and Configuration accessors **
177 
179  boost::container::stable_vector<Supercell> &get_supercell_list();
180 
182  const boost::container::stable_vector<Supercell> &get_supercell_list() const;
183 
185  const Supercell &get_supercell(Index i) const;
186 
189 
191  const Supercell &get_supercell(std::string scellname) const;
192 
194  Supercell &get_supercell(std::string scellname);
195 
197  Supercell &get_supercell(const Lattice &lat);
198 
200  const Configuration &configuration(const std::string &configname) const;
201  Configuration &configuration(const std::string &configname);
202 
204  config_iterator config_begin();
205 
207  config_iterator config_end();
208 
210  config_const_iterator config_begin() const;
211 
213  config_const_iterator config_end() const;
214 
216  config_const_iterator config_cbegin() const;
217 
219  config_const_iterator config_cend() const;
220 
222  config_iterator selected_config_begin();
223 
225  config_iterator selected_config_end();
226 
228  config_const_iterator selected_config_cbegin() const;
229 
231  config_const_iterator selected_config_cend() const;
232 
233 
235 
236 
237  // **** Mutators ****
238 
241  void set_composition_axes(const CompositionConverter &_converter);
242 
243  // **** IO ****
244 
247  void write_config_list(std::set<std::string> scel_to_delete = {});
248 
249 
250  // **** Operators ****
251 
252  // **** Functions for preparing CLEXulators ****
253 
254  //Generate the global orbitree
255  //John G 011013
257 
259  void generate_supercells(const ScelEnumProps &enum_props);
260 
261  //Enumerate configurations for all the supercells that are stored in 'supercell_list'
262  void print_enum_info(std::ostream &stream);
263  void print_supercells(std::set<std::string> scel_to_delete = {}) const;
264  void print_supercells(std::ostream &stream, std::set<std::string> scel_to_delete = {}) const;
265  void read_supercells(std::istream &stream);
267 
268 
269  //ParamComposition i/o and calculators in PrimClex
270 
271  void read_config_list();
272 
274  void read_scel_props(int scel_index, const std::string &JSON_output);
276  void read_all_scel_props(const std::string &JSON_output);
277 
279  int amount_selected() const;
280 
281  bool contains_supercell(std::string scellname, Index &index) const;
282 
283  bool contains_supercell(const Supercell &scel) const;
284  bool contains_supercell(const Supercell &scel, Index &index) const;
285 
286  Index add_supercell(const Lattice &superlat);
287 
288  Index add_canonical_supercell(const Lattice &superlat);
289 
290  Eigen::Matrix3i calc_transf_mat(const Lattice &superlat) const;
291 
293  void set_global_dof_state(const Configuration &curr_config)const {
294  m_dof_manager.set_global_dof_state(curr_config);
295  };
296 
297  void set_local_dof_state(const Configuration &curr_config, Index l)const {
298  m_dof_manager.set_local_dof_state(curr_config, l);
299  };
300 
303  //void clear_reference_states();
304 
307  //void set_reference_state(int refid, const Configuration &config);
308 
314  //bool valid_reference_state(int refid, const Configuration &config, std::string &reason_invalid) const;
315 
320  //void set_reference_state_auto();
321 
328  //void generate_references();
329 
330  bool has_orbitree(const ClexDescription &key) const;
331  const SiteOrbitree &orbitree(const ClexDescription &key) const;
332 
333  bool has_clexulator(const ClexDescription &key) const;
334  Clexulator clexulator(const ClexDescription &key) const;
335 
336  bool has_eci(const ClexDescription &key) const;
337  const ECIContainer &eci(const ClexDescription &key) const;
338 
339  private:
340 
342  void _init();
343 
344  mutable std::map<ClexDescription, SiteOrbitree> m_orbitree;
345  mutable std::map<ClexDescription, Clexulator> m_clexulator;
346  mutable std::map<ClexDescription, ECIContainer> m_eci;
347 
348  };
349 
350 
352  SiteOrbitree make_orbitree(Structure &prim, const jsonParser &json, double _tol);
353 
355  void print_clexulator(const Structure &prim,
356  SiteOrbitree &tree,
357  const PrimNeighborList &nlist,
358  std::string class_name,
359  std::ostream &stream,
360  double xtal_tol);
361 
362 }
363 #endif
bool m_vacancy_allowed
Definition: PrimClex.hh:60
CompositionConverter m_comp_converter
Definition: PrimClex.hh:72
Eigen::MatrixXd MatrixXd
Clexulator clexulator(const ClexDescription &key) const
Definition: PrimClex.cc:1030
bool has_orbitree(const ClexDescription &key) const
const Access to global orbitree
Definition: PrimClex.cc:983
boost::container::stable_vector< Supercell > & get_supercell_list()
Access entire supercell_list.
Definition: PrimClex.cc:299
Structure prim
Definition: PrimClex.hh:59
void set_global_dof_state(const Configuration &config)
Definition: DoFManager.cc:60
int amount_selected() const
Count over the number of configurations that are selected in all supercells.
Definition: PrimClex.cc:700
void set_local_dof_state(const Configuration &curr_config, Index l) const
Definition: PrimClex.hh:297
Specifies a particular cluster expansion.
void write_config_list(std::set< std::string > scel_to_delete={})
Definition: PrimClex.cc:450
fs::path get_config_list_path() const
Return config_list.json file path.
Definition: PrimClex.cc:220
fs::path root
Definition: PrimClex.hh:54
ProjectSettings m_settings
Definition: PrimClex.hh:57
void print_clex_configurations()
void set_local_dof_state(const Configuration &config, Index l)
Definition: DoFManager.cc:52
const ProjectSettings & settings() const
Definition: PrimClex.hh:120
bool has_clexulator(const ClexDescription &key) const
Definition: PrimClex.cc:1018
Eigen::MatrixXd shift_vectors() const
private:
Definition: PrimClex.cc:973
Specification of CASM project directory structure.
const DirectoryStructure & dir() const
Definition: PrimClex.hh:112
ConfigIterator< Configuration, PrimClex > config_iterator
Definition: PrimClex.hh:85
fs::path get_path() const
Return casm project directory path.
Definition: PrimClex.cc:202
Structure specifies the lattice and atomic basis of a crystal.
Definition: Structure.hh:29
bool has_composition_axes() const
check if CompositionConverter object initialized
Definition: PrimClex.cc:231
void refresh(bool read_settings=false, bool read_composition=false, bool read_chem_ref=false, bool read_configs=false, bool clear_clex=false)
Reload PrimClex data from settings.
Definition: PrimClex.cc:90
void set_composition_axes(const CompositionConverter &_converter)
Sets the composition axes.
Definition: PrimClex.cc:749
std::map< ClexDescription, ECIContainer > m_eci
Definition: PrimClex.hh:346
Main CASM namespace.
Definition: complete.cpp:8
Represents a supercell of the primitive parent crystal structure.
Definition: Supercell.hh:37
std::string name() const
Return project name.
Definition: PrimClex.cc:194
config_iterator selected_config_end()
Configuration iterator: end.
Definition: PrimClex.cc:424
config_iterator config_begin()
Configuration iterator: begin.
Definition: PrimClex.cc:371
void generate_supercells(const ScelEnumProps &enum_props)
Use the given CSPECS.
Definition: PrimClex.cc:492
config_iterator config_end()
Configuration iterator: end.
Definition: PrimClex.cc:379
boost::container::stable_vector< Supercell > supercell_list
Contains all the supercells that were involved in the enumeration.
Definition: PrimClex.hh:66
bool has_chemical_reference() const
check if ChemicalReference object initialized
Definition: PrimClex.cc:245
void print_enum_info(std::ostream &stream)
ConfigIterator< const Configuration, const PrimClex > config_const_iterator
Definition: PrimClex.hh:86
bool vacancy_allowed() const
returns true if vacancy are an allowed species
Definition: PrimClex.cc:284
config_const_iterator selected_config_cend() const
const Configuration iterator: end
Definition: PrimClex.cc:438
double crystallography_tol() const
Definition: PrimClex.hh:124
Logging(Log &log=default_log(), Log &debug_log=default_log(), Log &err_log=default_err_log())
Definition: Log.hh:250
Read/modify settings of an already existing CASM project.
config_const_iterator selected_config_cbegin() const
const Configuration iterator: begin
Definition: PrimClex.cc:430
std::map< ClexDescription, SiteOrbitree > m_orbitree
Definition: PrimClex.hh:344
void read_all_scel_props(const std::string &JSON_output)
Call read_config_props on every Supercell.
EigenIndex Index
For long integer indexing:
DoFManager m_dof_manager
Definition: PrimClex.hh:63
Evaluates correlations.
Definition: Clexulator.hh:240
void read_supercells(std::istream &stream)
Definition: PrimClex.cc:605
config_const_iterator config_cend() const
const Configuration iterator: end
Definition: PrimClex.cc:407
DirectoryStructure m_dir
Definition: PrimClex.hh:56
ProjectSettings & settings()
Definition: PrimClex.hh:116
config_iterator selected_config_begin()
Configuration iterator: begin.
Definition: PrimClex.cc:413
Index m_vacancy_index
Definition: PrimClex.hh:61
const CompositionConverter & composition_axes() const
const Access CompositionConverter object
Definition: PrimClex.cc:237
Index add_canonical_supercell(const Lattice &superlat)
Definition: PrimClex.cc:511
const ChemicalReference & chemical_reference() const
const Access ChemicalReference object
Definition: PrimClex.cc:251
double lin_alg_tol() const
Definition: PrimClex.hh:128
config_const_iterator config_cbegin() const
const Configuration iterator: begin
Definition: PrimClex.cc:399
PrimNeighborList & nlist() const
Access to the primitive neighbor list.
Definition: PrimClex.cc:266
const Configuration & configuration(const std::string &configname) const
access configuration by name (of the form "scellname/[NUMBER]", e.g., ("SCEL1_1_1_1_0_0_0/0") ...
Definition: PrimClex.cc:347
bool has_eci(const ClexDescription &key) const
Definition: PrimClex.cc:1065
void print_supercells(std::set< std::string > scel_to_delete={}) const
Definition: PrimClex.cc:557
bool m_has_composition_axes
Definition: PrimClex.hh:71
notstd::cloneable_ptr< ChemicalReference > m_chem_ref
Definition: PrimClex.hh:76
Index add_supercell(const Lattice &superlat)
Definition: PrimClex.cc:550
ConfigIO::GenericConfigFormatter< std::string > configname()
Constructs DataFormmaterDictionary containing all Configuration DatumFormatters.
Definition: ConfigIO.cc:340
notstd::cloneable_ptr< PrimNeighborList > m_nlist
Definition: PrimClex.hh:80
Index vacancy_index() const
returns the index of vacancies in composition vectors
Definition: PrimClex.cc:290
Convert between number of species per unit cell and parametric composition.
The PrimNeighborList gives the coordinates of UnitCell that are neighbors of the origin UnitCell...
Definition: NeighborList.hh:24
double crystallography_tol() const
Get current project crystallography tolerance.
const Supercell & get_supercell(Index i) const
const Access supercell by index
Definition: PrimClex.cc:311
void print_clexulator(const Structure &prim, SiteOrbitree &tree, const PrimNeighborList &nlist, std::string class_name, std::ostream &stream, double xtal_tol)
Print clexulator.
Definition: PrimClex.cc:1219
PrimClex(const Structure &_prim, const Logging &logging=Logging())
Initial construction of a PrimClex, from a primitive Structure.
Definition: PrimClex.cc:21
A 'cloneable_ptr' can be used in place of 'unique_ptr'.
void read_scel_props(int scel_index, const std::string &JSON_output)
Fill up props of every configuration for a partucluar supercell. This will be deprecated when props d...
DoFManager holds multiple DoFEnvironments, and provides a simple interface for adding and managing Do...
Definition: DoFManager.hh:13
void read_config_list()
Definition: PrimClex.cc:680
void set_global_dof_state(const Configuration &curr_config) const
Set internal values of each DoFEnvironment.
Definition: PrimClex.hh:293
bool contains_supercell(std::string scellname, Index &index) const
Definition: PrimClex.cc:709
std::map< ClexDescription, Clexulator > m_clexulator
Definition: PrimClex.hh:345
SiteOrbitree make_orbitree(Structure &prim, const jsonParser &json, double _tol)
Make orbitree. For now specifically global.
Definition: PrimClex.cc:1097
const SiteOrbitree & orbitree(const ClexDescription &key) const
Definition: PrimClex.cc:996
void _init()
Initialization routines.
Definition: PrimClex.cc:49
Eigen::Matrix3i calc_transf_mat(const Lattice &superlat) const
Definition: PrimClex.cc:731
A Configuration represents the values of all degrees of freedom in a Supercell.
const Structure & get_prim() const
const Access to primitive Structure
Definition: PrimClex.cc:260
const ECIContainer & eci(const ClexDescription &key) const
Definition: PrimClex.cc:1076
double lin_alg_tol() const
Get current project linear algebra tolerance.
A sparse container of ECI values and their corresponding orbit indices.
Definition: ECIContainer.hh:12