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 program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  *
25  * @END LICENSE
26  */
27 
28 //
29 // pointgrp.h
30 //
31 // Additional modifications made by Justin Turney <jturney@ccqc.uga.edu>
32 // for use in PSI4.
33 //
34 // Modifications are
35 // Copyright (C) 1996 Limit Point Systems, Inc.
36 //
37 // Author: Edward Seidl <seidl@janed.com>
38 // Maintainer: LPS
39 //
40 // This file is part of the SC Toolkit.
41 //
42 // The SC Toolkit is free software; you can redistribute it and/or modify
43 // it under the terms of the GNU Library General Public License as published by
44 // the Free Software Foundation; either version 2, or (at your option)
45 // any later version.
46 //
47 // The SC Toolkit is distributed in the hope that it will be useful,
48 // but WITHOUT ANY WARRANTY; without even the implied warranty of
49 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50 // GNU Library General Public License for more details.
51 //
52 // You should have received a copy of the GNU General Public License along
53 // with this program; if not, write to the Free Software Foundation, Inc.,
54 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
55 //
56 // The U.S. Government is granted a limited license as per AL 91-7.
57 //
58 
59 /* pointgrp.h -- definition of the point group classes
60  *
61  * THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
62  * "UNITED STATES GOVERNMENT WORK". IT WAS WRITTEN AS A PART OF THE
63  * AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE. THIS MEANS IT
64  * CANNOT BE COPYRIGHTED. THIS SOFTWARE IS FREELY AVAILABLE TO THE
65  * PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
66  * RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
67  *
68  * Author:
69  * E. T. Seidl
70  * Bldg. 12A, Rm. 2033
71  * Computer Systems Laboratory
72  * Division of Computer Research and Technology
73  * National Institutes of Health
74  * Bethesda, Maryland 20892
75  * Internet: seidl@alw.nih.gov
76  * June, 1993
77  */
78 
79 #ifndef _math_symmetry_pointgrp_h
80 #define _math_symmetry_pointgrp_h
81 
82 #include "psi4/libmints/vector3.h"
83 #include "psi4/psi4-dec.h"
84 
85 #include <string>
86 #include <cstdio>
87 #include <stdint.h>
88 #include <vector>
89 #include <map>
90 
91  #include "psi4/pragma.h"
92  PRAGMA_WARNING_PUSH
93  PRAGMA_WARNING_IGNORE_DEPRECATED_DECLARATIONS
94  #include <memory>
96 
97 namespace psi {
98 
99 #define NUM_TO_OPERATOR_ID(x) ((x) ? 1<<((x)-1) : 0)
100 #define SKIP_THIS_OPERATOR(num, bit) ((bit) ? !((1<<((bit)-1)) & (num)) : 0 )
101 
102 namespace SymmOps {
104 {
105  E = 0, C2_z = 1, C2_y = 2, C2_x = 4, i = 8, Sigma_xy = 16, Sigma_xz = 32, Sigma_yz = 64, ID = 128
106 };
107 }
108 
109 namespace PointGroups {
110 enum Groups
111 {
129 };
130 
131 void similar(unsigned char bits, unsigned char *sim, char& cnt);
132 
133 }
134 
135 // //////////////////////////////////////////////////////////////////
136 
141 {
142 private:
143  double d[3][3];
144  unsigned short bits_;
145 
146  void analyze_d();
147 
148 public:
152 
153  SymmetryOperation& operator=(SymmetryOperation const& a); // Assignment operator
154 
156  double trace() const
157  { return d[0][0] + d[1][1] + d[2][2]; }
158 
160  double *operator[](int i)
161  { return d[i]; }
162 
164  const double *operator[](int i) const
165  { return d[i]; }
166 
169  double& operator()(int i, int j)
170  { return d[i][j]; }
171 
173  double operator()(int i, int j) const
174  { return d[i][j]; }
175 
177  void zero()
178  { ::memset(d, 0, sizeof(double) * 9); }
179 
182 
185 
187  unsigned char bit() const
188  { return bits_; }
189 
191  void unit()
192  {
193  zero();
194  d[0][0] = d[1][1] = d[2][2] = 1.0;
195  }
196 
198  void E()
199  {
200  unit();
201  bits_ = SymmOps::E;
202  }
203 
205  void i()
206  {
207  zero();
208  d[0][0] = d[1][1] = d[2][2] = -1.0;
209  bits_ = SymmOps::i;
210  }
211 
213  void sigma_xy()
214  {
215  unit();
216  d[2][2] = -1.0;
218  }
219 
221  void sigma_xz()
222  {
223  unit();
224  d[1][1] = -1.0;
226  }
227 
229  void sigma_yz()
230  {
231  unit();
232  d[0][0] = -1.0;
234  }
235 
237  void rotation(int n);
238  void rotation(double theta);
239 
241  void c2_x()
242  {
243  i();
244  d[0][0] = 1.0;
246  }
247 
249  void c2_y()
250  {
251  i();
252  d[1][1] = 1.0;
254  }
255 
257  void c2_z()
258  {
259  i();
260  d[2][2] = 1.0;
262  }
263 
264  void transpose();
265 
267  void print(std::string out);
268 };
269 
270 // //////////////////////////////////////////////////////////////////
271 
277 class SymRep
278 {
279 private:
280  int n;
281  double d[5][5];
282 
283 public:
284  SymRep(int = 0);
285  SymRep(const SymmetryOperation&);
286  ~SymRep();
287 
289  operator SymmetryOperation() const;
290 
292  inline double trace() const;
293 
295  void set_dim(int i)
296  { n = i; }
297 
299  double *operator[](int i)
300  { return d[i]; }
302  const double *operator[](int i) const
303  { return d[i]; }
304 
307  double& operator()(int i, int j)
308  { return d[i][j]; }
310  double operator()(int i, int j) const
311  { return d[i][j]; }
312 
314  void zero()
315  { ::memset(d, 0, sizeof(double) * 25); }
316 
318  SymRep operate(const SymRep& r) const;
319 
321  SymRep transform(const SymRep& r) const;
322 
324  void unit()
325  {
326  zero();
327  d[0][0] = d[1][1] = d[2][2] = d[3][3] = d[4][4] = 1.0;
328  }
329 
331  void E()
332  { unit(); }
333 
335  void i()
336  {
337  zero();
338  d[0][0] = d[1][1] = d[2][2] = d[3][3] = d[4][4] = -1.0;
339  }
340 
342  void sigma_h();
343 
345  void sigma_xz();
346 
348  void sigma_yz();
349 
351  void rotation(int n);
352  void rotation(double theta);
353 
355  void c2_x();
356 
358  void c2_y();
359 
361  void c2_z();
362 
364  // void print(std::ostream& =ExEnv::out0()) const;
365 };
366 
367 inline double
369 {
370  double r = 0;
371  for (int i = 0; i < n; i++)
372  r += d[i][i];
373  return r;
374 }
375 
376 // //////////////////////////////////////////////////////////////////
377 
378 
379 class CharacterTable;
380 
389 {
390  friend class CharacterTable;
391 
392 private:
393  int g; // the order of the group
394  int degen; // the degeneracy of the irrep
395  int nrot_; // the number of rotations in this irrep
396  int ntrans_; // the number of translations in this irrep
397  int complex_; // true if this irrep has a complex representation
398  char *symb; // mulliken symbol for this irrep
399  char *csymb; // mulliken symbol for this irrep w/o special characters
400 
401  SymRep *rep; // representation matrices for the symops
402 
403 public:
409  IrreducibleRepresentation(int, int, const char *, const char * = 0);
410 
412 
414 
416  void init(int = 0, int = 0, const char * = 0, const char * = 0);
417 
419  int order() const
420  { return g; }
421 
423  int degeneracy() const
424  { return degen; }
425 
427  int complex() const
428  { return complex_; }
429 
431  int nproj() const
432  { return degen * degen; }
433 
435  int nrot() const
436  { return nrot_; }
437 
439  int ntrans() const
440  { return ntrans_; }
441 
443  const char *symbol() const
444  { return symb; }
445 
449  const char *symbol_ns() const
450  { return (csymb ? csymb : symb); }
451 
454  double character(int i) const
455  {
456  return complex_ ? 0.5 * rep[i].trace() : rep[i].trace();
457  }
458 
460  double p(int x1, int x2, int i) const
461  { return rep[i](x1, x2); }
462 
465  double p(int d, int i) const
466  {
467  int dc = d / degen;
468  int dr = d % degen;
469  return rep[i](dr, dc);
470  }
471 
475  void print(std::string = "outfile") const;
476 };
477 
478 // ///////////////////////////////////////////////////////////
488 {
489  int nt;
491  int nirrep_;
494  int *_inv;
495  std::string symb;
496  unsigned char bits_;
497 
499  int make_table();
500  void common_init();
501 
502 public:
503  CharacterTable();
506  CharacterTable(const std::string&);
509  CharacterTable(unsigned char);
510 
512  ~CharacterTable();
513 
515 
517  int nirrep() const
518  { return nirrep_; }
520  int order() const
521  { return nirrep_; }
523  const std::string& symbol() const
524  { return symb; }
527  { return gamma_[i]; }
530  { return symop[i]; }
531 
535  int complex() const
536  {
537  return 0;
538  }
539 
541  int inverse(int i) const
542  { return _inv[i]; }
543 
544  int ncomp() const
545  {
546  int ret = 0;
547  for (int i = 0; i < nirrep_; i++) {
548  int nc = (gamma_[i].complex()) ? 1 : gamma_[i].degen;
549  ret += nc;
550  }
551  return ret;
552  }
553 
555  int which_irrep(int i)
556  {
557  for (int ir = 0, cn = 0; ir < nirrep_; ir++) {
558  int nc = (gamma_[ir].complex()) ? 1 : gamma_[ir].degen;
559  for (int c = 0; c < nc; c++, cn++)
560  if (cn == i)
561  return ir;
562  }
563  return -1;
564  }
565 
567  int which_comp(int i)
568  {
569  for (int ir = 0, cn = 0; ir < nirrep_; ir++) {
570  int nc = (gamma_[ir].complex()) ? 1 : gamma_[ir].degen;
571  for (int c = 0; c < nc; c++, cn++)
572  if (cn == i)
573  return c;
574  }
575  return -1;
576  }
577 
578  unsigned char bits();
579 
581  void print(std::string = "outfile") const;
582 };
583 
584 // ///////////////////////////////////////////////////////////
585 
594 {
595 private:
596  std::string symb;
598  unsigned char bits_;
599 
600 public:
601  PointGroup();
602 
603  // These 2 constructors do not work right now.
606  PointGroup(const std::string&);
609  PointGroup(const std::string&, const Vector3&);
610 
612  PointGroup(unsigned char bits);
614  PointGroup(unsigned char bits, const Vector3&);
615 
650  // PointGroup(const Ref<KeyVal>&);
651 
652  // PointGroup(StateIn&);
653  PointGroup(const PointGroup&);
654  PointGroup(const std::shared_ptr<PointGroup>&);
655  ~PointGroup();
656 
658 
660  int equiv(const std::shared_ptr<PointGroup>&, double tol = 1.0e-6) const;
661 
663  CharacterTable char_table() const;
665  std::string symbol() const
666  { return symb; }
670  { return origin_; }
671  const Vector3& origin() const
672  { return origin_; }
673 
675  void set_symbol(const std::string&);
676 
678  unsigned char bits() const
679  { return bits_; }
680 
681  static const char *bits_to_full_name(unsigned char bits);
682  static const char *bits_to_basic_name(unsigned char bits);
683  static bool full_name_to_bits(const std::string& pg, unsigned char& bits);
684 
685  void print(std::string OutFileRMR = "outfile") const;
686 };
687 
688 }
689 
690 #endif
691 
692 // Local Variables:
693 // mode: c++
694 // c-file-style: "ETS"
695 // End:
unsigned short bits_
Definition: pointgrp.h:144
SymRep * rep
Definition: pointgrp.h:401
Definition: pointgrp.h:105
void print(std::string="outfile") const
This prints the irrep to the given file, or stdout if none is given.
Definition: chartab.cc:149
void c2_z()
Set equal to C2 about the z axis.
Definition: rep.cc:303
int g
Definition: pointgrp.h:393
Definition: pointgrp.h:122
double trace() const
returns the trace of the transformation matrix
Definition: pointgrp.h:156
int complex_
Definition: pointgrp.h:397
void unit()
Set equal to a unit matrix.
Definition: pointgrp.h:324
CharacterTable char_table() const
Returns the CharacterTable for this point group.
Definition: pointgrp.cc:221
const std::string & symbol() const
Returns the Schoenflies symbol for the point group.
Definition: pointgrp.h:523
CharacterTable()
Definition: chartab.cc:89
int nirrep() const
Returns the number of irreps.
Definition: pointgrp.h:517
int complex() const
Definition: pointgrp.h:535
IrreducibleRepresentation()
Definition: irrep.cc:87
int nproj() const
Returns the number of projection operators for the irrep.
Definition: pointgrp.h:431
void set_dim(int i)
set the dimension of d
Definition: pointgrp.h:295
static const char * bits_to_full_name(unsigned char bits)
Definition: pointgrp.cc:289
void unit()
Set equal to a unit matrix.
Definition: pointgrp.h:191
int inverse(int i) const
Returns the index of the symop which is the inverse of symop[i].
Definition: pointgrp.h:541
Definition: pointgrp.h:277
double * operator[](int i)
returns the i&#39;th row of the transformation matrix
Definition: pointgrp.h:160
void E()
Set equal to the identity.
Definition: pointgrp.h:331
Definition: pointgrp.h:105
unsigned char bit() const
Get the bit value.
Definition: pointgrp.h:187
void E()
Set equal to E.
Definition: pointgrp.h:198
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:241
std::string symb
Definition: pointgrp.h:596
int degeneracy() const
Returns the degeneracy of the irrep.
Definition: pointgrp.h:423
void transpose()
Definition: symop.cc:195
void print(std::string="outfile") const
Definition: irrep.cc:157
Definition: pointgrp.h:116
Definition: pointgrp.h:119
int complex() const
Returns the value of complex_.
Definition: pointgrp.h:427
~CharacterTable()
Definition: chartab.cc:102
Definition: pointgrp.h:115
const double * operator[](int i) const
const version of the above
Definition: pointgrp.h:302
void zero()
zero out the symop
Definition: pointgrp.h:177
SymRep transform(const SymRep &r) const
This performs the transform r * this * r~.
Definition: rep.cc:131
Definition: vector3.h:36
Definition: pointgrp.h:105
double character(int i) const
Definition: pointgrp.h:454
SymmetryOperation * symop
the matrices describing sym ops
Definition: pointgrp.h:493
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:228
double p(int x1, int x2, int i) const
Returns the element (x1,x2) of the i&#39;th representation matrix.
Definition: pointgrp.h:460
Groups
Definition: pointgrp.h:110
void analyze_d()
Definition: symop.cc:101
PointGroups::Groups pg
the class of the point group
Definition: pointgrp.h:490
int * _inv
index of the inverse symop
Definition: pointgrp.h:494
int ntrans() const
Returns the number of translations associated with the irrep.
Definition: pointgrp.h:439
void c2_y()
Set equal to C2 about the y axis.
Definition: pointgrp.h:249
Definition: pointgrp.h:105
CharacterTable & operator=(const CharacterTable &)
Definition: chartab.cc:111
double * operator[](int i)
returns the i&#39;th row of the transformation matrix
Definition: pointgrp.h:299
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:91
double d[5][5]
Definition: pointgrp.h:281
Vector3 origin_
Definition: pointgrp.h:597
int degen
Definition: pointgrp.h:394
Definition: pointgrp.h:105
Definition: pointgrp.h:113
~PointGroup()
Definition: pointgrp.cc:198
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:465
PointGroup & operator=(const PointGroup &)
Definition: pointgrp.cc:203
~SymRep()
Definition: rep.cc:83
double operator()(int i, int j) const
const version of the above
Definition: pointgrp.h:173
int order() const
Returns the order of the group.
Definition: pointgrp.h:419
SymmetryOperation & symm_operation(int i)
Returns the i&#39;th symmetry operation.
Definition: pointgrp.h:529
double d[3][3]
Definition: pointgrp.h:143
unsigned char bits() const
Returns the bitwise representation of the point group.
Definition: pointgrp.h:678
void sigma_yz()
Set equal to reflection in yz plane.
Definition: rep.cc:195
void i()
Set equal to an inversion.
Definition: pointgrp.h:335
unsigned char bits_
Bitwise representation of the symmetry operations.
Definition: pointgrp.h:496
SymmetryOperation()
Definition: symop.cc:71
PointGroup()
Definition: pointgrp.cc:151
Definition: pointgrp.h:105
Operations
Definition: pointgrp.h:103
SymRep operate(const SymRep &r) const
This operates on this with r (i.e. return r * this).
Definition: rep.cc:107
Definition: pointgrp.h:126
PRAGMA_WARNING_PUSH PRAGMA_WARNING_IGNORE_DEPRECATED_DECLARATIONS PRAGMA_WARNING_POP
Definition: integraliter.cc:42
IrreducibleRepresentation & operator=(const IrreducibleRepresentation &)
Definition: irrep.cc:113
Definition: pointgrp.h:117
Definition: pointgrp.h:123
int which_irrep(int i)
Returns the irrep component i belongs to.
Definition: pointgrp.h:555
Definition: pointgrp.h:127
Definition: pointgrp.h:120
const Vector3 & origin() const
Definition: pointgrp.h:671
SymmetryOperation & operator=(SymmetryOperation const &a)
Definition: symop.cc:90
void sigma_xz()
Set equal to reflection in xz plane.
Definition: pointgrp.h:221
void set_symbol(const std::string &)
Sets (or resets) the Schoenflies symbol.
Definition: pointgrp.cc:211
void i()
Set equal to an inversion.
Definition: pointgrp.h:205
int order() const
Returns the order of the point group.
Definition: pointgrp.h:520
const double * operator[](int i) const
const version of the above
Definition: pointgrp.h:164
int ntrans_
Definition: pointgrp.h:396
int ncomp() const
Definition: pointgrp.h:544
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:395
const char * symbol_ns() const
Definition: pointgrp.h:449
int nirrep_
the number of irreps in this pg
Definition: pointgrp.h:491
~IrreducibleRepresentation()
Definition: irrep.cc:107
Definition: pointgrp.h:125
char * csymb
Definition: pointgrp.h:399
static const char * bits_to_basic_name(unsigned char bits)
Definition: pointgrp.cc:330
int nt
order of the princ rot axis
Definition: pointgrp.h:489
Definition: pointgrp.h:114
IrreducibleRepresentation & gamma(int i)
Returns the i&#39;th irrep.
Definition: pointgrp.h:526
char * symb
Definition: pointgrp.h:398
void rotation(int n)
Set equal to a clockwise rotation by 2pi/n.
Definition: symop.cc:170
Definition: pointgrp.h:118
IrreducibleRepresentation * gamma_
an array of irreps
Definition: pointgrp.h:492
Definition: pointgrp.h:124
Definition: pointgrp.h:112
double trace() const
returns the trace of the transformation matrix
Definition: pointgrp.h:368
Definition: pointgrp.h:105
double operator()(int i, int j) const
const version of double&amp; operator()(int i, int j)
Definition: pointgrp.h:310
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:435
Definition: pointgrp.h:593
Definition: pointgrp.h:105
unsigned char bits()
Definition: chartab.cc:207
~SymmetryOperation()
Definition: symop.cc:86
const char * symbol() const
Returns the Mulliken symbol for the irrep.
Definition: pointgrp.h:443
void common_init()
Definition: chartab.cc:171
unsigned char bits_
Definition: pointgrp.h:598
Definition: pointgrp.h:121
void sigma_xz()
Set equal to reflection in xz plane.
Definition: rep.cc:181
Vector3 & origin()
Definition: pointgrp.h:669
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:213
Definition: pointgrp.h:487
int which_comp(int i)
Returns which component i is.
Definition: pointgrp.h:567
Definition: pointgrp.h:388
void c2_z()
Set equal to C2 about the z axis.
Definition: pointgrp.h:257
std::string symbol() const
Returns the Schoenflies symbol for this point group.
Definition: pointgrp.h:665
Definition: pointgrp.h:140
void zero()
zero out the symop
Definition: pointgrp.h:314
double & operator()(int i, int j)
Definition: pointgrp.h:307
static bool full_name_to_bits(const std::string &pg, unsigned char &bits)
Definition: pointgrp.cc:236
std::string symb
the Schoenflies symbol for the pg
Definition: pointgrp.h:495
void print(std::string OutFileRMR="outfile") const
Definition: pointgrp.cc:364
void print(std::string out)
print the matrix
Definition: symop.cc:208
double & operator()(int i, int j)
Definition: pointgrp.h:169
void sigma_yz()
Set equal to reflection in yz plane.
Definition: pointgrp.h:229
Definition: pointgrp.h:105
int n
Definition: pointgrp.h:280