CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
Molecule.hh
Go to the documentation of this file.
1 #ifndef MOLECULE_HH
2 #define MOLECULE_HH
3 
4 #include <iostream>
5 #include <array>
6 
8 #include "casm/basis_set/DoF.hh"
10 #include "casm/symmetry/SymOp.hh"
11 
12 namespace CASM {
13 
20  class Molecule;
21  template <typename T>
22  class OccupantDoF;
24  //****************************************************
25 
27  inline bool is_vacancy(const std::string &name) {
28  return (name == "VA" || name == "va" || name == "Va");
29  }
30 
31  class Specie {
32  public:
33  std::string name;
34  double mass, magmom, U, J; //Changed 05/10/13 -- was int
35  Specie() { };
36  explicit Specie(std::string init_name) : name(init_name) { };
37 
38  bool is_vacancy() const {
39  return CASM::is_vacancy(name);
40  }
41 
42 
43  bool operator==(const Specie &RHS) const {
44  return
45  (name == RHS.name);
46  };
47 
48  };
49 
50  jsonParser &to_json(const Specie &specie, jsonParser &json);
51 
52  void from_json(Specie &specie, const jsonParser &json);
53 
54  //****************************************************
55 
56  class AtomPosition : public Coordinate {
57  public:
58  typedef std::array<bool, 3> sd_type;
60 
61  sd_type SD_flag;
62 
63  explicit AtomPosition(const Lattice &init_lattice) : Coordinate(0, 0, 0, init_lattice, CART) { };
64  AtomPosition(double elem1,
65  double elem2,
66  double elem3,
67  std::string sp_name,
68  const Lattice &init_lattice,
69  COORD_TYPE mode,
70  sd_type _SD_flag = sd_type {{false, false, false}}) :
71  Coordinate(elem1, elem2, elem3, init_lattice, mode),
72  specie(sp_name),
73  SD_flag(_SD_flag) { };
74 
75 
76  bool operator==(const AtomPosition &RHS) const;
77 
78  void print(std::ostream &stream, const Coordinate &trans, int spaces, bool SD_is_on = false) const;
79  // TODO: If comparing coordinates alone does not suffice, add a == operator here.
80 
81  AtomPosition &apply_sym(const SymOp &op);
82  AtomPosition &apply_sym_no_trans(const SymOp &op);
83 
84 
85  };
86 
87  jsonParser &to_json(const AtomPosition &apos, jsonParser &json);
88 
89  // Lattice must be set already
90  void from_json(AtomPosition &apos, const jsonParser &json);
91 
92  //****************************************************
93 
100  class Molecule : public Array<AtomPosition> {
101 
102  Lattice const *m_home;
103 
105 
106  public:
110 
112  std::string name;
113 
114  explicit Molecule(const Lattice &init_home) : m_home(&init_home), center(0, 0, 0, init_home, CART) {};
115 
116  Lattice const *home() const {
117  return m_home;
118  }
119 
120  void get_center(); //TODO
121 
122  void generate_point_group(); //TODO
123 
124  bool is_vacancy() const {
125  return CASM::is_vacancy(name);
126  };
127 
128  Molecule &apply_sym(const SymOp &op); //TODO
129  Molecule &apply_sym_no_trans(const SymOp &op); //TODO
130 
131  void set_lattice(const Lattice &new_lat, COORD_TYPE invariant_mode);
132 
133  Molecule get_union(const Molecule &RHS); //TODO
134 
135  Molecule &operator*=(const SymOp &RHS); //TODO
136  Molecule &operator+=(const Coordinate &RHS); //TODO
137 
138  bool operator==(const Molecule &RHS) const;
139  bool contains(const std::string &name) const;
140 
141  void read(std::istream &stream);
142  void print(std::ostream &stream, const Coordinate &trans, int spaces, char delim, bool SD_is_on = false) const;
143 
144  jsonParser &to_json(jsonParser &json) const;
145 
146  // Lattice must be set already
147  void from_json(const jsonParser &json);
148  };
149 
150  Molecule operator*(const SymOp &LHS, const Molecule &RHS); //TODO
151  Molecule operator+(const Coordinate &LHS, const Molecule &RHS); //TODO
152  Molecule operator+(const Molecule &LHS, const Coordinate &RHS); //TODO
153 
155  Molecule make_atom(std::string atom_name, const Lattice &lat);
156 
158  Molecule make_vacancy(const Lattice &lat);
159 
161  bool is_molecule_name(const Molecule &mol, std::string name);
162 
163 
164  jsonParser &to_json(const Molecule &mol, jsonParser &json);
165 
166  // Lattice must be set already
167  void from_json(Molecule &mol, const jsonParser &json);
168 
170 };
171 #endif
Molecule & apply_sym(const SymOp &op)
Definition: Molecule.cc:128
double U
Definition: Molecule.hh:34
void from_json(ClexDescription &desc, const jsonParser &json)
Molecule & apply_sym_no_trans(const SymOp &op)
Definition: Molecule.cc:148
AtomPosition & apply_sym_no_trans(const SymOp &op)
Definition: Molecule.cc:90
double mass
Definition: Molecule.hh:34
bool is_vacancy(const std::string &name)
A vacancy is any Specie/Molecule with (name == "VA" || name == "va" || name == "Va") ...
Definition: Molecule.hh:27
bool operator==(const AtomPosition &RHS) const
Definition: Molecule.cc:42
bool operator==(const Specie &RHS) const
Definition: Molecule.hh:43
void set_lattice(const Lattice &new_lat, COORD_TYPE invariant_mode)
Definition: Molecule.cc:168
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
Array< SymOp > point_group
Definition: Molecule.hh:104
OccupantDoF< Molecule > MoleculeOccupant
Definition: Molecule.hh:22
bool is_molecule_name(const Molecule &mol, std::string name)
Return true if Molecule name matches 'name', including Va checks.
Definition: Molecule.cc:298
Main CASM namespace.
Definition: complete.cpp:8
Molecule get_union(const Molecule &RHS)
void print(std::ostream &stream, const Coordinate &trans, int spaces, char delim, bool SD_is_on=false) const
Definition: Molecule.cc:220
Molecule make_atom(std::string atom_name, const Lattice &lat)
Return an atomic Molecule with specified name and Lattice.
Definition: Molecule.cc:279
bool contains(const std::string &name) const
Definition: Molecule.cc:207
GenericCluster< CoordType > operator+(const GenericCluster< CoordType > &LHS, const Coordinate &RHS)
create translated cluster
Specie(std::string init_name)
Definition: Molecule.hh:36
double magmom
Definition: Molecule.hh:34
void print(std::ostream &stream, const Coordinate &trans, int spaces, bool SD_is_on=false) const
Definition: Molecule.cc:54
jsonParser & to_json(jsonParser &json) const
Definition: Molecule.cc:234
double J
Definition: Molecule.hh:34
SymOp is the Coordinate representation of a symmetry operation it keeps fraction (FRAC) and Cartesian...
Definition: SymOp.hh:28
BasisSet operator*(const SymOp &LHS, const BasisSet &RHS)
Definition: BasisSet.cc:1154
Represents cartesian and fractional coordinates.
Definition: Coordinate.hh:34
Molecule(const Lattice &init_home)
Definition: Molecule.hh:114
void read(std::istream &stream)
Molecule & operator+=(const Coordinate &RHS)
Lattice const * home() const
Definition: Molecule.hh:116
std::array< bool, 3 > sd_type
Definition: Molecule.hh:58
bool is_vacancy() const
Definition: Molecule.hh:38
void generate_point_group()
bool operator==(const Molecule &RHS) const
Definition: Molecule.cc:183
bool is_vacancy() const
Definition: Molecule.hh:124
Lattice const * m_home
Definition: Molecule.hh:102
Molecule make_vacancy(const Lattice &lat)
Return an vacancy Molecule with specified Lattice.
Definition: Molecule.cc:287
AtomPosition(const Lattice &init_lattice)
Definition: Molecule.hh:63
void from_json(const jsonParser &json)
Definition: Molecule.cc:252
std::string name
Definition: Molecule.hh:112
std::string name
Definition: Molecule.hh:33
Molecule & operator*=(const SymOp &RHS)
Basic std::vector like container (deprecated)
AtomPosition(double elem1, double elem2, double elem3, std::string sp_name, const Lattice &init_lattice, COORD_TYPE mode, sd_type _SD_flag=sd_type{{false, false, false}})
Definition: Molecule.hh:64
Coordinate center
Definition: Molecule.hh:111
Coordinate(const Lattice &_home)
Minimal constructor only takes a lattice.
Definition: Coordinate.hh:46
AtomPosition & apply_sym(const SymOp &op)
Definition: Molecule.cc:79