CASM  1.1.0
A Clusters Approach to Statistical Mechanics
Norm.hh
Go to the documentation of this file.
1 #ifndef CASM_Norm
2 #define CASM_Norm
3 
5 #include "casm/clex/Supercell.hh"
7 
8 namespace CASM {
9 
14 template <typename DataObject>
15 class Norm {
16  public:
17  virtual ~Norm() {}
18 
20  virtual double operator()(const DataObject &obj) const { return 1.0; }
21 
22  std::unique_ptr<Norm> clone() const {
23  return std::unique_ptr<Norm>(this->_clone());
24  }
25 
26  private:
27  virtual Norm *_clone() const { return new Norm(*this); }
28 };
29 
30 class NormPerUnitCell : public Norm<Configuration> {
31  public:
33  double operator()(const Configuration &config) const override {
34  return config.supercell().volume();
35  }
36 
38  std::unique_ptr<NormPerUnitCell> clone() const {
39  return notstd::make_unique<NormPerUnitCell>(*this);
40  }
41 
42  private:
43  NormPerUnitCell *_clone() const override {
44  return new NormPerUnitCell(*this);
45  }
46 };
47 
48 class NormPerSpecies : public Norm<Configuration> {
49  public:
51  double operator()(const Configuration &config) const override {
52  return n_species(config);
53  }
54 
56  std::unique_ptr<NormPerSpecies> clone() const {
57  return notstd::make_unique<NormPerSpecies>(*this);
58  }
59 
60  private:
61  NormPerSpecies *_clone() const override { return new NormPerSpecies(*this); }
62 };
63 
65 } // namespace CASM
66 
67 #endif
virtual ~Norm()
Definition: Norm.hh:17
virtual Norm * _clone() const
Definition: Norm.hh:27
virtual double operator()(const DataObject &obj) const
Default normalization is 1.0.
Definition: Norm.hh:20
std::unique_ptr< Norm > clone() const
Definition: Norm.hh:22
double operator()(const Configuration &config) const override
Return number of non-Va species in configuration per unitcell.
Definition: Norm.hh:51
std::unique_ptr< NormPerSpecies > clone() const
Clone.
Definition: Norm.hh:56
NormPerSpecies * _clone() const override
Definition: Norm.hh:61
std::unique_ptr< NormPerUnitCell > clone() const
Clone.
Definition: Norm.hh:38
NormPerUnitCell * _clone() const override
Definition: Norm.hh:43
double operator()(const Configuration &config) const override
Return configuration supercell size.
Definition: Norm.hh:33
double n_species(const Configuration &config)
Returns the total number species per unit cell.
ConfigIO::GenericConfigFormatter< jsonParser > config()
Definition: ConfigIO.cc:777
Main CASM namespace.
Definition: APICommand.hh:8