CASM  1.1.0
A Clusters Approach to Statistical Mechanics
SymRepBuilder.hh
Go to the documentation of this file.
1 #ifndef CASM_SymRepBuilder
2 #define CASM_SymRepBuilder
3 
4 #include <memory>
5 #include <string>
6 
8 #include "casm/global/eigen.hh"
10 #include "casm/misc/KroneckerTensorProduct.h"
11 
12 namespace CASM {
13 
22  public:
25  SymRepBuilderInterface(std::string const &_name, bool _time_reversal_active)
26  : m_name(_name), m_time_reversal_active(_time_reversal_active) {}
27 
29  std::string const &name() const { return m_name; }
30 
34 
38 
44  Eigen::Ref<const Eigen::Matrix3d> const &_matrix,
45  Eigen::Ref<const Eigen::Vector3d> const &_tau, bool time_reversal,
46  Index dim) const = 0;
47 
53  virtual Eigen::MatrixXcd symop_to_complex_matrix(
54  Eigen::Ref<const Eigen::Matrix3d> const &_matrix,
55  Eigen::Ref<const Eigen::Vector3d> const &_tau, bool time_reversal,
56  Index dim) const {
57  return symop_to_matrix(_matrix, _tau, time_reversal, dim)
58  .cast<std::complex<double> >();
59  }
60 
61  std::unique_ptr<SymRepBuilderInterface> clone() const {
62  return std::unique_ptr<SymRepBuilderInterface>(_clone());
63  }
64 
65  private:
66  virtual SymRepBuilderInterface *_clone() const = 0;
67 
68  std::string m_name;
70 };
71 
72 template <bool _uses_time_reversal>
74  public:
75  static const bool uses_time_reversal = _uses_time_reversal;
76 
77  protected:
78  TemplateSymRepBuilderBase(std::string const &_name)
79  : SymRepBuilderInterface(_name, _uses_time_reversal) {}
80 };
81 
83 
85 
88  public:
90 
92  Eigen::Ref<const Eigen::Matrix3d> const &_matrix,
93  Eigen::Ref<const Eigen::Vector3d> const &_tau, bool time_reversal,
94  Index dim) const override {
95  return Eigen::MatrixXd();
96  }
97 
98  private:
99  SymRepBuilderInterface *_clone() const override { return nullptr; }
100 };
101 
105  public:
107 
109  Eigen::Ref<const Eigen::Matrix3d> const &_matrix,
110  Eigen::Ref<const Eigen::Vector3d> const &_tau, bool time_reversal,
111  Index dim) const override {
112  return _matrix;
113  }
114 
115  private:
116  SymRepBuilderInterface *_clone() const override {
117  return new CartesianSymRepBuilder();
118  }
119 };
120 
123 template <typename Builder1, typename Builder2, Index Dim1, Index Dim2>
125  : public TemplateSymRepBuilderBase<Builder1::uses_time_reversal ||
126  Builder2::uses_time_reversal> {
127  public:
128  static const bool uses_time_reversal =
129  Builder1::uses_time_reversal || Builder2::uses_time_reversal;
130  KroneckerSymRepBuilder(std::string const &_name,
131  Builder1 _builder1 = Builder1(),
132  Builder2 _builder2 = Builder2())
134  m_builder1(_builder1),
135  m_builder2(_builder2) {}
136 
138  Eigen::Ref<const Eigen::Matrix3d> const &_matrix,
139  Eigen::Ref<const Eigen::Vector3d> const &_tau, bool time_reversal,
140  Index dim) const override {
141  assert(dim == Dim1 * Dim2);
142  Eigen::MatrixXd result;
143  kroneckerProduct(
144  m_builder1.symop_to_matrix(_matrix, _tau, time_reversal, Dim1),
145  m_builder2.symop_to_matrix(_matrix, _tau, time_reversal, Dim2), result);
146  return result;
147  }
148 
149  private:
150  SymRepBuilderInterface *_clone() const override {
151  return new KroneckerSymRepBuilder(*this);
152  }
153 
154  Builder1 m_builder1;
155  Builder2 m_builder2;
156 };
157 
161  public:
163 
165  Eigen::Ref<const Eigen::Matrix3d> const &_matrix,
166  Eigen::Ref<const Eigen::Vector3d> const &_tau, bool time_reversal,
167  Index dim) const override {
168  return Eigen::MatrixXd::Identity(dim, dim);
169  }
170 
171  private:
172  SymRepBuilderInterface *_clone() const override {
173  return new IdentitySymRepBuilder();
174  }
175 };
176 
180  public:
182  : TimeReversalSymRepBuilderBase("AngularMomentum") {}
183 
185  Eigen::Ref<const Eigen::Matrix3d> const &_matrix,
186  Eigen::Ref<const Eigen::Vector3d> const &_tau, bool time_reversal,
187  Index dim) const override {
188  return ((time_reversal ? -1. : 1.) * _matrix.determinant()) * _matrix;
189  }
190 
191  private:
192  SymRepBuilderInterface *_clone() const override {
193  return new AngularMomentumSymRepBuilder();
194  }
195 };
196 
200  public:
202 
204  Eigen::Ref<const Eigen::Matrix3d> const &_matrix,
205  Eigen::Ref<const Eigen::Vector3d> const &_tau, bool time_reversal,
206  Index dim) const override {
207  return (time_reversal ? -1. : 1.) * Eigen::MatrixXd::Identity(dim, dim);
208  }
209 
210  private:
211  SymRepBuilderInterface *_clone() const override {
212  return new TimeReversalSymRepBuilder();
213  }
214 };
215 
219  public:
221 
222  Eigen::MatrixXd symop_to_matrix(Eigen::Ref<const Eigen::Matrix3d> const &S,
223  Eigen::Ref<const Eigen::Vector3d> const &_tau,
224  bool time_reversal,
225  Index dim) const override {
226  Eigen::MatrixXd result(6, 6);
227 
228  result << S(0, 0) * S(0, 0), S(0, 1) * S(0, 1), S(0, 2) * S(0, 2),
229  sqrt(2) * S(0, 1) * S(0, 2), sqrt(2) * S(0, 2) * S(0, 0),
230  sqrt(2) * S(0, 0) * S(0, 1), S(1, 0) * S(1, 0), S(1, 1) * S(1, 1),
231  S(1, 2) * S(1, 2), sqrt(2) * S(1, 1) * S(1, 2),
232  sqrt(2) * S(1, 2) * S(1, 0), sqrt(2) * S(1, 0) * S(1, 1),
233  S(2, 0) * S(2, 0), S(2, 1) * S(2, 1), S(2, 2) * S(2, 2),
234  sqrt(2) * S(2, 1) * S(2, 2), sqrt(2) * S(2, 2) * S(2, 0),
235  sqrt(2) * S(2, 0) * S(2, 1), sqrt(2) * S(1, 0) * S(2, 0),
236  sqrt(2) * S(1, 1) * S(2, 1), sqrt(2) * S(1, 2) * S(2, 2),
237  S(1, 1) * S(2, 2) + S(1, 2) * S(2, 1),
238  S(1, 0) * S(2, 2) + S(1, 2) * S(2, 0),
239  S(1, 1) * S(2, 0) + S(1, 0) * S(2, 1), sqrt(2) * S(2, 0) * S(0, 0),
240  sqrt(2) * S(2, 1) * S(0, 1), sqrt(2) * S(2, 2) * S(0, 2),
241  S(2, 1) * S(0, 2) + S(2, 2) * S(0, 1),
242  S(2, 0) * S(0, 2) + S(2, 2) * S(0, 0),
243  S(2, 1) * S(0, 0) + S(2, 0) * S(0, 1), sqrt(2) * S(0, 0) * S(1, 0),
244  sqrt(2) * S(0, 1) * S(1, 1), sqrt(2) * S(0, 2) * S(1, 2),
245  S(0, 1) * S(1, 2) + S(0, 2) * S(1, 1),
246  S(0, 0) * S(1, 2) + S(0, 2) * S(1, 0),
247  S(0, 1) * S(1, 0) + S(0, 0) * S(1, 1);
248  return result;
249  }
250 
251  private:
252  SymRepBuilderInterface *_clone() const override {
253  return new Rank2TensorSymRepBuilder();
254  }
255 };
256 
257 // \brief Builds symmetry representation that is 2 x 2 identity (exchange)
258 // matrix if time_reversal is false (true)
260  public:
262  : TimeReversalSymRepBuilderBase("TimeReversalSwap") {}
263 
265  Eigen::Ref<const Eigen::Matrix3d> const &_matrix,
266  Eigen::Ref<const Eigen::Vector3d> const &_tau, bool time_reversal,
267  Index dim) const override {
268  assert(dim == 2);
269  Eigen::MatrixXd result(2, 2);
270  if (time_reversal) {
271  result << 0, 1, 1, 0;
272  } else {
273  result << 1, 0, 0, 1;
274  }
275  return result;
276  }
277 
278  private:
279  SymRepBuilderInterface *_clone() const override {
280  return new TimeReversalSwapSymRepBuilder();
281  }
282 };
283 
284 // \brief Build 15x15 symmetry representation for an unrolled d-orbital
285 // occupation matrix
287  public:
289 
291  Eigen::Ref<const Eigen::Matrix3d> const &_matrix,
292  Eigen::Ref<const Eigen::Vector3d> const &_tau, bool time_reversal,
293  Index dim) const override {
294  assert(dim == 15);
295  // Reduction matrix for reference d-orbitals
296  Eigen::MatrixXd P(5, 9);
297  P << 0, 1 / sqrt(2), 0, 1 / sqrt(2), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
298  1 / sqrt(2), 0, 1 / sqrt(2), 0, -1 / sqrt(6), 0, 0, 0, -1 / sqrt(6), 0,
299  0, 0, 2 / sqrt(6), 0, 0, 1 / sqrt(2), 0, 0, 0, 1 / sqrt(2), 0, 0,
300  1 / sqrt(2), 0, 0, 0, -1 / sqrt(2), 0, 0, 0, 0;
301 
302  // Reduction matrix for vectorized orbital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 0,
318  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
319  1 / sqrt(2), 0, 0, 0, 1 / sqrt(2), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
320  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 / sqrt(2), 0, 0, 0,
321  1 / sqrt(2), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 / sqrt(2),
322  0, 0, 0, 0, 0, 0, 0, 1 / sqrt(2), 0, 0, 0, 0, 0, 0, 0, 0;
323 
324  Eigen::MatrixXd kron_S_S(9, 9);
325  Eigen::kroneckerProduct(_matrix, _matrix, kron_S_S);
326  Eigen::MatrixXd G = P * kron_S_S * P.transpose();
327  Eigen::MatrixXd kron_GT_GT(25, 25);
328  Eigen::kroneckerProduct(G.transpose(), G.transpose(), kron_GT_GT);
329  Eigen::MatrixXd result = Q * kron_GT_GT * Q.transpose();
330  return result;
331  }
332 
333  private:
334  SymRepBuilderInterface *_clone() const override {
335  return new dOrbitalOccupationSymRepBuilder();
336  }
337 };
338 
339 // \brief Build 30x30 symmetry representation for an unrolled pair spin up/down
340 // d-orbital occupation matrices
342  : public KroneckerSymRepBuilder<TimeReversalSwapSymRepBuilder,
343  dOrbitalOccupationSymRepBuilder, 2, 15> {
344  public:
346  : KroneckerSymRepBuilder("dOrbitalOccupationSpinPolarized") {}
347 };
348 
349 // Named constructors for all previously defined SymRepBuilders
350 namespace SymRepBuilder {
352 
354 
357 }
358 
360  return TimeReversalSymRepBuilder();
361 }
362 
364  return Rank2TensorSymRepBuilder();
365 }
366 
369 }
370 
374 }
375 } // namespace SymRepBuilder
376 
377 } // namespace CASM
378 #endif
Builds symmetry representation that is the angular momentum symmetry representation of provided symop...
SymRepBuilderInterface * _clone() const override
Eigen::MatrixXd symop_to_matrix(Eigen::Ref< const Eigen::Matrix3d > const &_matrix, Eigen::Ref< const Eigen::Vector3d > const &_tau, bool time_reversal, Index dim) const override
Given the 3x3 rotation/rotoreflection matrix, translation vector 'tau', and time_reversal operator of...
Builds symmetry representation as the Cartesian matrix of povided SymOp.
SymRepBuilderInterface * _clone() const override
Eigen::MatrixXd symop_to_matrix(Eigen::Ref< const Eigen::Matrix3d > const &_matrix, Eigen::Ref< const Eigen::Vector3d > const &_tau, bool time_reversal, Index dim) const override
Given the 3x3 rotation/rotoreflection matrix, translation vector 'tau', and time_reversal operator of...
Builds symmetry representation as the 'dim' x 'dim' identity matrix, regardless of symop.
SymRepBuilderInterface * _clone() const override
Eigen::MatrixXd symop_to_matrix(Eigen::Ref< const Eigen::Matrix3d > const &_matrix, Eigen::Ref< const Eigen::Vector3d > const &_tau, bool time_reversal, Index dim) const override
Given the 3x3 rotation/rotoreflection matrix, translation vector 'tau', and time_reversal operator of...
Builds symmetry representation as the Kronecker product of two other representations.
SymRepBuilderInterface * _clone() const override
static const bool uses_time_reversal
KroneckerSymRepBuilder(std::string const &_name, Builder1 _builder1=Builder1(), Builder2 _builder2=Builder2())
Eigen::MatrixXd symop_to_matrix(Eigen::Ref< const Eigen::Matrix3d > const &_matrix, Eigen::Ref< const Eigen::Vector3d > const &_tau, bool time_reversal, Index dim) const override
Given the 3x3 rotation/rotoreflection matrix, translation vector 'tau', and time_reversal operator of...
Un-cloneable class for specifying absence of valid SymRepBuilder.
Eigen::MatrixXd symop_to_matrix(Eigen::Ref< const Eigen::Matrix3d > const &_matrix, Eigen::Ref< const Eigen::Vector3d > const &_tau, bool time_reversal, Index dim) const override
Given the 3x3 rotation/rotoreflection matrix, translation vector 'tau', and time_reversal operator of...
SymRepBuilderInterface * _clone() const override
Build 6x6 symmetry representation for a rank 2 Cartesian tensor represented in Kelvin notation.
Eigen::MatrixXd symop_to_matrix(Eigen::Ref< const Eigen::Matrix3d > const &S, Eigen::Ref< const Eigen::Vector3d > const &_tau, bool time_reversal, Index dim) const override
Given the 3x3 rotation/rotoreflection matrix, translation vector 'tau', and time_reversal operator of...
SymRepBuilderInterface * _clone() const override
Abstract base class that provides interface for converting cartesian isometry to specialized transfor...
SymRepBuilderInterface(std::string const &_name, bool _time_reversal_active)
Interace class manages the name of the SymRepBuilder and whether it is affected by time-reversal (i....
virtual Eigen::MatrixXd symop_to_matrix(Eigen::Ref< const Eigen::Matrix3d > const &_matrix, Eigen::Ref< const Eigen::Vector3d > const &_tau, bool time_reversal, Index dim) const =0
Given the 3x3 rotation/rotoreflection matrix, translation vector 'tau', and time_reversal operator of...
std::unique_ptr< SymRepBuilderInterface > clone() const
virtual ~SymRepBuilderInterface()
Virtual destructor allows deletion of derived classes through pointer to interface.
virtual SymRepBuilderInterface * _clone() const =0
std::string const & name() const
Returns name of SymRepBuilder type.
bool time_reversal_active() const
Returns true if symmetry representation is affected by time-reversal.
virtual Eigen::MatrixXcd symop_to_complex_matrix(Eigen::Ref< const Eigen::Matrix3d > const &_matrix, Eigen::Ref< const Eigen::Vector3d > const &_tau, bool time_reversal, Index dim) const
Given the 3x3 rotation/rotoreflection matrix, translation vector 'tau', and time_reversal operator of...
TemplateSymRepBuilderBase(std::string const &_name)
static const bool uses_time_reversal
Eigen::MatrixXd symop_to_matrix(Eigen::Ref< const Eigen::Matrix3d > const &_matrix, Eigen::Ref< const Eigen::Vector3d > const &_tau, bool time_reversal, Index dim) const override
Given the 3x3 rotation/rotoreflection matrix, translation vector 'tau', and time_reversal operator of...
SymRepBuilderInterface * _clone() const override
Builds symmetry representation that is 'dim'x'dim' +Identity (-Identity) matrix if time_reversal is f...
Eigen::MatrixXd symop_to_matrix(Eigen::Ref< const Eigen::Matrix3d > const &_matrix, Eigen::Ref< const Eigen::Vector3d > const &_tau, bool time_reversal, Index dim) const override
Given the 3x3 rotation/rotoreflection matrix, translation vector 'tau', and time_reversal operator of...
SymRepBuilderInterface * _clone() const override
SymRepBuilderInterface * _clone() const override
Eigen::MatrixXd symop_to_matrix(Eigen::Ref< const Eigen::Matrix3d > const &_matrix, Eigen::Ref< const Eigen::Vector3d > const &_tau, bool time_reversal, Index dim) const override
Given the 3x3 rotation/rotoreflection matrix, translation vector 'tau', and time_reversal operator of...
TimeReversalSymRepBuilder TimeReversal()
AngularMomentumSymRepBuilder AngularMomentum()
dOrbitalOccupationSymRepBuilder dOrbitalOccupation()
IdentitySymRepBuilder Identity()
dOrbitalOccupationSpinPolarizedSymRepBuilder dOrbitalOccupationSpinPolarized()
Rank2TensorSymRepBuilder Rank2Tensor()
CartesianSymRepBuilder Cartesian()
Main CASM namespace.
Definition: APICommand.hh:8
Eigen::MatrixXd MatrixXd
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39