CASM  1.1.0
A Clusters Approach to Statistical Mechanics
Configuration.hh
Go to the documentation of this file.
1 #ifndef CASM_Configuration
2 #define CASM_Configuration
3 
4 #include <map>
5 #include <memory>
6 
8 #include "casm/clex/ConfigDoF.hh"
14 #include "casm/database/Cache.hh"
16 #include "casm/database/Named.hh"
17 #include "casm/misc/Comparisons.hh"
19 
20 namespace CASM {
21 namespace xtal {
22 class Molecule;
23 class UnitCellCoord;
24 } // namespace xtal
25 using xtal::Molecule;
26 using xtal::UnitCellCoord;
27 
28 class IntegralCluster;
29 class PrimClex;
30 class Supercell;
31 class Clexulator;
32 class ConfigIsEquivalent;
33 template <typename ConfigType, typename IsEqualImpl>
34 class GenericConfigCompare;
36 
37 struct ConfigInsertResult;
38 struct RefToCanonicalPrim;
39 
48 
49 typedef ConfigCanonicalForm<
52 
64 // the supercell (i.e. the translationally unique perturbation), plus the
65 // values of the
75  public:
76  //********* CONSTRUCTORS *********
77 
88  explicit Configuration(
89  std::shared_ptr<Supercell const> const &_supercell_ptr);
90 
101  explicit Configuration(std::shared_ptr<Supercell const> const &_supercell_ptr,
102  ConfigDoF const &_dof);
103 
106  static Configuration zeros(
107  const std::shared_ptr<Supercell const> &_supercell_ptr);
108 
111  static Configuration zeros(
112  const std::shared_ptr<Supercell const> &_supercell_ptr, double _tol);
113 
114  // *** The following constructors should be avoided in new code, if possible
115  //
116  // They are currently still required in some code. In the future:
117  // - Configuration will make exclusive use of std::shared_ptr<Supercell
118  // const>
119  // - The jsonConstructor<Configuration>::from_json method will be used to
120  // construct Configuration from JSON
121 
129  explicit Configuration(Supercell const &_supercell);
130 
138  explicit Configuration(const Supercell &_supercell, const ConfigDoF &_dof);
139 
145  static Configuration zeros(Supercell const &_scel);
146 
152  static Configuration zeros(Supercell const &_scel, double _tol);
153 
154  // ******** Supercell **********************
155 
157  const Supercell &supercell() const;
158 
159  const Lattice &ideal_lattice() const;
160 
162  Index size() const;
163 
165  UnitCellCoord uccoord(Index site_l) const;
166 
168  Index linear_index(const UnitCellCoord &bijk) const;
169 
171  int sublat(Index site_l) const;
172 
173  // ******** Degrees of Freedom **************
174  //
175  // ** Note: Calculated properties are not automatically updated when dof are
176  // changed, **
177  // ** nor are the written records automatically updated **
178 
180  const ConfigDoF &configdof() const { return m_configdof; }
181 
186  _modify_dof();
187  return m_configdof;
188  }
189 
193  void clear();
194 
195  // ----- Occupation ------------
196 
200  void init_occupation();
201 
220  void set_occupation(Eigen::Ref<const Eigen::VectorXi> const &_occupation) {
221  configdof().set_occupation(_occupation);
222  }
223 
236  Eigen::VectorXi const &occupation() const { return configdof().occupation(); }
237 
250  void set_occ(Index site_l, int val);
251 
262  const int &occ(Index site_l) const { return configdof().occ(site_l); }
263 
271  const Molecule &mol(Index site_l) const;
272 
274  bool has_occupation() const { return configdof().has_occupation(); }
275 
279  // void clear_occupation();
280 
281  // ******** Comparisons, Symmetry, Crystallography ******
282 
286  bool operator<(const Configuration &B) const;
287 
288  ConfigCompare less() const;
289 
291 
293  bool is_primitive() const;
294 
298 
300  Configuration primitive() const;
301 
304 
307  std::vector<PermuteIterator> factor_group() const;
308 
312  std::vector<PermuteIterator> invariant_subgroup() const;
313 
316  bool is_canonical() const;
317 
319  int multiplicity() const;
320 
322  std::vector<PermuteIterator> point_group() const;
323 
325  std::string point_group_name() const;
326 
330 
331  //********** Composition ***********
332 
333  // Returns composition on each sublattice: sublat_comp[ prim basis site /
334  // sublattice][ molecule_type]
335  // molucule_type is ordered as in the Prim structure's site_occupant list
336  // for that basis site (includes vacancies)
337  std::vector<Eigen::VectorXd> sublattice_composition() const;
338 
339  // Returns number of each molecule by sublattice:
340  // sublat_num_each_molecule[ prim basis site / sublattice ][ molecule_type]
341  // molucule_type is ordered as in the Prim structure's site_occupant list
342  // for that basis site
343  std::vector<Eigen::VectorXi> sublat_num_each_molecule() const;
344 
345  // Returns composition, not counting vacancies
346  // composition[ molecule_type ]: molecule_type ordered as prim structure's
347  // get_struc_molecule(), with [Va]=0.0
349 
350  // Returns composition, including vacancies
351  // composition[ molecule_type ]: molecule_type ordered as prim structure's
352  // get_struc_molecule()
354 
357  Eigen::VectorXi num_each_molecule() const;
358 
361 
365 
366  //********* IO ************
367 
370  ConfigInsertResult insert(bool primitive_only = false) const;
371 
372  // /// Writes the Configuration to JSON
373  // jsonParser &to_json(jsonParser &json) const;
374  //
375  // /// Reads the Configuration from JSON
376  // void from_json(const jsonParser &json, const Supercell &scel,
377  // std::string _id);
378  //
379  // /// Reads the Configuration from JSON
380  // void from_json(const jsonParser &json, const PrimClex &primclex,
381  // std::string _configname);
382 
384  static std::pair<std::string, std::string> split_name(std::string configname);
385 
386  private:
387  friend struct Comparisons<Calculable<CRTPBase<Configuration>>>;
388  friend class DB::Named<CRTPBase<Configuration>>;
389 
390  std::string generate_name_impl() const;
391 
396  bool eq_impl(const Configuration &B) const;
397 
400 
402  std::shared_ptr<Supercell const> m_supercell_ptr;
403 
406 };
407 
417 
420 
423 
426 
429 };
430 
440  RefToCanonicalPrim(const Configuration &_config);
441 
442  std::string name() const;
443 
448  Eigen::Matrix3i transf_mat;
449 };
450 
461 Configuration sub_configuration(std::shared_ptr<Supercell const> sub_scel_ptr,
462  const Configuration &super_config,
463  const UnitCell &origin = UnitCell(0, 0, 0));
464 
467 
470  Clexulator const &clexulator);
471 
473 Eigen::VectorXd corr_contribution(Index linear_unitcell_index,
474  const Configuration &config,
475  Clexulator const &clexulator);
476 
479 Eigen::VectorXd point_corr(Index linear_unitcell_index, Index neighbor_index,
480  const Configuration &config,
481  Clexulator const &clexulator);
482 
486  Clexulator const &clexulator, DoFKey &key);
487 
490 
493 
495 double n_vacancy(const Configuration &config);
496 
498 double n_species(const Configuration &config);
499 
503 
507 
509 double energy(const Configuration &config);
510 
513 
515 double reference_energy(const Configuration &config);
516 
519 
521 double formation_energy(const Configuration &config);
522 
525 
528 
531 
534 double rms_force(const Configuration &_config);
535 
538 double atomic_deformation(const Configuration &_config);
539 
541 double lattice_deformation(const Configuration &_config);
542 
544 double volume_relaxation(const Configuration &_config);
545 
547 double relaxed_magmom(const Configuration &_config);
548 
550 double relaxed_magmom_per_species(const Configuration &_config);
551 
555 
559 
563  const Configuration &_config2);
564 
568  const Configuration &_config2);
569 
573  const Configuration &_bg, IntegralCluster &_clust);
574 
577 bool is_primitive(const Configuration &_config);
578 
581 bool is_canonical(const Configuration &_config);
582 
586 
588 std::string diff_trans_endpoint_of(const Configuration &_config);
589 
590 bool has_energy(const Configuration &_config);
591 
592 bool has_reference_energy(const Configuration &_config);
593 
594 bool has_formation_energy(const Configuration &_config);
595 
596 bool has_rms_force(const Configuration &_config);
597 
598 bool has_atomic_deformation(const Configuration &_config);
599 
600 bool has_lattice_deformation(const Configuration &_config);
601 
602 bool has_volume_relaxation(const Configuration &_config);
603 
604 bool has_relaxed_magmom(const Configuration &_config);
605 
606 bool has_relaxed_mag_basis(const Configuration &_config);
607 
610 Eigen::VectorXd correlations(const ConfigDoF &configdof, const Supercell &scel,
611  Clexulator const &clexulator);
612 
614 Eigen::VectorXd corr_contribution(Index linear_unitcell_index,
615  const ConfigDoF &configdof,
616  const Supercell &scel,
617  Clexulator const &clexulator);
618 
621 Eigen::VectorXd point_corr(Index linear_unitcell_index, Index neighbor_index,
622  const ConfigDoF &configdof, const Supercell &scel,
623  Clexulator const &clexulator);
624 
628  const Supercell &scel,
629  Clexulator const &clexulator, DoFKey &key);
630 
633 Eigen::VectorXi num_each_molecule(const ConfigDoF &configdof,
634  const Supercell &scel);
635 
638 Eigen::VectorXd comp_n(const ConfigDoF &configdof, const Supercell &scel);
639 
642 } // namespace CASM
643 
644 #endif
Evaluates correlations.
Definition: Clexulator.hh:440
Implements canonical form finding for Configuration and DiffTransConfiguration.
std::vector< PermuteIterator > invariant_subgroup() const
bool has_occupation() const
Definition: ConfigDoF.cc:60
Eigen::VectorXi const & occupation() const
Const reference occupation values.
Definition: ConfigDoF.cc:56
int & occ(Index i)
Reference occupation value on site i.
Definition: ConfigDoF.cc:34
void set_occupation(Eigen::Ref< const Eigen::VectorXi > const &_occupation)
Set occupation values.
Definition: ConfigDoF.cc:43
Class for comparison of Configurations (with the same Supercell)
Eigen::VectorXd num_each_component() const
bool is_canonical() const
const ConfigDoF & configdof() const
const Access the DoF
static Configuration zeros(const std::shared_ptr< Supercell const > &_supercell_ptr)
void set_occupation(Eigen::Ref< const Eigen::VectorXi > const &_occupation)
Set occupant variables.
Configuration primitive() const
Return the primitive Configuration.
Eigen::VectorXi const & occupation() const
Occupant variables.
std::shared_ptr< Supercell const > m_supercell_ptr
Used when constructing temporary Configuration in non-canonical Supercell.
std::vector< Eigen::VectorXd > sublattice_composition() const
Configuration & apply_sym(const PermuteIterator &it)
Transform Configuration from PermuteIterator via *this = permute_iterator * *this.
void clear()
Clear all DoF.
ConfigIsEquivalent equal_to() const
bool eq_impl(const Configuration &B) const
operator== comparison of Configuration, via ConfigEqual
bool has_occupation() const
True if Configuration has occupation DoF.
Configuration(std::shared_ptr< Supercell const > const &_supercell_ptr)
Eigen::VectorXi num_each_molecule() const
Eigen::VectorXd true_composition() const
const Lattice & ideal_lattice() const
std::vector< PermuteIterator > point_group() const
Returns the point group that leaves the Configuration unchanged.
PermuteIterator find_translation() const
Returns a PermuteIterator corresponding to the first non-zero pure translation that maps the Configur...
std::vector< Eigen::VectorXi > sublat_num_each_molecule() const
std::vector< PermuteIterator > invariant_subgroup() const
Returns the subgroup of the Supercell factor group that leaves the Configuration unchanged.
Index linear_index(const UnitCellCoord &bijk) const
Return the linear index corresponding to integral coordinates.
ConfigInsertResult insert(bool primitive_only=false) const
Insert this configuration (in primitive & canonical form) in the database.
Supercell const * m_supercell
Pointer to the Supercell for this Configuration.
std::string generate_name_impl() const
Returns a Configuration name.
UnitCellCoord uccoord(Index site_l) const
Get the UnitCellCoord for a given linear site index.
const Molecule & mol(Index site_l) const
Molecule on site l.
Eigen::VectorXd param_composition() const
Returns parametric composition, as calculated using PrimClex::param_comp.
const int & occ(Index site_l) const
Occupant variable on site l.
void init_occupation()
Set occupant variables to background structure.
static std::pair< std::string, std::string > split_name(std::string configname)
Split configuration name string into scelname and config id.
int multiplicity() const
Get symmetric multiplicity, excluding translations.
ConfigDoF & configdof()
Access the DoF.
ConfigCompare less() const
const Supercell & supercell() const
Get the Supercell for this Configuration.
ConfigDoF m_configdof
Degrees of Freedom.
Eigen::VectorXd composition() const
Configuration in_canonical_supercell() const
Returns the canonical form Configuration in the canonical Supercell.
void set_occ(Index site_l, int val)
Set occupant variable on site l.
std::string point_group_name() const
Returns the point group that leaves the Configuration unchanged.
int sublat(Index site_l) const
Get the basis site index for a given linear linear site index.
Index size() const
Returns number of sites, NOT the number of primitives that fit in here.
bool is_primitive() const
Check if this is a primitive Configuration.
bool operator<(const Configuration &B) const
Clear occupation.
std::vector< PermuteIterator > factor_group() const
Returns the subgroup of the Supercell factor group that leaves the Configuration unchanged.
Class for less than comparison of Configurations implemented via a ConfigTypeIsEqual class that also ...
Implements PrimClex dependent functions.
Definition: HasSupercell.hh:17
PrimClex is the top-level data structure for a CASM project.
Definition: PrimClex.hh:55
Represents a supercell of the primitive parent crystal structure.
Definition: Supercell.hh:51
SymOp is the Coordinate representation of a symmetry operation it keeps fraction (FRAC) and Cartesian...
Definition: SymOp.hh:28
Class representing a Molecule.
Definition: Molecule.hh:93
Unit Cell Coordinates.
Unit Cell Indices.
Base class for CRTP pattern.
Definition: CRTPBase.hh:8
double reference_energy(const Configuration &config)
Returns the reference energy, normalized per unit cell.
bool has_relaxed_magmom(const Configuration &_config)
Eigen::MatrixXd relaxed_forces(const Configuration &_config)
relaxed forces of configuration, determined from DFT (eV/Angstr.), as a 3xN matrix
bool has_volume_relaxation(const Configuration &_config)
double formation_energy(const Configuration &config)
Returns the formation energy, normalized per unit cell.
bool has_reference_energy(const Configuration &_config)
double formation_energy_per_species(const Configuration &config)
Returns the formation energy, normalized per species.
double clex_formation_energy_per_species(const Configuration &config)
Returns the formation energy, normalized per species.
double atomic_deformation(const Configuration &_config)
Cost function that describes the degree to which basis sites have relaxed.
Eigen::VectorXi num_each_molecule(const ConfigDoF &configdof, const Supercell &scel)
Returns num_each_molecule(molecule_type), where 'molecule_type' is ordered as Structure::get_struc_mo...
ConfigCanonicalForm< HasSupercell< Comparisons< Calculable< CRTPBase< Configuration > > > > > ConfigurationBase
std::string diff_trans_endpoint_of(const Configuration &_config)
returns which diff_trans _config is an endpoint of
Eigen::VectorXd correlations(const Configuration &config, Clexulator const &clexulator)
Returns correlations using 'clexulator'.
double clex_formation_energy(const Configuration &config)
Returns the formation energy, normalized per unit cell.
Eigen::VectorXd corr_contribution(Index linear_unitcell_index, const Configuration &config, Clexulator const &clexulator)
Returns correlation contribution from a single unit cell, not normalized.
bool is_diff_trans_endpoint(const Configuration &_config)
returns true if _config is an endpoint of any existing diff_trans_config
Eigen::VectorXd comp(const Configuration &config)
Returns parametric composition, as calculated using PrimClex::param_comp.
Configuration closest_setting(const Configuration &_config1, const Configuration &_config2)
Configuration sub_configuration(std::shared_ptr< Supercell const > sub_scel_ptr, const Configuration &super_config, const UnitCell &origin=UnitCell(0, 0, 0))
Returns the sub-configuration that fills a particular Supercell.
double rms_force(const Configuration &_config)
Root-mean-square forces of relaxed configurations, determined from DFT (eV/Angstr....
bool has_lattice_deformation(const Configuration &_config)
bool has_rms_force(const Configuration &_config)
double n_species(const Configuration &config)
Returns the total number species per unit cell.
bool is_primitive(const Configuration &_config)
returns true if _config describes primitive cell of the configuration it describes
double volume_relaxation(const Configuration &_config)
Change in volume due to relaxation, expressed as the ratio V/V_0.
double reference_energy_per_species(const Configuration &config)
Returns the reference energy, normalized per species.
Eigen::MatrixXd gradcorrelations(const Configuration &config, Clexulator const &clexulator, DoFKey &key)
Returns gradient correlations using 'clexulator', with respect to DoF 'dof_type'.
Eigen::VectorXd comp_n(const Configuration &config)
Returns the composition, as number of each species per unit cell.
IntegralCluster config_diff(const Configuration &_config1, const Configuration &_config2)
Returns an Integral Cluster representing the perturbed sites between the configs.
double relaxed_magmom(const Configuration &_config)
Returns the relaxed magnetic moment, normalized per unit cell.
Eigen::VectorXd site_frac(const Configuration &config)
Returns the composition as site fraction, in the order of Structure::get_struc_molecule.
Configuration make_configuration(const PrimClex &primclex, std::string name)
Make Configuration from name string.
double lattice_deformation(const Configuration &_config)
Cost function that describes the degree to which lattice has relaxed.
double energy(const Configuration &config)
Returns the energy, normalized per unit cell.
double n_vacancy(const Configuration &config)
Returns the vacancy composition, as number per unit cell.
Configuration config_clip(const Configuration &_config, const Configuration &_bg, IntegralCluster &_clust)
Returns a Configuration with the sites in _clust clipped from _config and placed in _bg.
Eigen::VectorXd point_corr(Index linear_unitcell_index, Index neighbor_index, const Configuration &config, Clexulator const &clexulator)
Returns point correlations from a single site, normalized by cluster orbit size.
double energy_per_species(const Configuration &config)
Returns the energy, normalized per species.
bool has_formation_energy(const Configuration &_config)
Eigen::VectorXd species_frac(const Configuration &config)
Returns the composition as species fraction, with [Va] = 0.0, in the order of Structure::get_struc_mo...
bool has_atomic_deformation(const Configuration &_config)
bool is_canonical(const Configuration &_config)
returns true if no symmetry transformation applied to _config will increase its lexicographic order
bool has_relaxed_mag_basis(const Configuration &_config)
double relaxed_magmom_per_species(const Configuration &_config)
Returns the relaxed magnetic moment, normalized per species.
bool has_energy(const Configuration &_config)
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
std::string DoFKey
Definition: DoFDecl.hh:7
GenericDatumFormatter< std::string, DataObject > name()
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
Eigen::VectorXd VectorXd
PrimClex * primclex
Definition: settings.cc:135
Holds results of Configuration::insert.
bool insert_canonical
True if canonical configuration did not exist before insertion.
iterator primitive_it
Iterator pointing at primitive.
bool insert_primitive
True if primitive did not exist before insertion.
iterator canonical_it
Iterator pointing at canonical, if existing.
DB::DatabaseIterator< Configuration > iterator
Operations that transform a canonical primitive configuration to any equivalent.
std::string name() const
Configuration prim_canon_config
PermuteIterator from_canonical_config
Eigen::Matrix3i transf_mat
RefToCanonicalPrim(const Configuration &_config)
Get operations that transform canonical primitive to this.
Implements other comparisons in terms of '<'.
Definition: Comparisons.hh:25