1 /*
2 
3 Copyright (C) 2007 Jindrich Kolorenc, Michal Bajdich
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 
21 #ifndef MO_MATRIX_BASFUNC_H_INCLUDED
22 #define MO_MATRIX_BASFUNC_H_INCLUDED
23 
24 #include "Array.h"
25 #include "Qmc_std.h"
26 #include "Basis_function.h"
27 #include "Center_set.h"
28 #include "MO_matrix.h"
29 
30 class System;
31 class Sample_point;
32 //----------------------------------------------------------------------------
33 
34 /*!
35 The reason for this exercise is to efficiently evaluate molecular orbitals,
36 when a molecular orbital is directly a basis function. Good for homogeneous
37 electron gas and related stuff (HEG_system). This MO evaluator is constructed
38 as a simplification of MO_matrix_standard. Equivalent complex-valued
39 functionality is provided by MO_matrix_Cbasfunc.
40 
41 Obviously, orb-file format is different from MO_matrix_standard,
42 MO_matrix_cutoff and MO_matrix_blas. Here, each MO is defined by a pair
43 AO# center# -> two columns of integers in the orb-file.
44 
45 JK: I am not sure if this class should be MO_matrix type, since it represents
46 different data (no coefficients, just links MO -> basis function), more
47 appropriate might be General_MO_matrix, if it is possible (would need
48 one more allocate in MO_matrix.h and likely other changes as well).
49 */
50 
51 //--------------------------------------------------------------------------
52 
53 class MO_matrix_basfunc: public MO_matrix
54 {
55 protected:
56   void init();
57 private:
58   Array2 <int> basisMO;
59   //!< basisMO replaces moCoeff, links given MO to its basis function
60   Array1 <int> eq_centers;
61   Array1 < Array1 <int> > moLists;
62   /*!< \brief moLists(spin,.) lists MO's corresponding to the given spin,
63        the same thing as totoccupation in Slat_wf_data
64   */
65   Array1 <doublevar> kptfac;
66   /*!< \brief
67     phase factor multiplying basis functions associated with
68     a given center, N.B. equivalent centers differ by integer
69     multiple of a lattice vector
70   */
71 
72   Array1 <doublevar> obj_cutoff; //!< cutoff for each basis object
73   Array1 <doublevar> cutoff;     //!< cutoff for individual basis functions
74 
75 public:
76 
77   /*!
78     Build several sets of MO's to be evaluated in updateVal and updateLap.
79     Each element in occupations should be a list of the MO's that should
80     be evaluated.  For example, one can create a list of spin up and spin
81     down MO's, and only evaluate up when an up electron is moved.
82    */
83   virtual void buildLists(Array1 <Array1 <int> > & occupations);
84 
85 
86   virtual int showinfo(ostream & os);
87 
88   virtual int writeinput(string &, ostream &);
89 
writeorb(ostream &,Array2<doublevar> & rotation,Array1<int> &)90   virtual void writeorb(ostream &, Array2 <doublevar> & rotation,
91                         Array1 <int> &) {
92     error("BASFUNC_MO: writeorb not implemented");
93   }
94 
95   // I guess the following three are ment for direct orbital optimization,
96   // there is nothing to optimize here, only basis functions
getMoCoeff(Array2<doublevar> & coeff)97   virtual void getMoCoeff(Array2 <doublevar> & coeff) {
98     error("BASFUNC_MO: getMoCoeff not implemented");
99   }
setMoCoeff(Array2<doublevar> & coeff)100   virtual void setMoCoeff(Array2 <doublevar> & coeff) {
101     error("BASFUNC_MO: setMoCoeff not implemented");
102   }
nMoCoeff()103   virtual int nMoCoeff() {
104     error("BASFUNC_MO: nMoCoeff not implemented");
105     return 0;
106   }
107 
108   // No problem to implement/copy, but what for is it
109   // anyway?
getBasisVal(Sample_point * sample,int e,Array1<doublevar> & newvals)110   virtual void getBasisVal(Sample_point * sample,
111 			   int e,
112 			   Array1 <doublevar> & newvals
113 			   ) {
114     error("BASFUNC_MO: getBasisVal not implemented");
115   }
116 
117   // finally, the two key functions of the class that actually evaluate the
118   // molecular orbitals (and their derivatives)
119   virtual void updateVal(Sample_point * sample,
120 			 int e,
121 			 //!< electron number
122 			 int listnum,
123 			 //!< Choose the list that was built in buildLists
124 			 Array2 <doublevar> & newvals
125 			 //!< The return: in form (MO)
126 			 );
127 
128   virtual void updateLap(Sample_point * sample,
129 			 int e,
130 			 //!< electron number
131 			 int listnum,
132 			 //!< Choose the list that was built in buildLists
133 			 Array2 <doublevar> & newvals
134 			 //!< The return: in form ([value gradient lap], MO)
135 			 );
136 
137   virtual void updateHessian(Sample_point * sample,
138 			     int e,
139 			     //!< electron number
140 			     int listnum,
141 			     //!< Choose the list that was built in buildLists
142 			     Array2 <doublevar>& newvals
143 			     //!< in form ([value gradient, dxx,dyy,dzz,dxy,dxz,dyz], MO)
144 			     );
145 
146 
MO_matrix_basfunc()147   MO_matrix_basfunc()
148   {}
149 
150 };
151 
152 
153 #endif // MO_MATRIX_BASFUNC_H_INCLUDED
154 
155 //--------------------------------------------------------------------------
156