1 /*
2 
3 Copyright (C) 2007 Lucas K. Wagner
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 "basis_writer.h"
21 #include <cassert>
22 #include <iomanip>
23 #include <cmath>
24 
25 using namespace std;
26 //###############################################
27 //Basis functions
28 //###############################################
29 
30 //----------------------------------------------------------------------
nfunction_symmetry(string & str)31 int nfunction_symmetry(string & str) {
32   if     (str=="S") return 1;
33   else if(str=="P"|| str=="P_siesta") return  3;
34   //else if(types[i]=="L") tot+=4;
35   else if(str=="5D" || str=="5D_siesta") return 5;
36   else if(str=="6D") return 6;
37   /*
38     add 7F_crystal basis, huihuo
39    */
40   else if(str=="7F" || str=="7F_siesta" || str=="7F_crystal") return 7;
41   else if(str=="10F") return 10;
42   else if(str=="15G") return 15;
43    std::cout << "WARNING! Unknown type '" << str << "'" << std::endl;
44   return 1;
45 }
46 
47 
48 
nfunc()49 int Gaussian_basis_set::nfunc() { //number of functions that this set has.
50   int tot=0;
51   for(unsigned int i=0; i< types.size(); i++) {
52     tot+=nfunction_symmetry(types[i]);
53   }
54   return tot;
55 }
56 
57 //----------------------------------------------------------------------
58 
print_basis(ostream & os)59 void Gaussian_basis_set::print_basis(ostream & os) {
60     os << label << "\nAOSPLINE\n";
61     os << endl;
62     os << options;
63     os << endl;
64     if(fabs(cutoff) > 1e-8)
65       os << "CUTOFF " << cutoff << endl;
66     os << "  GAMESS { \n";
67     int nmax=types.size();
68     assert(nmax==exponents.size());
69     assert(nmax==coefficients.size());
70     for(int j=0; j< nmax; j++) {
71       int kmax=exponents[j].size();
72         os << types[j];
73         os << "   " << kmax << endl;
74         assert(kmax==coefficients[j].size());
75         for(int k=0; k< kmax; k++) {
76           os << "      " << setw(10) << k+1;
77           os << setw(15) << exponents[j][k];
78           os << setw(15) << coefficients[j][k] << endl;
79         }
80     }
81     os << "}\n";
82 }
83 
84 //######################################################################
print_basis(ostream & os)85 void Spline_basis_writer::print_basis(ostream & os) {
86   assert(vals.size()==rad.size());
87   assert(vals.size()==types.size());
88 
89   os << label << "\nAOSPLINE\n";
90   os << endl;
91   os << endl;
92   int nf=vals.size();
93   for(int i=0; i< nf; i++) {
94     os << "SPLINE { \n";
95     os << types[i] << endl;
96     int ntot=rad[i].size();
97     assert(ntot==vals[i].size());
98     for(int j=0; j< ntot; j++) {
99       os << rad[i][j] << "  " << vals[i][j] << endl;
100     }
101     os << " } ";
102   }
103 
104 }
105 
nfunc()106 int Spline_basis_writer::nfunc() {
107   int tot=0;
108   for(unsigned int i=0; i< types.size(); i++) {
109     tot+=nfunction_symmetry(types[i]);
110   }
111   return tot;
112 }
113 
114 //######################################################################
115 
nfunc()116 int Pade_molecular_basis::nfunc(){
117   return 1;
118 }
119 
print_basis(ostream & os)120 void Pade_molecular_basis::print_basis(ostream & os) {
121   os << "LIKECUSP {\n"
122         " NULL\n"
123         " EXPONENTIAL_CUSP\n"
124         " GAMMA 1.0\n"
125         "  CUSP .25\n"
126         "}\n\n"
127 
128         "UNLIKECUSP {\n"
129         " NULL\n"
130         " EXPONENTIAL_CUSP\n"
131         " GAMMA 1.0\n"
132         " CUSP .5\n"
133         "}\n\n"
134 
135         "EEBASIS {\n"
136         "  NULL\n"
137         "  PADE\n"
138         "  ALPHA0 1.2\n"
139         "  NFUNC 2\n"
140         "}\n\n"
141         "EIBASIS {\n"
142         "  NULL\n"
143         "  PADE\n"
144         "  ALPHA0 1.6\n"
145         "  NFUNC 3\n"
146         "}\n\n";
147 }
148 
149 
150 //####################################################################
151 
nfunc()152 int Exponential_cusp_basis::nfunc() {
153   return 1;
154 }
155 
print_basis(ostream & os)156 void Exponential_cusp_basis::print_basis(ostream & os) {
157   os << label << endl;
158   os << " EXPONENTIAL_CUSP\n"
159         " GAMMA 1.0\n"
160         " CUSP 1.0\n";
161 }
162 
163 //####################################################################
164 
nfunc()165 int Cutoff_cusp_basis::nfunc() {
166   return 1;
167 }
168 
print_basis(ostream & os)169 void Cutoff_cusp_basis::print_basis(ostream & os) {
170   os << label << endl;
171   os << " CUTOFF_CUSP\n"
172         " GAMMA 24.0\n"
173         " CUSP 1.0\n"
174         " CUTOFF " << cutoff << endl;
175 
176 }
177 
178 
179 //####################################################################
180 
nfunc()181 int Poly_pade_basis::nfunc() {
182   return nfunc_;
183 }
184 
print_basis(ostream & os)185 void Poly_pade_basis::print_basis(ostream & os) {
186   os << label << endl;
187   os << " POLYPADE\n"
188      << " BETA0 " << beta0 << "\n"
189      << " NFUNC " << nfunc_ << endl
190      << " RCUT " << cutoff << endl;
191 
192 }
193 
194 //###################################################################
195