| 1 | //
|
|---|
| 2 | // chartab.cc
|
|---|
| 3 | //
|
|---|
| 4 | // Modifictions are
|
|---|
| 5 | // Copyright (C) 1996 Limit Point Systems, Inc.
|
|---|
| 6 | //
|
|---|
| 7 | // Author: Edward Seidl <seidl@janed.com>
|
|---|
| 8 | // Maintainer: LPS
|
|---|
| 9 | //
|
|---|
| 10 | // This file is part of the SC Toolkit.
|
|---|
| 11 | //
|
|---|
| 12 | // The SC Toolkit is free software; you can redistribute it and/or modify
|
|---|
| 13 | // it under the terms of the GNU Library General Public License as published by
|
|---|
| 14 | // the Free Software Foundation; either version 2, or (at your option)
|
|---|
| 15 | // any later version.
|
|---|
| 16 | //
|
|---|
| 17 | // The SC Toolkit 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 Library General Public License for more details.
|
|---|
| 21 | //
|
|---|
| 22 | // You should have received a copy of the GNU Library General Public License
|
|---|
| 23 | // along with the SC Toolkit; see the file COPYING.LIB. If not, write to
|
|---|
| 24 | // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|---|
| 25 | //
|
|---|
| 26 | // The U.S. Government is granted a limited license as per AL 91-7.
|
|---|
| 27 | //
|
|---|
| 28 |
|
|---|
| 29 | /* chartab.cc -- implementation of the point group classes
|
|---|
| 30 | *
|
|---|
| 31 | * THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
|
|---|
| 32 | * "UNITED STATES GOVERNMENT WORK". IT WAS WRITTEN AS A PART OF THE
|
|---|
| 33 | * AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE. THIS MEANS IT
|
|---|
| 34 | * CANNOT BE COPYRIGHTED. THIS SOFTWARE IS FREELY AVAILABLE TO THE
|
|---|
| 35 | * PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
|
|---|
| 36 | * RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
|
|---|
| 37 | *
|
|---|
| 38 | * Author:
|
|---|
| 39 | * E. T. Seidl
|
|---|
| 40 | * Bldg. 12A, Rm. 2033
|
|---|
| 41 | * Computer Systems Laboratory
|
|---|
| 42 | * Division of Computer Research and Technology
|
|---|
| 43 | * National Institutes of Health
|
|---|
| 44 | * Bethesda, Maryland 20892
|
|---|
| 45 | * Internet: seidl@alw.nih.gov
|
|---|
| 46 | * June, 1993
|
|---|
| 47 | */
|
|---|
| 48 |
|
|---|
| 49 | #include <ctype.h>
|
|---|
| 50 |
|
|---|
| 51 | #include <util/misc/formio.h>
|
|---|
| 52 | #include <util/misc/newstring.h>
|
|---|
| 53 | #include <math/symmetry/pointgrp.h>
|
|---|
| 54 |
|
|---|
| 55 | using namespace std;
|
|---|
| 56 | using namespace sc;
|
|---|
| 57 |
|
|---|
| 58 | ////////////////////////////////////////////////////////////////////////
|
|---|
| 59 |
|
|---|
| 60 | CharacterTable::CharacterTable()
|
|---|
| 61 | : g(0), nt(0), pg(C1), nirrep_(0), gamma_(0), symop(0), _inv(0), symb(0)
|
|---|
| 62 | {
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | CharacterTable::CharacterTable(const CharacterTable& ct)
|
|---|
| 66 | : g(0), nt(0), pg(C1), nirrep_(0), gamma_(0), symop(0), _inv(0), symb(0)
|
|---|
| 67 | {
|
|---|
| 68 | *this = ct;
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | CharacterTable::~CharacterTable()
|
|---|
| 72 | {
|
|---|
| 73 | if (symb) delete[] symb; symb=0;
|
|---|
| 74 | if (gamma_) delete[] gamma_; gamma_=0;
|
|---|
| 75 | if (symop) delete[] symop; symop=0;
|
|---|
| 76 | if (_inv) delete[] _inv; _inv=0;
|
|---|
| 77 | g=nt=nirrep_=0;
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | CharacterTable&
|
|---|
| 81 | CharacterTable::operator=(const CharacterTable& ct)
|
|---|
| 82 | {
|
|---|
| 83 | g=ct.g; nt=ct.nt; pg=ct.pg; nirrep_=ct.nirrep_;
|
|---|
| 84 |
|
|---|
| 85 | if (symb)
|
|---|
| 86 | delete[] symb;
|
|---|
| 87 |
|
|---|
| 88 | symb = new_string(ct.symb);
|
|---|
| 89 |
|
|---|
| 90 | if (gamma_) delete[] gamma_; gamma_=0;
|
|---|
| 91 | if (ct.gamma_) {
|
|---|
| 92 | gamma_ = new IrreducibleRepresentation[nirrep_];
|
|---|
| 93 | for (int i=0; i < nirrep_; i++) {
|
|---|
| 94 | gamma_[i].init();
|
|---|
| 95 | gamma_[i] = ct.gamma_[i];
|
|---|
| 96 | }
|
|---|
| 97 | }
|
|---|
| 98 |
|
|---|
| 99 | if (symop)
|
|---|
| 100 | delete[] symop;
|
|---|
| 101 | symop=0;
|
|---|
| 102 |
|
|---|
| 103 | if (ct.symop) {
|
|---|
| 104 | symop = new SymmetryOperation[g];
|
|---|
| 105 | for (int i=0; i < g; i++) {
|
|---|
| 106 | symop[i] = ct.symop[i];
|
|---|
| 107 | }
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 | if (_inv)
|
|---|
| 111 | delete[] _inv;
|
|---|
| 112 | _inv=0;
|
|---|
| 113 |
|
|---|
| 114 | if (ct._inv) {
|
|---|
| 115 | _inv = new int[g];
|
|---|
| 116 | memcpy(_inv,ct._inv,sizeof(int)*g);
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 | return *this;
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 122 | void
|
|---|
| 123 | CharacterTable::print(ostream& os) const
|
|---|
| 124 | {
|
|---|
| 125 | if (!g || !nirrep_) return;
|
|---|
| 126 |
|
|---|
| 127 | int i;
|
|---|
| 128 |
|
|---|
| 129 | os << indent << "point group " << symb << endl << endl;
|
|---|
| 130 |
|
|---|
| 131 | for (i=0; i < nirrep_; i++)
|
|---|
| 132 | gamma_[i].print(os);
|
|---|
| 133 |
|
|---|
| 134 | os << endl << indent << "symmetry operation matrices:"
|
|---|
| 135 | << endl << endl << incindent;
|
|---|
| 136 | for (i=0; i < g; i++)
|
|---|
| 137 | symop[i].print(os);
|
|---|
| 138 |
|
|---|
| 139 | os << decindent << indent << "inverse symmetry operation matrices:"
|
|---|
| 140 | << endl << endl << incindent;
|
|---|
| 141 | for (i=0; i < g; i++)
|
|---|
| 142 | symop[inverse(i)].print(os);
|
|---|
| 143 |
|
|---|
| 144 | os << decindent;
|
|---|
| 145 | }
|
|---|
| 146 |
|
|---|
| 147 | CharacterTable::CharacterTable(const char *cpg, const SymmetryOperation& frame)
|
|---|
| 148 | : g(0), nt(0), pg(C1), nirrep_(0), gamma_(0), symop(0), _inv(0), symb(0)
|
|---|
| 149 | {
|
|---|
| 150 | // first parse the point group symbol, this will give us the order of the
|
|---|
| 151 | // point group(g), the type of point group (pg), the order of the principle
|
|---|
| 152 | // rotation axis (nt), and the number of irreps (nirrep_)
|
|---|
| 153 |
|
|---|
| 154 | if (!cpg) {
|
|---|
| 155 | ExEnv::errn() << "CharacterTable::CharacterTable: null point group" << endl;
|
|---|
| 156 | exit(1);
|
|---|
| 157 | }
|
|---|
| 158 |
|
|---|
| 159 | symb = new char[strlen(cpg)+1];
|
|---|
| 160 | size_t i;
|
|---|
| 161 | for (i=0; i < strlen(cpg); i++) symb[i] = tolower(cpg[i]);
|
|---|
| 162 | symb[i] = '\0';
|
|---|
| 163 |
|
|---|
| 164 | if (parse_symbol() < 0) {
|
|---|
| 165 | ExEnv::errn() << "CharacterTable::CharacterTable: invalid point group "
|
|---|
| 166 | << cpg << endl;
|
|---|
| 167 | exit(1);
|
|---|
| 168 | }
|
|---|
| 169 |
|
|---|
| 170 | if (make_table() < 0) {
|
|---|
| 171 | ExEnv::errn() << "CharacterTable::CharacterTable: could not make table" << endl;
|
|---|
| 172 | exit(1);
|
|---|
| 173 | }
|
|---|
| 174 |
|
|---|
| 175 | int ig;
|
|---|
| 176 | for (ig=0; ig < g; ig++)
|
|---|
| 177 | symop[ig] = symop[ig].transform(frame);
|
|---|
| 178 | }
|
|---|
| 179 |
|
|---|
| 180 | CharacterTable::CharacterTable(const char *cpg)
|
|---|
| 181 | : g(0), nt(0), pg(C1), nirrep_(0), gamma_(0), symop(0), _inv(0), symb(0)
|
|---|
| 182 | {
|
|---|
| 183 | // first parse the point group symbol, this will give us the order of the
|
|---|
| 184 | // point group(g), the type of point group (pg), the order of the principle
|
|---|
| 185 | // rotation axis (nt), and the number of irreps (nirrep_)
|
|---|
| 186 |
|
|---|
| 187 | if (!cpg) {
|
|---|
| 188 | ExEnv::errn() << "CharacterTable::CharacterTable: null point group" << endl;
|
|---|
| 189 | exit(1);
|
|---|
| 190 | }
|
|---|
| 191 |
|
|---|
| 192 | symb = new char[strlen(cpg)+1];
|
|---|
| 193 | size_t i;
|
|---|
| 194 | for (i=0; i < strlen(cpg); i++) symb[i] = tolower(cpg[i]);
|
|---|
| 195 | symb[i] = '\0';
|
|---|
| 196 |
|
|---|
| 197 | if (parse_symbol() < 0) {
|
|---|
| 198 | ExEnv::errn() << "CharacterTable::CharacterTable: invalid point group "
|
|---|
| 199 | << cpg << endl;
|
|---|
| 200 | exit(1);
|
|---|
| 201 | }
|
|---|
| 202 |
|
|---|
| 203 | if (make_table() < 0) {
|
|---|
| 204 | ExEnv::errn() << "CharacterTable::CharacterTable: could not make table" << endl;
|
|---|
| 205 | exit(1);
|
|---|
| 206 | }
|
|---|
| 207 | }
|
|---|
| 208 |
|
|---|
| 209 | int
|
|---|
| 210 | CharacterTable::parse_symbol()
|
|---|
| 211 | {
|
|---|
| 212 | // default to C1 symmetry
|
|---|
| 213 | g=1; pg=C1; nt=1; nirrep_=1;
|
|---|
| 214 |
|
|---|
| 215 | if (!symb) return 0;
|
|---|
| 216 |
|
|---|
| 217 | if (!strcmp(symb,"c1")) return 0;
|
|---|
| 218 |
|
|---|
| 219 | if (!strcmp(symb,"ci")) {
|
|---|
| 220 | g = 2; pg = CI; nirrep_ = 2; nt = 2;
|
|---|
| 221 | return 0;
|
|---|
| 222 | }
|
|---|
| 223 |
|
|---|
| 224 | if(!strcmp(symb,"cs")) {
|
|---|
| 225 | g = 2; pg = CS; nirrep_ = 2; nt = 0;
|
|---|
| 226 | return 0;
|
|---|
| 227 | }
|
|---|
| 228 |
|
|---|
| 229 | if (symb[0] == 'c') {
|
|---|
| 230 | int nab,ne;
|
|---|
| 231 |
|
|---|
| 232 | if (symb[1] == '\0') return -1;
|
|---|
| 233 |
|
|---|
| 234 | nt = atoi(&symb[1]);
|
|---|
| 235 | ne = (nt%2) ? nt/2 : nt/2-1;
|
|---|
| 236 | nab = (nt%2) ? 1 : 2;
|
|---|
| 237 |
|
|---|
| 238 | char *vhd = &symb[1];
|
|---|
| 239 | while (*vhd && isdigit(*vhd))
|
|---|
| 240 | vhd++;
|
|---|
| 241 |
|
|---|
| 242 | if (*vhd) {
|
|---|
| 243 | if (*vhd == 'v') {
|
|---|
| 244 | g = 2*nt; pg = CNV; nirrep_ = 2*nab + ne;
|
|---|
| 245 | } else if (*vhd == 'h') {
|
|---|
| 246 | g = 2*nt; pg = CNH; nirrep_ = 2*(nab+ne);
|
|---|
| 247 | } else {
|
|---|
| 248 | return -1;
|
|---|
| 249 | }
|
|---|
| 250 | } else {
|
|---|
| 251 | g = nt; pg = CN; nirrep_ = nab+ne;
|
|---|
| 252 | }
|
|---|
| 253 |
|
|---|
| 254 | return 0;
|
|---|
| 255 | }
|
|---|
| 256 |
|
|---|
| 257 | if (symb[0] == 'd') {
|
|---|
| 258 | int nab,ne;
|
|---|
| 259 |
|
|---|
| 260 | if (symb[1] == '\0') return -1;
|
|---|
| 261 |
|
|---|
| 262 | nt = atoi(&symb[1]);
|
|---|
| 263 | ne = (nt%2) ? nt/2 : nt/2-1;
|
|---|
| 264 | nab = (nt%2) ? 1 : 2;
|
|---|
| 265 |
|
|---|
| 266 | char *vhd = &symb[1];
|
|---|
| 267 | while (*vhd && isdigit(*vhd))
|
|---|
| 268 | vhd++;
|
|---|
| 269 |
|
|---|
| 270 | if (*vhd) {
|
|---|
| 271 | if (*vhd == 'd') {
|
|---|
| 272 | g = 4*nt; pg = DND; nirrep_ = nt+3;
|
|---|
| 273 | } else if (*vhd == 'h') {
|
|---|
| 274 | g = 4*nt; pg = DNH; nirrep_ = 4*nab + 2*ne;
|
|---|
| 275 | } else {
|
|---|
| 276 | return -1;
|
|---|
| 277 | }
|
|---|
| 278 | } else {
|
|---|
| 279 | g = 2*nt; pg = DN; nirrep_ = 2*nab + ne;
|
|---|
| 280 | }
|
|---|
| 281 |
|
|---|
| 282 | return 0;
|
|---|
| 283 | }
|
|---|
| 284 |
|
|---|
| 285 | if (symb[0] == 's') {
|
|---|
| 286 | if (symb[1] == '\0') return -1;
|
|---|
| 287 |
|
|---|
| 288 | nt = atoi(&symb[1]);
|
|---|
| 289 |
|
|---|
| 290 | // only S2n groups make sense
|
|---|
| 291 | if (nt%2) return -1;
|
|---|
| 292 |
|
|---|
| 293 | g = nt; pg = SN; nirrep_ = nt/2+1;
|
|---|
| 294 |
|
|---|
| 295 | return 0;
|
|---|
| 296 | }
|
|---|
| 297 |
|
|---|
| 298 | if (symb[0] == 't') {
|
|---|
| 299 | if (symb[1] != '\0') {
|
|---|
| 300 | if (symb[1] == 'd') {
|
|---|
| 301 | g = 24; pg = TD; nirrep_ = 5;
|
|---|
| 302 | } else if(symb[1] == 'h') {
|
|---|
| 303 | g = 24; pg = TH; nirrep_ = 6;
|
|---|
| 304 | } else {
|
|---|
| 305 | return -1;
|
|---|
| 306 | }
|
|---|
| 307 | } else {
|
|---|
| 308 | g = 12; pg = T; nirrep_ = 3;
|
|---|
| 309 | }
|
|---|
| 310 |
|
|---|
| 311 | return 0;
|
|---|
| 312 | }
|
|---|
| 313 |
|
|---|
| 314 | if (symb[0] == 'o') {
|
|---|
| 315 | if (symb[1] != '\0') {
|
|---|
| 316 | if (symb[1] == 'h') {
|
|---|
| 317 | pg = OH; g = 48; nirrep_ = 10;
|
|---|
| 318 | } else {
|
|---|
| 319 | return -1;
|
|---|
| 320 | }
|
|---|
| 321 | } else {
|
|---|
| 322 | g = 24; pg = O; nirrep_ = 5;
|
|---|
| 323 | }
|
|---|
| 324 |
|
|---|
| 325 | return 0;
|
|---|
| 326 | }
|
|---|
| 327 |
|
|---|
| 328 | if (symb[0] == 'i') {
|
|---|
| 329 | if (symb[1] != '\0') {
|
|---|
| 330 | if (symb[1] == 'h') {
|
|---|
| 331 | g = 120; pg = IH; nirrep_ = 10;
|
|---|
| 332 | } else {
|
|---|
| 333 | return -1;
|
|---|
| 334 | }
|
|---|
| 335 | } else {
|
|---|
| 336 | g = 60; pg = I; nirrep_ = 5;
|
|---|
| 337 | }
|
|---|
| 338 |
|
|---|
| 339 | return 0;
|
|---|
| 340 | }
|
|---|
| 341 |
|
|---|
| 342 | return -1;
|
|---|
| 343 | }
|
|---|
| 344 |
|
|---|
| 345 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 346 |
|
|---|
| 347 | // Local Variables:
|
|---|
| 348 | // mode: c++
|
|---|
| 349 | // c-file-style: "ETS"
|
|---|
| 350 | // End:
|
|---|