CASM  1.1.0
A Clusters Approach to Statistical Mechanics
Site.hh
Go to the documentation of this file.
1 #ifndef SITE_HH
2 #define SITE_HH
3 
4 #include <iostream>
5 #include <string>
6 #include <vector>
7 
12 
13 namespace CASM {
14 namespace xtal {
15 
16 struct SymOp;
17 class Molecule;
18 
23 class Site : public Coordinate {
24  public:
25  explicit Site(const Lattice &init_home);
26 
27  Site(const Coordinate &init_pos, const std::string &occ_name);
28 
30  Site(const Coordinate &init_pos, const std::vector<Molecule> &site_occ);
31 
34  Site(const Coordinate &init_pos, const std::vector<Molecule> &site_occ,
35  const std::map<std::string, SiteDoFSet> &site_dof);
36 
39  Site(const Coordinate &init_pos, const std::vector<Molecule> &site_occ,
40  const std::vector<SiteDoFSet> &site_dof);
41 
42  ~Site();
43 
44  // TODO: Decide where this should actually go
45  static void print_occupant_dof(const std::vector<Molecule> &allowed_occupants,
46  std::ostream &out_stream);
47 
48  const std::vector<Molecule> &occupant_dof() const;
49 
50  SiteDoFSet const &dof(std::string const &_dof_type) const;
51 
52  Index dof_size() const;
53 
54  bool has_dof(std::string const &_dof_type) const;
55 
56  std::vector<std::string> dof_types() const;
57 
58  bool time_reversal_active() const;
59 
61  Index label() const;
62 
63  // TODO: Make comparators independent classes?
64  bool compare(const Coordinate &test_coord) const;
65  bool compare(const Site &test_site) const; // Ivy
66  bool compare_type(const Site &test_site) const; // Ivy
67  bool operator==(const Site &test_site) const;
68  bool almost_equal(const Site &test_site) const;
69 
70  // checks to see if species with name 'name' is allowed at site.
71  bool contains(const std::string &name) const;
72  bool contains(const std::string &name, int &index) const;
73 
74  void set_allowed_occupants(const std::vector<Molecule> &new_occ_domain);
75 
76  void set_dofs(std::map<std::string, SiteDoFSet> _dofs);
77 
78  std::map<std::string, SiteDoFSet> const &dofs() const { return m_dof_map; }
79 
80  // TODO: Change this to allowed_occupant_names or something
81  std::vector<std::string> allowed_occupants() const;
82 
85  void set_label(Index _new_label);
86 
87  void read(std::istream &stream, bool SD_is_on = false);
88  void read(std::istream &stream, std::string &elem, bool SD_is_on);
89 
90  void print(std::ostream &stream,
91  Eigen::IOFormat format = Eigen::IOFormat(7, 12)) const;
92 
93  Site &operator+=(const Coordinate &translation);
94  Site &operator-=(const Coordinate &translation);
95 
96  private:
97  // TODO: What is this?
98  static std::vector<Site> &_type_prototypes() {
99  static std::vector<Site> m_type_prototypes;
100  return m_type_prototypes;
101  }
102 
105 
106  // TODO: What is this?
107  mutable Index m_type_ID;
108 
109  // Configuration state is fundamentally different from most other degrees of
110  // freedom, so we'll treat it separately. 'occupant' is the discrete degree of
111  // freedom associated with the molecule that occupies the site
112  std::vector<Molecule> m_occupant_dof;
113 
115  std::map<std::string, SiteDoFSet> m_dof_map;
116 
117  //============
118 
119  bool _compare_type_no_ID(const Site &test_site) const;
120  Index _type_ID() const;
121 };
122 
123 std::ostream &operator<<(std::ostream &stream, const Site &site);
124 
126 Site operator*(const SymOp &LHS, const Site &RHS);
127 template <typename ExternSymOp>
128 Site operator*(const ExternSymOp &LHS, const Site &RHS) {
129  return adapter::Adapter<SymOp, ExternSymOp>()(LHS) * RHS;
130 }
131 
132 Site operator+(const Site &LHS, const Coordinate &RHS);
133 Site operator+(const Coordinate &LHS, const Site &RHS);
134 
136 } // namespace xtal
137 
138 namespace sym {
141 xtal::Site &apply(const xtal::SymOp &op, xtal::Site &mutating_site);
144 xtal::Site copy_apply(const xtal::SymOp &op, xtal::Site site);
145 } // namespace sym
146 } // namespace CASM
147 
148 #endif
Represents cartesian and fractional coordinates.
Definition: Coordinate.hh:34
bool _compare_type_no_ID(const Site &test_site) const
Definition: Site.cc:424
bool operator==(const Site &test_site) const
Definition: Site.cc:195
bool time_reversal_active() const
Definition: Site.cc:108
Index _type_ID() const
Definition: Site.cc:443
bool compare_type(const Site &test_site) const
Definition: Site.cc:189
std::map< std::string, SiteDoFSet > const & dofs() const
Definition: Site.hh:78
bool compare(const Coordinate &test_coord) const
Definition: Site.cc:169
Index dof_size() const
Definition: Site.cc:74
Site(const Lattice &init_home)
Definition: Site.cc:38
bool has_dof(std::string const &_dof_type) const
Definition: Site.cc:90
void read(std::istream &stream, bool SD_is_on=false)
Definition: Site.cc:262
bool contains(const std::string &name) const
Definition: Site.cc:207
Index m_type_ID
Definition: Site.hh:107
void set_dofs(std::map< std::string, SiteDoFSet > _dofs)
Definition: Site.cc:235
const std::vector< Molecule > & occupant_dof() const
Definition: Site.cc:68
Site & operator-=(const Coordinate &translation)
Definition: Site.cc:158
void print(std::ostream &stream, Eigen::IOFormat format=Eigen::IOFormat(7, 12)) const
Definition: Site.cc:396
SiteDoFSet const & dof(std::string const &_dof_type) const
Definition: Site.cc:78
void set_label(Index _new_label)
Definition: Site.cc:252
Index m_label
Integer label used to differentiate sites of otherwise identical type.
Definition: Site.hh:104
static std::vector< Site > & _type_prototypes()
Definition: Site.hh:98
std::vector< std::string > allowed_occupants() const
Definition: Site.cc:242
void set_allowed_occupants(const std::vector< Molecule > &new_occ_domain)
Definition: Site.cc:228
std::map< std::string, SiteDoFSet > m_dof_map
additional continuous degrees of freedom
Definition: Site.hh:115
Site & operator+=(const Coordinate &translation)
Definition: Site.cc:147
std::vector< std::string > dof_types() const
Definition: Site.cc:97
static void print_occupant_dof(const std::vector< Molecule > &allowed_occupants, std::ostream &out_stream)
Definition: Site.cc:407
std::vector< Molecule > m_occupant_dof
Definition: Site.hh:112
bool almost_equal(const Site &test_site) const
Definition: Site.cc:201
Index label() const
access m_label;
Definition: Site.cc:119
Coordinate operator*(const SymOp &LHS, const Coordinate &RHS)
Definition: Coordinate.cc:329
Coordinate operator+(const Coordinate &LHS, const Coordinate &RHS)
Definition: Coordinate.hh:290
xtal::Coordinate copy_apply(const xtal::SymOp &op, xtal::Coordinate coord)
Copy and apply SymOp to a Coordinate.
Definition: Coordinate.cc:354
xtal::Coordinate & apply(const xtal::SymOp &op, xtal::Coordinate &coord)
apply SymOp to a Coordinate
Definition: Coordinate.cc:347
std::ostream & operator<<(std::ostream &stream, const Site &site)
Definition: Site.cc:417
Main CASM namespace.
Definition: APICommand.hh:8
GenericDatumFormatter< std::string, DataObject > name()
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39