CheMPS2
Irreps.cpp
1 /*
2  CheMPS2: a spin-adapted implementation of DMRG for ab initio quantum chemistry
3  Copyright (C) 2013-2016 Sebastian Wouters
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 
20 #include <stdlib.h>
21 #include <iostream>
22 #include <string>
23 
24 #include "Irreps.h"
25 
26 using std::string;
27 using std::cout;
28 using std::endl;
29 
31 
32  isActivated = false;
33 
34 }
35 
36 CheMPS2::Irreps::Irreps(const int nGroup){
37 
38  if ((nGroup >= 0) && (nGroup <= 7)){
39  isActivated = true;
40  groupNumber = nGroup;
41  nIrreps = getNumberOfIrreps(groupNumber);
42  } else {
43  isActivated = false;
44  }
45 
46 }
47 
49 
50 bool CheMPS2::Irreps::setGroup(const int nGroup){
51 
52  if ((nGroup >= 0) && (nGroup <= 7)){
53  isActivated = true;
54  groupNumber = nGroup;
55  nIrreps = getNumberOfIrreps(groupNumber);
56  } else {
57  isActivated = false;
58  }
59 
60  return isActivated;
61 
62 }
63 
64 bool CheMPS2::Irreps::getIsActivated() const{ return isActivated; }
65 
66 int CheMPS2::Irreps::getGroupNumber() const{ return isActivated ? groupNumber : -1 ; }
67 
69 
70  return isActivated ? getGroupNamePrivate(groupNumber) : "error" ;
71 
72 }
73 
74 string CheMPS2::Irreps::getGroupName(const int nGroup){
75 
76  return ((nGroup>=0)&&(nGroup<=7)) ? getGroupNamePrivate(nGroup) : "error" ;
77 
78 }
79 
80 string CheMPS2::Irreps::getGroupNamePrivate(const int nGroup){
81 
82  if (nGroup==0) return "c1";
83  if (nGroup==1) return "ci";
84  if (nGroup==2) return "c2";
85  if (nGroup==3) return "cs";
86  if (nGroup==4) return "d2";
87  if (nGroup==5) return "c2v";
88  if (nGroup==6) return "c2h";
89  if (nGroup==7) return "d2h";
90  return "error";
91 
92 }
93 
95 
96  return isActivated ? nIrreps : -1 ;
97 
98 }
99 
101 
102  if ((nGroup < 0) || ( nGroup > 7)){ return -1; }
103  if (nGroup == 0) return 1;
104  if (nGroup <= 3) return 2;
105  if (nGroup <= 6) return 4;
106  return 8;
107 
108 }
109 
110 string CheMPS2::Irreps::getIrrepName(const int irrepNumber) const{
111 
112  if (!isActivated) return "error1";
113 
114  if ( (irrepNumber<0) || (irrepNumber >= nIrreps) ) return "error2";
115 
116  return getIrrepNamePrivate(groupNumber,irrepNumber);
117 
118 }
119 
120 string CheMPS2::Irreps::getIrrepNamePrivate(const int nGroup, const int nIrrep){
121 
122  if (nGroup == 0){
123  if (nIrrep == 0) return "A";
124  }
125 
126  if (nGroup == 1){
127  if (nIrrep == 0) return "Ag";
128  if (nIrrep == 1) return "Au";
129  }
130 
131  if (nGroup == 2){
132  if (nIrrep == 0) return "A";
133  if (nIrrep == 1) return "B";
134  }
135 
136  if (nGroup == 3){
137  if (nIrrep == 0) return "Ap";
138  if (nIrrep == 1) return "App";
139  }
140 
141  if (nGroup == 4){
142  if (nIrrep == 0) return "A";
143  if (nIrrep == 1) return "B1";
144  if (nIrrep == 2) return "B2";
145  if (nIrrep == 3) return "B3";
146  }
147 
148  if (nGroup == 5){
149  if (nIrrep == 0) return "A1";
150  if (nIrrep == 1) return "A2";
151  if (nIrrep == 2) return "B1";
152  if (nIrrep == 3) return "B2";
153  }
154 
155  if (nGroup == 6){
156  if (nIrrep == 0) return "Ag";
157  if (nIrrep == 1) return "Bg";
158  if (nIrrep == 2) return "Au";
159  if (nIrrep == 3) return "Bu";
160  }
161 
162  if (nGroup == 7){
163  if (nIrrep == 0) return "Ag";
164  if (nIrrep == 1) return "B1g";
165  if (nIrrep == 2) return "B2g";
166  if (nIrrep == 3) return "B3g";
167  if (nIrrep == 4) return "Au";
168  if (nIrrep == 5) return "B1u";
169  if (nIrrep == 6) return "B2u";
170  if (nIrrep == 7) return "B3u";
171  }
172 
173  return "error2";
174 
175 }
176 
177 void CheMPS2::Irreps::symm_psi2molpro( int * psi2molpro ) const{
178 
179  if (!isActivated) return;
180  symm_psi2molpro( psi2molpro, getGroupName() );
181 
182 }
183 
184 void CheMPS2::Irreps::symm_psi2molpro( int * psi2molpro, const string SymmLabel ){
185 
186  if ( SymmLabel.compare("c1")==0 ){
187  psi2molpro[0] = 1;
188  }
189  if ( ( SymmLabel.compare("ci")==0 ) || ( SymmLabel.compare("c2")==0 ) || ( SymmLabel.compare("cs")==0 ) ){
190  psi2molpro[0] = 1;
191  psi2molpro[1] = 2;
192  }
193  if ( ( SymmLabel.compare("d2")==0 ) ){
194  psi2molpro[0] = 1;
195  psi2molpro[1] = 4;
196  psi2molpro[2] = 3;
197  psi2molpro[3] = 2;
198  }
199  if ( ( SymmLabel.compare("c2v")==0 ) || ( SymmLabel.compare("c2h")==0 ) ){
200  psi2molpro[0] = 1;
201  psi2molpro[1] = 4;
202  psi2molpro[2] = 2;
203  psi2molpro[3] = 3;
204  }
205  if ( ( SymmLabel.compare("d2h")==0 ) ){
206  psi2molpro[0] = 1;
207  psi2molpro[1] = 4;
208  psi2molpro[2] = 6;
209  psi2molpro[3] = 7;
210  psi2molpro[4] = 8;
211  psi2molpro[5] = 5;
212  psi2molpro[6] = 3;
213  psi2molpro[7] = 2;
214  }
215 
216 }
217 
219 
220  for (int thegroup=0; thegroup<8; thegroup++){
221  cout << "######################################################" << endl;
222  cout << "Name = " << getGroupNamePrivate(thegroup) << endl;
223  cout << "nIrreps = " << getNumberOfIrreps(thegroup) << endl;
224  cout << "Multiplication table :" << endl;
225  for (int irrep1=-1; irrep1<getNumberOfIrreps(thegroup); irrep1++){
226  for (int irrep2=-1; irrep2<getNumberOfIrreps(thegroup); irrep2++){
227  if ((irrep1 == -1) && (irrep2 == -1)) cout << "\t";
228  if ((irrep1 == -1) && (irrep2 >= 0 )) cout << getIrrepNamePrivate(thegroup, irrep2) << "\t";
229  if ((irrep2 == -1) && (irrep1 >= 0 )) cout << getIrrepNamePrivate(thegroup, irrep1) << "\t";
230  if ((irrep2 >= 0) && (irrep1 >= 0 )) cout << getIrrepNamePrivate(thegroup, directProd(irrep1, irrep2)) << "\t";
231  }
232  cout << endl;
233  }
234  }
235  cout << "######################################################" << endl;
236 
237 }
238 
239 
bool setGroup(const int nGroup)
Set the group.
Definition: Irreps.cpp:50
int getNumberOfIrreps() const
Get the number of irreps for the currently activated group.
Definition: Irreps.cpp:94
static void printAll()
Print all info contained in this class.
Definition: Irreps.cpp:218
void symm_psi2molpro(int *psi2molpro) const
Fill the array psi2molpro with the irrep conventions of molpro for the currently activated group...
Definition: Irreps.cpp:177
int getGroupNumber() const
Get the group number.
Definition: Irreps.cpp:66
bool getIsActivated() const
Whether the group number is already activated.
Definition: Irreps.cpp:64
string getGroupName() const
Get the name of the group.
Definition: Irreps.cpp:68
virtual ~Irreps()
Destructor.
Definition: Irreps.cpp:48
static int directProd(const int Irrep1, const int Irrep2)
Get the direct product of the irreps with numbers Irrep1 and Irrep2: a bitwise XOR for psi4&#39;s convent...
Definition: Irreps.h:123
Irreps()
Constructor.
Definition: Irreps.cpp:30
string getIrrepName(const int irrepNumber) const
Get the name of the irrep with number irrepNumber of the activated group. The irrep with number 0 is ...
Definition: Irreps.cpp:110