Psi4
pointgrp.h
Go to the documentation of this file.
1 /*
2  * @BEGIN LICENSE
3  *
4  * Psi4: an open-source quantum chemistry software package
5  *
6  * Copyright (c) 2007-2017 The Psi4 Developers.
7  *
8  * The copyrights for code used from other parties are included in
9  * the corresponding files.
10  *
11  * This file is part of Psi4.
12  *
13  * Psi4 is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU Lesser General Public License as published by
15  * the Free Software Foundation, version 3.
16  *
17  * Psi4 is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License along
23  * with Psi4; if not, write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25  *
26  * @END LICENSE
27  */
28 
29 //
30 // pointgrp.h
31 //
32 // Additional modifications made by Justin Turney <jturney@ccqc.uga.edu>
33 // for use in PSI4.
34 //
35 // Modifications are
36 // Copyright (C) 1996 Limit Point Systems, Inc.
37 //
38 // Author: Edward Seidl <seidl@janed.com>
39 // Maintainer: LPS
40 //
41 // This file is part of the SC Toolkit.
42 //
43 // The SC Toolkit is free software; you can redistribute it and/or modify
44 // it under the terms of the GNU Library General Public License as published by
45 // the Free Software Foundation; either version 2, or (at your option)
46 // any later version.
47 //
48 // The SC Toolkit is distributed in the hope that it will be useful,
49 // but WITHOUT ANY WARRANTY; without even the implied warranty of
50 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
51 // GNU Library General Public License for more details.
52 //
53 // You should have received a copy of the GNU General Public License along
54 // with this program; if not, write to the Free Software Foundation, Inc.,
55 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
56 //
57 // The U.S. Government is granted a limited license as per AL 91-7.
58 //
59 
60 /* pointgrp.h -- definition of the point group classes
61  *
62  * THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
63  * "UNITED STATES GOVERNMENT WORK". IT WAS WRITTEN AS A PART OF THE
64  * AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE. THIS MEANS IT
65  * CANNOT BE COPYRIGHTED. THIS SOFTWARE IS FREELY AVAILABLE TO THE
66  * PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
67  * RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
68  *
69  * Author:
70  * E. T. Seidl
71  * Bldg. 12A, Rm. 2033
72  * Computer Systems Laboratory
73  * Division of Computer Research and Technology
74  * National Institutes of Health
75  * Bethesda, Maryland 20892
76  * Internet: seidl@alw.nih.gov
77  * June, 1993
78  */
79 
80 #ifndef _math_symmetry_pointgrp_h
81 #define _math_symmetry_pointgrp_h
82 
83 #include "psi4/libmints/vector3.h"
84 #include "psi4/psi4-dec.h"
85 
86 #include <string.h>
87 #include <cstdio>
88 #include <stdint.h>
89 #include <vector>
90 #include <map>
91 
92  #include "psi4/pragma.h"
93  PRAGMA_WARNING_PUSH
94  PRAGMA_WARNING_IGNORE_DEPRECATED_DECLARATIONS
95  #include <memory>
97 
98 namespace psi {
99 
100 #define NUM_TO_OPERATOR_ID(x) ((x) ? 1<<((x)-1) : 0)
101 #define SKIP_THIS_OPERATOR(num, bit) ((bit) ? !((1<<((bit)-1)) & (num)) : 0 )
102 
103 namespace SymmOps {
105 {
106  E = 0, C2_z = 1, C2_y = 2, C2_x = 4, i = 8, Sigma_xy = 16, Sigma_xz = 32, Sigma_yz = 64, ID = 128
107 };
108 }
109 
110 namespace PointGroups {
111 enum Groups
112 {
130 };
131 
132 void similar(unsigned char bits, unsigned char *sim, char& cnt);
133 
134 }
135 
136 // //////////////////////////////////////////////////////////////////
137 
142 {
143 private:
144  double d[3][3];
145  unsigned short bits_;
146 
147  void analyze_d();
148 
149 public:
153 
154  SymmetryOperation& operator=(SymmetryOperation const& a); // Assignment operator
155 
157  double trace() const
158  { return d[0][0] + d[1][1] + d[2][2]; }
159 
161  double *operator[](int i)
162  { return d[i]; }
163 
165  const double *operator[](int i) const
166  { return d[i]; }
167 
170  double& operator()(int i, int j)
171  { return d[i][j]; }
172 
174  double operator()(int i, int j) const
175  { return d[i][j]; }
176 
178  void zero()
179  { ::memset(d, 0, sizeof(double) * 9); }
180 
183 
186 
188  unsigned char bit() const
189  { return bits_; }
190 
192  void unit()
193  {
194  zero();
195  d[0][0] = d[1][1] = d[2][2] = 1.0;
196  }
197 
199  void E()
200  {
201  unit();
202  bits_ = SymmOps::E;
203  }
204 
206  void i()
207  {
208  zero();
209  d[0][0] = d[1][1] = d[2][2] = -1.0;
210  bits_ = SymmOps::i;
211  }
212 
214  void sigma_xy()
215  {
216  unit();
217  d[2][2] = -1.0;
219  }
220 
222  void sigma_xz()
223  {
224  unit();
225  d[1][1] = -1.0;
227  }
228 
230  void sigma_yz()
231  {
232  unit();
233  d[0][0] = -1.0;
235  }
236 
238  void rotation(int n);
239  void rotation(double theta);
240 
242  void c2_x()
243  {
244  i();
245  d[0][0] = 1.0;
247  }
248 
250  void c2_y()
251  {
252  i();
253  d[1][1] = 1.0;
255  }
256 
258  void c2_z()
259  {
260  i();
261  d[2][2] = 1.0;
263  }
264 
265  void transpose();
266 
268  void print(std::string out);
269 };
270 
271 // //////////////////////////////////////////////////////////////////
272 
278 class SymRep
279 {
280 private:
281  int n;
282  double d[5][5];
283 
284 public:
285  SymRep(int = 0);
286  SymRep(const SymmetryOperation&);
287  ~SymRep();
288 
290  operator SymmetryOperation() const;
291 
293  inline double trace() const;
294 
296  void set_dim(int i)
297  { n = i; }
298 
300  double *operator[](int i)
301  { return d[i]; }
303  const double *operator[](int i) const
304  { return d[i]; }
305 
308  double& operator()(int i, int j)
309  { return d[i][j]; }
311  double operator()(int i, int j) const
312  { return d[i][j]; }
313 
315  void zero()
316  { ::memset(d, 0, sizeof(double) * 25); }
317 
319  SymRep operate(const SymRep& r) const;
320 
322  SymRep transform(const SymRep& r) const;
323 
325  void unit()
326  {
327  zero();
328  d[0][0] = d[1][1] = d[2][2] = d[3][3] = d[4][4] = 1.0;
329  }
330 
332  void E()
333  { unit(); }
334 
336  void i()
337  {
338  zero();
339  d[0][0] = d[1][1] = d[2][2] = d[3][3] = d[4][4] = -1.0;
340  }
341 
343  void sigma_h();
344 
346  void sigma_xz();
347 
349  void sigma_yz();
350 
352  void rotation(int n);
353  void rotation(double theta);
354 
356  void c2_x();
357 
359  void c2_y();
360 
362  void c2_z();
363 
365  // void print(std::ostream& =ExEnv::out0()) const;
366 };
367 
368 inline double
370 {
371  double r = 0;
372  for (int i = 0; i < n; i++)
373  r += d[i][i];
374  return r;
375 }
376 
377 // //////////////////////////////////////////////////////////////////
378 
379 
380 class CharacterTable;
381 
390 {
391  friend class CharacterTable;
392 
393 private:
394  int g; // the order of the group
395  int degen; // the degeneracy of the irrep
396  int nrot_; // the number of rotations in this irrep
397  int ntrans_; // the number of translations in this irrep
398  int complex_; // true if this irrep has a complex representation
399  char *symb; // mulliken symbol for this irrep
400  char *csymb; // mulliken symbol for this irrep w/o special characters
401 
402  SymRep *rep; // representation matrices for the symops
403 
404 public:
410  IrreducibleRepresentation(int, int, const char *, const char * = 0);
411 
413 
415 
417  void init(int = 0, int = 0, const char * = 0, const char * = 0);
418 
420  int order() const
421  { return g; }
422 
424  int degeneracy() const
425  { return degen; }
426 
428  int complex() const
429  { return complex_; }
430 
432  int nproj() const
433  { return degen * degen; }
434 
436  int nrot() const
437  { return nrot_; }
438 
440  int ntrans() const
441  { return ntrans_; }
442 
444  const char *symbol() const
445  { return symb; }
446 
450  const char *symbol_ns() const
451  { return (csymb ? csymb : symb); }
452 
455  double character(int i) const
456  {
457  return complex_ ? 0.5 * rep[i].trace() : rep[i].trace();
458  }
459 
461  double p(int x1, int x2, int i) const
462  { return rep[i](x1, x2); }
463 
466  double p(int d, int i) const
467  {
468  int dc = d / degen;
469  int dr = d % degen;
470  return rep[i](dr, dc);
471  }
472 
476  void print(std::string = "outfile") const;
477 };
478 
479 // ///////////////////////////////////////////////////////////
489 {
490  int nt;
492  int nirrep_;
495  int *_inv;
496  std::string symb;
497  unsigned char bits_;
498 
500  int make_table();
501  void common_init();
502 
503 public:
504  CharacterTable();
507  CharacterTable(const std::string&);
510  CharacterTable(unsigned char);
511 
513  ~CharacterTable();
514 
516 
518  int nirrep() const
519  { return nirrep_; }
521  int order() const
522  { return nirrep_; }
524  const std::string& symbol() const
525  { return symb; }
528  { return gamma_[i]; }
531  { return symop[i]; }
532 
536  int complex() const
537  {
538  return 0;
539  }
540 
542  int inverse(int i) const
543  { return _inv[i]; }
544 
545  int ncomp() const
546  {
547  int ret = 0;
548  for (int i = 0; i < nirrep_; i++) {
549  int nc = (gamma_[i].complex()) ? 1 : gamma_[i].degen;
550  ret += nc;
551  }
552  return ret;
553  }
554 
556  int which_irrep(int i)
557  {
558  for (int ir = 0, cn = 0; ir < nirrep_; ir++) {
559  int nc = (gamma_[ir].complex()) ? 1 : gamma_[ir].degen;
560  for (int c = 0; c < nc; c++, cn++)
561  if (cn == i)
562  return ir;
563  }
564  return -1;
565  }
566 
568  int which_comp(int i)
569  {
570  for (int ir = 0, cn = 0; ir < nirrep_; ir++) {
571  int nc = (gamma_[ir].complex()) ? 1 : gamma_[ir].degen;
572  for (int c = 0; c < nc; c++, cn++)
573  if (cn == i)
574  return c;
575  }
576  return -1;
577  }
578 
579  unsigned char bits();
580 
582  void print(std::string = "outfile") const;
583 };
584 
585 // ///////////////////////////////////////////////////////////
586 
595 {
596 private:
597  std::string symb;
599  unsigned char bits_;
600 
601 public:
602  PointGroup();
603 
604  // These 2 constructors do not work right now.
607  PointGroup(const std::string&);
610  PointGroup(const std::string&, const Vector3&);
611 
613  PointGroup(unsigned char bits);
615  PointGroup(unsigned char bits, const Vector3&);
616 
651  // PointGroup(const Ref<KeyVal>&);
652 
653  // PointGroup(StateIn&);
654  PointGroup(const PointGroup&);
655  PointGroup(const std::shared_ptr<PointGroup>&);
656  ~PointGroup();
657 
659 
661  int equiv(const std::shared_ptr<PointGroup>&, double tol = 1.0e-6) const;
662 
664  CharacterTable char_table() const;
666  std::string symbol() const
667  { return symb; }
671  { return origin_; }
672  const Vector3& origin() const
673  { return origin_; }
674 
676  void set_symbol(const std::string&);
677 
679  unsigned char bits() const
680  { return bits_; }
681 
682  static const char *bits_to_full_name(unsigned char bits);
683  static const char *bits_to_basic_name(unsigned char bits);
684  static bool full_name_to_bits(const std::string& pg, unsigned char& bits);
685 
686  void print(std::string out_fname = "outfile") const;
687 };
688 
689 }
690 
691 #endif
692 
693 // Local Variables:
694 // mode: c++
695 // c-file-style: "ETS"
696 // End:
unsigned short bits_
Definition: pointgrp.h:145
SymRep * rep
Definition: pointgrp.h:402
Definition: pointgrp.h:106
void print(std::string="outfile") const
This prints the irrep to the given file, or stdout if none is given.
Definition: chartab.cc:151
void c2_z()
Set equal to C2 about the z axis.
Definition: rep.cc:303
int g
Definition: pointgrp.h:394
Definition: pointgrp.h:123
double trace() const
returns the trace of the transformation matrix
Definition: pointgrp.h:157
int complex_
Definition: pointgrp.h:398
void unit()
Set equal to a unit matrix.
Definition: pointgrp.h:325
CharacterTable char_table() const
Returns the CharacterTable for this point group.
Definition: pointgrp.cc:223
const std::string & symbol() const
Returns the Schoenflies symbol for the point group.
Definition: pointgrp.h:524
CharacterTable()
Definition: chartab.cc:91
int nirrep() const
Returns the number of irreps.
Definition: pointgrp.h:518
int complex() const
Definition: pointgrp.h:536
IrreducibleRepresentation()
Definition: irrep.cc:87
int nproj() const
Returns the number of projection operators for the irrep.
Definition: pointgrp.h:432
void set_dim(int i)
set the dimension of d
Definition: pointgrp.h:296
static const char * bits_to_full_name(unsigned char bits)
Definition: pointgrp.cc:291
void unit()
Set equal to a unit matrix.
Definition: pointgrp.h:192
int inverse(int i) const
Returns the index of the symop which is the inverse of symop[i].
Definition: pointgrp.h:542
Definition: pointgrp.h:278
double * operator[](int i)
returns the i&#39;th row of the transformation matrix
Definition: pointgrp.h:161
void E()
Set equal to the identity.
Definition: pointgrp.h:332
Definition: pointgrp.h:106
unsigned char bit() const
Get the bit value.
Definition: pointgrp.h:188
void E()
Set equal to E.
Definition: pointgrp.h:199
SymmetryOperation transform(const SymmetryOperation &r) const
This performs the transform r * this * r~.
Definition: symop.cc:139
int make_table()
this fills in the irrep and symop arrays.
Definition: maketab.cc:96
void c2_x()
Set equal to C2 about the x axis.
Definition: pointgrp.h:242
std::string symb
Definition: pointgrp.h:597
int degeneracy() const
Returns the degeneracy of the irrep.
Definition: pointgrp.h:424
void transpose()
Definition: symop.cc:195
void print(std::string="outfile") const
Definition: irrep.cc:157
Definition: pointgrp.h:117
Definition: pointgrp.h:120
int complex() const
Returns the value of complex_.
Definition: pointgrp.h:428
~CharacterTable()
Definition: chartab.cc:104
Definition: pointgrp.h:116
const double * operator[](int i) const
const version of the above
Definition: pointgrp.h:303
void zero()
zero out the symop
Definition: pointgrp.h:178
SymRep transform(const SymRep &r) const
This performs the transform r * this * r~.
Definition: rep.cc:131
Definition: vector3.h:37
Definition: pointgrp.h:106
double character(int i) const
Definition: pointgrp.h:455
SymmetryOperation * symop
the matrices describing sym ops
Definition: pointgrp.h:494
SymRep(int=0)
Definition: rep.cc:68
void sigma_h()
Set equal to reflection in xy plane.
Definition: rep.cc:169
int equiv(const std::shared_ptr< PointGroup > &, double tol=1.0e-6) const
Returns 1 if the point groups are equivalent, 0 otherwise.
Definition: pointgrp.cc:230
double p(int x1, int x2, int i) const
Returns the element (x1,x2) of the i&#39;th representation matrix.
Definition: pointgrp.h:461
Groups
Definition: pointgrp.h:111
void analyze_d()
Definition: symop.cc:101
PointGroups::Groups pg
the class of the point group
Definition: pointgrp.h:491
int * _inv
index of the inverse symop
Definition: pointgrp.h:495
int ntrans() const
Returns the number of translations associated with the irrep.
Definition: pointgrp.h:440
void c2_y()
Set equal to C2 about the y axis.
Definition: pointgrp.h:250
Definition: pointgrp.h:106
CharacterTable & operator=(const CharacterTable &)
Definition: chartab.cc:113
double * operator[](int i)
returns the i&#39;th row of the transformation matrix
Definition: pointgrp.h:300
void rotation(int n)
Set equal to a clockwise rotation by 2pi/n.
Definition: rep.cc:209
void similar(unsigned char bits, unsigned char *sim, char &cnt)
Definition: pointgrp.cc:93
double d[5][5]
Definition: pointgrp.h:282
Vector3 origin_
Definition: pointgrp.h:598
int degen
Definition: pointgrp.h:395
Definition: pointgrp.h:106
Definition: pointgrp.h:114
~PointGroup()
Definition: pointgrp.cc:200
void c2_x()
Set equal to C2 about the x axis.
Definition: rep.cc:275
double p(int d, int i) const
Definition: pointgrp.h:466
PointGroup & operator=(const PointGroup &)
Definition: pointgrp.cc:205
~SymRep()
Definition: rep.cc:83
double operator()(int i, int j) const
const version of the above
Definition: pointgrp.h:174
int order() const
Returns the order of the group.
Definition: pointgrp.h:420
SymmetryOperation & symm_operation(int i)
Returns the i&#39;th symmetry operation.
Definition: pointgrp.h:530
double d[3][3]
Definition: pointgrp.h:144
unsigned char bits() const
Returns the bitwise representation of the point group.
Definition: pointgrp.h:679
void sigma_yz()
Set equal to reflection in yz plane.
Definition: rep.cc:195
void i()
Set equal to an inversion.
Definition: pointgrp.h:336
unsigned char bits_
Bitwise representation of the symmetry operations.
Definition: pointgrp.h:497
SymmetryOperation()
Definition: symop.cc:71
PointGroup()
Definition: pointgrp.cc:153
Definition: pointgrp.h:106
Operations
Definition: pointgrp.h:104
SymRep operate(const SymRep &r) const
This operates on this with r (i.e. return r * this).
Definition: rep.cc:107
Definition: pointgrp.h:127
PRAGMA_WARNING_PUSH PRAGMA_WARNING_IGNORE_DEPRECATED_DECLARATIONS PRAGMA_WARNING_POP
Definition: integraliter.cc:43
IrreducibleRepresentation & operator=(const IrreducibleRepresentation &)
Definition: irrep.cc:113
Definition: pointgrp.h:118
Definition: pointgrp.h:124
int which_irrep(int i)
Returns the irrep component i belongs to.
Definition: pointgrp.h:556
Definition: pointgrp.h:128
Definition: pointgrp.h:121
const Vector3 & origin() const
Definition: pointgrp.h:672
SymmetryOperation & operator=(SymmetryOperation const &a)
Definition: symop.cc:90
void sigma_xz()
Set equal to reflection in xz plane.
Definition: pointgrp.h:222
void set_symbol(const std::string &)
Sets (or resets) the Schoenflies symbol.
Definition: pointgrp.cc:213
void i()
Set equal to an inversion.
Definition: pointgrp.h:206
int order() const
Returns the order of the point group.
Definition: pointgrp.h:521
const double * operator[](int i) const
const version of the above
Definition: pointgrp.h:165
int ntrans_
Definition: pointgrp.h:397
int ncomp() const
Definition: pointgrp.h:545
void init(int=0, int=0, const char *=0, const char *=0)
Initialize the order, degeneracy, and Mulliken symbol of the irrep.
Definition: irrep.cc:128
int nrot_
Definition: pointgrp.h:396
const char * symbol_ns() const
Definition: pointgrp.h:450
int nirrep_
the number of irreps in this pg
Definition: pointgrp.h:492
~IrreducibleRepresentation()
Definition: irrep.cc:107
Definition: pointgrp.h:126
char * csymb
Definition: pointgrp.h:400
static const char * bits_to_basic_name(unsigned char bits)
Definition: pointgrp.cc:332
int nt
order of the princ rot axis
Definition: pointgrp.h:490
Definition: pointgrp.h:115
IrreducibleRepresentation & gamma(int i)
Returns the i&#39;th irrep.
Definition: pointgrp.h:527
char * symb
Definition: pointgrp.h:399
void rotation(int n)
Set equal to a clockwise rotation by 2pi/n.
Definition: symop.cc:170
Definition: pointgrp.h:119
IrreducibleRepresentation * gamma_
an array of irreps
Definition: pointgrp.h:493
Definition: pointgrp.h:125
Definition: pointgrp.h:113
double trace() const
returns the trace of the transformation matrix
Definition: pointgrp.h:369
Definition: pointgrp.h:106
double operator()(int i, int j) const
const version of double&amp; operator()(int i, int j)
Definition: pointgrp.h:311
SymmetryOperation operate(const SymmetryOperation &r) const
This operates on this with r (i.e. return r * this).
Definition: symop.cc:124
int nrot() const
Returns the number of rotations associated with the irrep.
Definition: pointgrp.h:436
Definition: pointgrp.h:594
Definition: pointgrp.h:106
void print(std::string out_fname="outfile") const
Definition: pointgrp.cc:366
unsigned char bits()
Definition: chartab.cc:209
~SymmetryOperation()
Definition: symop.cc:86
const char * symbol() const
Returns the Mulliken symbol for the irrep.
Definition: pointgrp.h:444
void common_init()
Definition: chartab.cc:173
unsigned char bits_
Definition: pointgrp.h:599
Definition: pointgrp.h:122
void sigma_xz()
Set equal to reflection in xz plane.
Definition: rep.cc:181
Vector3 & origin()
Definition: pointgrp.h:670
void c2_y()
Set equal to C2 about the y axis.
Definition: rep.cc:289
void sigma_xy()
Set equal to reflection in xy plane.
Definition: pointgrp.h:214
Definition: pointgrp.h:488
int which_comp(int i)
Returns which component i is.
Definition: pointgrp.h:568
Definition: pointgrp.h:389
void c2_z()
Set equal to C2 about the z axis.
Definition: pointgrp.h:258
std::string symbol() const
Returns the Schoenflies symbol for this point group.
Definition: pointgrp.h:666
Definition: pointgrp.h:141
void zero()
zero out the symop
Definition: pointgrp.h:315
double & operator()(int i, int j)
Definition: pointgrp.h:308
static bool full_name_to_bits(const std::string &pg, unsigned char &bits)
Definition: pointgrp.cc:238
std::string symb
the Schoenflies symbol for the pg
Definition: pointgrp.h:496
void print(std::string out)
print the matrix
Definition: symop.cc:208
double & operator()(int i, int j)
Definition: pointgrp.h:170
void sigma_yz()
Set equal to reflection in yz plane.
Definition: pointgrp.h:230
Definition: pointgrp.h:106
int n
Definition: pointgrp.h:281