CASM  1.1.0
A Clusters Approach to Statistical Mechanics
ConfigIO.hh
Go to the documentation of this file.
1 #ifndef CONFIGIO_HH
2 #define CONFIGIO_HH
3 
10 
11 namespace CASM {
12 
18 
19 class Configuration;
20 template <typename DataObject>
21 class Norm;
22 class jsonParser;
23 
28 namespace ConfigIO_impl {
29 
35 class MolDependent : public VectorXdAttribute<Configuration> {
36  public:
37  MolDependent(const std::string &_name, const std::string &_desc)
38  : VectorXdAttribute<Configuration>(_name, _desc) {}
39 
40  // --- Specialized implementation -----------
41 
44  bool parse_args(const std::string &args) override;
45 
47  bool init(const Configuration &_tmplt) const override;
48 
50  std::vector<std::string> col_header(
51  const Configuration &_tmplt) const override;
52 
53  private:
54  mutable std::vector<std::string> m_mol_names;
55 };
56 
57 } // namespace ConfigIO_impl
58 
60 namespace ConfigIO {
61 
64 template <typename ValueType>
66 
67 template <typename ValueType>
69 
72 class Comp : public VectorXdAttribute<Configuration> {
73  public:
74  static const std::string Name;
75 
76  static const std::string Desc;
77 
79 
80  // --- Required implementations -----------
81 
83  Eigen::VectorXd evaluate(const Configuration &config) const override;
84 
86  std::unique_ptr<Comp> clone() const {
87  return std::unique_ptr<Comp>(this->_clone());
88  }
89 
90  // --- Specialized implementation -----------
91 
93  bool validate(const Configuration &config) const override;
94 
96  bool parse_args(const std::string &args) override;
97 
99  std::vector<std::string> col_header(
100  const Configuration &_tmplt) const override;
101 
102  private:
104  Comp *_clone() const override { return new Comp(*this); }
105 };
106 
110  public:
111  static const std::string Name;
112 
113  static const std::string Desc;
114 
116 
117  // --- Required implementations -----------
118 
120  Eigen::VectorXd evaluate(const Configuration &config) const override;
121 
123  std::unique_ptr<CompN> clone() const {
124  return std::unique_ptr<CompN>(this->_clone());
125  }
126 
127  private:
129  CompN *_clone() const override { return new CompN(*this); }
130 };
131 
138  public:
139  static const std::string Name;
140 
141  static const std::string Desc;
142 
144 
145  // --- Required implementations -----------
146 
148  Eigen::VectorXd evaluate(const Configuration &config) const override;
149 
151  std::unique_ptr<SiteFrac> clone() const {
152  return std::unique_ptr<SiteFrac>(this->_clone());
153  }
154 
155  private:
157  SiteFrac *_clone() const override { return new SiteFrac(*this); }
158 };
159 
168  public:
169  static const std::string Name;
170 
171  static const std::string Desc;
172 
174 
175  // --- Required implementations -----------
176 
178  Eigen::VectorXd evaluate(const Configuration &config) const override;
179 
181  std::unique_ptr<AtomFrac> clone() const {
182  return std::unique_ptr<AtomFrac>(this->_clone());
183  }
184 
185  private:
187  AtomFrac *_clone() const override { return new AtomFrac(*this); }
188 };
189 
192 
197 class Corr : public VectorXdAttribute<Configuration> {
198  public:
199  static const std::string Name;
200 
201  static const std::string Desc;
202 
204 
205  Corr(const Clexulator &clexulator)
207  m_clexulator(clexulator) {}
208 
209  // --- Required implementations -----------
210 
212  Eigen::VectorXd evaluate(const Configuration &config) const override;
213 
215  std::unique_ptr<Corr> clone() const {
216  return std::unique_ptr<Corr>(this->_clone());
217  }
218 
219  // --- Specialized implementation -----------
220 
222  bool init(const Configuration &_tmplt) const override;
223 
226  bool parse_args(const std::string &args) override;
227 
228  private:
230  Corr *_clone() const override { return new Corr(*this); }
231 
233  mutable std::string m_clex_name;
234 };
235 
240 class CorrContribution : public VectorXdAttribute<Configuration> {
241  public:
242  static const std::string Name;
243 
244  static const std::string Desc;
245 
249  m_clex_name("") {}
250 
251  CorrContribution(const Clexulator &clexulator)
254  m_clexulator(clexulator) {}
255 
256  // --- Required implementations -----------
257 
259  Eigen::VectorXd evaluate(const Configuration &config) const override;
260 
262  std::unique_ptr<CorrContribution> clone() const {
263  return std::unique_ptr<CorrContribution>(this->_clone());
264  }
265 
266  // --- Specialized implementation -----------
267 
269  bool init(const Configuration &_tmplt) const override;
270 
271  bool parse_args(const std::string &args) override;
272 
273  private:
275  CorrContribution *_clone() const override {
276  return new CorrContribution(*this);
277  }
278 
281  mutable std::string m_clex_name;
282 };
283 
289 class PointCorr : public VectorXdAttribute<Configuration> {
290  public:
291  static const std::string Name;
292 
293  static const std::string Desc;
294 
298  m_neighbor_index(0),
299  m_clex_name("") {}
300 
301  PointCorr(const Clexulator &clexulator)
304  m_neighbor_index(0),
305  m_clexulator(clexulator) {}
306 
307  // --- Required implementations -----------
308 
310  Eigen::VectorXd evaluate(const Configuration &config) const override;
311 
313  std::unique_ptr<PointCorr> clone() const {
314  return std::unique_ptr<PointCorr>(this->_clone());
315  }
316 
317  // --- Specialized implementation -----------
318 
320  bool init(const Configuration &_tmplt) const override;
321 
324  bool parse_args(const std::string &args) override;
325 
326  private:
328  PointCorr *_clone() const override { return new PointCorr(*this); }
329 
333  mutable std::string m_clex_name;
334 };
335 
340 class GradCorr : public MatrixXdAttribute<Configuration> {
341  public:
342  static const std::string Name;
343 
344  static const std::string Desc;
345 
347 
348  GradCorr(const Clexulator &clexulator)
350  m_clexulator(clexulator) {}
351 
352  // --- Required implementations -----------
353 
355  Eigen::MatrixXd evaluate(const Configuration &config) const override;
356 
358  std::unique_ptr<GradCorr> clone() const {
359  return std::unique_ptr<GradCorr>(this->_clone());
360  }
361 
362  // --- Specialized implementation -----------
363 
365  bool init(const Configuration &_tmplt) const override;
366 
370  bool parse_args(const std::string &args) override;
371 
372  private:
374  GradCorr *_clone() const override { return new GradCorr(*this); }
375 
377  mutable std::string m_clex_name;
378  mutable DoFKey m_key;
379 };
380 
385 class Clex : public ScalarAttribute<Configuration> {
386  public:
387  static const std::string Name;
388 
389  static const std::string Desc;
390 
391  Clex();
392 
395  Clex(const Clexulator &clexulator, const ECIContainer &eci,
396  const Norm<Configuration> &norm);
397 
398  // --- Required implementations -----------
399 
401  double evaluate(const Configuration &config) const override;
402 
404  std::unique_ptr<Clex> clone() const;
405 
406  // --- Specialized implementation -----------
407 
408  // validate: predicted property can always be calculated if clexulator and
409  // eci were obtained ok
410 
413  bool init(const Configuration &_tmplt) const override;
414 
417  bool parse_args(const std::string &args) override;
418 
421  std::string short_header(const Configuration &_tmplt) const override {
422  return "clex(" + m_clex_name + ")";
423  }
424 
425  private:
427  double _norm(const Configuration &config) const;
428 
430  Clex *_clone() const override;
431 
432  mutable std::string m_clex_name;
436 };
437 } // namespace ConfigIO
438 
439 namespace ConfigIO {
440 
443 // void initialize_formatting_dictionary(DataFormatterDictionary<Configuration>
444 // &dict);
445 
447 
449 
451 
453 
455 
457 
459 
461 
463 
465 
467 
469 
471 
473 
475 
477 
479 
481 
483 
485 
487 
489 
491 
493 
495 
497 
499 
501 
503 
505 } // namespace ConfigIO
506 
507 template <>
510 
511 template <>
514 
515 template <>
518 
519 template <>
522 
523 template <>
526 
527 template <>
530 
533 } // namespace CASM
534 
535 #endif
Abstract base class for creating 1D DatumFormatter.
A DatumFormatter that returns a value of specified 2d container.
Base class for creating scalar DatumFormatter.
Evaluates correlations.
Definition: Clexulator.hh:440
Returns fraction of all species that are a particular species, excluding vacancies.
Definition: ConfigIO.hh:167
std::unique_ptr< AtomFrac > clone() const
Clone using copy constructor.
Definition: ConfigIO.hh:181
Eigen::VectorXd evaluate(const Configuration &config) const override
Returns the atom fraction.
Definition: ConfigIO.cc:170
static const std::string Name
Definition: ConfigIO.hh:169
AtomFrac * _clone() const override
Clone using copy constructor.
Definition: ConfigIO.hh:187
static const std::string Desc
Definition: ConfigIO.hh:171
Returns predicted formation energy.
Definition: ConfigIO.hh:385
double evaluate(const Configuration &config) const override
Returns the atom fraction.
Definition: ConfigIO.cc:486
std::string m_clex_name
Definition: ConfigIO.hh:432
std::string short_header(const Configuration &_tmplt) const override
Short header returns: 'clex(formation_energy)', 'clex(formation_energy_per_species)',...
Definition: ConfigIO.hh:421
double _norm(const Configuration &config) const
Returns the normalization.
Definition: ConfigIO.cc:551
bool init(const Configuration &_tmplt) const override
If not yet initialized, use the global clexulator and eci from the PrimClex.
Definition: ConfigIO.cc:497
notstd::cloneable_ptr< Norm< Configuration > > m_norm
Definition: ConfigIO.hh:435
ECIContainer m_eci
Definition: ConfigIO.hh:434
bool parse_args(const std::string &args) override
Expects 'clex', 'clex(formation_energy)', or 'clex(formation_energy_per_species)'.
Definition: ConfigIO.cc:518
Clex * _clone() const override
Clone using copy constructor.
Definition: ConfigIO.cc:556
Clexulator m_clexulator
Definition: ConfigIO.hh:433
static const std::string Name
Definition: ConfigIO.hh:387
static const std::string Desc
Definition: ConfigIO.hh:389
std::unique_ptr< Clex > clone() const
Clone using copy constructor.
Definition: ConfigIO.cc:491
Calculate param composition of a Configuration.
Definition: ConfigIO.hh:72
Comp * _clone() const override
Clone using copy constructor.
Definition: ConfigIO.hh:104
bool validate(const Configuration &config) const override
Returns true if the PrimClex has composition axes.
Definition: ConfigIO.cc:107
static const std::string Desc
Definition: ConfigIO.hh:76
bool parse_args(const std::string &args) override
Expects arguments of the form 'comp' or 'comp(a)', 'comp(b)', etc.
Definition: ConfigIO.cc:112
static const std::string Name
Definition: ConfigIO.hh:74
std::unique_ptr< Comp > clone() const
Clone using copy constructor.
Definition: ConfigIO.hh:86
Eigen::VectorXd evaluate(const Configuration &config) const override
Returns the parametric composition.
Definition: ConfigIO.cc:102
std::vector< std::string > col_header(const Configuration &_tmplt) const override
col_header returns: {'comp(a)', 'comp(b)', ...'}
Definition: ConfigIO.cc:124
Calculate number of each species per unit cell.
Definition: ConfigIO.hh:109
std::unique_ptr< CompN > clone() const
Clone using copy constructor.
Definition: ConfigIO.hh:123
Eigen::VectorXd evaluate(const Configuration &config) const override
Returns the parametric composition.
Definition: ConfigIO.cc:142
static const std::string Desc
Definition: ConfigIO.hh:113
CompN * _clone() const override
Clone using copy constructor.
Definition: ConfigIO.hh:129
static const std::string Name
Definition: ConfigIO.hh:111
Returns correlation values.
Definition: ConfigIO.hh:240
Eigen::VectorXd evaluate(const Configuration &config) const override
Returns the atom fraction.
Definition: ConfigIO.cc:253
bool parse_args(const std::string &args) override
Definition: ConfigIO.cc:277
CorrContribution * _clone() const override
Clone using copy constructor.
Definition: ConfigIO.hh:275
bool init(const Configuration &_tmplt) const override
If not yet initialized, use the global clexulator from the PrimClex.
Definition: ConfigIO.cc:258
CorrContribution(const Clexulator &clexulator)
Definition: ConfigIO.hh:251
static const std::string Name
Definition: ConfigIO.hh:242
std::unique_ptr< CorrContribution > clone() const
Clone using copy constructor.
Definition: ConfigIO.hh:262
static const std::string Desc
Definition: ConfigIO.hh:244
Returns correlation values.
Definition: ConfigIO.hh:197
static const std::string Desc
Definition: ConfigIO.hh:201
std::string m_clex_name
Definition: ConfigIO.hh:233
Corr(const Clexulator &clexulator)
Definition: ConfigIO.hh:205
static const std::string Name
Definition: ConfigIO.hh:199
bool init(const Configuration &_tmplt) const override
If not yet initialized, use the global clexulator from the PrimClex.
Definition: ConfigIO.cc:200
Eigen::VectorXd evaluate(const Configuration &config) const override
Returns the atom fraction.
Definition: ConfigIO.cc:195
Clexulator m_clexulator
Definition: ConfigIO.hh:232
Corr * _clone() const override
Clone using copy constructor.
Definition: ConfigIO.hh:230
bool parse_args(const std::string &args) override
Expects 'corr', 'corr(clex_name)', 'corr(index_expression)', or 'corr(clex_name,index_expression)'.
Definition: ConfigIO.cc:215
std::unique_ptr< Corr > clone() const
Clone using copy constructor.
Definition: ConfigIO.hh:215
Returns correlation values.
Definition: ConfigIO.hh:340
GradCorr(const Clexulator &clexulator)
Definition: ConfigIO.hh:348
static const std::string Desc
Definition: ConfigIO.hh:344
std::string m_clex_name
Definition: ConfigIO.hh:377
bool parse_args(const std::string &args) override
Expects 'gradcorr(dof_name)', 'gradcorr(dof_name,clex_name)', 'gradcorr(dof_name,index_expression)',...
Definition: ConfigIO.cc:431
GradCorr * _clone() const override
Clone using copy constructor.
Definition: ConfigIO.hh:374
bool init(const Configuration &_tmplt) const override
If not yet initialized, use the global clexulator from the PrimClex.
Definition: ConfigIO.cc:416
Eigen::MatrixXd evaluate(const Configuration &config) const override
Returns the atom fraction.
Definition: ConfigIO.cc:411
static const std::string Name
Definition: ConfigIO.hh:342
std::unique_ptr< GradCorr > clone() const
Clone using copy constructor.
Definition: ConfigIO.hh:358
Returns point correlation values.
Definition: ConfigIO.hh:289
bool init(const Configuration &_tmplt) const override
If not yet initialized, use the global clexulator from the PrimClex.
Definition: ConfigIO.cc:333
PointCorr * _clone() const override
Clone using copy constructor.
Definition: ConfigIO.hh:328
static const std::string Desc
Definition: ConfigIO.hh:293
std::unique_ptr< PointCorr > clone() const
Clone using copy constructor.
Definition: ConfigIO.hh:313
PointCorr(const Clexulator &clexulator)
Definition: ConfigIO.hh:301
static const std::string Name
Definition: ConfigIO.hh:291
Eigen::VectorXd evaluate(const Configuration &config) const override
Returns the atom fraction.
Definition: ConfigIO.cc:327
bool parse_args(const std::string &args) override
Expects 'corr', 'corr(clex_name)', 'corr(index_expression)', or 'corr(clex_name,index_expression)'.
Definition: ConfigIO.cc:353
Returns fraction of sites occupied by a species, including vacancies.
Definition: ConfigIO.hh:137
SiteFrac * _clone() const override
Clone using copy constructor.
Definition: ConfigIO.hh:157
static const std::string Desc
Definition: ConfigIO.hh:141
std::unique_ptr< SiteFrac > clone() const
Clone using copy constructor.
Definition: ConfigIO.hh:151
Eigen::VectorXd evaluate(const Configuration &config) const override
Returns the site fraction.
Definition: ConfigIO.cc:156
static const std::string Name
Definition: ConfigIO.hh:139
Returns fraction of sites occupied by a species.
Definition: ConfigIO.hh:35
bool init(const Configuration &_tmplt) const override
Adds index rules corresponding to the parsed args.
Definition: ConfigIO.cc:54
bool parse_args(const std::string &args) override
Expects arguments of the form 'name' or 'name(Au)', 'name(Pt)', etc.
Definition: ConfigIO.cc:48
std::vector< std::string > m_mol_names
Definition: ConfigIO.hh:54
MolDependent(const std::string &_name, const std::string &_desc)
Definition: ConfigIO.hh:37
std::vector< std::string > col_header(const Configuration &_tmplt) const override
col_header returns: {'name(Au)', 'name(Pt)', ...}
Definition: ConfigIO.cc:81
Prints a string value specified at construction. A header string can also be passed.
Parsing dictionary for constructing a DataFormatter<DataObject> object.
A sparse container of ECI values and their corresponding orbit indices.
Definition: ECIContainer.hh:12
A DatumFormatter that returns a 1D value of specified type, via functions that may be specified at ru...
A DatumFormatter that returns a value of specified type, via functions that may be specified at runti...
A 'cloneable_ptr' can be used in place of 'unique_ptr'.
MatrixXdAttributeDictionary< Configuration > make_matrixxd_dictionary< Configuration >()
Definition: ConfigIO.cc:882
IntegerAttributeDictionary< Configuration > make_integer_dictionary< Configuration >()
Definition: ConfigIO.cc:834
BooleanAttributeDictionary< Configuration > make_boolean_dictionary< Configuration >()
Definition: ConfigIO.cc:822
ScalarAttributeDictionary< Configuration > make_scalar_dictionary< Configuration >()
Definition: ConfigIO.cc:845
VectorXdAttributeDictionary< Configuration > make_vectorxd_dictionary< Configuration >()
Definition: ConfigIO.cc:869
StringAttributeDictionary< Configuration > make_string_dictionary< Configuration >()
Definition: ConfigIO.cc:809
T norm(const Tensor< T > &ttens)
Definition: Tensor.hh:932
ConfigIO::GenericConfigFormatter< std::string > poscar()
Definition: ConfigIO.cc:793
ConfigIO::GenericConfigFormatter< bool > is_canonical()
Definition: ConfigIO.cc:714
ConfigIO::GenericConfigFormatter< double > atomic_deformation()
Definition: ConfigIO.cc:730
ConfigIO::GenericConfigFormatter< double > energy_per_species()
Definition: ConfigIO.cc:648
ConfigIO::GenericConfigFormatter< double > lattice_deformation()
Definition: ConfigIO.cc:738
ConfigIO::GenericConfigFormatter< double > reference_energy()
Definition: ConfigIO.cc:654
ConfigIO::GenericConfigFormatter< std::string > point_group_name()
Definition: ConfigIO.cc:618
ConfigIO::GenericConfigFormatter< jsonParser > properties()
Definition: ConfigIO.cc:785
ConfigIO::GenericConfigFormatter< jsonParser > config()
Definition: ConfigIO.cc:777
ConfigIO::GenericConfigFormatter< double > formation_energy()
Definition: ConfigIO.cc:670
ConfigIO::GenericConfigFormatter< double > relaxed_magmom()
Definition: ConfigIO.cc:752
ConfigIO::GenericConfigFormatter< jsonParser > structure()
Definition: ConfigIO.cc:766
ConfigIO::GenericConfigFormatter< double > volume_relaxation()
Definition: ConfigIO.cc:745
ConfigIO::GenericConfigFormatter< std::string > failure_type()
Definition: ConfigIO.cc:588
ConfigIO::GenericConfigFormatter< double > formation_energy_per_species()
Definition: ConfigIO.cc:678
Generic1DDatumFormatter< std::vector< double >, Configuration > relaxation_strain()
ConfigIO::GenericConfigFormatter< double > relaxed_energy()
Definition: ConfigIO.cc:627
ConfigIO::GenericConfigFormatter< bool > is_primitive()
Definition: ConfigIO.cc:707
ConfigIO::GenericConfigFormatter< Index > multiplicity()
Definition: ConfigIO.cc:608
AtomFrac SpeciesFrac
In the future, AtomFrac will actually be atoms only.
Definition: ConfigIO.hh:191
ConfigIO::GenericConfigFormatter< bool > is_calculated()
Definition: ConfigIO.cc:697
ConfigIO::GenericConfigFormatter< Index > scel_size()
Definition: ConfigIO.cc:599
ConfigIO::GenericConfigFormatter< double > relaxed_energy_per_species()
Definition: ConfigIO.cc:641
ConfigIO::GenericConfigFormatter< std::string > scelname()
Definition: ConfigIO.cc:569
ConfigIO::GenericConfigFormatter< double > relaxed_magmom_per_species()
Definition: ConfigIO.cc:759
ConfigIO::GenericConfigFormatter< std::string > calc_status()
Definition: ConfigIO.cc:577
ConfigIO::GenericConfigFormatter< std::string > diff_trans_endpoint_of()
ConfigIO::GenericConfigFormatter< double > rms_force()
Definition: ConfigIO.cc:722
ConfigIO::GenericConfigFormatter< double > energy()
Definition: ConfigIO.cc:634
ConfigIO::GenericConfigFormatter< std::string > configname()
Constructs DataFormmaterDictionary containing all Configuration DatumFormatters.
Definition: ConfigIO.cc:563
ConfigIO::GenericConfigFormatter< double > reference_energy_per_species()
Definition: ConfigIO.cc:662
Main CASM namespace.
Definition: APICommand.hh:8
Eigen::MatrixXd MatrixXd
std::string DoFKey
Definition: DoFDecl.hh:7
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
Eigen::VectorXd VectorXd
pair_type eci
Definition: settings.cc:146